From nobody@FreeBSD.org  Sun Dec  3 11:04:46 2006
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 0FB3E16A412
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  3 Dec 2006 11:04:46 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [69.147.83.33])
	by mx1.FreeBSD.org (Postfix) with ESMTP id D7A1F43C9D
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  3 Dec 2006 11:04:19 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id kB3B4jkh098475
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 3 Dec 2006 11:04:45 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id kB3B4jcS098474;
	Sun, 3 Dec 2006 11:04:45 GMT
	(envelope-from nobody)
Message-Id: <200612031104.kB3B4jcS098474@www.freebsd.org>
Date: Sun, 3 Dec 2006 11:04:45 GMT
From: Rene Ladan<r.c.ladan@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [msdosfs] : correct setting of archive flag
X-Send-Pr-Version: www-3.0

>Number:         106255
>Category:       kern
>Synopsis:       [msdosfs] [patch]: correct setting of archive flag
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    trhodes
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Dec 03 11:10:10 GMT 2006
>Closed-Date:    
>Last-Modified:  Fri May  3 17:30:00 UTC 2013
>Originator:     Rene Ladan
>Release:        7.0 CURRENT 2006-11-26
>Organization:
>Environment:
FreeBSD s000655.campus.tue.nl 7.0-CURRENT FreeBSD 7.0-CURRENT #21: Mon Nov 27 17:53:03 CET 2006     root@s000655.campus.tue.nl:/usr/obj/usr/src-current/sys/RENE  i386

>Description:
The MSDOS file system has an archive bit in the flags field.  This bit roughly corresponds to the archive flag on the UFS file system.  However, it is set the wrong way around: the flag should be set when the bit is present, and cleared when the bit is absent.
>How-To-Repeat:
1. Mount an MSDOS file system with some files marked as archived, and some not.
2. List its files with 'ls -lo'
   The archive flag will turn up inversed.

>Fix:


Patch attached with submission follows:

--- msdosfs_vnops.c	Mon Nov  6 14:41:57 2006
+++ msdosfs_vnops.c.rene	Sun Dec  3 11:58:47 2006
@@ -352,7 +352,7 @@
 		vap->va_ctime = vap->va_mtime;
 	}
 	vap->va_flags = 0;
-	if ((dep->de_Attributes & ATTR_ARCHIVE) == 0)
+	if (dep->de_Attributes & ATTR_ARCHIVE)
 		vap->va_flags |= SF_ARCHIVED;
 	vap->va_gen = 0;
 	vap->va_blocksize = pmp->pm_bpcluster;

>Release-Note:
>Audit-Trail:

From: Bruce Evans <bde@zeta.org.au>
To: Rene Ladan <r.c.ladan@gmail.com>
Cc: freebsd-gnats-submit@FreeBSD.org, freebsd-bugs@FreeBSD.org
Subject: Re: kern/106255: [msdosfs] : correct setting of archive flag
Date: Mon, 4 Dec 2006 11:39:32 +1100 (EST)

 On Sun, 3 Dec 2006, Rene Ladan wrote:
 
 >> Description:
 > The MSDOS file system has an archive bit in the flags field.  This bit roughly corresponds to the archive flag on the UFS file system.  However, it is set the wrong way around: the flag should be set when the bit is present, and cleared when the bit is absent.
 
 The comment in msdosfs/direntry.h says that ATTR_ARCHIVE means that
 the file is new or modified (in other words, not archived), while the
 comment in sys/stat.h says that SF_ARCHIVED means that the file is
 archived, but I think both mean that it is archived.
 
 > --- msdosfs_vnops.c	Mon Nov  6 14:41:57 2006
 > +++ msdosfs_vnops.c.rene	Sun Dec  3 11:58:47 2006
 > @@ -352,7 +352,7 @@
 > 		vap->va_ctime = vap->va_mtime;
 > 	}
 > 	vap->va_flags = 0;
 > -	if ((dep->de_Attributes & ATTR_ARCHIVE) == 0)
 > +	if (dep->de_Attributes & ATTR_ARCHIVE)
 > 		vap->va_flags |= SF_ARCHIVED;
 > 	vap->va_gen = 0;
 > 	vap->va_blocksize = pmp->pm_bpcluster;
 
 This only fixes the reporting of the flag.  msdosfs still maintains
 the flag perfectly backwards (except DETIMES() is missing setting of
 it for for all changes -- I think all changes to metadata except
 possibly to atimes should set it to be perfectly backwards and clear
 it to be correct).
 
 Grep shows that this flag is negatively useful in FreeBSD.  No file
 systems maintain it (except for getting it backwards in msdosfs).
 All archiving utilities need to maintain it for it to be useful,
 but none except tar even reference it (except possibly indirectly via
 strtofflags(3)), and tar seems to just print it (indirectly via a
 special version of strtofflags(3)).
 
 Bruce

