return true; /* bound! */
}
-static int get_current_uevent_seqnum(uint64_t *ret) {
- _cleanup_free_ char *p = NULL;
- int r;
-
- r = read_full_virtual_file("/sys/kernel/uevent_seqnum", &p, NULL);
- if (r < 0)
- return log_debug_errno(r, "Failed to read current uevent sequence number: %m");
-
- r = safe_atou64(strstrip(p), ret);
- if (r < 0)
- return log_debug_errno(r, "Failed to parse current uevent sequence number: %s", p);
-
- return 0;
-}
-
static int open_lock_fd(int primary_fd, int operation) {
_cleanup_close_ int lock_fd = -EBADF;
_cleanup_(cleanup_clear_loop_close) int loop_with_fd = -EBADF; /* This must be declared before lock_fd. */
_cleanup_close_ int fd = -EBADF, lock_fd = -EBADF;
_cleanup_free_ char *node = NULL;
- uint64_t diskseq = 0, seqnum = UINT64_MAX;
- usec_t timestamp = USEC_INFINITY;
+ uint64_t diskseq = 0;
dev_t devno;
int r;
"Removed partitions on the loopback block device.");
if (!loop_configure_broken) {
- /* Acquire uevent seqnum immediately before attaching the loopback device. This allows
- * callers to ignore all uevents with a seqnum before this one, if they need to associate
- * uevent with this attachment. Doing so isn't race-free though, as uevents that happen in
- * the window between this reading of the seqnum, and the LOOP_CONFIGURE call might still be
- * mistaken as originating from our attachment, even though might be caused by an earlier
- * use. But doing this at least shortens the race window a bit. */
- r = get_current_uevent_seqnum(&seqnum);
- if (r < 0)
- return log_device_debug_errno(dev, r, "Failed to get the current uevent seqnum: %m");
-
- timestamp = now(CLOCK_MONOTONIC);
-
if (ioctl(fd, LOOP_CONFIGURE, c) < 0) {
/* Do fallback only if LOOP_CONFIGURE is not supported, propagate all other
* errors. Note that the kernel is weird: non-existing ioctls currently return EINVAL
}
if (loop_configure_broken) {
- /* Let's read the seqnum again, to shorten the window. */
- r = get_current_uevent_seqnum(&seqnum);
- if (r < 0)
- return log_device_debug_errno(dev, r, "Failed to get the current uevent seqnum: %m");
-
- timestamp = now(CLOCK_MONOTONIC);
-
if (ioctl(fd, LOOP_SET_FD, c->fd) < 0)
return log_device_debug_errno(dev, errno, "ioctl(LOOP_SET_FD) failed: %m");
.devno = devno,
.dev = TAKE_PTR(dev),
.diskseq = diskseq,
- .uevent_seqnum_not_before = seqnum,
- .timestamp_not_before = timestamp,
.sector_size = c->block_size,
.device_size = device_size,
.created = true,
.relinquished = true, /* It's not ours, don't try to destroy it when this object is freed */
.devno = devnum,
.diskseq = diskseq,
- .uevent_seqnum_not_before = UINT64_MAX,
- .timestamp_not_before = USEC_INFINITY,
.sector_size = sector_size,
.device_size = device_size,
.created = false,