]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
loop-util: also set LoopDevice.diskseq when created with loop_device_open()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 4 Sep 2022 17:05:52 +0000 (02:05 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 4 Sep 2022 18:29:06 +0000 (03:29 +0900)
src/shared/loop-util.c

index 928792281c58be1ff9b0bcf585a15a67d44cb255..90451415ff95148956280ed345778facb02e49e8 100644 (file)
@@ -800,6 +800,7 @@ int loop_device_open(
         _cleanup_close_ int loop_fd = -1, lock_fd = -1;
         _cleanup_free_ char *p = NULL;
         struct loop_info64 info;
+        uint64_t diskseq = 0;
         struct stat st;
         LoopDevice *d;
         int nr;
@@ -826,6 +827,10 @@ int loop_device_open(
         } else
                 nr = -1;
 
+        r = fd_get_diskseq(loop_fd, &diskseq);
+        if (r < 0 && r != -EOPNOTSUPP)
+                return r;
+
         if ((lock_op & ~LOCK_NB) != LOCK_UN) {
                 lock_fd = open_lock_fd(loop_fd, lock_op);
                 if (lock_fd < 0)
@@ -847,6 +852,7 @@ int loop_device_open(
                 .node = TAKE_PTR(p),
                 .relinquished = true, /* It's not ours, don't try to destroy it when this object is freed */
                 .devno = st.st_dev,
+                .diskseq = diskseq,
                 .uevent_seqnum_not_before = UINT64_MAX,
                 .timestamp_not_before = USEC_INFINITY,
         };