From: Rene Ladan <r.c.ladan@gmail.com>
To: Bruce Evans <bde@zeta.org.au>
Cc: freebsd-gnats-submit@FreeBSD.org,  freebsd-bugs@FreeBSD.org
Subject: Re: kern/106255: [msdosfs] : correct setting of archive flag
Date: Mon, 04 Dec 2006 10:37:37 +0100

 Bruce Evans schreef:
 > On Sun, 3 Dec 2006, Rene Ladan wrote:
 > 
 >>> Description:
 >> The MSDOS file system has an archive bit in the flags field.  This bit
 >> roughly corresponds to the archive flag on the UFS file system. 
 >> However, it is set the wrong way around: the flag should be set when
 >> the bit is present, and cleared when the bit is absent.
 > 
 > The comment in msdosfs/direntry.h says that ATTR_ARCHIVE means that
 > the file is new or modified (in other words, not archived), while the
 > comment in sys/stat.h says that SF_ARCHIVED means that the file is
 > archived, but I think both mean that it is archived.
 > 
 Indeed, the MSDOS archive bit means that the user should archive the file.
 
 >> --- msdosfs_vnops.c    Mon Nov  6 14:41:57 2006
 >> +++ msdosfs_vnops.c.rene    Sun Dec  3 11:58:47 2006
 >> @@ -352,7 +352,7 @@
 >>         vap->va_ctime = vap->va_mtime;
 >>     }
 >>     vap->va_flags = 0;
 >> -    if ((dep->de_Attributes & ATTR_ARCHIVE) == 0)
 >> +    if (dep->de_Attributes & ATTR_ARCHIVE)
 >>         vap->va_flags |= SF_ARCHIVED;
 >>     vap->va_gen = 0;
 >>     vap->va_blocksize = pmp->pm_bpcluster;
 > 
 > This only fixes the reporting of the flag.  msdosfs still maintains
 > the flag perfectly backwards (except DETIMES() is missing setting of
 > it for for all changes -- I think all changes to metadata except
 > possibly to atimes should set it to be perfectly backwards and clear
 > it to be correct).
 > 
 Thanks, I'll look into that.
 
 > Grep shows that this flag is negatively useful in FreeBSD.  No file
 > systems maintain it (except for getting it backwards in msdosfs).
 > All archiving utilities need to maintain it for it to be useful,
 > but none except tar even reference it (except possibly indirectly via
 > strtofflags(3)), and tar seems to just print it (indirectly via a
 > special version of strtofflags(3)).
 >
 That's up to the utilities.
 
 > Bruce
 > 
 
 Regards,
 Rene
 -- 
 GPG fingerprint = E738 5471 D185 7013 0EE0  4FC8 3C1D 6F83 12E1 84F6
 (subkeys.pgp.net)
 
 "It won't fit on the line."
 		-- me, 2001
 

From: Rene Ladan <r.c.ladan@gmail.com>
To: Bruce Evans <bde@zeta.org.au>
Cc: freebsd-gnats-submit@FreeBSD.org,  freebsd-bugs@FreeBSD.org
Subject: Re: kern/106255: [msdosfs] : correct setting of archive flag
Date: Mon, 04 Dec 2006 13:26:53 +0100

 This is a multi-part message in MIME format.
 --------------010800070203070007080707
 Content-Type: text/plain; charset=ISO-8859-1
 Content-Transfer-Encoding: 7bit
 
 Bruce Evans schreef:
 > On Sun, 3 Dec 2006, Rene Ladan wrote:
 > 
 >>> Description:
 >> The MSDOS file system has an archive bit in the flags field.  This bit
 >> roughly corresponds to the archive flag on the UFS file system. 
 >> However, it is set the wrong way around: the flag should be set when
 >> the bit is present, and cleared when the bit is absent.
 > 
 > The comment in msdosfs/direntry.h says that ATTR_ARCHIVE means that
 > the file is new or modified (in other words, not archived), while the
 > comment in sys/stat.h says that SF_ARCHIVED means that the file is
 > archived, but I think both mean that it is archived.
 > 
 [patch 1]
 
 > This only fixes the reporting of the flag.  msdosfs still maintains
 > the flag perfectly backwards (except DETIMES() is missing setting of
 > it for for all changes -- I think all changes to metadata except
 > possibly to atimes should set it to be perfectly backwards and clear
 > it to be correct).
 >
 I've attached a new patch which
   * fixes reporting of the flag (as in the previous patch)
   * sets the archive flag in DETIMES() when the file is created
   * cleans up the logic of not supporting setting the archive flag on
 directories (chunk 3)
   * does not set the flag when (vap->va_atime.tv_sec != VNOVAL) or
 (vap->va_mode != VNOVAL) in msdosfs_setattr()
 
 I think that only userland tools should send a 'clear request', as the
 flag only needs to be cleared when the file is backed up.  The kernel
 cannot know when a file has been backed up.
 
 Any comments are welcome.
 
 > Bruce
 > 
 
 Regards,
 Rene
 -- 
 GPG fingerprint = E738 5471 D185 7013 0EE0  4FC8 3C1D 6F83 12E1 84F6
 (subkeys.pgp.net)
 
 "It won't fit on the line."
 		-- me, 2001
 
 
 --------------010800070203070007080707
 Content-Type: text/plain;
  name="msdos.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="msdos.diff"
 
 --- msdosfs_vnops.c.orig	Sun Dec  3 20:45:24 2006
 +++ msdosfs_vnops.c	Mon Dec  4 12:43:37 2006
 @@ -354,7 +354,7 @@
  		vap->va_birthtime.tv_nsec = 0;
  	}
  	vap->va_flags = 0;
 -	if ((dep->de_Attributes & ATTR_ARCHIVE) == 0)
 +	if (dep->de_Attributes & ATTR_ARCHIVE)
  		vap->va_flags |= SF_ARCHIVED;
  	vap->va_gen = 0;
  	vap->va_blocksize = pmp->pm_bpcluster;
 @@ -431,12 +431,13 @@
  			if (error)
  				return (error);
  		}
 -		if (vap->va_flags & ~SF_ARCHIVED)
 -			return EOPNOTSUPP;
  		if (vap->va_flags & SF_ARCHIVED)
  			dep->de_Attributes &= ~ATTR_ARCHIVE;
 -		else if (!(dep->de_Attributes & ATTR_DIRECTORY))
 -			dep->de_Attributes |= ATTR_ARCHIVE;
 +		else
 +			if (dep->de_Attributes & ATTR_DIRECTORY)
 +				return EOPNOTSUPP;
 +			else 
 +				dep->de_Attributes |= ATTR_ARCHIVE;
  		dep->de_flag |= DE_MODIFIED;
  	}
  
 @@ -506,8 +507,9 @@
  				dep->de_flag &= ~DE_UPDATE;
  				timespec2fattime(&vap->va_mtime, 0,
  				    &dep->de_MDate, &dep->de_MTime, NULL);
 +				dep->de_Attributes |= ATTR_ARCHIVE;
 +				/* only set archive flag when file has changed */
  			}
 -			dep->de_Attributes |= ATTR_ARCHIVE;
  			dep->de_flag |= DE_MODIFIED;
  		}
  	}
 @@ -531,7 +533,6 @@
  				dep->de_Attributes &= ~ATTR_READONLY;
  			else
  				dep->de_Attributes |= ATTR_READONLY;
 -			dep->de_Attributes |= ATTR_ARCHIVE;
  			dep->de_flag |= DE_MODIFIED;
  		}
  	}
 --- denode.h.orig	Thu Oct 26 11:21:07 2006
 +++ denode.h	Mon Dec  4 12:35:00 2006
 @@ -239,6 +239,7 @@
  		timespec2fattime((cre), 0, &(dep)->de_CDate,		\
  		    &(dep)->de_CTime, &(dep)->de_CHun);			\
  		    (dep)->de_flag |= DE_MODIFIED;			\
 +		    (dep)->de_Attributes |= ATTR_ARCHIVE;		\
  	}								\
  	(dep)->de_flag &= ~(DE_UPDATE | DE_CREATE | DE_ACCESS);		\
  } while (0)
 
 --------------010800070203070007080707--

