master - lvm-file: wrapper to read ctim from stat
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6606b1bff3fba90cc7af92dcda1c6eafdbf5e200 Commit: 6606b1bff3fba90cc7af92dcda1c6eafdbf5e200 Parent: 17583f1b591bc4f84acf1e6be76083ddd84020ac Author: Zdenek Kabelac <[email protected]> AuthorDate: Wed Mar 18 10:54:08 2015 +0100 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Wed Mar 18 13:42:24 2015 +0100
lvm-file: wrapper to read ctim from stat
When available use nanosecond stat info.
If commands are running closely enough after config update, the .cache file from persistent filter could have been ignored.
This happens sometimes during i.e. synthetic test suite run.
--- lib/misc/lvm-file.c | 11 +++++++++++ lib/misc/lvm-file.h | 11 +++++++++++ 2 files changed, 22 insertions(+), 0 deletions(-)
lib/misc/lvm-file.c +11 -0
@@ -21,6 +21,7 @@#include <sys/file.h> #include <fcntl.h> #include <dirent.h> +#include <sys/time.h> /* * Creates a temporary filename, and opens a descriptor to the
@@ -273,3 +274,13 @@ int lvm_fclose(FILE *fp, const char *filename)return EOF ; } + +void lvm_stat_ctim (struct timespec *ctim,const struct stat *buf) +{ +#ifdef HAVE_STAT_ST_CTIM + *ctim = buf->st_ctim; +#else + ctim->tv_sec = buf->st_ctime; + ctim->tv_nsec =0 ; +#endif +}
lib/misc/lvm-file.h +11 -0
@@ -62,4 +62,15 @@ void fcntl_unlock_file(int lockfd);*/ int lvm_fclose (FILE *fp,const char *filename); +/* +* Convert stat->st_ctim status of last change in nanoseconds +* uses st_ctime when not available. +*/ +void lvm_stat_ctim (struct timespec *ts,const struct stat *buf); + +/* Inspired by <sys/time.h> timercmp() macro for timeval */ +#define timespeccmp (tsp, usp, cmp)\ + (((tsp)->tv_sec == (usp)->tv_sec) ?\ + ((tsp)->tv_nsec cmp (usp)->tv_nsec) :\ + ((tsp)->tv_sec cmp (usp)->tv_sec))#endif