Date: Fri, 20 Sep 1996 19:57:18 +0300 (EET DST) From: Sakari Jalovaara <sja@sja.home.tekla.fi> To: FreeBSD-gnats-submit@freebsd.org Subject: bin/1657: ls(1) output of future mtime Message-ID: <199609201657.TAA00841@sja.home.tekla.fi> Resent-Message-ID: <199609201700.KAA05754@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 1657 >Category: bin >Synopsis: ls(1) output of future mtime >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Sep 20 10:00:01 PDT 1996 >Last-Modified: >Originator: Sakari Jalovaara >Organization: >Release: FreeBSD 2.2-960801-SNAP i386 >Environment: Any >Description: If a file has modification time far in the future, the output of ls(1) does not show the modification year. (Ditto for access and change times.) >How-To-Repeat: Create a file with a modification time more than a year in the future (e.g. use "touch -t".) Type "ls -lt". E.g.: (note that "Sep 13" seems to be sorted before "Sep 14", which is confusing) ~/Xm (sja@estabur) 127> /bin/ls -lt DialogS* -rw-r--r-- 1 sja sja 5328 Sep 13 23:29 DialogS.c -rw-r--r-- 1 sja sja 62413 Sep 14 16:24 DialogS.o ~/Xm (sja@estabur) 128> /bin/ls -ltT DialogS* -rw-r--r-- 1 sja sja 5328 Sep 13 23:29:31 2000 DialogS.c -rw-r--r-- 1 sja sja 62413 Sep 14 16:24:43 1996 DialogS.o (The cause of the above 4-year time warp is unknown. Kernel bug, hardware clock glitch, ...?) ls should _not_ print the year for _all_ future times, since network file systems often cause time shifts of a few seconds. The year is useful for dates more than six months in the future. >Fix: /usr/src/bin/ls/print.c, function printtime(): *** print.c.orig Sat Sep 14 16:45:55 1996 --- print.c Sat Sep 14 16:53:51 1996 *************** *** 231,236 **** --- 231,240 ---- { int i; char longstring[80]; + static time_t now; + + if (now == 0) + now = time(NULL); strftime(longstring, sizeof(longstring), "%c", localtime(&ftime)); for (i = 4; i < 11; ++i) *************** *** 240,246 **** if (f_sectime) for (i = 11; i < 24; i++) (void)putchar(longstring[i]); ! else if (ftime + SIXMONTHS > time(NULL)) for (i = 11; i < 16; ++i) (void)putchar(longstring[i]); else { --- 244,250 ---- if (f_sectime) for (i = 11; i < 24; i++) (void)putchar(longstring[i]); ! else if (ftime + SIXMONTHS > now && ftime < now + SIXMONTHS) for (i = 11; i < 16; ++i) (void)putchar(longstring[i]); else { >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199609201657.TAA00841>