From: Bruce Evans <bde@zeta.org.au>
To: Rene Ladan <r.c.ladan@gmail.com>
Cc: freebsd-gnats-submit@FreeBSD.org, freebsd-bugs@FreeBSD.org
Subject: Re: kern/106255: [msdosfs] : correct setting of archive flag
Date: Tue, 5 Dec 2006 11:07:36 +1100 (EST)

 On Mon, 4 Dec 2006, Rene Ladan wrote:
 
 > Bruce Evans schreef:
 >> On Sun, 3 Dec 2006, Rene Ladan wrote:
 >>
 >>>> Description:
 >>> The MSDOS file system has an archive bit in the flags field.  This bit
 >>> roughly corresponds to the archive flag on the UFS file system.
 >>> However, it is set the wrong way around: the flag should be set when
 >>> the bit is present, and cleared when the bit is absent.
 >>
 >> The comment in msdosfs/direntry.h says that ATTR_ARCHIVE means that
 >> the file is new or modified (in other words, not archived), while the
 >> comment in sys/stat.h says that SF_ARCHIVED means that the file is
 >> archived, but I think both mean that it is archived.
 >>
 > Indeed, the MSDOS archive bit means that the user should archive the file.
 
 Not indeed.  The MSDOS archive bit does mean that the file needs to be
 archived, but this means that it has the opposite sense to SF_ARCHIVED
 and the main bug is in the patch in the PR.
 
 >>> --- msdosfs_vnops.c    Mon Nov  6 14:41:57 2006
 >>> +++ msdosfs_vnops.c.rene    Sun Dec  3 11:58:47 2006
 >>> @@ -352,7 +352,7 @@
 >>>         vap->va_ctime = vap->va_mtime;
 >>>     }
 >>>     vap->va_flags = 0;
 >>> -    if ((dep->de_Attributes & ATTR_ARCHIVE) == 0)
 >>> +    if (dep->de_Attributes & ATTR_ARCHIVE)
 >>>         vap->va_flags |= SF_ARCHIVED;
 >>>     vap->va_gen = 0;
 >>>     vap->va_blocksize = pmp->pm_bpcluster;
 >>
 >> This only fixes the reporting of the flag.  msdosfs still maintains
 >> the flag perfectly backwards (except DETIMES() is missing setting of
 >> it for for all changes -- I think all changes to metadata except
 >> possibly to atimes should set it to be perfectly backwards and clear
 >> it to be correct).
 >>
 > Thanks, I'll look into that.
 
 The above actually only breaks the reporting of the flag.  ATTR_ARCHIVE
 has the opposite sese to SF_ARCHIVED, so !ATTR_ARCHIVED must be converted
 to SF_ARCHIVED as in the original code above, and the reverse conversion
 must be done when setting msdosfs attributes from FreeBSD attributes
 (as done in msdosfs_setattr()).  At the user level, thus means that
 when ls -o displays "attr", it means that the file is archived, but
 when an msdosfs's attrib utility displays "A" it means that the file
 is not archived.
 
 The main bug here seems to be just for directories.  The archive
 attribute doesn't apply for directories, and the above doesn't have
 a special case for directories, so the above tests garbage for the
 directory case.  The garbage is usually (maybe always?) 0, so
 SF_ARVCHIVED is usually set for directories and ls -o displays "attr".
 This is consistent with attrib not displaying "A" but strange.
 
 msdosfs_setattr() is more careful with the archive bit for directories,
 but still wrong.  It silently ignores attempts to set this bit.  Thus
 applications like cp -p succeed where they should fail, masking the
 bug in msdosfs_getattr(): msdosfs_getattr() bogusly turns the absence
 of an ATTR_ARCHIVE bit into a setting of SF_ARCHIVED; cp -p tries to
 preserve this setting but cannot, and the error goes undetected since
 msdosfs_setattr() silently ignores it.
 
 More in another reply.
 
 Bruce

