summaryrefslogtreecommitdiffstats
path: root/src/gpt-auto-generator
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2022-02-14 13:35:27 +0100
committerLennart Poettering <lennart@poettering.net>2022-02-14 13:40:59 +0100
commitd5cb053cd93d516f516e0b748271b55f9dfb3a29 (patch)
treeb1fa6a5710bf38157770c3d5642346d927685676 /src/gpt-auto-generator
parentsd-device: refuse opening device mit major/minor of zero early (diff)
downloadsystemd-d5cb053cd93d516f516e0b748271b55f9dfb3a29.tar.xz
systemd-d5cb053cd93d516f516e0b748271b55f9dfb3a29.zip
gpt-auto: properly handle case where we can't determine devno of /usr/ fs
get_block_device_harder() returns == 0 if the fs is valid, but it is not backed by a single devno. (As opposed to returning > 0 if the devno is valid). Let's catch this case and log a clear message, and don't bother open the device in that case. This is mostly cosmetical, as either way, systemd-gpt-auto-generator doesn't work in scenarios like that. Prompted-by: #22504
Diffstat (limited to 'src/gpt-auto-generator')
-rw-r--r--src/gpt-auto-generator/gpt-auto-generator.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c
index 64ca9bb2f9..28982a4c34 100644
--- a/src/gpt-auto-generator/gpt-auto-generator.c
+++ b/src/gpt-auto-generator/gpt-auto-generator.c
@@ -779,12 +779,16 @@ static int add_mounts(void) {
return btrfs_log_dev_root(LOG_ERR, r, "root file system");
if (r < 0)
return log_error_errno(r, "Failed to determine block device of root file system: %m");
- if (r == 0) { /* Not backed by block device */
+ if (r == 0) { /* Not backed by a single block device. (Could be NFS or so, or could be multi-device RAID or so) */
r = get_block_device_harder("/usr", &devno);
if (r == -EUCLEAN)
return btrfs_log_dev_root(LOG_ERR, r, "/usr");
if (r < 0)
- return log_error_errno(r, "Failed to determine block device of /usr file system: %m");
+ return log_error_errno(r, "Failed to determine block device of /usr/ file system: %m");
+ if (r == 0) { /* /usr/ not backed by single block device, either. */
+ log_debug("Neither root nor /usr/ file system are on a (single) block device.");
+ return 0;
+ }
}
} else if (r < 0)
return log_error_errno(r, "Failed to read symlink /run/systemd/volatile-root: %m");