Systemd/src/udev
Lennart Poettering b8380cc67a udev: make sure to install an inotify watch whenever we find a block device locked
This fixes a race where a block device that pops up and immediately is
locked (such as a loopback device in preparation) might result in
udev never run any rules for it, and thus never turn on inotify watching
for it (as inotify watching is controlled via an option set via udev
rules), thus not noticing when the device is unlocked/closed again
(which is noticed via IN_CLOSE_WRITE inotify events).

This changes two things:

1. Whenever we encounter a locked block device we'll now inotify watch
   it, so that it is guaranteed we'll notice when the BSD lock fd is
   closed again, and will reprobe.

2. We'll now turn off inotify watching again once we realise the
   udev rules don't actually want that. Previously, once watching a
   device was enabled via a udev rule, it would be watched forever until
   the device disappeared, even if the option was dropped by the rules
   for later events.

Together this will make sure that we'll watch the device via inotify
in both of the following cases:

a) The block device has been BSD locked when udev wanted to look at it

b) The udev rules run for the last seen event for the device say so

In all other cases inotify is off for block devices.

This new behaviour both fixes the race, but also makes the most sense,
as the rules (when they are run) actually really control the watch state
now. And if someone BSD locks a block device then it should be OK to
inotify watch it briefly until the lock is released again as the user
this way more or less opts into the locking protocol.
2020-10-09 13:22:29 +02:00
..
ata_id Remove unneded {}s 2020-04-13 09:31:49 +02:00
cdrom_id udev/cdrom_id: Do not open CD-rom in exclusive mode. 2019-10-24 00:09:18 +02:00
fido_id test: move {test,fuzz}-fido-id-desc.c into src/udev/fido_id 2019-10-31 10:37:42 +09:00
mtd_probe coccinelle: make use of SYNTHETIC_ERRNO 2018-11-22 10:54:38 +01:00
net basic: convert ifname_valid_full() to take flags and allow numeric interfaces 2020-09-10 00:46:44 +02:00
scsi_id tree-wide: coccinelle fixes 2020-10-04 12:32:21 +02:00
v4l_id tree-wide: replace explicit NULL checks with their shorter variants 2019-04-28 14:28:49 +02:00
.vimrc
generate-keyboard-keys-gperf.sh scripts: use 4 space indentation 2019-04-12 08:30:31 +02:00
generate-keyboard-keys-list.sh scripts: use 4 space indentation 2019-04-12 08:30:31 +02:00
meson.build udev: single binary replacing udevd and udevadm 2020-06-01 09:41:21 +02:00
udev-builtin-blkid.c libblkid: open device in nonblock mode. 2019-11-08 12:11:32 +01:00
udev-builtin-btrfs.c udev: modernize udev-rules.c 2019-06-02 14:15:26 +09:00
udev-builtin-hwdb.c udev: change the modalias string for usb devices to include the device name 2020-07-16 19:00:26 +02:00
udev-builtin-input_id.c udev: if a tablet has BTN_0, label it as ID_INPUT_TABLET_PAD 2020-09-17 10:14:25 +02:00
udev-builtin-keyboard.c tree-wide: drop assignments to r when we only need errno 2020-09-24 16:36:43 +02:00
udev-builtin-kmod.c tree-wide: drop libkmod.h when module-util.h is included 2019-11-04 00:30:32 +09:00
udev-builtin-net_id.c Replace gendered pronouns with gender neutral ones. (#16844) 2020-08-27 11:52:48 +09:00
udev-builtin-net_setup_link.c udev: modernize udev-rules.c 2019-06-02 14:15:26 +09:00
udev-builtin-path_id.c udev: spi: include chip select number in ID_PATH 2020-07-01 13:12:11 +09:00
udev-builtin-uaccess.c sd-device: make log_device_error() or friends return void 2020-09-09 02:34:38 +09:00
udev-builtin-usb_id.c tree-wide: fix spelling of "fallback" 2020-08-20 17:45:32 +02:00
udev-builtin.c udev: fix indentation 2020-09-10 13:11:43 +09:00
udev-builtin.h udev: modernize udev-rules.c 2019-06-02 14:15:26 +09:00
udev-ctrl.c udev: make use of NULL callback in IO handlers 2020-10-07 09:40:32 +02:00
udev-ctrl.h udev-ctrl: split out logic of waiting for reply to udev_ctrl_wait() 2019-02-20 06:17:42 +09:00
udev-event.c Merge pull request #16635 from keszybz/do-not-for-each-word 2020-09-09 17:43:38 +02:00
udev-event.h udev: udev_event_apply_format() always make buf NUL terminated 2020-06-18 13:53:08 +09:00
udev-node.c udev: apply access mode/ownership to device nodes with O_PATH 2020-09-28 18:45:54 +02:00
udev-node.h udev: run programs in the specified order 2019-03-05 09:27:29 +01:00
udev-rules.c sd-device: make log_device_error() or friends return void 2020-09-09 02:34:38 +09:00
udev-rules.h udev: split rules object creation and loading 2020-06-23 18:04:18 +02:00
udev-watch.c sd-device: make log_device_error() or friends return void 2020-09-09 02:34:38 +09:00
udev-watch.h udev-watch: replace udev_device by sd_device and modernize code a bit 2018-10-11 04:21:14 +09:00
udev.conf udev: make signal that we use to kill workers on timeout configurable 2020-06-05 11:09:17 +02:00
udev.pc.in {systemd,udev}.pc: add names with underscores, deprecate the old ones 2020-03-27 20:12:44 +01:00
udevadm-control.c udevadm: rename option '--log-priority' into '--log-level' 2020-09-22 09:05:57 +02:00
udevadm-hwdb.c coccinelle: make use of SYNTHETIC_ERRNO 2018-11-22 10:54:38 +01:00
udevadm-info.c udev: fix codesonar warnings 2020-07-30 18:55:50 +02:00
udevadm-monitor.c tree-wide: define iterator inside of the macro 2020-09-08 12:14:05 +02:00
udevadm-settle.c udevadm: beef up deprecation log warning 2020-07-14 14:57:19 +02:00
udevadm-test-builtin.c udev: modernize udev-rules.c 2019-06-02 14:15:26 +09:00
udevadm-test.c tree-wide: define iterator inside of the macro 2020-09-08 12:14:05 +02:00
udevadm-trigger.c udevadm: ignore -ENODEV on trigger 2020-10-06 08:25:54 +02:00
udevadm-util.c udevadm: allow a .device unit to be specified for query and trigger 2018-12-11 09:24:31 +01:00
udevadm-util.h udevadm-info,trigger: replace udev_device by sd_device 2018-10-17 03:31:20 +09:00
udevadm.c Make failures of mac_selinux_init() fatal 2020-06-23 19:10:07 +02:00
udevadm.h udevadm: add a workaround for dracut 2019-01-02 10:26:16 +01:00
udevd.c udev: make sure to install an inotify watch whenever we find a block device locked 2020-10-09 13:22:29 +02:00
udevd.h udev: single binary replacing udevd and udevadm 2020-06-01 09:41:21 +02:00