From: Bruce Evans <bde@zeta.org.au>
To: Rene Ladan <r.c.ladan@gmail.com>
Cc: freebsd-gnats-submit@FreeBSD.org, freebsd-bugs@FreeBSD.org
Subject: Re: kern/106255: [msdosfs] : correct setting of archive flag
Date: Tue, 5 Dec 2006 12:44:36 +1100 (EST)

 On Mon, 4 Dec 2006, Rene Ladan wrote:
 
 > I've attached a new patch which
 >  * fixes reporting of the flag (as in the previous patch)
 >  * sets the archive flag in DETIMES() when the file is created
 >  * cleans up the logic of not supporting setting the archive flag on
 > directories (chunk 3)
 >  * does not set the flag when (vap->va_atime.tv_sec != VNOVAL) or
 > (vap->va_mode != VNOVAL) in msdosfs_setattr()
 
 The first fix is the one that most needs some directory logic (see a
 previous reply).
 
 Wasn't the archive flag already set in SF_ARCHIVED?
 
 I will enclose my old patches for DETIMES() at the end.  I had noticed
 that the archive flag shouldn't be set for null changes to the times.
 Also, checking for null changes to times is a good optimization in
 general since it avoids some disk writes.  ffs should do it too.  The
 disk writes are delayed so many of them get coalesced, but even 1
 is expensive.  The file time granularity of 1-2 seconds is much longer
 than when CPUs were thousands of times slower.  Of course, this
 optimization becomes null for ffs if you use the vfs.timestamp_precision
 sysctl to set a very small file time granularity.
 
 > I think that only userland tools should send a 'clear request', as the
 > flag only needs to be cleared when the file is backed up.  The kernel
 > cannot know when a file has been backed up.
 
 Except it should be a set request of SF_ARCHIVED.
 
 % --- msdosfs_vnops.c.orig	Sun Dec  3 20:45:24 2006
 % +++ msdosfs_vnops.c	Mon Dec  4 12:43:37 2006
 % @@ -354,7 +354,7 @@
 %  		vap->va_birthtime.tv_nsec = 0;
 %  	}
 %  	vap->va_flags = 0;
 % -	if ((dep->de_Attributes & ATTR_ARCHIVE) == 0)
 % +	if (dep->de_Attributes & ATTR_ARCHIVE)
 %  		vap->va_flags |= SF_ARCHIVED;
 %  	vap->va_gen = 0;
 %  	vap->va_blocksize = pmp->pm_bpcluster;
 
 Needs to do nothing for directories and not change for non-directories.
 
 % @@ -431,12 +431,13 @@
 %  			if (error)
 %  				return (error);
 %  		}
 % -		if (vap->va_flags & ~SF_ARCHIVED)
 % -			return EOPNOTSUPP;
 
 Removing this is just a bug.  It is needed to reject attempts to set
 flags other than SF_ARCHIVED.  All such flags are unsupported.
 
 %  		if (vap->va_flags & SF_ARCHIVED)
 %  			dep->de_Attributes &= ~ATTR_ARCHIVE;
 
 I think the error return for the directory case belongs here, although
 this is inconsistent with the reversal of the flags.  The archive bit
 just doesn't exist for directories so attempts to set SF_ARCHIVED ==
 clear ATTR_ARCHIVE are nonsense.  More importantly, the raw bit with
 the same value as ATTR_ARCHIVE might have a different meaning for
 directories, so it shouldn't be cleared blindly.
 
 % -		else if (!(dep->de_Attributes & ATTR_DIRECTORY))
 % -			dep->de_Attributes |= ATTR_ARCHIVE;
 % +		else
 % +			if (dep->de_Attributes & ATTR_DIRECTORY)
 % +				return EOPNOTSUPP;
 % +			else 
 % +				dep->de_Attributes |= ATTR_ARCHIVE;
 
 This has some indentation errors.
 
 The multiple reversals make this error handling very confusing and wrong,
 especially for directories:
 - ATTR_ARCHIVE should be clear initially.  Reversing the reversal in setattr
    gives SF_ARCHIVED clear for the wrong reason.
 - now if we cp -p the direcctory, then we don't try to set SF_ARCHIVED so
    we reach the above.  SF_ARCHIVED clear is interpreted as a request to
    set ATTR_ARCHIVE and rejected.
 
 Untested fixes:
 
  		if (dep->de_Attributes & ATTR_DIRECTORY) {
  			if (vap->va_flags & SF_ARCHIVED)
  				return (EOPNOTSUPP);
  		} else {
  			if (vap->va_flags & SF_ARCHIVED) {
  				dep->de_Attributes &= ~ATTR_ARCHIVE;
  			else
  				dep->de_Attributes |= ATTR_ARCHIVE;
  		}
 
 %  		dep->de_flag |= DE_MODIFIED;
 %  	}
 % 
 % @@ -506,8 +507,9 @@
 %  				dep->de_flag &= ~DE_UPDATE;
 %  				timespec2fattime(&vap->va_mtime, 0,
 %  				    &dep->de_MDate, &dep->de_MTime, NULL);
 % +				dep->de_Attributes |= ATTR_ARCHIVE;
 % +				/* only set archive flag when file has changed */
 
 Various style bugs in the comment.
 
 %  			}
 % -			dep->de_Attributes |= ATTR_ARCHIVE;
 %  			dep->de_flag |= DE_MODIFIED;
 
 Now it doesn't set the archive flag when the atime changes but the mtime
 doesn't change.  Is this intentional?  This change has no effect since
 all callers set both times and we don't check for null changes to the
 times.  Checking for null changes here is not worth it as an optimization,
 but probably right for correctness (so as not to set the archive flag for
 null changes).
 
 We don't handle null changes for setting attributes in general.  Msdosfs
 doesn't have many attributes so the only other problem cases are:
 - null changes to the archive bit itself.  Not detecting these is only
    a pessimization.  It doesn't mess up the archive bit itself.
 - null changes to the mode.  These force the archive bit on (for
    directories only).
 
 I once made some minor improvements for null changes to attributes in
 ffs.  IIRC, they were for chown(), and the result is the following
 very delicate handling of null changes:
 - permission is required for even null changes of the uid
 - no extra permission is required for null changes of the gid (non-null
    changes require certain group permission).  This is what I changed.
 - even null changes must update the inode change time (POSIX spec).
    Similarly for other null changes to attributes.  Thus changes to
    attributes can only end up as null if the inode change time update
    is null.
 msdosfs doesn't have uids, gids or inode change times, so it cannot be
 a POSIX file system and has more possible null changes to attributes.
 
 %  		}
 %  	}
 % @@ -531,7 +533,6 @@
 %  				dep->de_Attributes &= ~ATTR_READONLY;
 %  			else
 %  				dep->de_Attributes |= ATTR_READONLY;
 % -			dep->de_Attributes |= ATTR_ARCHIVE;
 %  			dep->de_flag |= DE_MODIFIED;
 %  		}
 %  	}
 
 This is for chmod().  I don't think this is right.  Changes to the mode
 should be backed up.
 
 % --- denode.h.orig	Thu Oct 26 11:21:07 2006
 % +++ denode.h	Mon Dec  4 12:35:00 2006
 % @@ -239,6 +239,7 @@
 %  		timespec2fattime((cre), 0, &(dep)->de_CDate,		\
 %  		    &(dep)->de_CTime, &(dep)->de_CHun);			\
 %  		    (dep)->de_flag |= DE_MODIFIED;			\
 % +		    (dep)->de_Attributes |= ATTR_ARCHIVE;		\
 %  	}								\
 %  	(dep)->de_flag &= ~(DE_UPDATE | DE_CREATE | DE_ACCESS);		\
 %  } while (0)
 
 Hmm, if the setting is forced in DETIMES() then it might cover changes in
 msdosfs_setattr(), like updating the inode change time does in ffs. but
 the time here is only the creation time -- the archive flag needs to be
 set here but it won't cover all changes like the inode change time does.
 
 Here is my old patch for DETIMES():
 
 % Index: denode.h
 % ===================================================================
 % RCS file: /home/ncvs/src/sys/fs/msdosfs/denode.h,v
 % retrieving revision 1.27
 % diff -u -2 -r1.27 denode.h
 % --- denode.h	26 Dec 2003 17:24:37 -0000	1.27
 % +++ denode.h	27 Dec 2003 07:55:25 -0000
 % @@ -220,4 +220,5 @@
 %  #define	DETIMES(dep, acc, mod, cre) do {				\
 %  	if ((dep)->de_flag & DE_UPDATE) { 				\
 % +		/* XXX missing optimization for no-change case. */	\
 %  		(dep)->de_flag |= DE_MODIFIED;				\
 %  		unix2dostime((mod), &(dep)->de_MDate, &(dep)->de_MTime,	\
 % @@ -236,13 +237,16 @@
 %  			(dep)->de_flag |= DE_MODIFIED;			\
 %  			(dep)->de_ADate = adate;			\
 % +			/* XXX intentionally don't set ATTR_ARCHIVE. */	\
 %  		}							\
 %  	}								\
 %  	if ((dep)->de_flag & DE_CREATE) {				\
 % +		/* XXX missing optimization for no-change case. */	\
 %  		unix2dostime((cre), &(dep)->de_CDate, &(dep)->de_CTime,	\
 %  		    &(dep)->de_CHun);					\
 % -		    (dep)->de_flag |= DE_MODIFIED;			\
 % +		(dep)->de_flag |= DE_MODIFIED;				\
 % +		(dep)->de_Attributes |= ATTR_ARCHIVE;	 		\
 %  	}								\
 %  	(dep)->de_flag &= ~(DE_UPDATE | DE_CREATE | DE_ACCESS);		\
 % -} while (0);
 % +} while (0)
 % 
 %  /*
 
 It is the same as your patch except for comments and an identation fix.
 I didn't understand DE_CREATE when I wrote it.  DE_CREATE is always
 set to gether with DE_UPDATE, and unless there is a bug it is only
 set when the file is created (it is quite different from an inode
 change time).  Thus the above change is null (ATTR_ARCHIVE has already
 been set since DE_UPDATE is set).
 
 Bruce
Responsible-Changed-From-To: freebsd-bugs->trhodes 
Responsible-Changed-By: remko 
Responsible-Changed-When: Fri Dec 29 20:47:44 UTC 2006 
Responsible-Changed-Why:  
assign to tom 

http://www.freebsd.org/cgi/query-pr.cgi?pr=106255 

From: John Baldwin <jhb@freebsd.org>
To: bug-followup@freebsd.org,
 r.c.ladan@gmail.com
Cc: Ken Merry <ken@freebsd.org>
Subject: Re: kern/106255: [msdosfs] [patch]: correct setting of archive flag
Date: Fri, 3 May 2013 11:51:51 -0400

 Posssibly this one is relevant to Ken's file flags patches as well.
 
 -- 
 John Baldwin
>Unformatted:
