Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Nov 2006 14:40:39 +0100 (CET)
From:      Oliver Fromme <olli@lurza.secnetix.de>
To:        freebsd-fs@FreeBSD.ORG, r.c.ladan@gmail.com
Subject:   Re: file creation timestamps wrong on msdos fs?
Message-ID:  <200611271340.kARDed3F033672@lurza.secnetix.de>
In-Reply-To: <456AB7B8.6010504@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Rene Ladan wrote:
 > rene@s000655:~>cd /media/stick
 > rene@s000655:/media/stick>date && touch a-new-dos-file
 > ma 27 nov 2006 10:53:59 CET
 > rene@s000655:/media/stick>ls -lUT a-new-dos-file
 > -rwxr-xr-x  1 rene  wheel  0  1 jan 01:11:23 1970 a-new-dos-file
 >                                     ^^^^^^^^^^^^^
 > 
 > Any idea why this happens?  ls and msdosfs themselves seem to be
 > alright.  The access and modification timestamps of msdosfs files are
 > shown correctly.

There seems to be a bug in src/sys/fs/msdosfs/msdosfs_vnops.c
because of a subtle confusion between what msdosfs calls
"ctime" (creation time) and what UNIX calls "ctime" (inode
change time, unsupported by msdosfs).  If your -current is
older than 2006-10-24, look for these lines:

	dos2unixtime(dep->de_MDate, dep->de_MTime, 0, &vap->va_mtime);
	if (pmp->pm_flags & MSDOSFSMNT_LONGNAME) {
		dos2unixtime(dep->de_ADate, 0, 0, &vap->va_atime);
		dos2unixtime(dep->de_CDate, dep->de_CTime, dep->de_CHun, &vap->va_ctime);
	} else {
		vap->va_atime = vap->va_mtime;
		vap->va_ctime = vap->va_mtime;
	}

If your -current is newer, the dos2unixtime() function has
been replaced by fattime2timespec(), but the rest should be
the same.

The code assigns the "ctime" from the FAT directory entry
node to the "ctime" of the vnode's struct attr, which is
wrong.  Please replace vap->va_ctime by vap->va_birthtime
in the above code (two occurences), then recompile and
install your kernel and reboot (if you load msdosfs as a
kernel module only, then you only need recompile, install,
unload and reload that module, of course).

That should fix the output of "ls -lUT" (please report).
However, the question remains what the vnode's ctime should
be set to.  There's no such thing as an inode change time
in FAT's directory entries.  Maybe it should simply be
copied from the mtime.

Best regards
   Oliver

-- 
Oliver Fromme,  secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing
Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.

PI:
int f[9814],b,c=9814,g,i;long a=1e4,d,e,h;
main(){for(;b=c,c-=14;i=printf("%04d",e+d/a),e=d%a)
while(g=--b*2)d=h*b+a*(i?f[b]:a/5),h=d/--g,f[b]=d%g;}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200611271340.kARDed3F033672>