bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

mtime nanoseconds on AIX


From: Bruno Haible
Subject: mtime nanoseconds on AIX
Date: Fri, 30 Mar 2007 00:05:38 +0200
User-agent: KMail/1.5.4

Hi,

Built coreutils-6.9 on AIX 4.3.2 and using these binaries on AIX 5.1.
'ls' and 'stat' show modification times with negative nanosecond values,
on a filesystem of type 'jfs2' (e.g. /tmp).

$ stat abc9
  File: `abc9'
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: a0007h/655367d  Inode: 52          Links: 1
Access: (0644/-rw-r--r--)  Uid: (  299/  haible)   Gid: (  430/    user)
Access: 2007-03-29 22:37:57.-1140204768 
Modify: 2007-03-29 22:35:25.-1707590240 
Change: 2007-03-29 22:35:25.-1707590240 
$ ls -l --full-time abc9
-rw-r--r-- 1 haible user 0 2007-03-29 22:35:25.-1707590240 +0100abc9

This happens on average on every second file.

To investigate this, I wrote a simple program which prints the st_spare2
value of the 'struct stat' of a file, filled a directory with 1000 files
created over a time period of a few seconds, and printed the st_spare2 value
of each.
  $ find . -type f | xargs -n 1 a.out | sort -n
7463700
7463700
7464697
7464802
7464802
7464859
7464859
7465053
7465264
7465264
17462924
17462924
...
987465545
987465617
987465633
997464420
997464436
997464614
997465457
997465546
997465546
997465910
997465910
997465943

As you can see, the range of the st_spare2 field is 0 .. 10^9. The negative
values come from an integer overflow caused by a multiplication with 1000
in coreutils-6.9/lib/stat-time.h:134.

Bruno

--------- Program that prints st_spare2 field ------
/*#define _LARGE_FILES 1*/
#include <sys/stat.h>
#include <stdio.h>
int main (int argc, char *argv[])
{
  struct stat statbuf;
  memset (&statbuf, 0, sizeof (struct stat));
  if (stat (argv[1], &statbuf) < 0) return 1;
  printf ("%d\n", statbuf.st_spare2);
  return 0;
}





reply via email to

[Prev in Thread] Current Thread [Next in Thread]