summaryrefslogtreecommitdiff
path: root/rules.d
Commit message (Collapse)AuthorAgeFilesLines
* udev/iocost: invert DEVTYPE matchYu Watanabe2023-04-261-3/+1
| | | | | No functional change, just refactoring. Addresses https://github.com/systemd/systemd/pull/23325#discussion_r1171006967.
* udev/iocost: use ID_MODEL_FROM_DATABASE if existsYu Watanabe2023-04-261-1/+5
| | | | To make the rule consistent with 'iocost query'.
* Merge pull request #27349 from mrc0mmand/codespellLuca Boccassi2023-04-201-2/+2
|\ | | | | tree-wide: code spelling fixes
| * tree-wide: code spelling fixesFrantisek Sumsal2023-04-201-2/+2
| | | | | | | | As reported by Fossies.
* | Apply known iocost solutions to block devicesGustavo Noronha Silva2023-04-202-0/+21
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Meta's resource control demo project[0] includes a benchmark tool that can be used to calculate the best iocost solutions for a given SSD. [0]: https://github.com/facebookexperimental/resctl-demo A project[1] has now been started to create a publicly available database of results that can be used to apply them automatically. [1]: https://github.com/iocost-benchmark/iocost-benchmarks This change adds a new tool that gets triggered by a udev rule for any block device and queries the hwdb for known solutions. The format for the hwdb file that is currently generated by the github action looks like this: # This file was auto-generated on Tue, 23 Aug 2022 13:03:57 +0000. # From the following commit: # https://github.com/iocost-benchmark/iocost-benchmarks/commit/ca82acfe93c40f21d3b513c055779f43f1126f88 # # Match key format: # block:<devpath>:name:<model name>: # 12 points, MOF=[1.346,1.346], aMOF=[1.249,1.249] block:*:name:HFS256GD9TNG-62A0A:fwver:*: IOCOST_SOLUTIONS=isolation isolated-bandwidth bandwidth naive IOCOST_MODEL_ISOLATION=rbps=1091439492 rseqiops=52286 rrandiops=63784 wbps=192329466 wseqiops=12309 wrandiops=16119 IOCOST_QOS_ISOLATION=rpct=0.00 rlat=8807 wpct=0.00 wlat=59023 min=100.00 max=100.00 IOCOST_MODEL_ISOLATED_BANDWIDTH=rbps=1091439492 rseqiops=52286 rrandiops=63784 wbps=192329466 wseqiops=12309 wrandiops=16119 IOCOST_QOS_ISOLATED_BANDWIDTH=rpct=0.00 rlat=8807 wpct=0.00 wlat=59023 min=100.00 max=100.00 IOCOST_MODEL_BANDWIDTH=rbps=1091439492 rseqiops=52286 rrandiops=63784 wbps=192329466 wseqiops=12309 wrandiops=16119 IOCOST_QOS_BANDWIDTH=rpct=0.00 rlat=8807 wpct=0.00 wlat=59023 min=100.00 max=100.00 IOCOST_MODEL_NAIVE=rbps=1091439492 rseqiops=52286 rrandiops=63784 wbps=192329466 wseqiops=12309 wrandiops=16119 IOCOST_QOS_NAIVE=rpct=99.00 rlat=8807 wpct=99.00 wlat=59023 min=75.00 max=100.00 The IOCOST_SOLUTIONS key lists the solutions available for that device in the preferred order for higher isolation, which is a reasonable default for most client systems. This can be overriden to choose better defaults for custom use cases, like the various data center workloads. The tool can also be used to query the known solutions for a specific device or to apply a non-default solution (say, isolation or bandwidth). Co-authored-by: Santosh Mahto <santosh.mahto@collabora.com>
* Merge pull request #27169 from yuwata/udev-rule-refuse-unsafe-pathZbigniew Jędrzejewski-Szmek2023-04-111-1/+9
|\ | | | | sd-device,udev: refuse unsafe path in SYMLINK= and TAG=
| * rules: drop doubled spaceYu Watanabe2023-04-081-1/+1
| |
| * udev: restore compat symlink for nvme devicesZbigniew Jędrzejewski-Szmek2023-04-081-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In 5118e8e71dda211d20e34ec8d3012186ba27d3d3, the rules were changed to add OPTIONS="string_escape=replace" to creation of ENV{ID_SERIAL}="$env{ID_MODEL}_$env{ID_SERIAL_SHORT}", so that "/" would be escaped. But this also changes how the symlink looks for devices that do not have "/". This adds back the old symlink for compat, except when a slash is present. In the meantime, we changed the symlink format to include ${ND_NSID}. Since the symlink with unescaped characters are older than that, for compat we only need to cover the older type. (Symlinks without escaping and with ${ND_NSID} were never created.) This makes it slightly easier on users: the non-deprecated symlinks are with "_${ND_NSID}", so they are easier to distinguish. Fixes #27155. Mostly untested :( I only have a boring nvme device with no special characters in the id, and the symlinks are unchanged for it by this patch.
* | udev/scsi_id: rename positional argumentsYu Watanabe2023-04-112-4/+4
|/
* rules: add whitespace after comma before the line continuationDmitry V. Levin2023-03-271-2/+2
|
* rules: remove stray whitespace before comma between tokensDmitry V. Levin2023-03-271-1/+1
|
* udev-rules: fix nvme symlink creation on namespace changesThomas Blume2023-03-211-0/+8
| | | | | | | | | | The nvme by-id symlink changes to the latest namespace when a new namespace gets added, for example by connecting multiple NVMe/TCP host controllers via nvme connect-all. That is incorrect for persistent device links. The persistent symbolic device link should continue to point to the same NVMe namespace throughout the lifetime of the current boot. Therefore the namespace id needs to be added to the link name.
* udev: add /dev/loop/ symlinksLennart Poettering2023-03-091-0/+11
| | | | | | | | | | | | | | | | | | | | This adds symlinks that allow accessing loopback block devices via stable names that reference their backing block devices, make the unpredictable naming of loopback devices less of an issue. Example: 1. Create a loopback block device for a file $F losetup --find $F 2. Reference the backing block device via its inode: L="$(stat -c '/dev/loop/by-inode/%Hd:%Ld-%i' $F)" fdisk $L In the above the loop device name (which might be /dev/loop47 or any other name) is not used at all.
* rules: do not use blkid builtin if built without blkid supportDmitry V. Levin2023-03-082-1/+3
| | | | | | | | | | When built without blkid, then udev-builtin-blkid is not built, and the verifier warns about the unknown builtin: 60-persistent-storage.rules:114 Unknown builtin command: blkid --hint=session_offset=$env{ID_CDROM_MEDIA_SESSION_LAST_OFFSET} 60-persistent-storage.rules:117 Unknown builtin command: blkid --noraid 60-persistent-storage.rules:120 Unknown builtin command: blkid 60-persistent-storage.rules: udev rules check failed
* rules: remove redundant duplicate comparisonsDmitry V. Levin2023-02-261-2/+2
| | | | | | | | | | | | $ grep -F -n -o 'ENV{DISKSEQ}=="?*", ' rules.d/60-persistent-storage.rules 139:ENV{DISKSEQ}=="?*", 139:ENV{DISKSEQ}=="?*", 140:ENV{DISKSEQ}=="?*", 140:ENV{DISKSEQ}=="?*", Reported-by: Alexey Gladkov <legion@kernel.org> Fixes: 17d97d4c90f8 ("udev: create disk/by-diskseq symlink only when the device has diskseq") Fixes: 583dc6d933d8 ("udev: also create partition /dev/disk/by-diskseq/ symlinks")
* meson: Install missing udev ruleJan Janssen2023-01-271-0/+1
|
* udev: also create partition /dev/disk/by-diskseq/ symlinksLennart Poettering2022-12-231-0/+1
|
* rules: add missing line continuationYu Watanabe2022-12-211-1/+1
| | | | | | Fixes a bug introduced by 953c928c24455744d5534679998d129b947a5e04. Fixes #25811.
* udev: rework 60-evdev.rules to be "additive"Zbigniew Jędrzejewski-Szmek2022-12-121-10/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We would execute up to four hwdb match patterns (+ the keyboard builtin): After the first hit, we would skip the other patterns, because of the GOTO="evdev_end" action. 57bb707d48131f4daad2b1b746eab586eb66b4f3 (rules: Add extended evdev/input match rules for event nodes with the same name), added an additional match with ":phys:<phys>:ev:<ev>" inserted. This breaks backwards compatibility for user hwdb patterns, because we quit after the first match. In general hwdb properties are "additive". We often have a general rule that matches a wider class and then some specific overrides. E.g. in this particular case, we have a match for all trackpoints, and then a bunch of model-specific settings. So let's change the rules to try all the match patterns and combine the received properties. We execute builtin-keyboard once at the end, if there was at least one match. Fixes #25698. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=2152226. This also impacts other cases which I think would be very confusing for users. Since we quit after a first successful match, if we had e.g. a match for 'evdev:input:b*v*p*' in out database, and the user added a match using 'evdev:name:*', which is the approach we document in the .hwdb files and which users quite often use, it would be silently ignored. What's worse, if we added our 'evdev:input:b*v*p*' match at a later point, user's match would stop working. If we combine all the properties, we get more stable behaviour.
* udev: add safe guard for setting by-id symlinkYu Watanabe2022-11-031-0/+1
| | | | The ID_BUS property is necessary for creating by-id symlinks.
* udev: drop redundant call of usb_id and assignment of ID_USB_INTERFACE_NUMYu Watanabe2022-11-031-2/+0
| | | | | The usb_id builtin command is already called in the above, and the command sets the ID_USB_INTERFACE_NUM property.
* udev: first set properties based on usb subsystemYu Watanabe2022-11-031-2/+3
| | | | | | | | | | After 479da1107a0d4e2f7ef5cd938512b87a0e45f180, the usb_id builtin command does not set ID_SERIAL if ID_BUS is already set. Before the commit, all properties set based on pci bus were overwritten by the usb_id, hence now it is sufficient setting them only when ID_BUS is not set yet. Fixes #25238.
* udev: always create device symlinks for USB disksYu Watanabe2022-10-301-2/+8
| | | | | | | | | Previously, ata_id might not be able to retrieve attributes correctly, and properties from usb_id were used as a fallback. See issue #24921 and PR #24923. To keep backward compatibility, still we need to create symlinks based on USB serial. Fixes #25179.
* udev-builtin-kmod: support to run without argumentsYu Watanabe2022-10-141-1/+1
| | | | | | | | | | | If no module name is provided, then try to load modules based on the device modealias. Previously, MODALIAS property is passed as an argument, but it may contain quotation. Hence, unfortunately the modalias may be modified and cannot load expected modules. Fixes #24715.
* udev/rules: add by-path and by-ibdev links to infiniband verbsLubomir Rintel2022-10-141-0/+12
| | | | | | | | | | The uverbs devices are sequentially numbered and are not guarranteed to stay stable across reboot. At least one good person was disappointed by this, because they couldn't find their device: https://bugzilla.redhat.com/show_bug.cgi?id=2036515 Let's add a few helpful links.
* udev: support by-path devlink for multipath nvme block devicesYu Watanabe2022-09-231-0/+1
| | | | | | | | | | | | | | | If multipath feature is enabled, nvme block devices may belong to the "nvme-subsystem" subsystem, instead of "nvme" subsystem. (What a confusing name...) Then, the syspath is something like the following, /sys/devices/virtual/nvme-subsystem/nvme-subsys0/nvme0n1 Hence, we need to find the 'real parent' device, such as /sys/devices/pci0000:00/0000:00:1c.4/0000:3c:00.0/nvme/nvme0 Fixes https://bugzilla.redhat.com/show_bug.cgi?id=2031810. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=2124964. Replaces #24748.
* udev/rules,hwdb: filter out mostly meaningless default stringsYu Watanabe2022-09-061-2/+3
| | | | | | | | | | | | The filter is generated based on the following results: --- git clone git@github.com:linuxhw/DMI.git cd DMI git grep -h -A2 '^System Information$' | grep 'Manufacturer' | sort | uniq -c | sort -nr | less git grep -h -A2 '^System Information$' | grep 'Product Name' | sort | uniq -c | sort -nr | less --- Closes #24446.
* rules: import previous SYSTEMD_READY state for suspended DM devices and skip ↵Michal Sekletar2022-08-191-0/+6
| | | | | | | | | | | other rules We can't get any FS meta-data from a suspended device. Hence defer making any plugged/unplugged decisions, i.e. we just import whatever was previous state and skip processing all other rules. Thanks Lennart Poettering <lennart@poettering.net> for suggesting this solution.
* udev: hwdb: Add rules to match cros-ec-accel by 'location' sysfs fileAlper Nebi Yasak2022-08-181-0/+11
| | | | | | | | | | | | | The cros-ec-accel devices report their mounting location by the 'label' sysfs file only since Linux v6.0. With earlier kernels, a nonstandard 'location' file reports this, but slightly differently (lid instead of display) [1]. Add udev rules to import the correct hwdb entries based on this 'location' file for cros-ec-accel devices, so that the base-mounted accel matrix has the correct value for older kernels as well. [1] https://kernel.org/doc/Documentation/ABI/testing/sysfs-bus-iio-cros-ec
* udev: hwdb: Match iio sensors based on their labelAlper Nebi Yasak2022-08-181-0/+5
| | | | | | | | | | | | | | | | | | The IIO subsystem exposes a 'label' sysfs file to help userspace better identify its devices [1]. Standardized labels include the sensor type along with its location, including 'accel-base' and 'accel-display'. Most Chrome OS boards have two accelerometers that are indistinguishable except for this label (or a 'location' sysfs file before Linux v6.0), and need different mounting matrix corrections based on their location. Add a udev rule that matches hwdb entries using this label, so we can correct both accelerometers on these devices with hwdb entries. The existing rules and hwdb entries are not modified to keep potential out-of-tree entries working, but new entries in this form will override existing ones. Also add currently standardized labels to parse-hwdb.py. [1] https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-bus-iio
* hwdb: Allow users access to USB serial for analysersBastien Nocera2022-08-091-0/+1
| | | | | | | Allow users at the console access to the USB serial interface for USB analysers. See 9e2dbfef479060ed850ccdd9cd82d3f0cda2b5c0
* udev: add flag to allow disabling blkid probingDarsey Litzenberger2022-07-151-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | This can be useful for users of slow block devices. For example, the persistent-storage rules are needed for USB floppy drives be recognized by udisks2, but the extra blkid calls cause thrashing for 25+ seconds after every disk change. With this change, a user wishing to avoid the extra blkid invocation(s) could create /etc/udev/rules.d/55-floppy-noprobe.rules as follows: # Don't probe PC floppy drives SUBSYSTEM=="block", KERNEL=="fd*", \ ENV{UDEV_DISABLE_PERSISTENT_STORAGE_BLKID_FLAG}="1" # Don't probe USB floppy drives SUBSYSTEM=="block", SUBSYSTEMS=="usb", \ ATTRS{bInterfaceClass}=="08", ATTRS{bInterfaceSubClass}=="04", \ ENV{UDEV_DISABLE_PERSISTENT_STORAGE_BLKID_FLAG}="1" I didn't exclude floppies by default in this change, because floppy devices are also emulated by some BIOSes/hypervisors in some cases, and I don't know how many systems would fail to boot if /dev/disk/by-uuid/* became unavailable for 'floppy disks' on those systems.
* meson: install 70-power-switch.rulesYu Watanabe2022-05-191-0/+3
| | | | | | Fixes a bug introduced by 155078c835a00fed264a7b36b06f709d9b57cb1b. Fixes #23425.
* Add support to set autosuspend delay via hwdbMario Limonciello2022-05-091-0/+4
|
* meson: move vconsole rules to rules.d/Zbigniew Jędrzejewski-Szmek2022-05-052-0/+14
|
* meson: move udev rules to rules.d/Zbigniew Jędrzejewski-Szmek2022-05-055-48/+280
|
* udev: set ID_IGNORE_DISKSEQ for md devicesYu Watanabe2022-04-141-0/+4
|
* udev: do not create disk/by-diskseq symlink when ID_IGNORE_DISKSEQ property ↵Yu Watanabe2022-04-141-1/+1
| | | | is set
* udev: create disk/by-diskseq symlink only when the device has diskseqYu Watanabe2022-04-131-1/+1
| | | | Follow-up for 0d08db7f89ee665a9dcb6dd66c1f9e203192e8ec.
* meson: also allow setting GIT_VERSION via templatesZbigniew Jędrzejewski-Szmek2022-04-051-1/+1
| | | | | | | | | GIT_VERSION is not available as a config.h variable, because it's rendered into version.h during builds. Let's rework jinja2 rendering to also parse version.h. No functional change, the new variable is so far unused. I guess this will make partial rebuilds a bit slower, but it's useful to be able to use the full version string.
* udev: add /dev/disk/by-diskseq symlink for block devicesLennart Poettering2022-04-011-0/+5
| | | | | | | | | | | | | | | | | This adds another symlink for block devices: /dev/disk/by-diskseq/<number> where the number is the diskseq number as exposed by the kernel. It's useful for apps because they can use it to open a device by diskseq, in a way that is safe against device node reuse. I.e. if a device node path like this is passed to an app it could open the device node via the symlink and also parse the diskseq from the path. Once the device is opened it could compare the parsed diskseq with the one returned by BLKGETDISKSEQ on the open node, and if it matches they know they are talking to the right device. Fixes: #22906
* udev: 60-persistent-storage-tape.rules: handle duplicate device IDDavid Bond2022-03-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Some SCSI tape devices use the same device ID (NAA registered device designator) for the SCSI tape changer device and the first actual tape device. For example, this one: https://docs.oracle.com/en/storage/tape-storage/storagetek-sl150-modular-tape-library/slofs/bridged-tape-drives.html You must connect the bridged drive to an HBA supporting multiple LUNs (also referred to as LUN scanning). The SL150 Library uses a single SCSI ID and two logical unit numbers (LUN). LUN 0 controls the tape drive and LUN 1 which is configured as a SCSI medium changer device controls the robotics. Data is sent to the remaining LUN on the bridged drive or to LUNs on the other, unbridged drives in the partition, all of which are configured as SCSI sequential-access (tape) devices. This may lead to errors because /dev/tape/by-id symlinks may sometimes point to the st device representing the tape, and sometimes to the sg device representing the changer. Fix this by assigning an increased priority to the tape device, and creating a separate -changer link for the SCSI tape changer. Co-developed-by: Martin Wilck <mwilck@suse.com>
* meson: do not use split() in file listsZbigniew Jędrzejewski-Szmek2022-03-021-25/+24
| | | | | | | | | | | The approach to use '''…'''.split() instead of a list of strings was initially used when converting from automake because it allowed identical blocks of lines to be used for both, making the conversion easier. But over the years we have been using normal lists more and more, especially when there were just a few filenames listed. This converts the rest. No functional change.
* rule: fallback to use board information if product information is not setYu Watanabe2022-01-231-0/+3
|
* rule: make ID_SYSFS_ATTRIBUTE_MODEL also accept product_nameYu Watanabe2022-01-231-2/+5
|
* Revert "udev: Import hwdb matches for USB devices"Zbigniew Jędrzejewski-Szmek2022-01-041-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 94cb45d57f6e94dd4c93bd4706f9be70634bf03f. This rule set up a duplicate import: $ udevadm test /devices/pci0000:00/0000:00:14.0/usb2/2-4/2-4.1/2-4.1.3 ... 2-4.1.3: /usr/lib/udev/rules.d/40-libgphoto2.rules:9 Importing properties from results of builtin command 'usb_id' 2-4.1.3: /usr/lib/udev/rules.d/50-udev-default.rules:13 Skipping builtin 'usb_id' in IMPORT key 2-4.1.3: /usr/lib/udev/rules.d/50-udev-default.rules:13 Importing properties from results of builtin command 'hwdb --subsystem=usb' 2-4.1.3: hwdb modalias key: "usb:v17EFp3054:OneLink+ Giga" 2-4.1.3: /usr/lib/udev/rules.d/50-udev-default.rules:15 Importing properties from results of builtin command 'hwdb 'usb:v17efp3054'' 2-4.1.3: No entry found from hwdb. 2-4.1.3: /usr/lib/udev/rules.d/50-udev-default.rules:15 Failed to run builtin 'hwdb 'usb:v17efp3054'': No data available 2-4.1.3: /usr/lib/udev/rules.d/50-udev-default.rules:52 MODE 0664 except that the existing one was done with uppercase digits and the full match pattern, and the second one was done with lowercase digits. With the previous commit we only have uppercase digits in our match patterns, so we can drop the duplicate import. (Some other projects might have rules that used the lowercase match patterns, and people might have some local rules that did that too. But the second import was only added recently so I think it's better to rip off the bandaid quickly.)
* Enable /dev/sgx_vepc access for the group 'sgx'Jarkko Sakkinen2021-12-121-0/+1
| | | | | | | Enable /dev/sgx_vepc access for the group 'sgx', which allows KVM-backed VMs to host Intel Software Guard eXtension (SGX) enclaves. The upcoming QEMU 6.2 uses /dev/sgx_vepc to reserve portions of Enclave Page Cache (EPC) for VMs. EPC is the reserved physical memory used for hosting enclaves.
* build: preserve correct mode when generating files via jinja2Christian Brauner2021-11-081-2/+1
| | | | | | | | | When using "capture : true" in custom_target()s the mode of the source file is not preserved when the generated file is not installed and so needs to be tweaked manually. Switch from output capture to creating the target file and copy the permissions from the input file. Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
* hwdb: Tag IR cameras as suchwip/hadess/webcamsBastien Nocera2021-10-272-0/+10
| | | | | | So that front-ends can ignore them if they wish to. See https://gitlab.gnome.org/GNOME/cheese/-/merge_requests/4
* docs: Fixing typo in systemd.device man page and README.alexlzhu2021-09-291-1/+1
| | | | | | | | | systemd-udevd.service listens to kernel uevents and is needed for device units to be available. systemd-udevd.service is misspelled as systemd-udev.service in a couple places. Fixing typo.