udev: String substitutions can be done in ENV, too
[systemd_ALT.git] / src / basic / path-lookup.h
blob6d6163fb9d70c2d203835864e61464eb640ea841
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
4 #include <stdbool.h>
6 #include "constants.h"
7 #include "macro.h"
8 #include "runtime-scope.h"
10 typedef enum LookupPathsFlags {
11 LOOKUP_PATHS_EXCLUDE_GENERATED = 1 << 0,
12 LOOKUP_PATHS_TEMPORARY_GENERATED = 1 << 1,
13 LOOKUP_PATHS_SPLIT_USR = 1 << 2,
14 } LookupPathsFlags;
16 typedef struct LookupPaths {
17 /* Where we look for unit files. This includes the individual special paths below, but also any vendor
18 * supplied, static unit file paths. */
19 char **search_path;
21 /* Where we shall create or remove our installation symlinks, aka "configuration", and where the user/admin
22 * shall place their own unit files. */
23 char *persistent_config;
24 char *runtime_config;
26 /* Where units from a portable service image shall be placed. */
27 char *persistent_attached;
28 char *runtime_attached;
30 /* Where to place generated unit files (i.e. those a "generator" tool generated). Note the special semantics of
31 * this directory: the generators are flushed each time a "systemctl daemon-reload" is issued. The user should
32 * not alter these directories directly. */
33 char *generator;
34 char *generator_early;
35 char *generator_late;
37 /* Where to place transient unit files (i.e. those created dynamically via the bus API). Note the special
38 * semantics of this directory: all units created transiently have their unit files removed as the transient
39 * unit is unloaded. The user should not alter this directory directly. */
40 char *transient;
42 /* Where the snippets created by "systemctl set-property" are placed. Note that for transient units, the
43 * snippets are placed in the transient directory though (see above). The user should not alter this directory
44 * directly. */
45 char *persistent_control;
46 char *runtime_control;
48 /* The root directory prepended to all items above, or NULL */
49 char *root_dir;
51 /* A temporary directory when running in test mode, to be nuked */
52 char *temporary_dir;
53 } LookupPaths;
55 int lookup_paths_init(LookupPaths *lp, RuntimeScope scope, LookupPathsFlags flags, const char *root_dir);
56 int lookup_paths_init_or_warn(LookupPaths *lp, RuntimeScope scope, LookupPathsFlags flags, const char *root_dir);
58 int xdg_user_dirs(char ***ret_config_dirs, char ***ret_data_dirs);
59 int xdg_user_runtime_dir(char **ret, const char *suffix);
60 int xdg_user_config_dir(char **ret, const char *suffix);
61 int xdg_user_data_dir(char **ret, const char *suffix);
63 bool path_is_user_data_dir(const char *path);
64 bool path_is_user_config_dir(const char *path);
66 void lookup_paths_log(LookupPaths *p);
67 void lookup_paths_free(LookupPaths *p);
69 char **generator_binary_paths(RuntimeScope scope);
70 char **env_generator_binary_paths(RuntimeScope scope);
72 #define NETWORK_DIRS ((const char* const*) CONF_PATHS_STRV("systemd/network"))
73 #define NETWORK_DIRS_NULSTR CONF_PATHS_NULSTR("systemd/network")
75 #define PORTABLE_PROFILE_DIRS CONF_PATHS_NULSTR("systemd/portable/profile")
76 int find_portable_profile(const char *name, const char *unit, char **ret_path);