From owner-freebsd-fs@FreeBSD.ORG Mon Nov 27 13:40:47 2006 Return-Path: X-Original-To: freebsd-fs@FreeBSD.ORG Delivered-To: freebsd-fs@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 244EA16A59C for ; Mon, 27 Nov 2006 13:40:47 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (lurza.secnetix.de [83.120.8.8]) by mx1.FreeBSD.org (Postfix) with ESMTP id DB1F243D45 for ; Mon, 27 Nov 2006 13:39:45 +0000 (GMT) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (zcdsdy@localhost [127.0.0.1]) by lurza.secnetix.de (8.13.4/8.13.4) with ESMTP id kARDedLi033673; Mon, 27 Nov 2006 14:40:44 +0100 (CET) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.13.4/8.13.1/Submit) id kARDed3F033672; Mon, 27 Nov 2006 14:40:39 +0100 (CET) (envelope-from olli) Date: Mon, 27 Nov 2006 14:40:39 +0100 (CET) Message-Id: <200611271340.kARDed3F033672@lurza.secnetix.de> From: Oliver Fromme To: freebsd-fs@FreeBSD.ORG, r.c.ladan@gmail.com In-Reply-To: <456AB7B8.6010504@gmail.com> X-Newsgroups: list.freebsd-fs User-Agent: tin/1.8.2-20060425 ("Shillay") (UNIX) (FreeBSD/4.11-STABLE (i386)) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.1.2 (lurza.secnetix.de [127.0.0.1]); Mon, 27 Nov 2006 14:40:44 +0100 (CET) Cc: Subject: Re: file creation timestamps wrong on msdos fs? X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Nov 2006 13:40:47 -0000 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;}