summaryrefslogtreecommitdiffstats
path: root/src/shared/find-esp.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* find-esp: adjust parameter indentating to our usual coding styleLennart Poettering2024-01-041-17/+23
|
* find-esp: add debugging log about failure in parsing env variableYu Watanabe2023-12-191-1/+5
| | | | Addresses https://github.com/systemd/systemd/pull/30321#discussion_r1429716344.
* find-esp: do not skip fstype check even when --root= or --image= is specifiedYu Watanabe2023-12-131-6/+0
| | | | | The check was introduced by 63105f33edad423691e2d53bf7071f99c83799ba, but there is no reason to skip the check even in such cases.
* find-esp: introduce verify_esp_flags_init() helper functionYu Watanabe2023-12-131-31/+33
| | | | | | And split VERIFY_ESP_RELAX_CHECKS into two. No functional change, just refactoring.
* find-esp: do not fail when /boot on btrfs RAID on searching ESP or xbootldrYu Watanabe2023-12-131-0/+14
| | | | | | | | | | | | | | | | | | When /boot or friends is on btrfs RAID, btrfs_get_block_device_at() will succeed with 0 and provide zero devnum. Then, - if we are previleged, devname_from_devnum() maps the devnum to /run/systemd/inaccessible/blk, and the subsequent verification by blkid will fail, - if we are unprevileged, sd_device_new_from_devnum() will fail. This makes - when find_esp() or find_xbootldr() is called without any paths, that is, called with the searching mode, then returns -ENOKEY, which should be handled gracefully by the caller, - when they are called with an input path, then they provide the proper error message and suggestion. Fixes RHBZ#2251262 (https://bugzilla.redhat.com/show_bug.cgi?id=2251262).
* tree-wide: fix typo found by Fossies Codespell reportYu Watanabe2023-07-211-1/+1
|
* stat-util: Make sure we trigger automounts when looking for ESP/XBOOTLDRDaan De Meyer2023-06-301-0/+7
| | | | Fixes #25417
* find-esp: fix XBOOTLDR stx_dev_major=0 and not btrfs fixнаб2023-06-161-1/+1
| | | | | | | | | | | | | | | | | | The original commit is fully correct in its analysis, description, and mechanics, but the patch changes an identical condition around line 500 (find_esp_and_warn()), instead of line 800 (find_xbootldr_and_warn()). The internal patch I distributed to testers was correct (L800), and neither the reviewers, nor me, caught that I wrote the wrong line for upstream submission. I've re-checked that this patch applied to systemd 252.11-1 fixes the issue. Keep the -ENOTTY condition for find_esp_and_warn(), since the conditions are clearly supposed to be the same and similar semantics apply. Fixes: commit ed89819f8fd7bfe99cd652082076e85e1417e4e9 ("find-esp: don't silently error bootctl install if presumed XBOOTLDR part is stx_dev_major=0 but not btrfs")
* find-esp: drop some redundant 'else'Lennart Poettering2023-05-311-2/+2
|
* find-esp: change "unprivileged_mode" parameter to be tristateLennart Poettering2023-05-311-22/+38
| | | | | | | | | | | | | | | Previously, unprivileged mode for find_esp_and_warn() and find_xbootldr_and_warn() could be enabled or disabled. With this change it can also be set to negative in which case the functions will enable it automatically if found to be executing without privileges. This just moves te geteuid() check we often do for the param inside of the functions. At the same time internally in the functions we also pass around the VerifyESPFlags field across the various functions instead of booleans. Both changes are just refactoring. No changes in behaviour.
* chase: replace path_prefix_root_cwd() with chaseat_prefix_root()Yu Watanabe2023-04-181-2/+2
| | | | | | | | | | | | | | The function path_prefix_root_cwd() was introduced for prefixing the result from chaseat() with root, but - it is named slightly generic, - the logic is different from what chase() does. This makes the name more explanative and specific for the result of the chaseat(), and make the logic consistent with chase(). Fixes https://github.com/systemd/systemd/pull/27199#issuecomment-1511387731. Follow-up for #27199.
* find-esp: use path_prefix_root_cwd()Yu Watanabe2023-04-101-10/+6
| | | | | | | | | | | Unlikely, but even if find_esp() or friends called with unnormalized or relative 'root', let's make the result path normalized and absolute. Note, before 63105f33edad423691e2d53bf7071f99c83799ba, these functions returned an absolute and normalized path. But the commit made the result path simply concatenated with root. Follow-up for 63105f33edad423691e2d53bf7071f99c83799ba.
* fd-util: introduce dir_fd_is_root_or_cwd()Yu Watanabe2023-04-041-4/+1
|
* find-esp: Add openat() like helpers that operate on fdsDaan De Meyer2023-04-011-136/+201
| | | | | | | | | | We also rework the internals of find-esp to work on directory file descriptors instead of absolute paths and do a lot of general cleanups. By passing the parent directory file descriptor to verify_fsroot_dir() along with the name of the directory we're operating on, we can get rid of the fallback that goes via path to open the parent directory if '..' fails due to permission errors.
* find-esp: Drop explicit automount triggerDaan De Meyer2023-04-011-5/+0
| | | | | | We call statx_fallback() which calls either statx() or fstatat(), both of which automount by default, so we don't need the explicit trigger.
* btrfs-util: Add btrfs_get_block_device_at()Daan De Meyer2023-04-011-12/+2
| | | | | | Let's make btrfs_get_block_device_fd() more generic by renaming it to btrfs_get_block_device_at() so it can operate on only paths, dir_fd and path, or only on fd by using xopenat().
* chase-symlinks: Rename chase_symlinks() to chase()Daan De Meyer2023-03-241-7/+7
| | | | | | | | | 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.
* find-esp: don't silently error bootctl install if presumed XBOOTLDR part is ↵наб2023-03-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | stx_dev_major=0 but not btrfs btrfs_get_block_device_fd() returns -ENOTTY if fstatfs().f_type != BTRFS_SUPER_MAGIC btrfs_get_block_device_fd() is run by verify_fsroot_dir() by verify_xbootldr() by find_xbootldr_and_warn() if statx($presumed-XBOOTLDR).stx_dev_major == 0 ("maybe a btrfs device") Every bootctl verb_install() runs find_xbootldr_and_warn(), by default with /boot If your /boot .stx_dev_major=0 but /not/ btrfs, bootctl install/update quietly exits 1 with no note so as to what exactly failed (debug also empty, and the strace isn't exactly clear since no syscall actually failed) This is the case on ZFS and the Debian filesystem layout: /boot/efi is the ESP, and everything else under / is ZFS: $ sudo env SYSTEMD_LOG_LEVEL=debug bootctl update Found cgroup2 on /sys/fs/cgroup/, full unified hierarchy Found container virtualization none. File system "/boot" is not a FAT EFI System Partition (ESP) file system. Using EFI System Partition at /boot/efi. Checking whether /boot/efi/EFI/systemd/ contains any files… $ echo $? 1 and funnier still: $ sudo bootctl update --graceful $ echo $? 1 Which is great, and also breaks postinst, which runs precisely the latter, with no feedback at all By checking for -ENOTTY we accept that the path being investigated "is not it" if it's on ZFS (and any other filesystem that returns .stx_dev_major == 0 but isn't btrfs)
* 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.
* blkid-util: define enum for blkid_do_safeprobe() return valuesLennart Poettering2022-12-011-4/+6
| | | | | | libblkid really should define an enum for this on its own, but it currently doesn't and returns literal numeric values. Lets make this more readable by adding our own symbolic names via an enum.
* tree-wide: use errno_or_else() more, instead of homegrown checksLennart Poettering2022-12-011-4/+4
|
* Revert "find-esp: Relax filesystem root directory check"Daan De Meyer2022-11-231-30/+31
| | | | | | | This reverts commit d91a5f6481d35e28148fe46bc490bb4f34656947. This is the wrong approach as we don't detect the UUID and devid of valid ESP/XBOOTLDR partitions.
* find-esp: Relax filesystem root directory checkDaan De Meyer2022-11-231-31/+30
| | | | | | | | | When relaxed checks are requested, let's not require the efi/xbootldr directory to be the root of the filesystem. When building images, image builders might install all efi/xbootldr files to a regular directory first before packing them up into a partition. To allow bootctl to be used in such scenarios to install systemd-boot, we need to relax the fsroot check.
* find-esp: include device sysname in the log messageYu Watanabe2022-11-131-24/+28
|
* find-esp: downgrade and ignore error on retrieving PART_ENTRY_SCHEME when ↵Yu Watanabe2022-11-131-4/+10
| | | | | | searching Fixes #25332.
* 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.
* | find-esp: when searching, don't trip over inodes we expect to be dirs to be ↵Lennart Poettering2022-09-201-3/+3
| | | | | | | | something else, just continue searching
* | find-esp: rework verify_fsroot_dir() around statx()Lennart Poettering2022-09-201-49/+93
|/ | | | | | | | | | | | | | | Let's rework verify_fsroot_dir() around two statx() calls, which should usually give us all information we need. Let's then add a call to the btrfs ioctl only if the caller actually wants to know the backing block device (which it generally only wants if it then intends to verify partition type, and similar). This makes things more robust on new kernels, and bypasses the btrfs ioctls in environments where we cannot actually interpret the results properly (since they reference btrfs devices via /dev/ paths, which we likely cannot resolve in containers) Fixes: #24616
* Merge pull request #24536 from yuwata/dissect-take-loop-deviceYu Watanabe2022-09-021-2/+2
|\ | | | | dissect-image: introduce dissect_loop_device() which takes LoopDevice object
| * sd-device: rename devpath_from_devnum() -> devname_from_devnum()Yu Watanabe2022-09-021-2/+2
| | | | | | | | | | | | | | | | In sd-device, `devpath` is a kind of syspath without '/sys' prefix, e.g. /devices/pci0000:00/0000:00:1c.4/0000:3c:00.0/nvme/nvme0/nvme0n1, and `devname` is a path to the device node, e.g. /dev/nvme0n1. Let's use the consistent name for the helper function.
* | find-esp: call the right functionLennart Poettering2022-09-021-1/+1
|/ | | | We want the parent dir here, let's fix that.
* tree-wide: use devpath_from_devnum() and device_open_from_devnum()Yu Watanabe2022-08-281-18/+15
| | | | Fixes #24465.
* tree-wide: port things dirname_malloc() → path_extract_directory()Lennart Poettering2022-08-231-3/+3
|
* boot: a couple of tweaks recommended by CoccinelleFrantisek Sumsal2022-07-251-6/+6
|
* bootctl: add --root and --imageLuca Boccassi2022-07-081-43/+92
| | | | Operate on image/directory, and also take files to install from it
* sd-id128: rename and export sd_id128_string_equal()Zbigniew Jędrzejewski-Szmek2022-06-301-5/+5
| | | | | | | | We find this function useful in our code, so no reason not to export it. I changed the order of last two words in the name to match the arguments. (With "equal_string" I expected sd_id128_t first, string second, but in actual use, the second argument is usually a long constant so it's nice to keep this order of arguments.)
* esp: fix typoYu Watanabe2022-05-301-1/+1
| | | | Follow-up for 13d7c841a24f784995a000230706f259c4baec96.
* shared/find-esp: enhance loggingZbigniew Jędrzejewski-Szmek2022-05-261-38/+49
| | | | | | | If something doesn't match, let's print the non-matching value. If we can't query something, say what. And make the messages in the udev and blkid paths different, so we tell which approach failed from a log.
* shared/find-esp: fix inverted check for XBOOTLDR typeZbigniew Jędrzejewski-Szmek2022-05-261-1/+5
|
* basic: split out dev_t related calls into new devno-util.[ch]Lennart Poettering2022-04-131-0/+2
| | | | | | | | | | | | | | No actual code changes, just splitting out of some dev_t handling related calls from stat-util.[ch], they are quite a number already, and deserve their own module now I think. Also, try to settle on the name "devnum" as the name for the concept, instead of "devno" or "dev" or "devid". "devnum" is the name exported in udev APIs, hence probably best to stick to that. (this just renames a few symbols to "devum", local variables are left untouched, to make the patch not too invasive) No actual code changes.
* strv: declare iterator of FOREACH_STRING() in the loopZbigniew Jędrzejewski-Szmek2022-03-231-1/+2
| | | | | | | | | | | Same idea as 03677889f0ef42cdc534bf3b31265a054b20a354. No functional change intended. The type of the iterator is generally changed to be 'const char*' instead of 'char*'. Despite the type commonly used, modifying the string was not allowed. I adjusted the naming of some short variables for clarity and reduced the scope of some variable declarations in code that was being touched anyway.
* shared: split out ESP/XBOOTLDR search stuff from bootspec.cLennart Poettering2022-03-181-0/+709
The code is quite different from the rest of bootspec.c, with different deps and stuff. There's even a /***/ line to separate the two parts. Given how large the file already is, let#s just split it into two. No code changes, just some splitting out.