]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
repart: correct timespec_store usage too 32684/head
authorMike Yuan <me@yhndnzj.com>
Tue, 7 May 2024 12:15:57 +0000 (20:15 +0800)
committerMike Yuan <me@yhndnzj.com>
Tue, 7 May 2024 16:19:38 +0000 (00:19 +0800)
src/partition/repart.c

index 8442388359c109eaeb835402d1c97e4fafe7c98c..b50b9b6206a5cf9bf76233276d6ee64d07c6f613 100644 (file)
@@ -4898,7 +4898,6 @@ static int do_copy_files(Context *context, Partition *p, const char *root) {
                                                        strempty(arg_copy_source), *source, strempty(root), *target);
                 } else {
                         _cleanup_free_ char *dn = NULL, *fn = NULL;
-                        struct timespec tspec;
 
                         /* We are looking at a regular file */
 
@@ -4933,10 +4932,13 @@ static int do_copy_files(Context *context, Partition *p, const char *root) {
                         (void) copy_access(sfd, tfd);
                         (void) copy_times(sfd, tfd, 0);
 
-                        timespec_store_nsec(&tspec, ts);
+                        if (ts != USEC_INFINITY) {
+                                struct timespec tspec;
+                                timespec_store(&tspec, ts);
 
-                        if (ts != USEC_INFINITY && futimens(pfd, (const struct timespec[2]) { { .tv_nsec = UTIME_OMIT }, tspec }) < 0)
-                                return -errno;
+                                if (futimens(pfd, (const struct timespec[2]) { { .tv_nsec = UTIME_OMIT }, tspec }) < 0)
+                                        return -errno;
+                        }
                 }
         }