summaryrefslogtreecommitdiff
path: root/src/udev
Commit message (Collapse)AuthorAgeFilesLines
* udev-rules: check tokens orderDmitry V. Levin2023-04-031-0/+17
| | | | | When invoked by udevadm verify, warn about rules that have PROGRAM assignments specified after RESULT checks.
* fdset: add new fdset_consume() helperLennart Poettering2023-03-291-3/+1
|
* udev_rules_parse_file: do not ignore ENOENT when invoked by udevadm verifyDmitry V. Levin2023-03-291-1/+1
| | | | | | Make sure the ENOENT exception reintroduced by commit 9db7081d83d56cd2523b03f9eb9d67ef1c93c55f is not applied when the parser is invoked by udevadm verify.
* Revert "udev_rules_parse_file: do not skip ENOENT"Zbigniew Jędrzejewski-Szmek2023-03-281-1/+5
| | | | | | | | | This reverts commit 42a467b55219384c7c3b137ab3cc8b6a309a8a14. We need to skip -ENOENT when loading udev rules because new files with rules may be added or removed at any time, and the loading of rules is triggered asynchronously. Even though the window is fairly narrow, udev shouldn't throw an error if a rules file is removed.
* udev-rules: fix grammar in diagnostics about lines that have no effectDmitry V. Levin2023-03-271-3/+3
| | | | Fixes: 25de7aa7b90c ("udev: modernize udev-rules.c")
* udev-rules: extend the check for conflicting expressionsDmitry V. Levin2023-03-271-5/+22
| | | | | | | Log an error when a rule line contains the following kind of conflicting match expressions: KEY=="foo*", KEY=="bar*"
* udev-rules: check token delimitersDmitry V. Levin2023-03-271-2/+50
| | | | | | | | | | | | When udev_rules_parse_file() is called by udevadm verify, issue warnings about the following conditions in udev rules: * the first token in the rule is preceded with a comma * the last token in the rule is followed by a comma * there is no comma between tokens * there is no whitespace between tokens * there is more than a single comma between tokens * there is whitespace between a token and a comma * there is no whitespace after comma
* udev-rules: move udev_check_rule_line() invocationDmitry V. Levin2023-03-274-8/+9
| | | | | | | | | Move udev_check_rule_line() invocation from udev_rule_file_get_issues() to udev_rules_parse_file(), invoke udev_check_rule_line() only when udev_rules_parse_file() is called by udevadm verify. Subsequent commits are going to perform more checks invoked from udev_rules_parse_file().
* udev-rules: move udev_rules_parse_file() after udev_check_rule_line()Dmitry V. Levin2023-03-271-118/+118
| | | | | Move udev_rules_parse_file() after udev_check_rule_line() as the former us going to use the latter.
* chase-symlinks: Rename chase_symlinks() to chase()Daan De Meyer2023-03-242-2/+2
| | | | | | | | | Chasing symlinks is a core function that's used in a lot of places so it deservers a less verbose names so let's rename it to chase() and chaseat(). We also slightly change the pattern used for the chaseat() helpers so we get chase_and_openat() and similar.
* Merge pull request #26785 from keszybz/udev-distcheckZbigniew Jędrzejewski-Szmek2023-03-247-234/+309
|\ | | | | Implement --help/--version in all udev builtins
| * udev/ata_id: use unliagned helpersZbigniew Jędrzejewski-Szmek2023-03-161-5/+6
| | | | | | | | | | | | The array is a union, aligned as uint16_t, so we were accessing fields at offsets of two, so we didn't do actually do unaligned access. But let's make this explicit.
| * udev/v4l_id: use O_CLOEXEC|O_NOCTTYZbigniew Jędrzejewski-Szmek2023-03-161-1/+1
| | | | | | | | | | | | This is the usual set of flags. O_CLOEXEC doesn't matter because we don't spawn anything, but O_NOCTTY could possibly make a difference if the helper is called on a wrong device type.
| * meson: add udev builtins to dist-checkZbigniew Jędrzejewski-Szmek2023-03-161-0/+1
| | | | | | | | | | They now pass, and we might as well test them to avoid unexpected regressions.
| * udev: implement --version in all builtinsZbigniew Jędrzejewski-Szmek2023-03-166-19/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Those are separate binaries, and occasionally people will get a misplaced binary that doesn't match the rest of the installed system and be confused, so it good to be able to check the version. It is also nice to have the same interface in all binaries. Note that we usually use a separate 'enum ARG_VERSION = 0x100' for an option without a short name. We can use a less verbose approach of simply taking any unused letter, which works just as well and even the compiler would warn us if we tried to use the letter in another place. This way we avoid a few lines of boilerplate. The help texts are adjusted to have an empty line between the synopsis and option list, and no empty lines after the option list.
| * udev/cdrom_id: do not abort on unknown optionsZbigniew Jędrzejewski-Szmek2023-03-161-0/+2
| | | | | | | | Copy-pasta is good, but you have to pick a reliable source.
| * udev/mtd_probe: convert to run()Zbigniew Jędrzejewski-Szmek2023-03-161-14/+10
| |
| * udev/mtd_probe: implement --helpZbigniew Jędrzejewski-Szmek2023-03-161-4/+34
| |
| * udev/fido_id: implement --helpZbigniew Jędrzejewski-Szmek2023-03-161-9/+38
| |
| * udev/ata_id: stop using errno, fix logicZbigniew Jędrzejewski-Szmek2023-03-161-118/+95
| | | | | | | | | | | | | | | | | | | | The code was setting errno, which we don't do, and which is hard to get right… Rework the code to use the usual negative-errno convention and add some debug logging. disk_scsi_inquiry_command() was working partially by accident: the v3 fallback would enter the v4 check path, and pass it because the v4 data would still be initialized to 0.
| * udev/ata_id: drop unused output parameterZbigniew Jędrzejewski-Szmek2023-03-161-22/+10
| |
| * udev/ata_id: convert to run()Zbigniew Jędrzejewski-Szmek2023-03-151-10/+9
| |
| * udev/ata_id: split out parse_argv()Zbigniew Jędrzejewski-Szmek2023-03-151-37/+44
| | | | | | | | Beef up syntax and error messages a bit.
| * udev/v4l_id: convert to run() and add error messagesZbigniew Jędrzejewski-Szmek2023-03-131-13/+29
| | | | | | | | | | Also split out parse_argv(), use "ARG" instead of "<arg>". Make the syntax help a bit more precise.
* | udev-rules: add another check for conflicting expressionsDmitry V. Levin2023-03-211-5/+37
| | | | | | | | | | | | | | Log an error when a rule line contains the following kind of conflicting match expressions: KEY=="foo", KEY=="bar"
* | udev-rules: fix check for conflicting and duplicate expressionsDmitry V. Levin2023-03-191-5/+23
| | | | | | | | | | | | | | Fix check for conflicting and duplicate expressions of types that support alternative patterns. Fixes: 3ec58d0cd8f6 ("udev-rules: check for conflicting and duplicate expressions")
* | Revert "udev: prepare memory for extra NUL termination for NULSTR"Dmitry V. Levin2023-03-191-3/+1
| | | | | | | | | | | | This reverts commit cd3c8a117ccf3505e49d34324473e2175ef0a9ce which was papering over the bug instead of a proper fix made by the previous commit.
* | Merge pull request #26783 from yuwata/loop-ref-follow-upDaan De Meyer2023-03-171-6/+8
|\ \ | | | | | | udev: slightly extend comment and add more tests
| * | udev: mention that the kernel silently truncates lo_file_name if too longYu Watanabe2023-03-141-6/+8
| | | | | | | | | | | | Resolves the confusion in https://github.com/systemd/systemd/pull/26693#discussion_r1131151335.
* | | udevadm-verify: add a short summaryYu Watanabe2023-03-161-2/+18
| | |
* | | udev-rules: check for conflicting and duplicate expressionsDmitry V. Levin2023-03-161-2/+78
|/ / | | | | | | | | | | | | | | Log an error when a rule line contains conflicting match expressions, e.g. NAME=="value", NAME!="value" Log a warning when a rule line contains duplicate expressions, e.g. NAME=="value", NAME=="value"
* | udevadm-verify: fix indentation of help messageYu Watanabe2023-03-131-1/+1
| |
* | udevadm: enable colorized loggingYu Watanabe2023-03-131-2/+1
| |
* | udev-rules: inline rule_line_append_token()Yu Watanabe2023-03-131-10/+3
| |
* | udev-rules: modernize free functionsYu Watanabe2023-03-131-10/+24
| |
* | udev-rules: do not set 'issues' tag when applying rules to event deviceYu Watanabe2023-03-131-7/+5
| | | | | | | | | | The tagging is used by `udevadm verify` and the command only parses udev rules but not apply them.
* | udev-rules: introduce log_event_truncated() helper functionYu Watanabe2023-03-131-62/+47
| |
* | udev-rule: rework logging about udev rulesYu Watanabe2023-03-134-445/+441
|/ | | | | | | | | | | | | | | This makes the loggers take the most relevant object, i.e. when applying udev rules to a device, the loggers take sd_device and UdevRuleToken object, and when parsing udev rules, they take UdevRuleLine or UdevRuleFile object. To achieve that, this drops 'iterators' in UdevRules or friends named `current_file` or so. Instead of that, each object now has its parent object, e.g. UdevRuleToken.rule_line that references the UdevRuleLine object the token belonging to. And each function previously took UdevRules object now takes the most relevant object, e.g. UdevRuleToken. Solves the discussion in https://github.com/systemd/systemd/pull/26698#discussion_r1129261193.
* Merge pull request #26641 from medhefgo/boot-elf2efiYu Watanabe2023-03-111-2/+4
|\ | | | | boot: Drop gnu-efi / Add elf2efi.py
| * meson: Introduce userspace depJan Janssen2023-03-101-2/+4
| | | | | | | | This will help in a later commit to separate userspace from EFI builds.
* | udev_rules_parse_file: issue diagnostics about duplicate LABEL tokensDmitry V. Levin2023-03-101-0/+3
| | | | | | | | | | | | When a rules contains several LABEL tokens, the parser used to silently discard all of them besides the last one without any diagnostics at all. It's time to break the vow of silence and let the parser issue a warning.
* | udevadm verify: introduce --root optionDmitry V. Levin2023-03-101-5/+28
| | | | | | | | | | | | When udevadm verify is invoked without positional arguments and loads all rules files from the system like the udev daemon does, this option can be used to operate on files underneath the specified root path.
* | udevadm verify: load all rules from the system if no rules were givenDmitry V. Levin2023-03-101-4/+14
|/ | | | | | When udevadm verify is invoked without positional arguments, that is, when no udev rules files are specified, load all rules files from the system like the udev daemon does, and verify them.
* udev-builtin-blkid: pick up info of backing fileLennart Poettering2023-03-091-0/+108
| | | | | | | | | | | | | | | | | | | This adds support for retrieving info about the inode backing a loopback file to udev-builtin-blkid. It will pick up the inode number and device of the backing inode, as well as the lo_file_name[] array that the loopback device maintains. A later patch uses this information to create block device symlinks in /dev/ that allow refering block devices by their backing inodes. This is useful when separate tools set up a loopback device from those which ultimately shall mount them, and there shall be a stable reference be passed along. For example, we can add a new kernel option setuploop= or so which allows setting up a block device via a generator, and still have a way to safely reference later. And yes, this doesn't directly have anything to do with the probing libblkid does, but it's close enough, and we have the device open anyway here, so the additional ioctl() here should not hurt.
* udev: add new udev_builtin_add_propertyf() helperLennart Poettering2023-03-092-0/+21
|
* udev_rules_parse_file: issue diagnostics about line continuation at EOFDmitry V. Levin2023-03-081-0/+5
| | | | | | | When udev rules file ends with a line continuation, the parser used to silently ignore the line without any diagnostics at all. It's time to break the vow of silence and let the parser issue some error diagnostics.
* udevadm-verify: check for unused labelsDmitry V. Levin2023-03-081-2/+16
| | | | | | Check for unused labels in the specified udev rules files, report such labels and exit with a non-zero exit code if any unused labels are found.
* udevadm: introduce new 'verify' commandDmitry V. Levin2023-03-086-0/+140
| | | | | | | | | | | | | | | | | | | We seem to have no tool to verify udev rule files. There is a simple udev rules syntax checker in the tree, test/rule-syntax-check.py, but it is too simple to detect less trivial issues not detected by udev, e.g. redundant comparisons (#26593) or labels without references. Such a tool would be beneficial not only for maintaining udev rules distributed along with udev, but also and even more so for maintaining third party udev rules that are more likely to have issues with syntax and semantic correctness. Implement a udev rules syntax and semantics checker in the form of 'udevadm verify [OPTIONS] FILE...' command that is based on udev_rules_parse_file() interface and would apply further checks on top of it in subsequent commits. Resolves: #26606
* udev_rules_parse_file: mark logged issuesDmitry V. Levin2023-03-081-6/+52
| | | | | | | | | | | | | Traditionally, all issues found in udev rules by udev_rules_parse_file() are logged and ignored, so there was no mechanism to propagate the information about these issues back to the caller. Introduce such a mechanism by adding a new member to UdevRuleFile. This new member is a bitmask describing which log levels were used in messages logged with regards to the rule file. This mechanism is going to be used by udevadm verify in subsequent commits.
* udev: Don't mark as tablet if device has relative coordinatesJoshua Goins2023-03-071-1/+1
| | | | | | | | | | | Tablets don't typically have relative coordinates (they are separated on the kernel device layer). However, some Logitech mice report similar supported events, so use the existence of EV_REL to determiner whether or not the device is really a tablet. Fixes bug introduced by 0855ce67726f87a5a67b4fb536d58e0e4428a248. Fixes: #26600