summaryrefslogtreecommitdiff
path: root/src/udev/udev-builtin-blkid.c
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* 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.
* tree-wide: use -EBADF for fd initializationZbigniew Jędrzejewski-Szmek2022-12-191-1/+1
| | | | | | | | | | | | | | | | -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.
* blkid: add helpers that get gpt partition uuid as sd_id128_tLennart Poettering2022-11-291-21/+18
| | | | just some refactoring to make things simpler.
* udev: make sure auto-root logic also works in UKIs booted from XBOOTLDRLennart Poettering2022-11-221-14/+13
| | | | | | | | | | | | | | If no root= switch is specified on the kernel command line we'll use the root disk on which the partition the LoaderDevicePartUUID efi var is located – as long as that partition is an ESP. Let's slightly liberalize that and also allow it if that partition is an XBOOTLDR partition. This ensures that UKIs spawned directly from XBOOTLDR work the same as those from the ESP. (Note that this makes no difference if sd-boot is in the mix, as in that case LoaderDevicePartUUID is always set to the ESP, as that's where sd-boot is located, and sd-boot will set the var first, sd-stub will only set it later if it#s not set yet.)
* Merge pull request #24709 from keszybz/partition-table-constantsLennart Poettering2022-09-211-4/+4
|\ | | | | Expose various GPT UUIDs as public contants and link them up in docs
| * headers: export partition uuids and flags in new sd-gpt.h fileZbigniew Jędrzejewski-Szmek2022-09-201-4/+4
| | | | | | | | | | | | I think those constants are generally useful. It's quite easy to make a mistake when copying things from the docs, so let's make them easy and convenient to access.
* | udev: always open with O_NOCTTYYu Watanabe2022-09-101-1/+1
|/ | | | | All files or device nodes opened here should not be console tty. Let's open it the flags for safety.
* udev: enable BLKID_SUBLKS_FSINFO tagsAndrey Albershteyn2022-07-221-0/+8
| | | | | | | | libblkid gained new tags - FSSIZE, FSLASTBLOCK and FSBLOCKSIZE. These tags are filesystem related properties probed from superblock. All of them are enabled by BLKID_SUBLKS_FSINFO flag. Set the flag to allow these tags to be cached in udev db.
* udev: use sd_device_open() where appropriateYu Watanabe2022-04-011-4/+5
|
* udev: pass rtnl to builtin commandsYu Watanabe2021-08-311-1/+1
|
* udev/builtins: inline iterator variables and other small modernizationsZbigniew Jędrzejewski-Szmek2021-08-071-8/+7
|
* udev: when booting without root= specification, and searching a root ↵Lennart Poettering2021-07-021-8/+14
| | | | | | | | | | | | | | | partition actually do the version comparison magic Since 08fe0a53869f27a9bfbc5bd31f27058145d46745 when dissecting a disk image we'll automatically pick the "newest" root fs if multiple exist, by comparing GPT partition labels. This works in systemd-nspawn, systemd-dissect, systemd-tmpfiles --image, … and so on. It also works already in systemd-gpt-auto-generator. However, there was one missing place: in the logic that automatically finds a root fs in case no root= was specified on the kernel logic at all. This logic doesn't use the dissection logic, but a much simpler one. Let's fill the gap, and implement it there too.
* udev: ignore the case that the device is already removedYu Watanabe2021-06-021-2/+5
| | | | See #19788.
* udev: add missing short option nameYu Watanabe2021-01-131-2/+2
| | | | | | Follow-up for 4fcc033b5476039a7a8030e1edc261d42cec028b. Fixes CID#1442307.
* udev-builtin-blkid: add support for --hint offsetsKarel Zak2021-01-131-8/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The next libblkid v2.37 is going to support session offsets for multi-session CD/DVDs. This feature is implemented by "hint offsets". These offsets are optional and prober specific (e.g., iso, udf, ...). For this purpose, the library provides a new function blkid_probe_set_hint(), and blkid(8) provides a new command-line option --hint <name>=<offset>. For CD/DVD, the offset name is "session_offset". The difference between classic --offset and the new --hint is that --offset is very restrictive and defines the probing area and the rest of the device is invisible to the library. The new --hint works like a suggestion, it provides a hint where the user assumes the filesystem, but the rest of the device is still readable for the library (for example, to get some additional superblock information etc.). If the --hint is without a value then it defaults to zero. The option --hint implementation in udev-builtin-blkid.c is backwardly compatible. If compiled against old libblkid, then the option is used in the same way as --offset. Addresses: https://github.com/karelzak/util-linux/issues/1161 Addresses: https://github.com/systemd/systemd/pull/17424
* udev-builtin-blkid: add VOLUME_ID, LOGICAL_VOLUME_ID, VOLUME_SET_ID and ↵Karel Zak2020-12-121-0/+16
| | | | | | | DATA_PREPARER_ID The new libblkid release will provide these variables. Let's keep is accessible also from udev-db for the rest of the system.
* license: GPL-2.0+ -> GPL-2.0-or-laterYu Watanabe2020-11-091-1/+1
|
* libblkid: open device in nonblock mode.Michal Suchanek2019-11-081-1/+1
| | | | | | | | | | | | | | | | | | | | | When autoclose is set (kernel default but many distributions reverse the setting) opening a CD-rom device causes the tray to close. The function of blkid is to report the current state of the device and not to change it. Hence it should use O_NONBLOCK when opening the device to avoid closing a CD-rom tray. blkid is used liberally in scripts so it can potentially interfere with the user operating the CD-rom hardware. [kzak@redhat.com: add O_NONBLOCK also to: - wipefs - blkid_new_probe_from_filename() - blkid_evaluate_tag()] Signed-off-by: Michal Suchanek <msuchanek@suse.de> Signed-off-by: Karel Zak <kzak@redhat.com> (cherry picked from commit 39f5af25982d8b0244000e92a9d0e0e6557d0e17)
* tree-wide: drop blkid.h when blkid-util.h is includedYu Watanabe2019-11-041-1/+0
|
* tree-wide: drop string.h when string-util.h or friends are includedYu Watanabe2019-11-041-1/+0
|
* util-lib: split shared/efivars into basic/efivars and shared/efi-loaderZbigniew Jędrzejewski-Szmek2019-09-161-1/+1
| | | | | | I want to use efivars.[ch] in proc-cmdline.c, but most of the efivars stuff is not needed in basic/. Move the file from shared/ to basic/, but then move back most of the higher-level functions to the new shared/efi-loader.c file.
* tree-wide: make use of errno_or_else() everywhereLennart Poettering2019-07-111-1/+2
|
* udev: modernize udev-rules.cYu Watanabe2019-06-021-1/+1
| | | | | | | | | | | This does the following: - rename enum udev_builtin_cmd -> UdevBuiltinCmd - rename struct udev_builtin -> UdevBuiltin - move type definitions to udev-rules.h - move prototypes of functions defined in udev-rules.c to udev-rules.h - drop to use strbuf - propagate critical errors in applying rules, - drop limitation for number of tokens per line.
* udev: use SYNTHETIC_ERRNO() macro in log_device_*_errno()Yu Watanabe2019-01-131-1/+1
|
* udev-builtin-blkid: add more debug log messagesYu Watanabe2018-10-241-14/+16
|
* udev-builtin: propagate negative errnoYu Watanabe2018-10-231-15/+14
|
* udev: replace udev_device by sd_device from prototype of udev builtin commandsYu Watanabe2018-10-231-2/+1
|
* udev: replace udev_device by sd_device in udev-builtin-blkid.cYu Watanabe2018-10-231-48/+45
|
* udev: make udev_builtin_add_property() take sd_device instead of udev_deviceYu Watanabe2018-10-231-20/+20
|
* udev-builtin: move definitions related to builtin commands to udev-builtin.hYu Watanabe2018-10-111-1/+2
|
* 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-2/+2
| | | | | | Let's use a proper unicode copyright symbol where we can, it's prettier. This important patch is very important.
* tree-wide: drop redundant _cleanup_ macros (#8810)Lennart Poettering2018-04-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | This drops a good number of type-specific _cleanup_ macros, and patches all users to just use the generic ones. In most recent code we abstained from defining type-specific macros, and this basically removes all those added already, with the exception of the really low-level ones. Having explicit macros for this is not too useful, as the expression without the extra macro is generally just 2ch wider. We should generally emphesize generic code, unless there are really good reasons for specific code, hence let's follow this in this case too. Note that _cleanup_free_ and similar really low-level, libc'ish, Linux API'ish macros continue to be defined, only the really high-level OO ones are dropped. From now on this should really be the rule: for really low-level stuff, such as memory allocation, fd handling and so one, go ahead and define explicit per-type macros, but for high-level, specific program code, just use the generic _cleanup_() macro directly, in order to keep things simple and as readable as possible for the uninitiated. Note that before this patch some of the APIs (notable libudev ones) were already used with the high-level macros at some places and with the generic _cleanup_ macro at others. With this patch we hence unify on the latter.
* udevadm: prevent segfault in blkid builtin when offset not specifiedDouglas Christman2018-03-011-3/+10
| | | | | | | | | | "--offset" takes an optional argument; if none is specified, stroull() will attempt to parse a NULL pointer. For example: $ udevadm test-builtin 'blkid --offset' /sys/dev/block/8:1 Update "--offset" to require an argument; also verify that the offset is not negative.
* Add SPDX license identifiers to source files under the GPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
|
* build-sys: use #if Y instead of #ifdef Y everywhereZbigniew Jędrzejewski-Szmek2017-10-041-1/+1
| | | | | | | | | | | | | | | The advantage is that is the name is mispellt, cpp will warn us. $ git grep -Ee "conf.set\('(HAVE|ENABLE)_" -l|xargs sed -r -i "s/conf.set\('(HAVE|ENABLE)_/conf.set10('\1_/" $ git grep -Ee '#ifn?def (HAVE|ENABLE)' -l|xargs sed -r -i 's/#ifdef (HAVE|ENABLE)/#if \1/; s/#ifndef (HAVE|ENABLE)/#if ! \1/;' $ git grep -Ee 'if.*defined\(HAVE' -l|xargs sed -i -r 's/defined\((HAVE_[A-Z0-9_]*)\)/\1/g' $ git grep -Ee 'if.*defined\(ENABLE' -l|xargs sed -i -r 's/defined\((ENABLE_[A-Z0-9_]*)\)/\1/g' + manual changes to meson.build squash! build-sys: use #if Y instead of #ifdef Y everywhere v2: - fix incorrect setting of HAVE_LIBIDN2
* udev: never ask libblkid for detecting superblocks with bad checksums (#6215)Lennart Poettering2017-06-281-12/+1
| | | | | | | | | | | | | | | | Previously, we'd ask liblkid to also tell us about recognized superblocks with bad checksums. We'd then log about them and ignore them. This however created ambuigity problems, see #6110: the BLKID_SUBLKS_BADCSUM is not as innocent as it appears. This patch drops bad checksum handling and we ignore all such superblocks entirely again, as it was the status quo ante d47f6ca5f9b7a0b400d8bdb050151a0284fb4bdb (where this was snuck in). Ideally, libblkid would be changed to avoid this ambiguity problems for bad checksums, but that's not going to happen any time soon, according to @karelzak. Fixes: #6110
* udev-builtin-blkid: Use _cleanup_blkid_free_probe_ to free probe (#6108)Nate Clark2017-06-161-2/+2
| | | | Use the _cleanup_blkid_free_probe_ to guarantee that the blkid_probe will be freed when builtin_blkid exits.
* build-sys: correct blkid.h includesMatt Clarkson2017-04-061-1/+1
| | | | | | | | | | | | | | | | | | When using pkg-config to determine the include flags for blkid the flags are returned as: $ pkg-config blkid --cflags -I/usr/include/blkid -I/usr/include/uuid We use the <blkid/blkid.h> include which would be correct when using the default compiler /usr/include header search path. However, when cross-compiling the blkid.h will not be installed at /usr/include and highly likely in a temporary system root. It is futher compounded if the cross-compile packages are split up and the blkid package is not available in the same sysroot as the compiler. Regardless of the compilation setup, the correct include path should be <blkid.h> if using the pkg-config returned CFLAGS.
* udev-builtin-blkid: use -errno not -1 as error codeZbigniew Jędrzejewski-Szmek2017-02-211-1/+1
| | | | The code that calls this function doesn't care, but it looks bad.
* tree-wide: simplify handling of blkid errorsZbigniew Jędrzejewski-Szmek2017-02-211-1/+1
|
* udev-builtin-blkid: fix GPT_FLAG_NO_AUTO check for ESP (#3450)Lennart Poettering2016-06-091-5/+5
| | | | | | | | | | The flags check was accidentally placed in the ESP if block, but should be in the root if block. This corrects: 0238d4c660e732dd03ba0cdb54a29ec5870ee849 Fixes: #3440 Also see: #3441
* 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: check if errno is greater then zeroZbigniew Jędrzejewski-Szmek2016-01-131-1/+1
| | | | | | | | | | | | | | gcc is confused by the common idiom of return errno ? -errno : -ESOMETHING and thinks a positive value may be returned. Replace this condition with errno > 0 to help gcc and avoid many spurious warnings. I filed a gcc rfe a long time ago, but it hard to say if it will ever be implemented [1]. Both conventions were used in the codebase, this change makes things more consistent. This is a follow up to bcb161b0230f. [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61846
* udev: add emacs header lineZbigniew Jędrzejewski-Szmek2015-12-071-0/+2
| | | | | Otherwise emacs wants to use 2-space indentation and other attrocities.
* util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* util-lib: split out fd-related operations into fd-util.[ch]Lennart Poettering2015-10-251-0/+1
| | | | | There are more than enough to deserve their own .c file, hence move them over.