summaryrefslogtreecommitdiff
path: root/src/shared/loop-util.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-09-05 02:05:52 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-09-05 03:29:06 +0900
commitffcb33241e182a4f7b47f39ca84b49c9aa7ae314 (patch)
treefe7daa8baf4b971d1dde17150b27c9ff6270a2bf /src/shared/loop-util.c
parentb6ca2b281eff254dce2293990360e799af806ad4 (diff)
downloadsystemd-ffcb33241e182a4f7b47f39ca84b49c9aa7ae314.tar.gz
loop-util: also set LoopDevice.diskseq when created with loop_device_open()
Diffstat (limited to 'src/shared/loop-util.c')
-rw-r--r--src/shared/loop-util.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/shared/loop-util.c b/src/shared/loop-util.c
index 928792281c..90451415ff 100644
--- a/src/shared/loop-util.c
+++ b/src/shared/loop-util.c
@@ -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,
};