summaryrefslogtreecommitdiffstats
path: root/src/udev (follow)
Commit message (Collapse)AuthorAgeFilesLines
* sd-json,tree-wide: add sd_json_format_enabled() and use it everwhereZbigniew Jędrzejewski-Szmek2024-10-281-11/+9
| | | | | | | | | | | | | | | | | | | We often used a pattern like if (!FLAGS_SET(flags, SD_JSON_FORMAT_OFF)), which is rather verbose and also contains a double negative, which we try to avoid. Add a little helper to avoid an explicit bit check. This change clarifies an aditional thing: in some cases we treated SD_JSON_FORMAT_OFF as a flag (flags & SD_JSON_FORMAT_OFF), while in other cases we treated it as an independent enum value (flags == SD_JSON_FORMAT_OFF). In the first form, flags like SD_JSON_FORMAT_SSE do _not_ turn the json output on, while in the second form they do. Let's use the first form everywhere. No functional change intended. Initially I wasn't sure if this helper should be made public or just internal, but it seems such a common pattern that if we expose the flags, we might just as well expose it too, to make life easier for any consumers.
* tree-wide: replace for loop with FOREACH_ELEMENT or FOREACH_ARRAY macros ↵Integral2024-10-265-18/+16
| | | | (#34893)
* refactor: replace sizeof in loop with ELEMENTSOF & FOREACH_ELEMENT (#34863)Integral2024-10-232-7/+4
|
* udev: do not try to lock whole block device on remove eventYu Watanabe2024-10-152-0/+9
| | | | | | | As another device may be created with the same device node while udevd is processing the remove event of the previous owner of the device node. This also adds comment why we skip watching device node on remove.
* udev: do not re-create database on remove eventYu Watanabe2024-10-141-7/+12
| | | | | | | | Fixes a bug introduced by f6bda694f908cc227b002570b893029aa4c9e173 (v256). With the offending commit, on remove event, database file for a device is once removed in event_execute_rules_on_remove(), but later re-created here. This fixes the issue, and makes the database file not re-created on remove event.
* udev-node: drop unnecessary manager side cleaning up logic for stack directoryYu Watanabe2024-10-114-52/+0
| | | | | Unnecessary stack directories and their lock files are removed by workers. Hence, the logic is not necessary anymore.
* udev-node: drop workaround for by-diskseq symlinksYu Watanabe2024-10-111-83/+0
| | | | | | This effectively reverts 09373c1a50297079e6b0447ea97af4e9a60f77fa, as stack directories and lock files are removed by udev workers on unlocking.
* udev-node: remove lockfile and stack directory when not necessary if possibleYu Watanabe2024-10-111-26/+47
| | | | | | | | | | | | | | | | Replaces 09373c1a50297079e6b0447ea97af4e9a60f77fa. Let's remove stack directories and their lock files by workers if possible. Now, lock files must be created before creating stack directories, hence lock files are moved to /run/udev/links.lock/ , e.g., Before: /run/udev/links/disk\x2fby-diskseq\x2f1/.lock After: /run/udev/links.lock/disk\x2fby-diskseq\x2f1 Fixes ##34637.
* Merge pull request #34644 from yuwata/udev-node-diskseqLuca Boccassi2024-10-071-15/+100
|\ | | | | udev-node: do not create stack directory for by-diskseq symlink
| * udev-node: introduce node_remove_symlink()Yu Watanabe2024-10-071-14/+16
| | | | | | | | | | | | | | | | Also - make the failure propagated, - remove /dev/block or /dev/char if empty. Hopefully, no effective functionality changed. Just refactoring.
| * udev-node: rename node_symlink() -> node_create_symlink()Yu Watanabe2024-10-071-5/+5
| | | | | | | | | | | | Also adds short comment for the NULL arguments. No functional change, just refactoring.
| * udev-node: skip stack directory creation for diskseqYu Watanabe2024-10-071-0/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The disk/by-diskseq symlink should not be shared with multiple block devices. Hence, it is not necessary to create stack directory for the symlink that manages which device owns the symlink. This is not just a optimization. If a service unit tries to mount a disk image but the service fails, then the diskseq of the loop device for the image may be continuously increased during restart, and inodes in /run may increase rapidly, as the stack directories are cleaned up only when udev queue is empty. Fixes #34637.
* | tree-wide: drop doubled empty linesYu Watanabe2024-10-071-1/+0
|/
* path-lookup: move NETWORK_DIRS to network-util.hMike Yuan2024-10-061-0/+1
|
* fs-util: rename laccess to access_nofollowMike Yuan2024-10-051-1/+1
| | | | In order to distinguish it from libc function naming.
* tree-wide: Fix Wformat warningsDaan De Meyer2024-10-022-2/+2
| | | | | | The latest clang has started catching more integer promotions which cause us to pass the wrong type to printf() format specifiers so let's fix those.
* tree-wide: use strv_extend_strv_consume() where appropriateMike Yuan2024-09-211-1/+1
|
* test: quote paths to executablesYu Watanabe2024-09-181-1/+2
| | | | Fixes #34459.
* udev-rules: support case insensitive matchYu Watanabe2024-09-154-89/+146
| | | | | | | | | This introduces 'i' prefix for match string. When specified, string or pattern will match case-insensitively. Closes #34359. Co-authored-by: Ryan Wilson <ryantimwilson@meta.com>
* udev-rules: embed UdevRuleToken.attr_match_remove_trailing_whitespace flag ↵Yu Watanabe2024-09-151-12/+14
| | | | | | into UdevRuleMatchType No functional change, just refactoring and preparation for later change.
* tree-wide: make sigprocmask() changes more automaticLennart Poettering2024-09-133-11/+8
| | | | | | | | | | | | | This tries to get rid of most manual sigprocmask() changes, in favour of: 1. The SD_EVENT_SIGNAL_PROCMASK flag to sd_event_add_signal() 2. The sd_event_set_signal_exit() call for handling SIGTERM/SIGINT 3. Move masking of SIGWINCH into ptyfwd, out of nspawn/vmspawn/run And while we are at it get rid of a bunch of event source fields whose lifetime is bound to the sd_event object they belong to anyway, and make use of the "floating" event source feature of sd-event instead.
* udev/ata_id: export read look-ahead valuesTomas Bzatek2024-09-101-0/+4
| | | | | | | Indicates whether the ATA read look-ahead feature is supported and enabled. Signed-off-by: Tomas Bzatek <tbzatek@redhat.com>
* Fix grammar in udevadm settle timeout messagemarginaldev2024-09-081-1/+1
|
* socket-util: make recvmsg_safe() handle MSG_TRUNC tooMike Yuan2024-09-041-2/+10
| | | | Also, unify MSG_TRUNC handling all across the codebase.
* udev-ctrl: drop unused next_datagram_size_fd() callMike Yuan2024-09-041-6/+0
|
* udev-ctrl: add missing size check of received messageMike Yuan2024-09-041-3/+8
| | | | While at it, downgrade log level of ignored errors to LOG_WARNING.
* tree-wide: drop msg argument for DEFINE_CONFIG_PARSE() macro and friendsYu Watanabe2024-09-012-7/+4
| | | | | This makes the macros use log_syntax_parse_error(), hopefully which provides more informative log message in general, and reduces binary size.
* udevadm/info: also show driver subsystem and device IDYu Watanabe2024-08-271-2/+21
| | | | | | | | | This adds two more fields in 'udevadm info': - J for device ID, e.g. b128:1, c10:1, n1, and so on. - B for driver subsystem, e.g. pci, i2c, and so on. These, especially the device ID field may be useful to find udev database file under /run/udev/data for a device.
* sd-device: make device_get_device_id() publicYu Watanabe2024-08-273-7/+7
| | | | | | We have already exposed sd_device_new_from_device_id(), but we have never provide the way to get device ID from an existing sd_device object.
* Merge pull request #34102 from yuwata/udev-net_idYu Watanabe2024-08-231-19/+18
|\ | | | | udev/net_id: trivial cleanups
| * udev/net_id: update log messagesYu Watanabe2024-08-231-12/+12
| | | | | | | | This also downgrades the log level of a message to debug.
| * udev/net_id: move naming scheme checkYu Watanabe2024-08-231-7/+6
| | | | | | | | | | | | | | | | | | | | We usually do not set r = -1 when a functionality is disabled or not supported. Even though the error code is not used, let's set a negative errno in such case. No functional change, just refactoring. Follow-up for 0a4ecc54cb9f2d3418b970c51bfadb69c34ae9eb.
* | udevadm/test,test-builtin: enable debugging logs by default againYu Watanabe2024-08-232-0/+2
|/ | | | | The lines were mistakenly dropped by aa976d87889ae22b7347787a1ebd03a31dcc0a9e.
* udev-builtin-net_id: ignore firmware_node/sun == 0Etienne Champetier2024-08-231-1/+5
| | | | | | | | | | | | | Since ID_NET_NAME_SLOT was introduced we ignore slot == 0 https://github.com/systemd/systemd/blob/0035597a30d120f70df2dd7da3d6128fb8ba6051/src/udev/udev-builtin-net_id.c#L139 Qemu sets _SUN to PCI_SLOT() for all NICs, so _SUN is not unique. https://gitlab.com/qemu-project/qemu/-/issues/2530 In my tests with libvirt I can only set 'slot="0x00"' in interface definition, so all NICs end up with _SUN == 0, and this commit is enough to avoid the issue. Fixes 0a4ecc54cb9f2d3418b970c51bfadb69c34ae9eb
* udev-builtin-net_id: add NAMING_DEVICETREE_PORT_ALIASES to check of_node of ↵Matthias Schiffer2024-08-151-8/+17
| | | | | | | | | | | | | | | | netdevs before their parents The net_id builtin only checked the of_node of a netdev's parent device, not that of the netdev itself. While it is common that netdevs don't have an OF node assigned themselves, as they are derived from some parent device, this is not always the case. In particular when a single controller provides multiple ports that can be referenced indiviually in the Device Tree (both for aliases/MAC address assignment and phandle references), the correct of_node will be that of the netdev itself, not that of the parent, so it needs to be checked, too. A new naming scheme flag NAMING_DEVICETREE_PORT_ALIASES is added to allow selecting the new behavior.
* udevadm-info: support json output for --attribute-walkYu Watanabe2024-08-051-3/+107
| | | | Closes #33852.
* udevadm-info: trival cleanupsYu Watanabe2024-08-051-6/+7
| | | | | | - drop trailing an empty line, - use FOREACH_ARRAY() macro, - add short comment for boolean argument.
* udevadm: fix typoYu Watanabe2024-08-021-1/+1
| | | | Follow-up for 0e789e6d48046d43c50dd949a71ac56f1127bb96.
* sd-device-monitor: rename device_monitor_send_device() -> device_monitor_send()Yu Watanabe2024-08-022-2/+2
|
* udev: manage only socket address of device monitorYu Watanabe2024-08-021-7/+6
| | | | | | | Previously, the main process of systemd-udevd manages worker process with their sd_device_monitor object to save the destination address. Let's save only destination address, and drop worker's sd_device_monitor object.
* sd-device-monitor: bind socket in device_monitor_new_full()Yu Watanabe2024-08-021-8/+0
| | | | | | | | | | Previously, device_monitor_enable_receiving() does - update filter, - bind socket. But, binding socket can be done in when the socket is opened. Let's remove device_monitor_enable_receiving() and bind the socket in device_monitor_new_full().
* udev-builtin-net_id: use firmware_node/sun for ID_NET_NAME_SLOTEtienne Champetier2024-07-211-10/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | pci_get_hotplug_slot() has the following limitations: - if slots are not hotpluggable, they are not in /sys/bus/pci/slots. - the address at /sys/bus/pci/slots/X/addr doesn't contains the function part, so on some system, 2 different slots with different _SUN end up with the same hotplug_slot, leading to naming conflicts. - it tries all parent devices until it finds a slot number, which is incorrect, and what led to NAMING_BRIDGE_MULTIFUNCTION_SLOT being disabled. The use of PCI hotplug to find the slot (ACPI _SUN) was introduced in https://github.com/systemd/systemd/commit/0035597a30d120f70df2dd7da3d6128fb8ba6051 "udev: net_id - export PCI hotplug slot names" on 2012/11/26. At the same time on the kernel side we got https://github.com/torvalds/linux/commit/bb74ac23b10820d8722c3e1f4add9ef59e703f63 "ACPI: create _SUN sysfs file" on 2012/11/16. Using PCI hotplug was the only way at the time, but now 12 years later we can use firmware_node/sun sysfs file. Looking at a small selection of server HW, for HPE (Gen10 DL325), the _SUN is attached to the NIC device, whereas for Dell (R640/R6515/R6615) and Cisco (UCSC-C220-M5SX), the _SUN is on the first parent pcieport. We still fallback to pci_get_hotplug_slot() to handle the s390 case and maybe some other coner cases (_SUN on grand parent device that is not a bridge ?).
* terminal-util: split out color macros/helpers into its own headerLennart Poettering2024-07-192-0/+2
| | | | | | | | | This is a lot of stuff, and sometimes quite wild, let's turn this into its own header. All stuff color-related that just generates sequences is now in ansi-color.h (no .c file!), and everything more complex that probes/ineracts with terminals remains in termina-util.[ch]
* Merge pull request #32868 from keszybz/more-whomificationYu Watanabe2024-06-194-4/+4
|\ | | | | Fix confusion between killer and prey
| * various: move const ptr indicator to return valueZbigniew Jędrzejewski-Szmek2024-06-194-4/+4
| |
* | udev-spawn: fix typo and simplify codeAntonio Alvarez Feijoo2024-06-191-3/+2
|/ | | | Follow-up for 11706971e8b6aa289af56454330fffd87f5d5a78
* fs-util: add simple open_mkdir() wrapperLennart Poettering2024-06-152-2/+2
|
* libsystemd: turn json.[ch] into a public APILennart Poettering2024-06-121-13/+13
| | | | | | | | | | | | | | | This is preparation for making our Varlink API a public API. Since our Varlink API is built on top of our JSON API we need to make that public first (it's a nice API, but JSON APIs there are already enough, this is purely about the Varlink angle). I made most of the json.h APIs public, and just placed them in sd-json.h. Sometimes I wasn't so sure however, since the underlying data structures would have to be made public too. If in doubt I didn#t risk it, and moved the relevant API to src/libsystemd/sd-json/json-util.h instead (without any sd_* symbol prefixes). This is mostly a giant search/replace patch.
* udev: rewrite token_match_attr() to make it easier for Coverity to understandYu Watanabe2024-06-121-15/+16
| | | | | | No functional change. Closes CID#1469719.
* tree-wide: use LOG_PRI() and LOG_FAC()Yu Watanabe2024-05-121-1/+1
|