find-esp: make use of XAT_FDROOT

This commit is contained in:
Lennart Poettering
2026-01-17 12:37:39 +01:00
parent 7e64b58f4c
commit 80499cf1c8
+19 -11
View File
@@ -332,7 +332,7 @@ static int verify_esp(
dev_t devid = 0;
int r;
assert(rfd >= 0 || rfd == AT_FDCWD);
assert(rfd >= 0 || IN_SET(rfd, AT_FDCWD, XAT_FDROOT));
assert(path);
/* This logs about all errors, except:
@@ -442,14 +442,14 @@ int find_esp_and_warn_at(
VerifyESPFlags flags;
int r;
assert(rfd >= 0 || IN_SET(rfd, AT_FDCWD, XAT_FDROOT));
/* This logs about all errors except:
*
* -ENOKEY → when we can't find the partition
* -EACCESS → when unprivileged_mode is true, and we can't access something
*/
assert(rfd >= 0 || rfd == AT_FDCWD);
flags = verify_esp_flags_init(unprivileged_mode, "SYSTEMD_RELAX_ESP_CHECKS");
if (path)
@@ -527,9 +527,13 @@ int find_esp_and_warn(
dev_t devid;
int r;
rfd = open(empty_to_root(root), O_PATH|O_DIRECTORY|O_CLOEXEC);
if (rfd < 0)
return -errno;
if (empty_or_root(root))
rfd = XAT_FDROOT;
else {
rfd = open(root, O_PATH|O_DIRECTORY|O_CLOEXEC);
if (rfd < 0)
return -errno;
}
r = find_esp_and_warn_at(
rfd,
@@ -737,7 +741,7 @@ static int verify_xbootldr(
dev_t devid = 0;
int r;
assert(rfd >= 0 || rfd == AT_FDCWD);
assert(rfd >= 0 || IN_SET(rfd, AT_FDCWD, XAT_FDROOT));
assert(path);
r = chaseat(rfd, path, CHASE_AT_RESOLVE_IN_ROOT|CHASE_PARENT|CHASE_TRIGGER_AUTOFS, &p, &pfd);
@@ -800,7 +804,7 @@ int find_xbootldr_and_warn_at(
/* Similar to find_esp_and_warn(), but finds the XBOOTLDR partition. Returns the same errors. */
assert(rfd >= 0 || rfd == AT_FDCWD);
assert(rfd >= 0 || IN_SET(rfd, AT_FDCWD, XAT_FDROOT));
flags = verify_esp_flags_init(unprivileged_mode, "SYSTEMD_RELAX_XBOOTLDR_CHECKS");
@@ -862,9 +866,13 @@ int find_xbootldr_and_warn(
dev_t devid;
int r;
rfd = open(empty_to_root(root), O_PATH|O_DIRECTORY|O_CLOEXEC);
if (rfd < 0)
return -errno;
if (empty_or_root(root))
rfd = XAT_FDROOT;
else {
rfd = open(root, O_PATH|O_DIRECTORY|O_CLOEXEC);
if (rfd < 0)
return -errno;
}
r = find_xbootldr_and_warn_at(
rfd,