From owner-freebsd-bugs@FreeBSD.ORG Mon Dec 4 12:30:20 2006 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 953C016A416 for ; Mon, 4 Dec 2006 12:30:20 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [69.147.83.40]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8AC6043CAA for ; Mon, 4 Dec 2006 12:29:47 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id kB4CUJmI055979 for ; Mon, 4 Dec 2006 12:30:19 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id kB4CUJ9D055977; Mon, 4 Dec 2006 12:30:19 GMT (envelope-from gnats) Date: Mon, 4 Dec 2006 12:30:19 GMT Message-Id: <200612041230.kB4CUJ9D055977@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Rene Ladan Cc: Subject: Re: kern/106255: [msdosfs] : correct setting of archive flag X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Rene Ladan List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Dec 2006 12:30:20 -0000 The following reply was made to PR kern/106255; it has been noted by GNATS. From: Rene Ladan To: Bruce Evans 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--