summaryrefslogtreecommitdiff
path: root/src/udev/udev-watch.c
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: use -EBADF for fd initializationZbigniew Jędrzejewski-Szmek2022-12-191-2/+2
| | | | | | | | | | | | | | | | -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-0/+4
|
* udev: fix the errno check if a couple of placesFrantisek Sumsal2022-10-251-2/+2
| | | | Follow-up to 691a596da15.
* sd-device: move device_new_from_watch_handle_at() to udev-watch.cYu Watanabe2022-09-121-0/+23
| | | | And drop unused watch handle related functions.
* udev: use rm_rf() to remove old watch directoryYu Watanabe2022-09-121-24/+30
|
* udev-watch: remove symlink for saving inotify watch handle only when it is ↵Yu Watanabe2022-09-121-55/+121
| | | | | | | | | | owned by the processing device Before removing symlinks that stores watch handles, this makes udev worker check if the symlink is owned by the processing device. Then, we can avoid TOCTOU and drop the try-and-wait loop. This partially reverts 2d3af41f0e837390b734253f5c4a99a9f33c53e3.
* tree-wide: make FOREACH_DIRENT_ALL define the iterator variableZbigniew Jędrzejewski-Szmek2021-12-151-1/+0
| | | | | | | | | The variable is not useful outside of the loop (it'll always be null after the loop is finished), so we can declare it inline in the loop. This saves one variable declaration and reduces the chances that somebody tries to use the variable outside of the loop. For consistency, 'de' is used everywhere for the var name.
* udev-watch: retry to save watch handle with random delayYu Watanabe2021-09-131-4/+41
| | | | Also, remove the watch handle if we cannot save it.
* udev: explicitly mention that the error will be ignoredYu Watanabe2021-06-021-3/+6
| | | | See #19788.
* udev,sd_device: also save map from device ID to watch handle in /run/udev/watchYu Watanabe2021-04-301-70/+35
| | | | | | | | | | | | | | | | | Previously, watch handle is saved in the udev databse. But in most cases, the handle saved in the database is not updated. Especially, when udevd is restarted, the inotify watch is restarted, but the database is not updated. Moreover, it is not necessary to save watch handle in the database, as the handle is only take a effect during udevd is running, and the value is meaningless when udevd is restarted. So, this makes the opposite map from device ID to watch handle is saved in /run/udev/watch as a symbolic link, and the handle not saved in the database anymore. Fixes #18525.
* udev: make udev_watch_end() noop when device does not have devnameYu Watanabe2021-04-301-0/+3
|
* sd-device: rename device_get_id_filename() -> device_get_device_id()Yu Watanabe2021-04-301-11/+11
| | | | | | We have sd_device_new_from_device_id(), which takes device ID generated from device_get_id_filename(). For consistency, let's rename the function.
* udev: do not store inotify fd in a global variableYu Watanabe2021-04-301-32/+12
| | | | | | | When manager_exit() or manager_free() is called, the global variable in udev-watch.c is not set '-1'. Of course, that is safe, as the event source for the inotify fd is unref()ed in manager_exit() and manager_free(). But let's not store fd globally.
* license: GPL-2.0+ -> GPL-2.0-or-laterYu Watanabe2020-11-091-1/+1
|
* sd-device: make log_device_error() or friends return voidYu Watanabe2020-09-091-4/+2
|
* udev: don't complain when udev_watch_end() is called without udev_watch_init()Zbigniew Jędrzejewski-Szmek2020-07-161-2/+1
| | | | | | E.g. udevadm test prints "Invalid inotify descriptor." which is meaningless without any context. I think it should be OK to call udev_watch_end() from a cleanup path without any warning (even at debug level).
* coccinelle: also mark previous synthetic errnos as suchZbigniew Jędrzejewski-Szmek2018-11-221-5/+10
|
* udev: downgrade message when we fail to set inotify watch upZbigniew Jędrzejewski-Szmek2018-11-131-1/+4
| | | | | | | | | | | | | | | | | | | My logs are full of: systemd-udevd[6586]: seq 13515 queued, 'add' 'block' systemd-udevd[6586]: seq 13516 queued, 'change' 'block' systemd-udevd[6586]: seq 13517 queued, 'change' 'block' systemd-udevd[6586]: seq 13518 queued, 'remove' 'bdi' systemd-udevd[6586]: seq 13519 queued, 'remove' 'block' systemd-udevd[9865]: seq 13514 processed systemd-udevd[9865]: seq 13515 running systemd-udevd[9865]: GROUP 6 /usr/lib/udev/rules.d/50-udev-default.rules:59 systemd-udevd[9865]: IMPORT builtin 'blkid' /usr/lib/udev/rules.d/60-persistent-storage.rules:95 systemd-udevd[9865]: IMPORT builtin 'blkid' fails: No such file or directory systemd-udevd[9865]: loop4: Failed to add device '/dev/loop4' to watch: No such file or directory (the last line is at error level). If we are too slow to set up a watch and the device is already gone by the time we try, this is not an error.
* udev-watch: adjust level of log messagesYu Watanabe2018-11-061-8/+8
|
* udev-watch: make udev_watch_lookup() return 1 when device foundYu Watanabe2018-11-061-8/+9
|
* udev: drop redundant log message and fix returned error codeYu Watanabe2018-11-061-1/+1
|
* udev-watch: use log_device_*()Yu Watanabe2018-10-231-18/+10
|
* udev: make sd_device_get_devname() failure non-fatalYu Watanabe2018-10-171-6/+5
| | | | | | As it is just for logging. Follow-up for eb276e98419af59d4a587f2dd37e0b923e4c6fd2.
* udev: don't use devname before we acquired itLennart Poettering2018-10-161-4/+4
| | | | CID 1396107
* udev: use readlink_malloc() or its friendYu Watanabe2018-10-141-17/+12
| | | | | Follow-up for a2554acec652fc65c8ed0c6c1fede9ba8c3693b1 and 70068602713e8f441c5ddc2618f007f24488e422.
* udev-watch: replace udev_device by sd_device and modernize code a bitYu Watanabe2018-10-111-80/+123
|
* udev: drop unused udev structYu Watanabe2018-09-101-8/+8
|
* tree-wide: drop empty lines in commentsYu Watanabe2018-07-231-1/+0
|
* tree-wide: drop copyright headers from frequent contributorsZbigniew Jędrzejewski-Szmek2018-06-201-1/+0
| | | | | | | | Fixes #9320. for p in Shapovalov Chevalier Rozhkov Sievers Mack Herrmann Schmidt Rudenberg Sahani Landden Andersen Watanabe; do git grep -e 'Copyright.*'$p -l|xargs perl -i -0pe 's|/([*][*])?[*]\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\s*[*]([*][*])?/\n*|\n|gms; s|\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\n*|\n|gms' done
* Drop more license boilerplateZbigniew Jędrzejewski-Szmek2018-06-141-12/+0
| | | | | | | | $ git grep -e 'This program is free software' -l |grep -v LICENSE | \ xargs perl -i -0pe 's/ \* This program.*?for more details.\s*\*\n( \* You should have.*licenses.>.\n)?//gms' For some reason they were missed previously. All those files seem to have proper SDPX tags.
* tree-wide: use proper unicode © instead of (C) where we canLennart Poettering2018-06-141-3/+3
| | | | | | Let's use a proper unicode copyright symbol where we can, it's prettier. This important patch is very important.
* Add some handling to remaining unlinkat callsZbigniew Jędrzejewski-Szmek2018-02-191-1/+1
| | | | | | | | | | | Coverity now started warning about this ("Calling unlinkat without checking return value (as is done elsewhere 12 out of 15 times).", and it is right: most of the time we should at list print a log message so people can figure out something is wrong when this happens. v2: - use warning level in journald too (this is unlikely to happen ever, so it should be safe to something that is visible by default).
* Add SPDX license identifiers to source files under the GPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
|
* tree-wide: replace all readdir cycles with FOREACH_DIRENT{,_ALL} (#4853)Reverend Homer2016-12-091-2/+2
|
* udev/udev-watch: calculate the real buffer sizes neededZbigniew Jędrzejewski-Szmek2016-11-021-3/+3
|
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+0
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* tree-wide: use xsprintf() where applicableDaniel Mack2016-01-121-3/+4
| | | | Also add a coccinelle receipt to help with such transitions.
* udev: add emacs header lineZbigniew Jędrzejewski-Szmek2015-12-071-0/+2
| | | | | Otherwise emacs wants to use 2-space indentation and other attrocities.
* tree-wide: sort includesThomas Hindoe Paaboel Andersen2015-11-161-3/+3
| | | | Sort the includes accoding to the new coding style.
* tree-wide: update empty-if coccinelle script to cover empty-while and moreLennart Poettering2015-09-091-3/+2
| | | | Let's also clean up single-line while and for blocks.
* remove unused includesThomas Hindoe Paaboel Andersen2015-02-231-4/+0
| | | | | | This patch removes includes that are not used. The removals were found with include-what-you-use which checks if any of the symbols from a header is in use.
* treewide: use log_*_errno whenever %m is in the format stringMichal Schmidt2014-11-281-5/+5
| | | | | | | | | | | If the format string contains %m, clearly errno must have a meaningful value, so we might as well use log_*_errno to have ERRNO= logged. Using: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_(debug|info|notice|warning|error|emergency)\((".*%m.*")/log_\1_errno(errno, \2/' Plus some whitespace, linewrap, and indent adjustments.
* udev: place opening { at the same line as the function declarationKay Sievers2014-07-291-10/+5
|
* log: log_error() and friends add a newline after each line anyway, so avoid ↵Lennart Poettering2013-12-241-5/+5
| | | | including it in the log strings
* Standarize on one spelling of symlink error messageZbigniew Jędrzejewski-Szmek2013-04-241-1/+1
| | | | | It's polite to print the name of the link that wasn't created, and it makes little sense to print the target.
* use the same email address everywhereKay Sievers2012-11-121-1/+1
|
* udev: check return value of symlinkVáclav Pavlín2012-09-231-1/+4
|
* udev: export udev_device_new_from_device_id()Kay Sievers2012-08-101-2/+2
|
* udev: do not selinux label files in /run/udevKay Sievers2012-05-311-1/+1
|
* mkdir: append _label to all mkdir() calls that explicitly set the selinux ↵Kay Sievers2012-05-311-1/+1
| | | | context