diff options
author | Mike Yuan <me@yhndnzj.com> | 2023-07-29 14:05:58 +0200 |
---|---|---|
committer | Mike Yuan <me@yhndnzj.com> | 2023-07-29 14:06:41 +0200 |
commit | 7893a547ebcee007dbc6119373d3e5d809f221fe (patch) | |
tree | 3d80d35555f6da8406700de1e1934b9aac4aca8b | |
parent | fstab-util: add fstab_has_node (diff) | |
download | systemd-7893a547ebcee007dbc6119373d3e5d809f221fe.tar.xz systemd-7893a547ebcee007dbc6119373d3e5d809f221fe.zip |
gpt-auto: don't mount ESP if there's an fstab entry for it
Follow-up for #28511
Fixes #28550
-rw-r--r-- | src/gpt-auto-generator/gpt-auto-generator.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c index 4465038198..585aaae2ed 100644 --- a/src/gpt-auto-generator/gpt-auto-generator.c +++ b/src/gpt-auto-generator/gpt-auto-generator.c @@ -574,10 +574,17 @@ static int add_partition_esp(DissectedPartition *p, bool has_xbootldr) { return 0; } + /* Check if there's an existing fstab entry for ESP. If so, we just skip the gpt-auto logic. */ + r = fstab_has_node(p->node); + if (r < 0) + return log_error_errno(r, + "Failed to check if fstab entry for device '%s' exists: %m", p->node); + if (r > 0) + return 0; + /* If /boot/ is present, unused, and empty, we'll take that. * Otherwise, if /efi/ is unused and empty (or missing), we'll take that. - * Otherwise, we do nothing. - */ + * Otherwise, we do nothing. */ if (!has_xbootldr && slash_boot_exists()) { r = slash_boot_in_fstab(); if (r < 0) @@ -590,16 +597,6 @@ static int add_partition_esp(DissectedPartition *p, bool has_xbootldr) { esp_path = "/boot"; id = "boot"; } - } else { - /* Check if the fstab entry for /boot/ is already the ESP. If so, we don't need to - * check /efi/ or duplicate the mount there. */ - r = fstab_is_mount_point_full("/boot", p->node); - if (r < 0) - return log_error_errno(r, - "Failed to check if fstab entry for /boot uses the same device as '%s': %m", - p->node); - if (r > 0) - return 0; } } |