1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-30 14:55:37 +03:00

loop-util: also set LoopDevice.diskseq when created with loop_device_open()

This commit is contained in:
Yu Watanabe 2022-09-05 02:05:52 +09:00
parent b6ca2b281e
commit ffcb33241e

View 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,
};