if (!strv_isempty(arg_path))
return 0;
- r = find_esp_and_warn(NULL, NULL, /* unprivileged_mode= */ false, &esp_path, NULL, NULL, NULL, NULL, &esp_devid);
+ r = find_esp_and_warn_full(
+ /* root= */ NULL,
+ /* path= */ NULL,
+ /* unprivileged_mode= */ false,
+ &esp_path,
+ /* ret_part= */ NULL,
+ /* ret_pstart= */ NULL,
+ /* ret_psize= */ NULL,
+ /* ret_uuid= */ NULL,
+ &esp_devid);
if (r < 0 && r != -ENOKEY) /* ENOKEY means not found, and is the only error the function won't log about on its own */
return r;
- r = find_xbootldr_and_warn(NULL, NULL, /* unprivileged_mode= */ false, &xbootldr_path, NULL, &xbootldr_devid);
+ r = find_xbootldr_and_warn_full(
+ /* root= */ NULL,
+ /* path= */ NULL,
+ /* unprivileged_mode= */ false,
+ &xbootldr_path,
+ /* ret_uuid= */ NULL,
+ &xbootldr_devid);
if (r < 0 && r != -ENOKEY)
return r;
if (p.context.entry_token_type < 0)
p.context.entry_token_type = BOOT_ENTRY_TOKEN_AUTO;
- r = find_esp_and_warn_at(
+ r = find_esp_and_warn_at_full(
p.context.root_fd,
/* path= */ NULL,
/* unprivileged_mode= */ false,
p.context.root_fd,
/* path= */ NULL,
/* unprivileged_mode= */ false,
- &p.context.xbootldr_path,
- /* ret_uuid= */ NULL,
- /* ret_devid= */ NULL);
+ &p.context.xbootldr_path);
if (r == -ENOKEY)
log_debug_errno(r, "Didn't find an XBOOTLDR partition, using ESP as $BOOT.");
else if (r < 0)
int verb_random_seed(int argc, char *argv[], void *userdata) {
int r;
- r = find_esp_and_warn(arg_root, arg_esp_path, false, &arg_esp_path, NULL, NULL, NULL, NULL, NULL);
+ r = find_esp_and_warn(arg_root, arg_esp_path, /* unprivileged_mode= */ false, &arg_esp_path);
if (r == -ENOKEY) {
/* find_esp_and_warn() doesn't warn about ENOKEY, so let's do that on our own */
if (arg_graceful() == ARG_GRACEFUL_NO)
* we simply eat up the error here, so that --list and --status work too, without noise about
* this). */
- r = find_esp_and_warn(arg_root, arg_esp_path, unprivileged_mode, &np, ret_part, ret_pstart, ret_psize, ret_uuid, ret_devid);
+ r = find_esp_and_warn_full(arg_root, arg_esp_path, unprivileged_mode, &np, ret_part, ret_pstart, ret_psize, ret_uuid, ret_devid);
if (r == -ENOKEY) {
if (graceful)
return log_full_errno(arg_quiet ? LOG_DEBUG : LOG_INFO, r,
char *np;
int r;
- r = find_xbootldr_and_warn(arg_root, arg_xbootldr_path, unprivileged_mode, &np, ret_uuid, ret_devid);
+ r = find_xbootldr_and_warn_full(arg_root, arg_xbootldr_path, unprivileged_mode, &np, ret_uuid, ret_devid);
if (r == -ENOKEY || path_equal(np, arg_esp_path)) {
log_debug("Didn't find an XBOOTLDR partition, using the ESP as $BOOT.");
arg_xbootldr_path = mfree(arg_xbootldr_path);
/* rfd= */ c->rfd,
/* path= */ arg_xbootldr_path,
/* unprivileged_mode= */ -1,
- /* ret_path= */ &c->boot_root,
- /* ret_uuid= */ NULL,
- /* ret_devid= */ NULL);
+ /* ret_path= */ &c->boot_root);
if (r == -ENOKEY) {
log_debug_errno(r, "Couldn't find an XBOOTLDR partition.");
return 0;
/* rfd= */ c->rfd,
/* path= */ arg_esp_path,
/* unprivileged_mode= */ -1,
- /* ret_path= */ &c->boot_root,
- /* ret_part= */ NULL,
- /* ret_pstart= */ NULL,
- /* ret_psize= */ NULL,
- /* ret_uuid= */ NULL,
- /* ret_devid= */ NULL);
+ /* ret_path= */ &c->boot_root);
if (r == -ENOKEY) {
log_debug_errno(r, "Couldn't find EFI system partition, ignoring.");
return 0;
"Failed to determine whether /run/boot-loader-entries/ exists: %m");
}
- r = find_esp_and_warn(NULL, override_esp_path, /* unprivileged_mode= */ false, &esp_where, NULL, NULL, NULL, NULL, &esp_devid);
+ r = find_esp_and_warn_full(
+ /* root= */ NULL,
+ override_esp_path,
+ /* unprivileged_mode= */ false,
+ &esp_where,
+ /* ret_part= */ NULL,
+ /* ret_pstart= */ NULL,
+ /* ret_psize= */ NULL,
+ /* ret_uuid= */ NULL,
+ &esp_devid);
if (r < 0) /* we don't log about ENOKEY here, but propagate it, leaving it to the caller to log */
return r;
- r = find_xbootldr_and_warn(NULL, override_xbootldr_path, /* unprivileged_mode= */ false, &xbootldr_where, NULL, &xbootldr_devid);
+ r = find_xbootldr_and_warn_full(
+ /* root= */ NULL,
+ override_xbootldr_path,
+ /* unprivileged_mode= */ false,
+ &xbootldr_where,
+ /* ret_uuid= */ NULL,
+ &xbootldr_devid);
if (r < 0 && r != -ENOKEY)
return r; /* It's fine if the XBOOTLDR partition doesn't exist, hence we ignore ENOKEY here */
/* root= */ NULL,
/* path= */ NULL,
/* unprivileged_mode= */ false,
- &path,
- /* ret_uuid= */ NULL,
- /* ret_devid= */ NULL);
+ &path);
if (r < 0) {
if (r != -ENOKEY)
return log_error_errno(r, "Failed to find XBOOTLDR partition: %m");
/* root= */ NULL,
/* path= */ NULL,
/* unprivileged_mode= */ false,
- &path,
- /* ret_part= */ NULL,
- /* ret_pstart= */ NULL,
- /* ret_psize= */ NULL,
- /* ret_uuid= */ NULL,
- /* ret_devid= */ NULL);
+ &path);
if (r < 0) {
if (r != -ENOKEY)
return log_error_errno(r, "Failed to find ESP partition: %m");
return 0;
}
-int find_esp_and_warn_at(
+int find_esp_and_warn_at_full(
int rfd,
const char *path,
int unprivileged_mode,
return -ENOKEY;
}
-int find_esp_and_warn(
+int find_esp_and_warn_full(
const char *root,
const char *path,
int unprivileged_mode,
return -errno;
}
- r = find_esp_and_warn_at(
+ r = find_esp_and_warn_at_full(
rfd,
path,
unprivileged_mode,
return 0;
}
-int find_xbootldr_and_warn_at(
+int find_xbootldr_and_warn_at_full(
int rfd,
const char *path,
int unprivileged_mode,
return 0;
}
-int find_xbootldr_and_warn(
+int find_xbootldr_and_warn_full(
const char *root,
const char *path,
int unprivileged_mode,
return -errno;
}
- r = find_xbootldr_and_warn_at(
+ r = find_xbootldr_and_warn_at_full(
rfd,
path,
unprivileged_mode,
#include "shared-forward.h"
-int find_esp_and_warn_at(int rfd, const char *path, int unprivileged_mode, char **ret_path, uint32_t *ret_part, uint64_t *ret_pstart, uint64_t *ret_psize, sd_id128_t *ret_uuid, dev_t *ret_devid);
-int find_esp_and_warn(const char *root, const char *path, int unprivileged_mode, char **ret_path, uint32_t *ret_part, uint64_t *ret_pstart, uint64_t *ret_psize, sd_id128_t *ret_uuid, dev_t *ret_devid);
+int find_esp_and_warn_at_full(int rfd, const char *path, int unprivileged_mode, char **ret_path, uint32_t *ret_part, uint64_t *ret_pstart, uint64_t *ret_psize, sd_id128_t *ret_uuid, dev_t *ret_devid);
+int find_esp_and_warn_full(const char *root, const char *path, int unprivileged_mode, char **ret_path, uint32_t *ret_part, uint64_t *ret_pstart, uint64_t *ret_psize, sd_id128_t *ret_uuid, dev_t *ret_devid);
-int find_xbootldr_and_warn_at(int rfd, const char *path, int unprivileged_mode, char **ret_path, sd_id128_t *ret_uuid, dev_t *ret_devid);
-int find_xbootldr_and_warn(const char *root, const char *path, int unprivileged_mode, char **ret_path, sd_id128_t *ret_uuid, dev_t *ret_devid);
+static inline int find_esp_and_warn_at(int rfd, const char *path, int unprivileged_mode, char **ret_path) {
+ return find_esp_and_warn_at_full(rfd, path, unprivileged_mode, ret_path, NULL, NULL, NULL, NULL, NULL);
+}
+static inline int find_esp_and_warn(const char *root, const char *path, int unprivileged_mode, char **ret_path) {
+ return find_esp_and_warn_full(root, path, unprivileged_mode, ret_path, NULL, NULL, NULL, NULL, NULL);
+}
+
+int find_xbootldr_and_warn_at_full(int rfd, const char *path, int unprivileged_mode, char **ret_path, sd_id128_t *ret_uuid, dev_t *ret_devid);
+int find_xbootldr_and_warn_full(const char *root, const char *path, int unprivileged_mode, char **ret_path, sd_id128_t *ret_uuid, dev_t *ret_devid);
+
+static inline int find_xbootldr_and_warn_at(int rfd, const char *path, int unprivileged_mode, char **ret_path) {
+ return find_xbootldr_and_warn_at_full(rfd, path, unprivileged_mode, ret_path, NULL, NULL);
+}
+static inline int find_xbootldr_and_warn(const char *root, const char *path, int unprivileged_mode, char **ret_path) {
+ return find_xbootldr_and_warn_full(root, path, unprivileged_mode, ret_path, NULL, NULL);
+}
} else { /* boot, esp, or xbootldr */
r = 0;
if (IN_SET(rr->path_relative_to, PATH_RELATIVE_TO_BOOT, PATH_RELATIVE_TO_XBOOTLDR))
- r = find_xbootldr_and_warn(root, NULL, /* unprivileged_mode= */ -1, &relative_to, NULL, NULL);
+ r = find_xbootldr_and_warn(root, /* path= */ NULL, /* unprivileged_mode= */ -1, &relative_to);
if (r == -ENOKEY || rr->path_relative_to == PATH_RELATIVE_TO_ESP)
- r = find_esp_and_warn(root, NULL, -1, &relative_to, NULL, NULL, NULL, NULL, NULL);
+ r = find_esp_and_warn(root, /* path= */ NULL, /* unprivileged_mode= */ -1, &relative_to);
if (r < 0)
return log_error_errno(r, "Failed to resolve $BOOT: %m");
log_debug("Resolved $BOOT to '%s'", relative_to);