bug-hurd
[Top][All Lists]
Advanced

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

``struct stat'' issue


From: Thomas Schwinge
Subject: ``struct stat'' issue
Date: Sun, 10 Jun 2007 23:35:20 +0200
User-agent: Mutt/1.5.11

Hello!

Some months ago I created some patches for the ``struct stat'' issue
(<http://savannah.gnu.org/bugs/?18216>).  Perhaps now the time has come
for someone to review them?  First follows the glibc patch, then the Hurd
one.


glibc patch.

#v+
This patch is incomplete.  Reported on <http://savannah.gnu.org/bugs/?18216>.
The `sysdeps/mach/hurd/bits/stat.h' hunk alignes to what Linux uses.

What about the `st_?time_usec' symbols?  Linux has these as `st_?timensec'.

http://sources.redhat.com/ml/libc-alpha/2002-12/msg00011.html


Index: sysdeps/mach/hurd/xstatconv.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/mach/hurd/xstatconv.c,v
retrieving revision 1.4
diff -u -p -r1.4 xstatconv.c
--- sysdeps/mach/hurd/xstatconv.c       11 Jun 2002 23:03:14 -0000      1.4
+++ sysdeps/mach/hurd/xstatconv.c       13 Jun 2006 13:57:55 -0000
@@ -42,12 +42,18 @@ xstat64_conv (struct stat *buf, const st
   buf->st_uid = buf64->st_uid;
   buf->st_gid = buf64->st_gid;
   buf->st_size = buf64->st_size;
+#ifdef __USE_MISC /* TODO.  Hm.  */
+  buf->st_atim = buf64->st_atim;
+  buf->st_mtim = buf64->st_mtim;
+  buf->st_ctim = buf64->st_ctim;
+#else
   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;
+#endif
   buf->st_blksize = buf64->st_blksize;
   buf->st_blocks = buf64->st_blocks;
   buf->st_author = buf64->st_author;
Index: sysdeps/mach/hurd/bits/stat.h
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/mach/hurd/bits/stat.h,v
retrieving revision 1.7
diff -u -p -r1.7 stat.h
--- sysdeps/mach/hurd/bits/stat.h       8 Nov 2005 01:22:58 -0000       1.7
+++ sysdeps/mach/hurd/bits/stat.h       13 Jun 2006 13:57:55 -0000
@@ -55,12 +56,32 @@ struct stat
     __off64_t st_size;         /* Size in bytes.  */
 #endif
 
+#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
+    /* TODO: Align to the st_atimensec, etc. which Linux uses and define
+       _STATBUF_ST_NSEC?  This requires changes in a) the Hurd code
+       (which uses st_atime_usec etc.) and b) in the glibc documentation
+       (which doesn't mention st_atimensec etc. at all, but does explain
+       the st_atime_usec etc. interface).  */
     __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.  */
+#endif
 
     __blksize_t st_blksize;    /* Optimal size for I/O.  */
 
@@ -104,12 +125,29 @@ struct stat64
 
     __off64_t st_size;         /* Size in bytes.  */
 
+#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
+    /* TODO: Align to the st_atimensec, etc. which Linux uses and define
+       _STATBUF_ST_NSEC?  This requires changes in a) the Hurd code
+       (which uses st_atime_usec etc.) and b) in the glibc documentation
+       (which doesn't mention st_atimensec etc. at all, but does explain
+       the st_atime_used etc. interface).  */
     __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.  */
+#endif
 
     __blksize_t st_blksize;    /* Optimal size for I/O.  */
 
@@ -127,7 +165,8 @@ struct stat64
   };
 #endif
 
-#define        _STATBUF_ST_BLKSIZE     /* Tell code we have this member.  */
+/* Tell code we have these members.  */
+#define        _STATBUF_ST_BLKSIZE
 
 /* Encoding of the file mode.  */
 
@@ -138,23 +177,24 @@ struct stat64
 #define        __S_IFCHR       0020000 /* Character device.  */
 #define        __S_IFBLK       0060000 /* Block device.  */
 #define        __S_IFREG       0100000 /* Regular file.  */
+#define        __S_IFIFO       0010000 /* FIFO.  */
 #define        __S_IFLNK       0120000 /* Symbolic link.  */
 #define        __S_IFSOCK      0140000 /* Socket.  */
-#define        __S_IFIFO       0010000 /* FIFO.  */
 
-/* POSIX.1b objects.  */
-#define __S_TYPEISMQ(buf) (0)
-#define __S_TYPEISSEM(buf) (0)
-#define __S_TYPEISSHM(buf) (0)
+/* POSIX.1b objects.  Note that these macros always evaluate to zero.  But
+   they do it by enforcing the correct use of the macros.  */
+#define __S_TYPEISMQ(buf)  ((buf)->st_mode - (buf)->st_mode)
+#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
+#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
 
 /* Protection bits.  */
 
 #define        __S_ISUID       04000   /* Set user ID on execution.  */
 #define        __S_ISGID       02000   /* Set group ID on execution.  */
 #define        __S_ISVTX       01000   /* Save swapped text after use 
(sticky).  */
-#define        __S_IREAD       00400   /* Read by owner.  */
-#define        __S_IWRITE      00200   /* Write by owner.  */
-#define        __S_IEXEC       00100   /* Execute by owner.  */
+#define        __S_IREAD       0400    /* Read by owner.  */
+#define        __S_IWRITE      0200    /* Write by owner.  */
+#define        __S_IEXEC       0100    /* Execute by owner.  */
 
 
 #ifdef __USE_GNU
#v-


Hurd patch.

#v+
Index: console/console.c
===================================================================
RCS file: /cvsroot/hurd/hurd/console/console.c,v
retrieving revision 1.23
diff -u -p -r1.23 console.c
--- console/console.c   23 Jan 2006 22:19:13 -0000      1.23
+++ console/console.c   30 Mar 2007 15:52:56 -0000
@@ -501,16 +501,24 @@ netfs_attempt_utimes (struct iouser *cre
     {
       if (mtime)
        {
+#if __USE_MISC
+         node->nn_stat.st_mtim = *mtime;
+#else
          node->nn_stat.st_mtime = mtime->tv_sec;
          node->nn_stat.st_mtime_usec = mtime->tv_nsec / 1000;
+#endif
        }
       else
        flags |= TOUCH_MTIME;
       
       if (atime)
        {
+#if __USE_MISC
+         node->nn_stat.st_atim = *atime;
+#else
          node->nn_stat.st_atime = atime->tv_sec;
          node->nn_stat.st_atime_usec = atime->tv_nsec / 1000;
+#endif
        }
       else
        flags |= TOUCH_ATIME;
Index: console-client/trans.c
===================================================================
RCS file: /cvsroot/hurd/hurd/console-client/trans.c,v
retrieving revision 1.2
diff -u -p -r1.2 trans.c
--- console-client/trans.c      11 Jul 2005 13:59:24 -0000      1.2
+++ console-client/trans.c      30 Mar 2007 15:52:56 -0000
@@ -174,16 +174,24 @@ netfs_attempt_utimes (struct iouser *cre
     {
       if (mtime)
         {
+#if __USE_MISC
+          np->nn_stat.st_mtim = *mtime;
+#else
           np->nn_stat.st_mtime = mtime->tv_sec;
           np->nn_stat.st_mtime_usec = mtime->tv_nsec / 1000;
+#endif
         }
       else
         flags |= TOUCH_MTIME;
       
       if (atime)
         {
+#if __USE_MISC
+          np->nn_stat.st_atim = *atime;
+#else
           np->nn_stat.st_atime = atime->tv_sec;
           np->nn_stat.st_atime_usec = atime->tv_nsec / 1000;
+#endif
         }
       else
         flags |= TOUCH_ATIME;
Index: fatfs/inode.c
===================================================================
RCS file: /cvsroot/hurd/hurd/fatfs/inode.c,v
retrieving revision 1.6
diff -u -p -r1.6 inode.c
--- fatfs/inode.c       30 Mar 2007 14:15:49 -0000      1.6
+++ fatfs/inode.c       30 Mar 2007 15:52:56 -0000
@@ -385,9 +385,13 @@ read_node (struct node *np, vm_address_t
   {
     struct timespec ts;
     fat_to_epoch (dr->write_date, dr->write_time, &ts);
+#ifdef __USE_MISC
+    st->st_ctim = st->st_mtim = st->st_atim = ts;
+#else
     st->st_ctime = st->st_mtime = st->st_atime = ts.tv_sec;
     st->st_ctime_usec = st->st_mtime_usec = st->st_atime_usec
       = ts.tv_nsec / 1000;
+#endif
   }
   
   st->st_blksize = bytes_per_sector;
Index: ftpfs/netfs.c
===================================================================
RCS file: /cvsroot/hurd/hurd/ftpfs/netfs.c,v
retrieving revision 1.8
diff -u -p -r1.8 netfs.c
--- ftpfs/netfs.c       29 Dec 2001 22:11:50 -0000      1.8
+++ ftpfs/netfs.c       30 Mar 2007 15:52:56 -0000
@@ -76,16 +76,24 @@ netfs_attempt_utimes (struct iouser *cre
     {
       if (atime)
        {
+#if __USE_MISC
+         node->nn_stat.st_atim = *atime;
+#else
          node->nn_stat.st_atime = atime->tv_sec;
          node->nn_stat.st_atime_usec = atime->tv_nsec / 1000;
+#endif
        }
       else
        flags |= TOUCH_ATIME;
 
       if (mtime)
        {
+#if __USE_MISC
+         node->nn_stat.st_mtim = *mtime;
+#else
          node->nn_stat.st_mtime = mtime->tv_sec;
          node->nn_stat.st_mtime_usec = mtime->tv_nsec / 1000;
+#endif
        }
       else
        flags |= TOUCH_MTIME;
Index: hostmux/node.c
===================================================================
RCS file: /cvsroot/hurd/hurd/hostmux/node.c,v
retrieving revision 1.3
diff -u -p -r1.3 node.c
--- hostmux/node.c      31 Jan 1999 23:48:47 -0000      1.3
+++ hostmux/node.c      30 Mar 2007 15:52:56 -0000
@@ -78,16 +78,24 @@ netfs_attempt_utimes (struct iouser *cre
     {
       if (mtime)
        {
+#if __USE_MISC
+         node->nn_stat.st_mtim = *mtime;
+#else
          node->nn_stat.st_mtime = mtime->tv_sec;
          node->nn_stat.st_mtime_usec = mtime->tv_nsec / 1000;
+#endif
        }
       else
        flags |= TOUCH_MTIME;
       
       if (atime)
        {
+#if __USE_MISC
+         node->nn_stat.st_atim = *atime;
+#else
          node->nn_stat.st_atime = atime->tv_sec;
          node->nn_stat.st_atime_usec = atime->tv_nsec / 1000;
+#endif
        }
       else
        flags |= TOUCH_ATIME;
Index: isofs/inode.c
===================================================================
RCS file: /cvsroot/hurd/hurd/isofs/inode.c,v
retrieving revision 1.17
diff -u -p -r1.17 inode.c
--- isofs/inode.c       25 Mar 2007 20:29:33 -0000      1.17
+++ isofs/inode.c       30 Mar 2007 15:53:01 -0000
@@ -431,9 +431,13 @@ read_disknode (struct node *np, struct d
     {
       struct timespec ts;
       isodate_915 (dr->date, &ts);
+#ifdef __USE_MISC
+      st->st_ctim = st->st_mtim = st->st_atim = ts;
+#else
       st->st_ctime = st->st_mtime = st->st_atime = ts.tv_sec;
       st->st_ctime_usec = st->st_mtime_usec = st->st_atime_usec
        = ts.tv_nsec / 1000;
+#endif
     }
 
   /* Override what we have better info for */
@@ -441,20 +445,32 @@ read_disknode (struct node *np, struct d
     {
       if (rl->tfflags & TF_CREATION)
        {
+#ifdef __USE_MISC
+         st->st_ctim = rl->ctime;
+#else
          st->st_ctime = rl->ctime.tv_sec;
          st->st_ctime_usec = rl->ctime.tv_nsec / 1000;
+#endif
        }
 
       if (rl->tfflags & TF_ACCESS)
        {
+#ifdef __USE_MISC
+         st->st_atim = rl->atime;
+#else
          st->st_atime = rl->atime.tv_sec;
          st->st_atime_usec = rl->atime.tv_nsec / 1000;
+#endif
        }
 
       if (rl->tfflags & TF_MODIFY)
        {
+#ifdef __USE_MISC
+         st->st_mtim = rl->mtime;
+#else
          st->st_mtime = rl->mtime.tv_sec;
          st->st_mtime_usec = rl->mtime.tv_nsec / 1000;
+#endif
        }
     }
 
Index: libdiskfs/node-times.c
===================================================================
RCS file: /cvsroot/hurd/hurd/libdiskfs/node-times.c,v
retrieving revision 1.10
diff -u -p -r1.10 node-times.c
--- libdiskfs/node-times.c      3 Dec 2000 04:40:31 -0000       1.10
+++ libdiskfs/node-times.c      30 Mar 2007 15:53:01 -0000
@@ -41,9 +41,9 @@ diskfs_set_node_times (struct node *np)
      the update will happen at the next call.  */
   if (np->dn_set_mtime)
     {
-#ifdef notyet
-      np->dn_stat.st_mtimespec.ts_sec = t.tv_sec;
-      np->dn_stat.st_mtimespec.ts_nsec = t.tv_usec * 1000;
+#ifdef __USE_MISC
+      np->dn_stat.st_mtim.tv_sec = t.tv_sec;
+      np->dn_stat.st_mtim.tv_nsec = t.tv_usec * 1000;
 #else
       np->dn_stat.st_mtime = t.tv_sec;
       np->dn_stat.st_mtime_usec = t.tv_usec;
@@ -53,9 +53,9 @@ diskfs_set_node_times (struct node *np)
     }
   if (np->dn_set_atime)
     {
-#ifdef notyet
-      np->dn_stat.st_atimespec.ts_sec = t.tv_sec;
-      np->dn_stat.st_atimespec.ts_nsec = t.tv_usec * 1000;
+#ifdef __USE_MISC
+      np->dn_stat.st_atim.tv_sec = t.tv_sec;
+      np->dn_stat.st_atim.tv_nsec = t.tv_usec * 1000;
 #else
       np->dn_stat.st_atime = t.tv_sec;
       np->dn_stat.st_atime_usec = t.tv_usec;
@@ -65,9 +65,9 @@ diskfs_set_node_times (struct node *np)
     }
   if (np->dn_set_ctime)
     {
-#ifdef notyet
-      np->dn_stat.st_ctimespec.ts_sec = t.tv_sec;
-      np->dn_stat.st_ctimespec.ts_nsec = t.tv_usec * 1000;
+#ifdef __USE_MISC
+      np->dn_stat.st_ctim.tv_sec = t.tv_sec;
+      np->dn_stat.st_ctim.tv_nsec = t.tv_usec * 1000;
 #else
       np->dn_stat.st_ctime = t.tv_sec;
       np->dn_stat.st_ctime_usec = t.tv_usec;
Index: libfshelp/touch.c
===================================================================
RCS file: /cvsroot/hurd/hurd/libfshelp/touch.c,v
retrieving revision 1.1
diff -u -p -r1.1 touch.c
--- libfshelp/touch.c   1 Jul 1999 21:04:27 -0000       1.1
+++ libfshelp/touch.c   30 Mar 2007 15:53:01 -0000
@@ -32,17 +32,32 @@ fshelp_touch (struct stat *st, unsigned 
 
   if (what & TOUCH_ATIME)
     {
+#ifdef __USE_MISC
+      st->st_atim.tv_sec = tv.tv_sec;
+      st->st_atim.tv_nsec = tv.tv_usec * 1000;
+#else
       st->st_atime = tv.tv_sec;
       st->st_atime_usec = tv.tv_usec;
+#endif
     }
   if (what & TOUCH_CTIME)
     {
+#ifdef __USE_MISC
+      st->st_ctim.tv_sec = tv.tv_sec;
+      st->st_ctim.tv_nsec = tv.tv_usec * 1000;
+#else
       st->st_ctime = tv.tv_sec;
       st->st_ctime_usec = tv.tv_usec;
+#endif
     }
   if (what & TOUCH_MTIME)
     {
+#ifdef __USE_MISC
+      st->st_mtim.tv_sec = tv.tv_sec;
+      st->st_mtim.tv_nsec = tv.tv_usec * 1000;
+#else
       st->st_mtime = tv.tv_sec;
       st->st_mtime_usec = tv.tv_usec;
+#endif
     }
 }
Index: libtrivfs/times.c
===================================================================
RCS file: /cvsroot/hurd/hurd/libtrivfs/times.c,v
retrieving revision 1.3
diff -u -p -r1.3 times.c
--- libtrivfs/times.c   31 Jan 1999 23:50:16 -0000      1.3
+++ libtrivfs/times.c   30 Mar 2007 15:53:01 -0000
@@ -25,8 +25,13 @@ trivfs_set_atime (struct trivfs_control 
   time_value_t mtime;
   
   io_stat (cntl->underlying, &st);
+#ifdef __USE_MISC
+  mtime.seconds = st.st_mtim.tv_sec;
+  mtime.microseconds = st.st_mtim.tv_nsec / 1000;
+#else
   mtime.seconds = st.st_mtime;
   mtime.microseconds = st.st_mtime_usec;
+#endif
   atime.microseconds = -1;
   file_utimes (cntl->underlying, atime, mtime);
   return 0;
@@ -40,8 +45,13 @@ trivfs_set_mtime (struct trivfs_control 
   time_value_t mtime;
 
   io_stat (cntl->underlying, &st);
+#ifdef __USE_MISC
+  atime.seconds = st.st_atim.tv_sec;
+  atime.microseconds = st.st_atim.tv_nsec / 1000;
+#else
   atime.seconds = st.st_atime;
   atime.microseconds = st.st_atime_usec;
+#endif
   mtime.microseconds = -1;
   file_utimes (cntl->underlying, atime, mtime);
   return 0;
Index: nfs/nfs.c
===================================================================
RCS file: /cvsroot/hurd/hurd/nfs/nfs.c,v
retrieving revision 1.27
diff -u -p -r1.27 nfs.c
--- nfs/nfs.c   29 Sep 2002 15:11:59 -0000      1.27
+++ nfs/nfs.c   30 Mar 2007 15:53:01 -0000
@@ -335,10 +335,17 @@ xdr_encode_sattr_stat (int *p,
       *(p++) = htonl (st->st_uid);
       *(p++) = htonl (st->st_gid);
       *(p++) = htonl (st->st_size);
+#if __USE_MISC
+      *(p++) = htonl (st->st_atim.tv_sec);
+      *(p++) = htonl (st->st_atim.tv_nsec / 1000);
+      *(p++) = htonl (st->st_mtim.tv_sec);
+      *(p++) = htonl (st->st_mtim.tv_nsec / 1000);
+#else
       *(p++) = htonl (st->st_atime);
       *(p++) = htonl (st->st_atime_usec);
       *(p++) = htonl (st->st_mtime);
       *(p++) = htonl (st->st_mtime_usec);
+#endif
     }
   else
     {
@@ -351,11 +358,21 @@ xdr_encode_sattr_stat (int *p,
       *(p++) = htonl (1);              /* set size */
       p = xdr_encode_64bit (p, st->st_size);
       *(p++) = htonl (SET_TO_CLIENT_TIME); /* set atime */
+#if __USE_MISC
+      *(p++) = htonl (st->st_atim.tv_sec);
+      *(p++) = htonl (st->st_atim.tv_nsec);
+#else
       *(p++) = htonl (st->st_atime);
       *(p++) = htonl (st->st_atime_usec * 1000);
+#endif
       *(p++) = htonl (SET_TO_CLIENT_TIME); /* set mtime */
+#if __USE_MISC
+      *(p++) = htonl (st->st_mtim.tv_sec);
+      *(p++) = htonl (st->st_mtim.tv_nsec);
+#else
       *(p++) = htonl (st->st_mtime);
       *(p++) = htonl (st->st_mtime_usec * 1000);
+#endif
     }
   return p;
 }
@@ -442,6 +459,27 @@ xdr_decode_fattr (int *p, struct stat *s
   p++;
   st->st_ino = ntohl (*p);
   p++;
+#if __USE_MISC
+  st->st_atim.tv_sec = ntohl (*p);
+  p++;
+  st->st_atim.tv_nsec = ntohl (*p);
+  p++;
+  st->st_mtim.tv_sec = ntohl (*p);
+  p++;
+  st->st_mtim.tv_nsec = ntohl (*p);
+  p++;
+  st->st_ctim.tv_sec = ntohl (*p);
+  p++;
+  st->st_ctim.tv_nsec = ntohl (*p);
+  p++;
+
+  if (protocol_version < 3)
+    {
+      st->st_atim.tv_nsec *= 1000;
+      st->st_mtim.tv_nsec *= 1000;
+      st->st_ctim.tv_nsec *= 1000;
+    }
+#else /* __USE_MISC */
   st->st_atime = ntohl (*p);
   p++;
   st->st_atime_usec = ntohl (*p);
@@ -461,6 +499,7 @@ xdr_decode_fattr (int *p, struct stat *s
       st->st_mtime_usec /= 1000;
       st->st_ctime_usec /= 1000;
     }
+#endif /* __USE_MISC */
 
   return p;
 
Index: nfsd/ops.c
===================================================================
RCS file: /cvsroot/hurd/hurd/nfsd/ops.c,v
retrieving revision 1.8
diff -u -p -r1.8 ops.c
--- nfsd/ops.c  29 Sep 2002 15:12:48 -0000      1.8
+++ nfsd/ops.c  30 Mar 2007 15:53:01 -0000
@@ -104,18 +104,41 @@ complete_setattr (mach_port_t port,
     mtime.microseconds = 0;
 
   if (atime.seconds == -1)
+#if __USE_MISC
+    atime.seconds = st.st_atim.tv_sec;
+#else
     atime.seconds = st.st_atime;
+#endif
   if (atime.microseconds == -1)
+#if __USE_MISC
+    atime.microseconds = st.st_atim.tv_nsec / 1000;
+#else
     atime.microseconds = st.st_atime_usec;
+#endif
   if (mtime.seconds == -1)
+#if __USE_MISC
+    mtime.seconds = st.st_mtim.tv_sec;
+#else
     mtime.seconds = st.st_mtime;
+#endif
   if (mtime.microseconds == -1)
+#if __USE_MISC
+    mtime.microseconds = st.st_mtim.tv_nsec / 1000;
+#else
     mtime.microseconds = st.st_mtime_usec;
+#endif
 
+#if __USE_MISC
+  if (atime.seconds != st.st_atim.tv_sec
+      || atime.microseconds != st.st_atim.tv_nsec / 1000
+      || mtime.seconds != st.st_mtim.tv_sec
+      || mtime.microseconds != st.st_mtim.tv_nsec / 1000)
+#else
   if (atime.seconds != st.st_atime
       || atime.microseconds != st.st_atime_usec
       || mtime.seconds != st.st_mtime
       || mtime.microseconds != st.st_mtime_usec)
+#endif
     err = file_utimes (port, atime, mtime);
 
   return err;
Index: nfsd/xdr.c
===================================================================
RCS file: /cvsroot/hurd/hurd/nfsd/xdr.c,v
retrieving revision 1.5
diff -u -p -r1.5 xdr.c
--- nfsd/xdr.c  29 Sep 2002 15:12:48 -0000      1.5
+++ nfsd/xdr.c  30 Mar 2007 15:53:02 -0000
@@ -76,12 +76,21 @@ encode_fattr (int *p, struct stat *st, i
   *(p++) = htonl (st->st_blocks);
   *(p++) = htonl (st->st_fsid);
   *(p++) = htonl (st->st_ino);
+#if __USE_MISC
+  *(p++) = htonl (st->st_atim.tv_sec);
+  *(p++) = htonl (st->st_atim.tv_nsec / 1000);
+  *(p++) = htonl (st->st_mtim.tv_sec);
+  *(p++) = htonl (st->st_mtim.tv_nsec / 1000);
+  *(p++) = htonl (st->st_ctim.tv_sec);
+  *(p++) = htonl (st->st_ctim.tv_nsec / 1000);
+#else
   *(p++) = htonl (st->st_atime);
   *(p++) = htonl (st->st_atime_usec);
   *(p++) = htonl (st->st_mtime);
   *(p++) = htonl (st->st_mtime_usec);
   *(p++) = htonl (st->st_ctime);
   *(p++) = htonl (st->st_ctime_usec);
+#endif
   return p;
 }
 
Index: pflocal/io.c
===================================================================
RCS file: /cvsroot/hurd/hurd/pflocal/io.c,v
retrieving revision 1.41
diff -u -p -r1.41 io.c
--- pflocal/io.c        29 Aug 2005 09:41:21 -0000      1.41
+++ pflocal/io.c        30 Mar 2007 15:53:02 -0000
@@ -272,11 +272,19 @@ S_io_stat (struct sock_user *user, struc
   struct sock *sock;
   struct pipe *rpipe, *wpipe;
 
+#if __USE_MISC
+  void copy_time (time_value_t *from, time_t *to_sec, unsigned long *to_nsec)
+    {
+      *to_sec = from->seconds;
+      *to_nsec = from->microseconds * 1000;
+    }
+#else
   void copy_time (time_value_t *from, time_t *to_sec, unsigned long *to_usec)
     {
       *to_sec = from->seconds;
       *to_usec = from->microseconds;
     }
+#endif
 
   if (!user)
     return EOPNOTSUPP;
@@ -300,7 +308,11 @@ S_io_stat (struct sock_user *user, struc
   if (rpipe)
     {
       mutex_lock (&rpipe->lock);
+#if __USE_MISC
+      copy_time (&rpipe->read_time, &st->st_atim.tv_sec, &st->st_atim.tv_nsec);
+#else
       copy_time (&rpipe->read_time, &st->st_atime, &st->st_atime_usec);
+#endif
       /* This seems useful.  */
       st->st_size = pipe_readable (rpipe, 1);
       mutex_unlock (&rpipe->lock);
@@ -309,11 +321,19 @@ S_io_stat (struct sock_user *user, struc
   if (wpipe)
     {
       mutex_lock (&wpipe->lock);
+#if __USE_MISC
+      copy_time (&wpipe->write_time, &st->st_mtim.tv_sec, 
&st->st_mtim.tv_nsec);
+#else
       copy_time (&wpipe->write_time, &st->st_mtime, &st->st_mtime_usec);
+#endif
       mutex_unlock (&wpipe->lock);
     }
 
+#if __USE_MISC
+  copy_time (&sock->change_time, &st->st_ctim.tv_sec, &st->st_ctim.tv_nsec);
+#else
   copy_time (&sock->change_time, &st->st_ctime, &st->st_ctime_usec);
+#endif
 
   mutex_unlock (&sock->lock);
 
Index: ufs/inode.c
===================================================================
RCS file: /cvsroot/hurd/hurd/ufs/inode.c,v
retrieving revision 1.59
diff -u -p -r1.59 inode.c
--- ufs/inode.c 11 Jun 2002 21:41:06 -0000      1.59
+++ ufs/inode.c 30 Mar 2007 15:53:02 -0000
@@ -231,10 +231,11 @@ read_disknode (struct node *np)
                 | (di->di_trans ? S_IPTRANS : 0));
   st->st_nlink = read_disk_entry (di->di_nlink);
   st->st_size = read_disk_entry (di->di_size);
-#ifdef notyet
-  st->st_atimespec = di->di_atime;
-  st->st_mtimespec = di->di_mtime;
-  st->st_ctimespec = di->di_ctime;
+#ifdef __USE_MISC
+  /* Correct?  No need for `read_disk_entry'?  Probably.  */
+  st->st_atim = di->di_atime;
+  st->st_mtim = di->di_mtime;
+  st->st_ctim = di->di_ctime;
 #else
   st->st_atime = read_disk_entry (di->di_atime.tv_sec);
   st->st_atime_usec = read_disk_entry (di->di_atime.tv_nsec) / 1000;
@@ -357,10 +358,11 @@ write_node (struct node *np)
 
       write_disk_entry (di->di_nlink, st->st_nlink);
       write_disk_entry (di->di_size, st->st_size);
-#ifdef notyet
-      di->di_atime = st->st_atimespec;
-      di->di_mtime = st->st_mtimespec;
-      di->di_ctime = st->st_ctimespec;
+#ifdef __USE_MISC
+      /* Correct?  No need for `write_disk_entry'?  Probably.  */
+      di->di_atime = st->st_atim;
+      di->di_mtime = st->st_mtim;
+      di->di_ctime = st->st_ctim;
 #else
       write_disk_entry (di->di_atime.tv_sec, st->st_atime);
       write_disk_entry (di->di_atime.tv_nsec, st->st_atime_usec * 1000);
Index: usermux/node.c
===================================================================
RCS file: /cvsroot/hurd/hurd/usermux/node.c,v
retrieving revision 1.3
diff -u -p -r1.3 node.c
--- usermux/node.c      28 Feb 1999 16:35:07 -0000      1.3
+++ usermux/node.c      30 Mar 2007 15:53:02 -0000
@@ -80,16 +80,24 @@ netfs_attempt_utimes (struct iouser *cre
     {
       if (mtime)
        {
+#if __USE_MISC
+         node->nn_stat.st_mtim = *mtime;
+#else
          node->nn_stat.st_mtime = mtime->tv_sec;
          node->nn_stat.st_mtime_usec = mtime->tv_nsec / 1000;
+#endif
        }
       else
        flags |= TOUCH_MTIME;
 
       if (atime)
        {
+#if __USE_MISC
+         node->nn_stat.st_atim = *atime;
+#else
          node->nn_stat.st_atime = atime->tv_sec;
          node->nn_stat.st_atime_usec = atime->tv_nsec / 1000;
+#endif
        }
       else
        flags |= TOUCH_ATIME;
#v-


Regards,
 Thomas

Attachment: signature.asc
Description: Digital signature


reply via email to

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