]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storage: remove use of stat-time.h headers
authorDaniel P. Berrangé <berrange@redhat.com>
Wed, 22 Jan 2020 11:38:28 +0000 (11:38 +0000)
committerDaniel P. Berrangé <berrange@redhat.com>
Wed, 29 Jan 2020 14:51:39 +0000 (14:51 +0000)
The gnulib stat-time.h header provides wrapper functions
to hide the differences in 'struct stat' between various
platforms.

Linux and FreeBSD support the same names, except for
birthtime which Linux only provides in the new 'statx()'
syscall we're not using. macOS has completely different
naming. Since we only rely on this code in one place
we just use conditionals at time of need.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
src/storage/storage_util.c

index 987d937b0448c386dfe43888346a77ab756971df..7bbcfde064041bf9fe9960125b438e14034b1828 100644 (file)
@@ -71,7 +71,6 @@
 #include "virfile.h"
 #include "virjson.h"
 #include "virqemu.h"
-#include "stat-time.h"
 #include "virstring.h"
 #include "virxml.h"
 #include "virfdstream.h"
@@ -1830,10 +1829,22 @@ virStorageBackendUpdateVolTargetInfoFD(virStorageSourcePtr target,
 
     if (!target->timestamps && VIR_ALLOC(target->timestamps) < 0)
         return -1;
-    target->timestamps->atime = get_stat_atime(sb);
-    target->timestamps->btime = get_stat_birthtime(sb);
-    target->timestamps->ctime = get_stat_ctime(sb);
-    target->timestamps->mtime = get_stat_mtime(sb);
+
+#ifdef __APPLE__
+    target->timestamps->atime = sb->st_atimespec;
+    target->timestamps->btime = sb->st_birthtimespec;
+    target->timestamps->ctime = sb->st_ctimespec;
+    target->timestamps->mtime = sb->st_mtimespec;
+#else /* ! __APPLE__ */
+    target->timestamps->atime = sb->st_atim;
+# ifdef __linux__
+    target->timestamps->btime = (struct timespec){0, 0};
+# else /* ! __linux__ */
+    target->timestamps->btime = sb->st_birthtim;
+# endif /* ! __linux__ */
+    target->timestamps->ctime = sb->st_ctim;
+    target->timestamps->mtime = sb->st_mtim;
+#endif /* ! __APPLE__ */
 
     target->type = VIR_STORAGE_TYPE_FILE;