diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 03:50:40 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 03:50:40 +0000 |
commit | fc53809803cd2bc2434e312b19a18fa36776da12 (patch) | |
tree | b4b43bd6538f51965ce32856e9c053d0f90919c8 /src/shared/vpick.h | |
parent | Adding upstream version 255.5. (diff) | |
download | systemd-fc53809803cd2bc2434e312b19a18fa36776da12.tar.xz systemd-fc53809803cd2bc2434e312b19a18fa36776da12.zip |
Adding upstream version 256.upstream/256
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/shared/vpick.h')
-rw-r--r-- | src/shared/vpick.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/shared/vpick.h b/src/shared/vpick.h new file mode 100644 index 0000000..38251c8 --- /dev/null +++ b/src/shared/vpick.h @@ -0,0 +1,61 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +#pragma once + +#include <sys/types.h> + +#include "architecture.h" + +typedef enum PickFlags { + PICK_ARCHITECTURE = 1 << 0, /* Look for an architecture suffix */ + PICK_TRIES = 1 << 1, /* Look for tries left/tries done counters */ + PICK_RESOLVE = 1 << 2, /* Return the fully resolved (chased) path, rather than the path to the entry */ +} PickFlags; + +typedef struct PickFilter { + uint32_t type_mask; /* A mask of 1U << DT_REG, 1U << DT_DIR, … */ + const char *basename; /* Can be overridden by search pattern */ + const char *version; + Architecture architecture; + char * const *suffix; /* Can be overridden by search pattern */ +} PickFilter; + +typedef struct PickResult { + char *path; + int fd; /* O_PATH */ + struct stat st; + char *version; + Architecture architecture; + unsigned tries_left; + unsigned tries_done; +} PickResult; + +#define PICK_RESULT_NULL \ + (const PickResult) { \ + .fd = -EBADF, \ + .st.st_mode = MODE_INVALID, \ + .architecture = _ARCHITECTURE_INVALID, \ + .tries_left = UINT_MAX, \ + .tries_done = UINT_MAX, \ + } + +#define TAKE_PICK_RESULT(pick) TAKE_GENERIC(pick, PickResult, PICK_RESULT_NULL) + +void pick_result_done(PickResult *p); + +int path_pick( + const char *toplevel_path, + int toplevel_fd, + const char *path, + const PickFilter *filter, + PickFlags flags, + PickResult *ret); + +int path_pick_update_warn( + char **path, + const PickFilter *filter, + PickFlags flags, + PickResult *ret); + +extern const PickFilter pick_filter_image_raw; +extern const PickFilter pick_filter_image_dir; +extern const PickFilter pick_filter_image_any; |