]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/path-lookup.h
92083af5f5257b42c41ff4e0632d8ef4fa665af4
[thirdparty/systemd.git] / src / shared / path-lookup.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 /***
5 Copyright 2010 Lennart Poettering
6 ***/
7
8 #include <stdbool.h>
9
10 typedef struct LookupPaths LookupPaths;
11
12 #include "install.h"
13 #include "macro.h"
14
15 typedef enum LookupPathsFlags {
16 LOOKUP_PATHS_EXCLUDE_GENERATED = 1 << 0,
17 LOOKUP_PATHS_TEMPORARY_GENERATED = 1 << 1,
18 LOOKUP_PATHS_SPLIT_USR = 1 << 2,
19 } LookupPathsFlags;
20
21 struct LookupPaths {
22 /* Where we look for unit files. This includes the individual special paths below, but also any vendor
23 * supplied, static unit file paths. */
24 char **search_path;
25
26 /* Where we shall create or remove our installation symlinks, aka "configuration", and where the user/admin
27 * shall place his own unit files. */
28 char *persistent_config;
29 char *runtime_config;
30
31 /* Where to place generated unit files (i.e. those a "generator" tool generated). Note the special semantics of
32 * this directory: the generators are flushed each time a "systemctl daemon-reload" is issued. The user should
33 * not alter these directories directly. */
34 char *generator;
35 char *generator_early;
36 char *generator_late;
37
38 /* Where to place transient unit files (i.e. those created dynamically via the bus API). Note the special
39 * semantics of this directory: all units created transiently have their unit files removed as the transient
40 * unit is unloaded. The user should not alter this directory directly. */
41 char *transient;
42
43 /* Where the snippets created by "systemctl set-property" are placed. Note that for transient units, the
44 * snippets are placed in the transient directory though (see above). The user should not alter this directory
45 * directly. */
46 char *persistent_control;
47 char *runtime_control;
48
49 /* The root directory prepended to all items above, or NULL */
50 char *root_dir;
51
52 /* A temporary directory when running in test mode, to be nuked */
53 char *temporary_dir;
54 };
55
56 int lookup_paths_init(LookupPaths *p, UnitFileScope scope, LookupPathsFlags flags, const char *root_dir);
57 int xdg_user_dirs(char ***ret_config_dirs, char ***ret_data_dirs);
58 int xdg_user_runtime_dir(char **ret, const char *suffix);
59 int xdg_user_config_dir(char **ret, const char *suffix);
60 int xdg_user_data_dir(char **ret, const char *suffix);
61 bool path_is_user_data_dir(const char *path);
62 bool path_is_user_config_dir(const char *path);
63
64 int lookup_paths_reduce(LookupPaths *p);
65
66 int lookup_paths_mkdir_generator(LookupPaths *p);
67 void lookup_paths_trim_generator(LookupPaths *p);
68 void lookup_paths_flush_generator(LookupPaths *p);
69
70 void lookup_paths_free(LookupPaths *p);
71
72 char **generator_binary_paths(UnitFileScope scope);