Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
udevd: add short-duration inotify watch during udev block device even…
…t processing While external programs that take an exclusive flock on block devices while modifying them (e.g. partitioning or mkfs) will safely work with udevd so that the block device modifications don't race with udevd processing of the device (e.g. creating symlinks for the newly-created partitions), any external program that doesn't take an exclusive flock will race with udevd, and the changes made to the block device may be missed by udevd, leading to failures, e.g. udevd might not create the symlinks for new partitions, or might not create the /dev/disk/by-* for new filesystems. This updates the flock function to also take a short-duration inotify watch, so that after processing the device, udevd can synthesize a new uevent if it detected any IN_CLOSE_WRITE while the device was being processed, before the real watch was added. One example is the mkswap that we ourselves actually run, from the service created by cryptsetup-generator; we have it running mkswap: if (swap) fprintf(f, "ExecStartPost=/sbin/mkswap '/dev/mapper/%s'\n", name_escaped); However, this is racy, because it doesn't take an exclusive flock. This (and probably other places in our own code) should have done "flock ..." instead. If it's hard for us to get this right, it seems too much to expect all other non-systemd programs to also be aware they need to flock the block device. Fixes: systemd#10179
- Loading branch information