[PATCH 2/2] Add stat-time to get timestamps

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

 



!!! DON'T PUSH until stat-time lgpl 3 issue is fixed
!!! To tests this change lgpl version to 3 in bootstrap.conf:176

stat-time offers a much cleaner way of getting timestamps than
the current implementation. Therefor the implementation is changed.
---
 bootstrap.conf                |    1 +
 src/storage/storage_backend.c |   25 +++++--------------------
 2 files changed, 6 insertions(+), 20 deletions(-)

diff --git a/bootstrap.conf b/bootstrap.conf
index 9b42cbf..d80d92d 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -90,6 +90,7 @@ sigaction
 sigpipe
 snprintf
 socket
+stat-time
 stdarg
 stpcpy
 strchrnul
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 1ef6df9..c665711 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -57,6 +57,7 @@
 #include "storage_backend.h"
 #include "logging.h"
 #include "virfile.h"
+#include "stat-time.h"
 
 #if WITH_STORAGE_LVM
 # include "storage_backend_logical.h"
@@ -1155,11 +1156,6 @@ virStorageBackendUpdateVolTargetInfoFD(virStorageVolTargetPtr target,
                                        unsigned long long *capacity)
 {
     struct stat sb;
-    struct timespec *const atime = &target->timestamps.atime,
-                    *const btime = &target->timestamps.btime,
-                    *const catime = &target->timestamps.ctime,
-                    *const mtime = &target->timestamps.mtime;
-
 #if HAVE_SELINUX
     security_context_t filecon = NULL;
 #endif
@@ -1213,21 +1209,10 @@ virStorageBackendUpdateVolTargetInfoFD(virStorageVolTargetPtr target,
     target->perms.uid = sb.st_uid;
     target->perms.gid = sb.st_gid;
 
-    atime->tv_sec = sb.st_atime;
-    mtime->tv_sec = sb.st_mtime;
-    catime->tv_sec = sb.st_ctime;
-#if _BSD_SOURCE || _SVID_SOURCE || \
-    _POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700
-    atime->tv_nsec = sb.st_atim.tv_nsec;
-    mtime->tv_nsec = sb.st_mtim.tv_nsec;
-    catime->tv_nsec = sb.st_ctim.tv_nsec;
-#else
-    atime->tv_nsec = sb.st_atimensec;
-    mtime->tv_nsec = sb.st_mtimensec;
-    catime->tv_nsec = sb.st_ctimensec;
-#endif
-    btime->tv_sec = -1;
-    btime->tv_nsec = -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);
 
     VIR_FREE(target->perms.label);
 
-- 
1.7.9.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]