From owner-freebsd-questions@FreeBSD.ORG Wed Jan 4 14:02:41 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 88E06106564A for ; Wed, 4 Jan 2012 14:02:41 +0000 (UTC) (envelope-from jhs@berklix.com) Received: from tower.berklix.org (tower.berklix.org [83.236.223.114]) by mx1.freebsd.org (Postfix) with ESMTP id 2A94C8FC1C for ; Wed, 4 Jan 2012 14:02:40 +0000 (UTC) Received: from mart.js.berklix.net (p57BCF3E0.dip.t-dialin.net [87.188.243.224]) (authenticated bits=0) by tower.berklix.org (8.14.2/8.14.2) with ESMTP id q04E2Ls7004007; Wed, 4 Jan 2012 14:02:22 GMT (envelope-from jhs@berklix.com) Received: from fire.js.berklix.net (fire.js.berklix.net [192.168.91.41]) by mart.js.berklix.net (8.14.3/8.14.3) with ESMTP id q04E2ABg007040; Wed, 4 Jan 2012 15:02:10 +0100 (CET) (envelope-from jhs@berklix.com) Received: from fire.js.berklix.net (localhost [127.0.0.1]) by fire.js.berklix.net (8.14.4/8.14.4) with ESMTP id q04E1WQL057342; Wed, 4 Jan 2012 15:01:52 +0100 (CET) (envelope-from jhs@fire.js.berklix.net) Message-Id: <201201041401.q04E1WQL057342@fire.js.berklix.net> To: Devin Teske From: "Julian H. Stacey" Organization: http://www.berklix.com BSD Unix Linux Consultancy, Munich Germany User-agent: EXMH on FreeBSD http://www.berklix.com/free/ X-URL: http://www.berklix.com In-reply-to: Your message "Tue, 03 Jan 2012 13:09:13 PST." <050701ccca5b$f2c34560$d849d020$@fisglobal.com> Date: Wed, 04 Jan 2012 15:01:32 +0100 Sender: jhs@berklix.com Cc: 'Dan Nelson' , 'Polytropon' , 'FreeBSD Questions' Subject: Re: Exact timestamp for sorting and renaming files according to creation order X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Jan 2012 14:02:41 -0000 Hi, Devin Teske wrote: > > -----Original Message----- > > From: owner-freebsd-questions@freebsd.org [mailto:owner-freebsd- > > questions@freebsd.org] On Behalf Of Polytropon > > Sent: Tuesday, January 03, 2012 1:00 PM > > To: Dan Nelson > > Cc: FreeBSD Questions > > Subject: Re: Exact timestamp for sorting and renaming files according to > creation > > order > > > > On Tue, 3 Jan 2012 14:49:02 -0600, Dan Nelson wrote: > > > If you ask for the date to be printed in "float" (F) format, it gives > > > more precision. The default is unsigned int (U) format. > > > > > > % stat -f "%N %FB" /COPYRIGHT > > > /COPYRIGHT 1306190895.046721049 > > > > Strangely, I only get a 000000000 "suffix" for any time stamp, no matter if I > create > > the file or apply the command as shown above to an existing file: > > > > % stat -f "%N %FB" /COPYRIGHT > > /COPYRIGHT 1313951230.000000000 > > > > Am I missing some file system feature? > > > > Otherwise, this _exactly_ looks like what I'm searching for. It doesn't need > to be > > a "human-readable" date representation. > > > > by the way, I'm running FreeBSD 8.2-STABLE/x86 of late August 2011 here, file > > system used is UFS2. > > On ZFS, all is well... > > % df -hT /raid1/jails/package8-1/COPYRIGHT > Filesystem Type Size Used Avail Capacity Mounted on > raid1/jails/package8-1 zfs 835G 672M 835G 0% > /raid1/jails/package8-1 > > % stat -f "%N %FB" /raid1/jails/package8-1/COPYRIGHT > /raid1/jails/package8-1/COPYRIGHT 1324356049.328275367 > > But alas, on UFS2: > > % df -hT /COPYRIGHT > Filesystem Type Size Used Avail Capacity Mounted on > /dev/mfid0s1a ufs 989M 64M 846M 7% / > > % stat -f "%N %FB" /COPYRIGHT > /COPYRIGHT 1279505857.000000000 > > -- > Devin I was wondering how df (& stat) could show more than seconds (Remembering back to 1990 & my http://berklix.com/~jhs/src/bsd/jhs/bin/public/statv/ when Unix used unsigned long seconds since 1 jan 1970 ( & MSDOS was seconds divided by 2 since 1 jan 1980 ) ) FreeBSD 8.2-RELEASE /usr/src/usr.bin/stat/stat.c line 320 etc still uses the normal fstat stat lstat. But man 2 stat has extended : #ifndef _POSIX_SOURCE #define st_atime st_atimespec.tv_sec #define st_mtime st_mtimespec.tv_sec #define st_ctime st_ctimespec.tv_sec #endif cd /usr/include/sys ; vi -c/tv_sec /types.h stat.h #if __BSD_VISIBLE #define st_atime st_atimespec.tv_sec struct timespec #include time.h: #include timespec.h: struct timespec {time_t tv_sec;/* seconds */ long tv_nsec;/* nanoseconds */}; I guess extended timespec may get compiled in to VFS but not UFS, but no time to look further, Good luck Polytropn. PS Here with UFS (per Dan's tip, thanks) I see: sysctl vfs.timestamp_precision=2 ; stat -f "%N %FB" /etc/motd /etc/motd 1306839862.000000000 Cheers, Julian -- Julian Stacey, BSD Unix Linux C Sys Eng Consultants Munich http://berklix.com Reply below not above, cumulative like a play script, & indent with "> ". Format: Plain text. Not HTML, multipart/alternative, base64, quoted-printable.