Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gpt-auto-generator: correctly handle the return value of function slash_boot_in_fstab() #28652

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 3 additions & 8 deletions src/gpt-auto-generator/gpt-auto-generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -586,17 +586,12 @@ 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");
Copy link
Member

@YHNdnzj YHNdnzj Aug 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong. If the ESP already has an entry in fstab, fstab_has_node above should handle it. If not, we should only use /boot/ when it's not specified in fstab, and fallback to /efi/ otherwise. You're just overmounting /boot/ if it's empty, regardless of already listed in fstab or not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that although path_is_busy checks whether the path is already a mountpoint, no mount unit will have been started by the time the generator does its initial run, i.e. during systemd startup. So we need to check fstab explicitly.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the fstab on my system:

UUID=93fe18d5-1331-4d58-b6a5-fceb1d130300	/         	ext4      	rw,relatime	0 1
UUID=1DAD-F136      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2 

Does this mean that fstab_has_node is not as expected?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> #28690

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";
}
}

Expand Down