chiark / gitweb /
util: make it easy to initialize the crtime from the current time in fd_setcrtime()
authorLennart Poettering <lennart@poettering.net>
Thu, 8 Jan 2015 00:27:13 +0000 (01:27 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 8 Jan 2015 00:27:13 +0000 (01:27 +0100)
src/journal/journal-file.c
src/shared/util.c

index c20af5d9bfc2f90041776fe2782f1a954fb5af00..c1b54046f9af92eeeb8ebe60424fe4b789099df1 100644 (file)
@@ -2623,7 +2623,7 @@ int journal_file_open(
                  * attributes are not supported we'll just skip this,
                  * and rely solely on mtime/atime/ctime of the file. */
 
-                fd_setcrtime(f->fd, now(CLOCK_REALTIME));
+                fd_setcrtime(f->fd, 0);
 
 #ifdef HAVE_GCRYPT
                 /* Try to load the FSPRG state, and if we can't, then
index 88fd78ec8d61f5b0de698d085e9e68c2ec83b346..7d753e448a4f5da69b8d86045d90b6388a85a921 100644 (file)
@@ -7670,6 +7670,9 @@ int fd_setcrtime(int fd, usec_t usec) {
 
         assert(fd >= 0);
 
+        if (usec <= 0)
+                usec = now(CLOCK_REALTIME);
+
         le = htole64((uint64_t) usec);
         if (fsetxattr(fd, "user.crtime_usec", &le, sizeof(le), 0) < 0)
                 return -errno;