delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2021/11/16/09:07:04

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5DBED385AC28
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1637071622;
bh=/TD3H4M7K+uLVM0t/ei7FTb2jHUxMhTfE5TKQzNVb94=;
h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:
From;
b=OIxGHix8DdEw99wTKSF9A7fCWjY/R5OjIPgwzzPbaRYkp1FsZLaAFa2QuMSllVn4J
6VQ6hFuCHuJeTumDtnjItAdCj5pIanfCtXD69ZZ8JmzC7AIsQ6v5/l85xHkgLH8eGi
Sy5LXeqtzcYTAEGEZZyhYVGvshCXBG7T2XZSMBVA=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BA50F385B804
Date: Tue, 16 Nov 2021 15:06:27 +0100
To: cygwin AT cygwin DOT com
Subject: Re: Editing with vim clears Windows 10 file system archive bit.
Message-ID: <YZO6435IBP+UmU0F@calimero.vinschen.de>
Mail-Followup-To: cygwin AT cygwin DOT com
References: <SN6PR04MB4799AEB60421601D02E22680BB979 AT SN6PR04MB4799 DOT namprd04 DOT prod DOT outlook DOT com>
<305aedc4-9bb2-02b8-f5ab-f88aba39e9cf AT t-online DOT de>
<YZK9ciahf8PDvX7A AT calimero DOT vinschen DOT de>
<20211115221818 DOT GA12715 AT phoenix>
MIME-Version: 1.0
In-Reply-To: <20211115221818.GA12715@phoenix>
X-Provags-ID: V03:K1:pt0dUkcYIxjQVpVJZFEpq3aFMqTyOB7hh1HYQyc6An7XyNh68fq
qVmqCI8amIantbQV/HvHJjpH5M6SJUmavbaCTr95viQQkg4f1pVemrf543mqqBR2eg3VYC6
amQ6zm8gqC6uj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AL,
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 AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Corinna Vinschen via Cygwin <cygwin AT cygwin DOT com>
Reply-To: cygwin AT cygwin DOT com
Cc: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>

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

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019