public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: Editing with vim clears Windows 10 file system archive bit.
Date: Tue, 16 Nov 2021 15:06:27 +0100	[thread overview]
Message-ID: <YZO6435IBP+UmU0F@calimero.vinschen.de> (raw)
In-Reply-To: <20211115221818.GA12715@phoenix>

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

      reply	other threads:[~2021-11-16 14:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-14 18:56 Steve Ward
2021-11-15 18:54 ` Christian Franke
2021-11-15 20:05   ` Corinna Vinschen
2021-11-15 22:18     ` Gary Johnson
2021-11-16 14:06       ` Corinna Vinschen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YZO6435IBP+UmU0F@calimero.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).