From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.kundenserver.de (mout.kundenserver.de [217.72.192.73]) by sourceware.org (Postfix) with ESMTPS id BA50F385B804 for ; Tue, 16 Nov 2021 14:06:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BA50F385B804 Received: from calimero.vinschen.de ([24.134.7.25]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MXoxG-1nCINk1uuK-00YDri for ; Tue, 16 Nov 2021 15:06:28 +0100 Received: by calimero.vinschen.de (Postfix, from userid 500) id 05546A80D6A; Tue, 16 Nov 2021 15:06:28 +0100 (CET) Date: Tue, 16 Nov 2021 15:06:27 +0100 From: Corinna Vinschen To: cygwin@cygwin.com Subject: Re: Editing with vim clears Windows 10 file system archive bit. Message-ID: Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com References: <305aedc4-9bb2-02b8-f5ab-f88aba39e9cf@t-online.de> <20211115221818.GA12715@phoenix> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20211115221818.GA12715@phoenix> X-Provags-ID: V03:K1:pt0dUkcYIxjQVpVJZFEpq3aFMqTyOB7hh1HYQyc6An7XyNh68fq qVmqCI8amIantbQV/HvHJjpH5M6SJUmavbaCTr95viQQkg4f1pVemrf543mqqBR2eg3VYC6 amQ6zm8gqC6ujSVkLdT7hFDoE9XiJf/vCgysXvv1zh63+rw9m5KSBlOg6IbwbGZav81mpew I3gFVUy16vJnNjmv3vVEQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:GY2dwOiGkEk=:u33X4fIzpRND9H6eMQFH+Z xE7yKTEj54PCtRzcnVwDk5aMoQFzi9q232238wZuf2S+uaSYZLP2wb8XKiOdXA7jG8TyUiRRI OT+K/5zfVpU1DXksRFHk0dNeh2UuriVJ8A3FAISyRrAgyQlalaTSjc1RAOjMBVjyXj2E2g1VW xe5lRd5oN4NkaKPA4kuumnqrmpVDUDPGKzLOe5lB7BJkpdNnBB5Z59gw8azeRdZI7AX4o0o3d JfPIeITJ/+p0ANXqVaRjDblFHOrOB/RrL4yF4g764VWRaL8/JmmKFRxPbPp8iHnGdrHmpICe4 dxbX674ErdVubcEq97An0ojuMwblfxHKDVeykG5Bx/4mA0H0HiVkWrQ1ig2u7LwNLTS/4UjlW OTw2mln7Minz8mAUMD0aEqFDLQ1kRQjmH2q6DDVfNkX9S1hUuPz5v11Ls7sqbVWfiHpd9hZUx Sjrok5n7gY2L9b80nW/LIrhbtkeaOuudtMOVbrlJHJ4IHTJnBAuV+IdQxNtc2oV7tsZSFqJ1k gf2hFWW0UFGRUhqgS14/WOJm0dbsjWCcKxLZ6AuQurEM2twjoFZ2p7AK6NJVnEz5n/95RQGxZ Kh7Bb12thvymC2RHt64aELiCWB7ZENXCgF5nAFqBi5Svv0nj/IOLJLpBLhJyiFC6q0aTXtnoF msGjFm4BD+guL9w78fD6cyMzZMXyGtaDdMI6WhqOV9ixwb+83DK6Jg051i62hGO7ZhzVo+o2X 6HzYwXhS83cPSnih X-Spam-Status: No, score=-99.1 required=5.0 tests=BAYES_00, GOOD_FROM_CORINNA_CYGWIN, JMQ_SPF_NEUTRAL, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: cygwin@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Nov 2021 14:06:31 -0000 On Nov 15 14:18, Gary Johnson wrote: > On 2021-11-15, Corinna Vinschen via Cygwin wrote: > > Changing that is actually pretty simple, just set FILE_ATTRIBUTE_ARCHIVE > > as soon as the underlying NtCreateFile is called for an open(O_CREAT). > > > > Fixed in current git. > > I had thought that this might be a bug in Vim, so did a git bisect > to find the offending commit. For the record, it was this one: > [...] > The only change I see to an open() call was removing O_TRUNC on > systems with ftruncate() and adding a later call to ftruncate() on > systems that have it. There were also some changes to the setting > of permissions (fchown(), fchmod() and chmod()). These changes were > all in the buf_write() function in fileio.c. > > That open() call had the O_CREAT flag before and after the change. You are sooo right. My bugfix appears to work, but it's fixing a non-existent bug. NtCreateFile actually sets the ARCHIVE bit all the time when creating a new file, even if it's not explicitely given as parameter. That makes a lot of sense, of course, given how the archiving mechanism works on Windows. The *real* problem is in fact that Cygwin caches the wrong file attribute bits when creating a new file, and that's where fchmod fails: It writes back the wrongly cached bits. This doesn't happen with chmod, because it re-opens the existing file and fetches the correct attributes bit at the time. I guess I'll revert my patch and create a new one which is more to the point. Thanks, Corinna