loop-util: read kernel's uevent seqnum right before attaching a loopback device

Later, this will allow us to ignore uevents from earlier attachments a
bit better, as we can compare uevent seqnums with this boundary. It's
not a full fix for the race though, since we cannot atomically determine
the uevent and attach the device, but it at least shortens the window a
bit.
This commit is contained in:
Lennart Poettering
2021-04-20 17:13:56 +02:00
parent 79e8393a6a
commit 31c75fcc41
2 changed files with 47 additions and 2 deletions
+1
View File
@@ -13,6 +13,7 @@ struct LoopDevice {
dev_t devno;
char *node;
bool relinquished;
uint64_t uevent_seqnum_not_before; /* uevent sequm right before we attached the loopback device, or UINT64_MAX if we don't know */
};
int loop_device_make(int fd, int open_flags, uint64_t offset, uint64_t size, uint32_t loop_flags, LoopDevice **ret);