From: Lennart Poettering Date: Mon, 8 Dec 2025 12:33:20 +0000 (+0100) Subject: find-esp: make use of XAT_FDROOT X-Git-Tag: v260-rc1~371^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=80499cf1c85326abab59bd5f7920cc27d562730d;p=thirdparty%2Fsystemd.git find-esp: make use of XAT_FDROOT --- diff --git a/src/shared/find-esp.c b/src/shared/find-esp.c index 8e1737eebb9..cf4eddbbfa6 100644 --- a/src/shared/find-esp.c +++ b/src/shared/find-esp.c @@ -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,