gpt-auto: don't mount ESP if there's an fstab entry for it

Follow-up for #28511

Fixes #28550
This commit is contained in:
Mike Yuan
2023-07-29 20:06:41 +08:00
parent 24c0078a84
commit 7893a547eb
+9 -12
View File
@@ -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;
}
}