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