summaryrefslogtreecommitdiffstats
path: root/src/gpt-auto-generator
diff options
context:
space:
mode:
authorMike Yuan <me@yhndnzj.com>2024-02-12 12:12:17 +0100
committerGitHub <noreply@github.com>2024-02-12 12:12:17 +0100
commit4d0b06d5353988b90b8859fc745f1edf032cc894 (patch)
treef2295126e6c292dae5e08465653698fd41536b24 /src/gpt-auto-generator
parentMerge pull request #30209 from yuwata/sd-journal-reduce-fstat (diff)
parentNEWS: gpt-auto-generator will become more defensive with ESP and XBOOTLDR (diff)
downloadsystemd-4d0b06d5353988b90b8859fc745f1edf032cc894.tar.xz
systemd-4d0b06d5353988b90b8859fc745f1edf032cc894.zip
Merge pull request #31181 from fbuihuu/gpt-auto-more-defensive
gpt-auto-generator: be more defensive when checking the presence of E…
Diffstat (limited to 'src/gpt-auto-generator')
-rw-r--r--src/gpt-auto-generator/gpt-auto-generator.c61
1 files changed, 15 insertions, 46 deletions
diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c
index d23999ed93..1fd687108a 100644
--- a/src/gpt-auto-generator/gpt-auto-generator.c
+++ b/src/gpt-auto-generator/gpt-auto-generator.c
@@ -463,18 +463,6 @@ static int add_automount(
return generator_add_symlink(arg_dest, SPECIAL_LOCAL_FS_TARGET, "wants", unit);
}
-static int slash_boot_in_fstab(void) {
- static int cache = -1;
-
- if (cache >= 0)
- return cache;
-
- cache = fstab_is_mount_point("/boot");
- if (cache < 0)
- return log_error_errno(cache, "Failed to parse fstab: %m");
- return cache;
-}
-
static int add_partition_xbootldr(DissectedPartition *p) {
_cleanup_free_ char *options = NULL;
int r;
@@ -486,14 +474,6 @@ static int add_partition_xbootldr(DissectedPartition *p) {
return 0;
}
- r = slash_boot_in_fstab();
- if (r < 0)
- return r;
- if (r > 0) {
- log_debug("/boot/ specified in fstab, ignoring XBOOTLDR partition.");
- return 0;
- }
-
r = path_is_busy("/boot");
if (r < 0)
return r;
@@ -523,18 +503,6 @@ static int add_partition_xbootldr(DissectedPartition *p) {
}
#if ENABLE_EFI
-static int slash_efi_in_fstab(void) {
- static int cache = -1;
-
- if (cache >= 0)
- return cache;
-
- cache = fstab_is_mount_point("/efi");
- if (cache < 0)
- return log_error_errno(cache, "Failed to parse fstab: %m");
- return cache;
-}
-
static bool slash_boot_exists(void) {
static int cache = -1;
@@ -574,27 +542,16 @@ static int add_partition_esp(DissectedPartition *p, bool has_xbootldr) {
* Otherwise, if /efi/ is unused and empty (or missing), we'll take that.
* Otherwise, we do nothing. */
if (!has_xbootldr && slash_boot_exists()) {
- r = slash_boot_in_fstab();
+ r = path_is_busy("/boot");
if (r < 0)
return r;
if (r == 0) {
- r = path_is_busy("/boot");
- if (r < 0)
- return r;
- if (r == 0) {
- esp_path = "/boot";
- id = "boot";
- }
+ esp_path = "/boot";
+ id = "boot";
}
}
if (!esp_path) {
- r = slash_efi_in_fstab();
- if (r < 0)
- return r;
- if (r > 0)
- return 0;
-
r = path_is_busy("/efi");
if (r < 0)
return r;
@@ -781,6 +738,18 @@ static int process_loader_partitions(DissectedPartition *esp, DissectedPartition
assert(esp);
assert(xbootldr);
+ /* If any paths in fstab look similar to our favorite paths for ESP or XBOOTLDR, we just exit
+ * early. We also don't bother with cases where one is configured explicitly and the other shall be
+ * mounted automatically. */
+
+ r = fstab_has_mount_point_prefix_strv(STRV_MAKE("/boot", "/efi"));
+ if (r > 0) {
+ log_debug("Found mount entries in the /boot/ or /efi/ hierarchies in fstab, not generating ESP or XBOOTLDR mounts.");
+ return 0;
+ }
+ if (r < 0)
+ log_debug_errno(r, "Failed to check fstab existing paths, ignoring: %m");
+
if (!is_efi_boot()) {
log_debug("Not an EFI boot, skipping loader partition UUID check.");
goto mount;