summaryrefslogtreecommitdiff
path: root/src/udev/udevd.c
Commit message (Collapse)AuthorAgeFilesLines
* udev: port to DelegateSubgroup=Lennart Poettering2023-04-271-51/+8
|
* process-util: make safe_fork() unset $NOTIFY_SOCKETYu Watanabe2023-04-171-2/+0
| | | | | | | | Propagating $NOTIFY_SOCKET is typically dangerous. Let's unset it unless explicitly requested to keep it. Fixes #27288. Replaces #27291.
* udevd: enable memory pressure/SIGRTMIN+18 logicLennart Poettering2023-03-011-1/+18
|
* udevd: configure a child process name for worker processesYu Watanabe2023-02-071-1/+1
| | | | | | | | | This effectively reverts commit ff86c92e3043f71fc801cf687600a480ee8f6778, and re-apply 49f3ee7e74c714f55aab395c080b1099fc17f7fd. The change was dropped due to the process name was not correctly logged, but the issue was fixed by dd15e4cb57129b915e01495e113696bfe0b70214. Let's set the child process name again.
* udevd: implement the full Type=notify-reload protocolLennart Poettering2023-01-101-20/+27
| | | | | | We are basically already there, just need to add MONOTONIC_USEC= to the RELOADING=1 message, and make sure the message is generated in really all cases.
* tree-wide: introduce PIPE_EBADF macroYu Watanabe2022-12-201-1/+1
|
* tree-wide: use -EBADF also in pipe initializersZbigniew Jędrzejewski-Szmek2022-12-191-1/+1
| | | | In some places, initialization is dropped when unnecesary.
* tree-wide: use -EBADF for fd initializationZbigniew Jędrzejewski-Szmek2022-12-191-7/+7
| | | | | | | | | | | | | | | | -1 was used everywhere, but -EBADF or -EBADFD started being used in various places. Let's make things consistent in the new style. Note that there are two candidates: EBADF 9 Bad file descriptor EBADFD 77 File descriptor in bad state Since we're initializating the fd, we're just assigning a value that means "no fd yet", so it's just a bad file descriptor, and the first errno fits better. If instead we had a valid file descriptor that became invalid because of some operation or state change, the other errno would fit better. In some places, initialization is dropped if unnecessary.
* udev: drop trivial wrapper for udev_watch_begin()Yu Watanabe2022-10-311-1/+5
|
* udev: drop redundant description settingYu Watanabe2022-10-191-4/+0
| | | | Follow-up for f714ecd450828e45a6f04e6277011d67a10c323f.
* tree-wide: add ERRNO_IS_XATTR_ABSENT() helperLennart Poettering2022-10-101-1/+1
| | | | | We check the same list of error codes on various xattr operations, and we should on some more. Add a common helper for this purpose.
* udev: use block_device_is_whole_disk()Yu Watanabe2022-09-201-35/+27
| | | | | | | | No functional changes, just refactoring. Note, this also makes synthesize_change() propagate the error from synthesize_change_one(). However, the caller of synthesize_change() ignores the failure anyway, hence the change does not take any effect.
* udev: do not ignore -ENOENT from sd_device_get_devname() for block deviceYu Watanabe2022-09-181-2/+0
| | | | | | We already checked that the sd_device object 'dev' is for a whole block device. So, -ENOENT should not be triggeered here, and if it is, there exists something spurious. Hence we should not ignore the failure.
* udev: use block_device_get_whole_disk()Yu Watanabe2022-09-181-17/+7
| | | | This should not change anything effectively.
* Merge pull request #24622 from yuwata/udev-open-with-nocttyLennart Poettering2022-09-171-2/+2
|\ | | | | udev: open with O_NOCTTY
| * udev: always open with O_NOCTTYYu Watanabe2022-09-101-2/+2
| | | | | | | | | | All files or device nodes opened here should not be console tty. Let's open it the flags for safety.
* | tree-wide: use ASSERT_PTR moreDavid Tardon2022-09-131-26/+10
| |
* | Merge pull request #23087 from yuwata/udev-watchYu Watanabe2022-09-121-16/+22
|\ \ | | | | | | udev: resolve race in saving inotify watch handle
| * | udev: drop unnecessary call of udev_watch_end()Yu Watanabe2022-09-121-3/+1
| | | | | | | | | | | | As it is already called by udev_event_execute_rules().
| * | udev: ignore IN_IGNORED inotify event earlierYu Watanabe2022-09-121-8/+18
| | |
| * | udev: not necessary to return 1 from on_inotify()Yu Watanabe2022-09-121-5/+3
| |/
* | Merge pull request #23043 from yuwata/udev-node-use-flockYu Watanabe2022-09-121-0/+10
|\ \ | |/ |/| udev-node: use flock() for symlink stack directory
| * udev: cleanup stack directory /run/udev/links when all workers exitedYu Watanabe2022-09-031-0/+10
| | | | | | | | | | | | By the previous commit, the stack directories are not removed even if it is empty. To reduce the inode usage of /run, let's cleanup the directories.
* | blockdev-util: split out blockdev_reread_partition_table()Yu Watanabe2022-09-101-16/+6
| | | | | | | | No functional changes, just refactoring.
* | udevd: use partition enumerator at one more placeYu Watanabe2022-09-101-34/+5
|/ | | | No functional changes, just refactoring.
* udev: do not kill workers when requested to set the same log level currently ↵Yu Watanabe2022-08-281-0/+10
| | | | | | assigned Also refuse invalid log level.
* udev: drop unnecessary calls of event_queue_start()Yu Watanabe2022-08-261-21/+0
| | | | | | | As the subsequent call of on_post() will call it if necessary. This also drop unnecessary call of event_source_disable() for killing idle workers, as the event source is disabled in event_queue_start().
* udev: certainly restart event for previously locked deviceYu Watanabe2022-08-261-0/+20
| | | | | | | | | | | | If udevd receives a uevent for a locked block device, then the event is requeued. However, the queued event will be processed only when at least one sd_event_source is processed. Hence, if udevd has no event under processing, or receives no new uevent, etc., then the requeued event will be never processed. Follow-up for 400e3d21f8cae53a8ba9f9567f244fbf6f3e076c. Fixes #24439.
* udev: fix inversed inequality for timeout of retrying eventYu Watanabe2022-08-221-1/+1
| | | | Follow-up for 5d354e525a56955ae7f68062e283dda85ab07794.
* udev: rename various validate() -> should_reload() for builtin commandsYu Watanabe2022-08-171-1/+1
| | | | | | Previously, true by validate() means several configs are outdated and we need to reload configs. That's not intuitive for me. Let's rename the functions.
* udev: set description for device monitorYu Watanabe2022-08-121-0/+4
|
* udev: reload rules and builtins only when mtime of a config changedYu Watanabe2022-07-231-27/+31
| | | | | | | This makes udevd reload rules only when the timestamp is updated, even on SIGHUP or `udevadm control --reload`. So, we can call `udevadm control --reload` without huge performance penalty when no rules, .link files, and so on are changed.
* udev: save stats of all udev rules fileYu Watanabe2022-07-231-1/+1
| | | | | The mtime of directory is not updated when an existing rule file is changed. Hence, paths_check_timestamp() is not reliable.
* udev: delay to start queued events on `udevadm control --start-exec-queue`Yu Watanabe2022-07-231-1/+1
|
* udev: use event_reset_time_relative()Yu Watanabe2022-07-231-3/+4
|
* udev: downgrade error level and mention that the error is ignoredYu Watanabe2022-07-231-1/+1
|
* udev: fix error checkYu Watanabe2022-07-231-1/+1
|
* Merge pull request #23855 from keszybz/drop-list-is-emptyLennart Poettering2022-07-051-4/+3
|\ | | | | basic/list: drop LIST_IS_EMPTY
| * basic/list: drop LIST_IS_EMPTYZbigniew Jędrzejewski-Szmek2022-07-021-4/+3
| | | | | | | | | | | | | | | | | | | | This was a trivial wrapper that didn't provide any added value. With more complicated structures like strvs, hashmaps, sets, and arrays, it is possible to have an empty container. But in case of a list, the list is empty only when the head is missing. Also, we generally want the positive condition, so we replace many if (!LIST_IS_EMPTY(x)) with just if (x).
* | Merge pull request #23088 from yuwata/udev-event-blockerZbigniew Jędrzejewski-Szmek2022-07-021-76/+31
|\ \ | |/ |/| udev: cleanups for event blocker
| * udev: also make uevent blocked by events for the same device nodeYu Watanabe2022-05-041-1/+10
| | | | | | | | | | | | | | | | | | Even if the device node is the same, devnum (thus, device ID) and syspath may be different. If a 'remove' and 'add' events for the same device node but with different devnum and syspath are queued, previously, we might process them in parallel. And, udev_watch_end() for the 'remove' event and udev_watch_begin() for the 'add' event may interfere each other.
| * udev: make newer event also blocked by DEVPATH_OLDYu Watanabe2022-05-041-28/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, a device has DEVPATH_OLD is blocked by a previous event whose devpath is equivalent to the DEVPATH_OLD. This extends the condtion. 1. an event has DEVPATH_OLD is blocked by a previous event whose devpath is a parent of, child of, or equivalent to the DEVPATH_OLD. 2. an event is blocked by a previous event whose DEVPATH_OLD is a parent of, child of, or equivalent to the devpath of the new event. I am not sure such check is really necessary. But, the cost of the check is expected to be extremely small, as device renaming does not occur so frequently. Hence, it should not introduce any significant performance regression.
| * udev: use device ID to find blockersYu Watanabe2022-05-041-57/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If two devices have the same devnum and subsystem (more specifically, if the device is block or not), or have the same ifindex, then IDs of these devices are equivalent. Hence, the previous conditions are covered by comparing device IDs. Of course, events with a same ID should be already blocked by the devpath check. So, this should not change anything. However, udevd saves many kinds of data under /run/udev named with the device ID. If multiple workers processes events for the same device ID, then the database may become corrupted. Let's explicitly check the device IDs for safety and simplicity.
* | add program name to log linePhilipp Gortan2022-06-181-1/+1
| |
* | tree-wide: replace AF_LOCAL with AF_UNIXYu Watanabe2022-05-141-2/+2
|/
* udev: use child event source to manage workersYu Watanabe2022-04-131-52/+44
|
* udev: use EventResult typeYu Watanabe2022-04-131-4/+5
| | | | This also adds EVENT_RESULT_SUCCESS for readability.
* udev: add a brief comment about the origin of the filtersYu Watanabe2022-04-061-0/+6
| | | | | | I am not sure whether the original discussions are correct or not. This is just for adding references for future verification for the filters.
* udev: use sd_device_open() where appropriateYu Watanabe2022-04-011-25/+20
|
* udev: rename functions to emphasize whole disk is lockedYu Watanabe2022-03-311-6/+6
|