author | Boris Chiu <boris.chiu@oracle.com> |
Wed, 18 Jun 2014 11:31:57 -0700 | |
changeset 1951 | da0722ff8ee6 |
parent 1833 | 0edb05d72e6b |
permissions | -rw-r--r-- |
1833
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
1 |
Changes to implement: |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
2 |
16575074 stat could support birthtime/crtime on ZFS |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
3 |
|
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
4 |
These changes have already been accepted upstream. See: |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
5 |
http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=ea916c70a5fc47ee6036a05416bc7462fd8dc1cd |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
6 |
|
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
7 |
--- coreutils-8.16/configure.ac.orig 2014-03-18 20:12:23.362356112 -0700 |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
8 |
+++ coreutils-8.16/configure.ac 2014-03-18 20:13:47.327463395 -0700 |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
9 |
@@ -240,6 +240,13 @@ |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
10 |
AC_DEFINE([LOCALTIME_CACHE], [1], [FIXME]) |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
11 |
fi |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
12 |
|
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
13 |
+# Assume that if getattrat exists, it's compatible with Solaris 11. |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
14 |
+AC_CHECK_FUNCS([getattrat]) |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
15 |
+if test $ac_cv_func_getattrat = yes; then |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
16 |
+ LIB_NVPAIR=-lnvpair |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
17 |
+ AC_SUBST([LIB_NVPAIR]) |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
18 |
+fi |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
19 |
+ |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
20 |
# SCO-ODT-3.0 is reported to need -los to link programs using initgroups |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
21 |
AC_CHECK_FUNCS([initgroups]) |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
22 |
if test $ac_cv_func_initgroups = no; then |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
23 |
--- coreutils-8.16/src/Makefile.am.orig 2014-03-18 20:19:34.447566111 -0700 |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
24 |
+++ coreutils-8.16/src/Makefile.am 2014-03-18 20:20:20.876086076 -0700 |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
25 |
@@ -326,6 +326,9 @@ |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
26 |
runcon_LDADD += $(LIB_SELINUX) |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
27 |
stat_LDADD += $(LIB_SELINUX) |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
28 |
|
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
29 |
+# for nvlist_lookup_uint64_array |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
30 |
+stat_LDADD += $(LIB_NVPAIR) |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
31 |
+ |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
32 |
# for gettime, settime, utimecmp, utimens |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
33 |
copy_LDADD += $(LIB_CLOCK_GETTIME) |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
34 |
date_LDADD += $(LIB_CLOCK_GETTIME) |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
35 |
--- coreutils-8.16/src/stat.c.orig 2014-03-16 16:55:52.605732676 -0700 |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
36 |
+++ coreutils-8.16/src/stat.c 2014-03-18 20:27:04.302699124 -0700 |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
37 |
@@ -148,6 +148,11 @@ |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
38 |
# endif |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
39 |
#endif |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
40 |
|
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
41 |
+#if HAVE_GETATTRAT |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
42 |
+# include <attr.h> |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
43 |
+# include <sys/nvpair.h> |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
44 |
+#endif |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
45 |
+ |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
46 |
/* FIXME: these are used by printf.c, too */ |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
47 |
#define isodigit(c) ('0' <= (c) && (c) <= '7') |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
48 |
#define octtobin(c) ((c) - '0') |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
49 |
@@ -689,7 +694,7 @@ |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
50 |
/* Print statfs info. Return zero upon success, nonzero upon failure. */ |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
51 |
static bool ATTRIBUTE_WARN_UNUSED_RESULT |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
52 |
print_statfs (char *pformat, size_t prefix_len, unsigned int m, |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
53 |
- char const *filename, |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
54 |
+ int fd, char const *filename, |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
55 |
void const *data) |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
56 |
{ |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
57 |
STRUCT_STATVFS const *statfsbuf = data; |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
58 |
@@ -861,6 +866,38 @@ |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
59 |
return fail; |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
60 |
} |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
61 |
|
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
62 |
+static struct timespec |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
63 |
+get_birthtime (int fd, char const *filename, struct stat const *st) |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
64 |
+{ |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
65 |
+ struct timespec ts = get_stat_birthtime (st); |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
66 |
+ |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
67 |
+#if HAVE_GETATTRAT |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
68 |
+ if (ts.tv_nsec < 0) |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
69 |
+ { |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
70 |
+ nvlist_t *response; |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
71 |
+ if ((fd < 0 |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
72 |
+ ? getattrat (AT_FDCWD, XATTR_VIEW_READWRITE, filename, &response) |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
73 |
+ : fgetattr (fd, XATTR_VIEW_READWRITE, &response)) |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
74 |
+ == 0) |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
75 |
+ { |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
76 |
+ uint64_t *val; |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
77 |
+ uint_t n; |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
78 |
+ if (nvlist_lookup_uint64_array (response, A_CRTIME, &val, &n) == 0 |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
79 |
+ && 2 <= n |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
80 |
+ && val[0] <= TYPE_MAXIMUM (time_t) |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
81 |
+ && val[1] < 1000000000 * 2 /* for leap seconds */) |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
82 |
+ { |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
83 |
+ ts.tv_sec = val[0]; |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
84 |
+ ts.tv_nsec = val[1]; |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
85 |
+ } |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
86 |
+ nvlist_free (response); |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
87 |
+ } |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
88 |
+ } |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
89 |
+#endif |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
90 |
+ |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
91 |
+ return ts; |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
92 |
+} |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
93 |
+ |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
94 |
/* Map a TS with negative TS.tv_nsec to {0,0}. */ |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
95 |
static inline struct timespec |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
96 |
neg_to_zero (struct timespec ts) |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
97 |
@@ -874,7 +911,7 @@ |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
98 |
/* Print stat info. Return zero upon success, nonzero upon failure. */ |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
99 |
static bool |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
100 |
print_stat (char *pformat, size_t prefix_len, unsigned int m, |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
101 |
- char const *filename, void const *data) |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
102 |
+ int fd, char const *filename, void const *data) |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
103 |
{ |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
104 |
struct stat *statbuf = (struct stat *) data; |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
105 |
struct passwd *pw_ent; |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
106 |
@@ -967,7 +1004,7 @@ |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
107 |
break; |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
108 |
case 'w': |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
109 |
{ |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
110 |
- struct timespec t = get_stat_birthtime (statbuf); |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
111 |
+ struct timespec t = get_birthtime (fd, filename, statbuf); |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
112 |
if (t.tv_nsec < 0) |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
113 |
out_string (pformat, prefix_len, "-"); |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
114 |
else |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
115 |
@@ -976,7 +1013,7 @@ |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
116 |
break; |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
117 |
case 'W': |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
118 |
out_epoch_sec (pformat, prefix_len, statbuf, |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
119 |
- neg_to_zero (get_stat_birthtime (statbuf))); |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
120 |
+ neg_to_zero (get_birthtime (fd, filename, statbuf))); |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
121 |
break; |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
122 |
case 'x': |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
123 |
out_string (pformat, prefix_len, human_time (get_stat_atime (statbuf))); |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
124 |
@@ -1051,9 +1088,9 @@ |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
125 |
calling PRINT_FUNC for each %-directive encountered. |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
126 |
Return zero upon success, nonzero upon failure. */ |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
127 |
static bool ATTRIBUTE_WARN_UNUSED_RESULT |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
128 |
-print_it (char const *format, char const *filename, |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
129 |
+print_it (char const *format, int fd, char const *filename, |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
130 |
bool (*print_func) (char *, size_t, unsigned int, |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
131 |
- char const *, void const *), |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
132 |
+ int, char const *, void const *), |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
133 |
void const *data) |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
134 |
{ |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
135 |
bool fail = false; |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
136 |
@@ -1102,7 +1139,8 @@ |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
137 |
putchar ('%'); |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
138 |
break; |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
139 |
default: |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
140 |
- fail |= print_func (dest, len + 1, fmt_code, filename, data); |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
141 |
+ fail |= print_func (dest, len + 1, fmt_code, |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
142 |
+ fd, filename, data); |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
143 |
break; |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
144 |
} |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
145 |
break; |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
146 |
@@ -1185,7 +1223,7 @@ |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
147 |
return false; |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
148 |
} |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
149 |
|
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
150 |
- bool fail = print_it (format, filename, print_statfs, &statfsbuf); |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
151 |
+ bool fail = print_it (format, -1, filename, print_statfs, &statfsbuf); |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
152 |
return ! fail; |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
153 |
} |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
154 |
|
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
155 |
@@ -1194,11 +1232,12 @@ |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
156 |
do_stat (char const *filename, char const *format, |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
157 |
char const *format2) |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
158 |
{ |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
159 |
+ int fd = STREQ (filename, "-") ? 0 : -1; |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
160 |
struct stat statbuf; |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
161 |
|
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
162 |
- if (STREQ (filename, "-")) |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
163 |
+ if (0 <= fd) |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
164 |
{ |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
165 |
- if (fstat (STDIN_FILENO, &statbuf) != 0) |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
166 |
+ if (fstat (fd, &statbuf) != 0) |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
167 |
{ |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
168 |
error (0, errno, _("cannot stat standard input")); |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
169 |
return false; |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
170 |
@@ -1218,7 +1257,7 @@ |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
171 |
if (S_ISBLK (statbuf.st_mode) || S_ISCHR (statbuf.st_mode)) |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
172 |
format = format2; |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
173 |
|
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
174 |
- bool fail = print_it (format, filename, print_stat, &statbuf); |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
175 |
+ bool fail = print_it (format, fd, filename, print_stat, &statbuf); |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
176 |
return ! fail; |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
177 |
} |
0edb05d72e6b
16575074 stat could support birthtime/crtime on ZFS
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
178 |