1
From: Thomas Schwinge <thomas@schwinge.name>
2
Subject: [PATCH] struct_stat
6
Needed for HEAD and glibc-2_7-branch.
8
<http://sources.redhat.com/ml/libc-alpha/2002-12/msg00011.html>
10
Reported on <http://savannah.gnu.org/bugs/?18216>.
13
2007-10-05 Thomas Schwinge <tschwinge@gnu.org>
15
* sysdeps/mach/hurd/bits/stat.h (struct stat): Align to what is done
16
for Linux: use nsec instead of usec, as well as:
17
[__USE_MISC] (st_atim, st_mtim, st_ctim): Provide these ``struct
19
(struct stat64): Likewise.
20
(_STATBUF_ST_NSEC): Define.
21
* sysdeps/mach/hurd/xstatconv.c (xstat64_conv): Adapt to that.
24
sysdeps/mach/hurd/bits/stat.h | 56 +++++++++++++++++++++++++++++++---------
25
sysdeps/mach/hurd/xstatconv.c | 9 ++----
26
2 files changed, 46 insertions(+), 19 deletions(-)
28
diff --git a/sysdeps/mach/hurd/bits/stat.h b/sysdeps/mach/hurd/bits/stat.h
29
index b64a658..50d18c4 100644
30
--- a/sysdeps/mach/hurd/bits/stat.h
31
+++ b/sysdeps/mach/hurd/bits/stat.h
32
@@ -59,12 +59,27 @@ struct stat
33
__off64_t st_size; /* Size in bytes. */
36
- __time_t st_atime; /* Access time, seconds */
37
- unsigned long int st_atime_usec; /* and microseconds. */
38
- __time_t st_mtime; /* Modification time, seconds */
39
- unsigned long int st_mtime_usec; /* and microseconds. */
40
- __time_t st_ctime; /* Status change time, seconds */
41
- unsigned long int st_ctime_usec; /* and microseconds. */
42
+#if defined(__USE_MISC) || defined(__USE_XOPEN2K8)
43
+ /* Nanosecond resolution timestamps are stored in a format
44
+ equivalent to 'struct timespec'. This is the type used
45
+ whenever possible but the Unix namespace rules do not allow the
46
+ identifier 'timespec' to appear in the <sys/stat.h> header.
47
+ Therefore we have to handle the use of this header in strictly
48
+ standard-compliant sources special. */
49
+ struct timespec st_atim; /* Time of last access. */
50
+ struct timespec st_mtim; /* Time of last modification. */
51
+ struct timespec st_ctim; /* Time of last status change. */
52
+# define st_atime st_atim.tv_sec /* Backward compatibility. */
53
+# define st_mtime st_mtim.tv_sec
54
+# define st_ctime st_ctim.tv_sec
56
+ __time_t st_atime; /* Time of last access. */
57
+ unsigned long int st_atimensec; /* Nscecs of last access. */
58
+ __time_t st_mtime; /* Time of last modification. */
59
+ unsigned long int st_mtimensec; /* Nsecs of last modification. */
60
+ __time_t st_ctime; /* Time of last status change. */
61
+ unsigned long int st_ctimensec; /* Nsecs of last status change. */
64
__blksize_t st_blksize; /* Optimal size for I/O. */
66
@@ -108,12 +123,24 @@ struct stat64
68
__off64_t st_size; /* Size in bytes. */
70
- __time_t st_atime; /* Access time, seconds */
71
- unsigned long int st_atime_usec; /* and microseconds. */
72
- __time_t st_mtime; /* Modification time, seconds */
73
- unsigned long int st_mtime_usec; /* and microseconds. */
74
- __time_t st_ctime; /* Status change time, seconds */
75
- unsigned long int st_ctime_usec; /* and microseconds. */
76
+#if defined(__USE_MISC) || defined(__USE_XOPEN2K8)
77
+ /* Nanosecond resolution timestamps are stored in a format
78
+ equivalent to 'struct timespec'. This is the type used
79
+ whenever possible but the Unix namespace rules do not allow the
80
+ identifier 'timespec' to appear in the <sys/stat.h> header.
81
+ Therefore we have to handle the use of this header in strictly
82
+ standard-compliant sources special. */
83
+ struct timespec st_atim; /* Time of last access. */
84
+ struct timespec st_mtim; /* Time of last modification. */
85
+ struct timespec st_ctim; /* Time of last status change. */
87
+ __time_t st_atime; /* Time of last access. */
88
+ unsigned long int st_atimensec; /* Nscecs of last access. */
89
+ __time_t st_mtime; /* Time of last modification. */
90
+ unsigned long int st_mtimensec; /* Nsecs of last modification. */
91
+ __time_t st_ctime; /* Time of last status change. */
92
+ unsigned long int st_ctimensec; /* Nsecs of last status change. */
95
__blksize_t st_blksize; /* Optimal size for I/O. */
97
@@ -131,7 +158,10 @@ struct stat64
101
-#define _STATBUF_ST_BLKSIZE /* Tell code we have this member. */
102
+/* Tell code we have these members. */
103
+#define _STATBUF_ST_BLKSIZE
104
+/* Nanosecond resolution time values are supported. */
105
+#define _STATBUF_ST_NSEC
107
/* Encoding of the file mode. */
109
diff --git a/sysdeps/mach/hurd/xstatconv.c b/sysdeps/mach/hurd/xstatconv.c
110
index e28643c..d320285 100644
111
--- a/sysdeps/mach/hurd/xstatconv.c
112
+++ b/sysdeps/mach/hurd/xstatconv.c
113
@@ -42,12 +42,9 @@ xstat64_conv (struct stat *buf, const struct stat64 *buf64)
114
buf->st_uid = buf64->st_uid;
115
buf->st_gid = buf64->st_gid;
116
buf->st_size = buf64->st_size;
117
- buf->st_atime = buf64->st_atime;
118
- buf->st_atime_usec = buf64->st_atime_usec;
119
- buf->st_mtime = buf64->st_mtime;
120
- buf->st_mtime_usec = buf64->st_mtime_usec;
121
- buf->st_ctime = buf64->st_ctime;
122
- buf->st_ctime_usec = buf64->st_ctime_usec;
123
+ buf->st_atim = buf64->st_atim;
124
+ buf->st_mtim = buf64->st_mtim;
125
+ buf->st_ctim = buf64->st_ctim;
126
buf->st_blksize = buf64->st_blksize;
127
buf->st_blocks = buf64->st_blocks;
128
buf->st_author = buf64->st_author;
129
tg: (0234227..) t/struct_stat (depends on: baseline)