From owner-freebsd-bugs Fri Sep 20 10:00:07 1996 Return-Path: owner-bugs Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id KAA05776 for bugs-outgoing; Fri, 20 Sep 1996 10:00:07 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id KAA05754; Fri, 20 Sep 1996 10:00:03 -0700 (PDT) Resent-Date: Fri, 20 Sep 1996 10:00:03 -0700 (PDT) Resent-Message-Id: <199609201700.KAA05754@freefall.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-bugs Resent-Reply-To: FreeBSD-gnats@freefall.FreeBSD.org, sja@sja.home.tekla.fi Received: from sja.home.tekla.fi (ppp8.tekla.fi [192.98.7.98]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id JAA04890 for ; Fri, 20 Sep 1996 09:57:50 -0700 (PDT) Received: (from sja@localhost) by sja.home.tekla.fi (8.7.5/8.7.3) id TAA00841; Fri, 20 Sep 1996 19:57:18 +0300 (EET DST) Message-Id: <199609201657.TAA00841@sja.home.tekla.fi> Date: Fri, 20 Sep 1996 19:57:18 +0300 (EET DST) From: Sakari Jalovaara Reply-To: sja@sja.home.tekla.fi To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: bin/1657: ls(1) output of future mtime Sender: owner-bugs@freebsd.org X-Loop: FreeBSD.org Precedence: bulk >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: