mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
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.
This commit is contained in:
parent
17583f1b59
commit
6606b1bff3
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user