This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ``struct stat'' issue


Hello!

On Sun, Jun 10, 2007 at 07:49:34PM -0700, Roland McGrath wrote:
> In stat.h, the pedantic-mode members need to be called nsec, not usec.
> They are just another name for the struct timespec, which is ns, not us.

I changed that and aligned to the Linux version.


> Other stat.h changes unrelated to st_?tim* do not belong in the same patch.
> Discuss those on their own.

Removed for now.


I did not yet test this patch, but I'm confident it's fine and will test
it and write ChangeLog entries as soon as Roland says that it's fine.

#v+
diff --git a/sysdeps/mach/hurd/bits/stat.h b/sysdeps/mach/hurd/bits/stat.h
index c3f9666..62c4201 100644
--- a/sysdeps/mach/hurd/bits/stat.h
+++ b/sysdeps/mach/hurd/bits/stat.h
@@ -55,12 +55,27 @@ struct stat
     __off64_t st_size;		/* Size in bytes.  */
 #endif
 
-    __time_t st_atime;		/* Access time, seconds */
-    unsigned long int st_atime_usec; /* and microseconds.  */
-    __time_t st_mtime;		/* Modification time, seconds */
-    unsigned long int st_mtime_usec; /* and microseconds.  */
-    __time_t st_ctime;		/* Status change time, seconds */
-    unsigned long int st_ctime_usec; /* and microseconds.  */
+#ifdef __USE_MISC
+    /* Nanosecond resolution timestamps are stored in a format
+       equivalent to 'struct timespec'.  This is the type used
+       whenever possible but the Unix namespace rules do not allow the
+       identifier 'timespec' to appear in the <sys/stat.h> header.
+       Therefore we have to handle the use of this header in strictly
+       standard-compliant sources special.  */
+    struct timespec st_atim;		/* Time of last access.  */
+    struct timespec st_mtim;		/* Time of last modification.  */
+    struct timespec st_ctim;		/* Time of last status change.  */
+# define st_atime st_atim.tv_sec	/* Backward compatibility.  */
+# define st_mtime st_mtim.tv_sec
+# define st_ctime st_ctim.tv_sec
+#else
+    __time_t st_atime;			/* Time of last access.  */
+    unsigned long int st_atimensec;	/* Nscecs of last access.  */
+    __time_t st_mtime;			/* Time of last modification.  */
+    unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
+    __time_t st_ctime;			/* Time of last status change.  */
+    unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
+#endif
 
     __blksize_t st_blksize;	/* Optimal size for I/O.  */
 
@@ -104,12 +119,24 @@ struct stat64
 
     __off64_t st_size;		/* Size in bytes.  */
 
-    __time_t st_atime;		/* Access time, seconds */
-    unsigned long int st_atime_usec; /* and microseconds.  */
-    __time_t st_mtime;		/* Modification time, seconds */
-    unsigned long int st_mtime_usec; /* and microseconds.  */
-    __time_t st_ctime;		/* Status change time, seconds */
-    unsigned long int st_ctime_usec; /* and microseconds.  */
+#ifdef __USE_MISC
+    /* Nanosecond resolution timestamps are stored in a format
+       equivalent to 'struct timespec'.  This is the type used
+       whenever possible but the Unix namespace rules do not allow the
+       identifier 'timespec' to appear in the <sys/stat.h> header.
+       Therefore we have to handle the use of this header in strictly
+       standard-compliant sources special.  */
+    struct timespec st_atim;		/* Time of last access.  */
+    struct timespec st_mtim;		/* Time of last modification.  */
+    struct timespec st_ctim;		/* Time of last status change.  */
+#else
+    __time_t st_atime;			/* Time of last access.  */
+    unsigned long int st_atimensec;	/* Nscecs of last access.  */
+    __time_t st_mtime;			/* Time of last modification.  */
+    unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
+    __time_t st_ctime;			/* Time of last status change.  */
+    unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
+#endif
 
     __blksize_t st_blksize;	/* Optimal size for I/O.  */
 
@@ -127,7 +154,10 @@ struct stat64
   };
 #endif
 
-#define	_STATBUF_ST_BLKSIZE	/* Tell code we have this member.  */
+/* Tell code we have these members.  */
+#define	_STATBUF_ST_BLKSIZE
+/* Nanosecond resolution time values are supported.  */
+#define _STATBUF_ST_NSEC
 
 /* Encoding of the file mode.  */
 
diff --git a/sysdeps/mach/hurd/xstatconv.c b/sysdeps/mach/hurd/xstatconv.c
index e28643c..d320285 100644
--- a/sysdeps/mach/hurd/xstatconv.c
+++ b/sysdeps/mach/hurd/xstatconv.c
@@ -42,12 +42,9 @@ xstat64_conv (struct stat *buf, const struct stat64 *buf64)
   buf->st_uid = buf64->st_uid;
   buf->st_gid = buf64->st_gid;
   buf->st_size = buf64->st_size;
-  buf->st_atime = buf64->st_atime;
-  buf->st_atime_usec = buf64->st_atime_usec;
-  buf->st_mtime = buf64->st_mtime;
-  buf->st_mtime_usec = buf64->st_mtime_usec;
-  buf->st_ctime = buf64->st_ctime;
-  buf->st_ctime_usec = buf64->st_ctime_usec;
+  buf->st_atim = buf64->st_atim;
+  buf->st_mtim = buf64->st_mtim;
+  buf->st_ctim = buf64->st_ctim;
   buf->st_blksize = buf64->st_blksize;
   buf->st_blocks = buf64->st_blocks;
   buf->st_author = buf64->st_author;
#v-


Also, the glibc documentation should be updated (`manual/filesys.texi')
should be updated to not talk about `st_?time_usec' any longer.


Regards,
 Thomas

Attachment: signature.asc
Description: Digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]