chiark / gitweb /
Prep v225: Added needed udev support and re-enabled some masked cgroup functions.
[elogind.git] / src / shared / install.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 #pragma once
4
5 /***
6   This file is part of systemd.
7
8   Copyright 2011 Lennart Poettering
9
10   systemd is free software; you can redistribute it and/or modify it
11   under the terms of the GNU Lesser General Public License as published by
12   the Free Software Foundation; either version 2.1 of the License, or
13   (at your option) any later version.
14
15   systemd is distributed in the hope that it will be useful, but
16   WITHOUT ANY WARRANTY; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18   Lesser General Public License for more details.
19
20   You should have received a copy of the GNU Lesser General Public License
21   along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 ***/
23
24 typedef enum UnitFileScope UnitFileScope;
25 typedef enum UnitFileState UnitFileState;
26 typedef enum UnitFilePresetMode UnitFilePresetMode;
27 typedef enum UnitFileChangeType UnitFileChangeType;
28 typedef struct UnitFileChange UnitFileChange;
29 typedef struct UnitFileList UnitFileList;
30 typedef struct UnitFileInstallInfo UnitFileInstallInfo;
31
32 #include "hashmap.h"
33 #include "unit-name.h"
34 #include "path-lookup.h"
35
36 enum UnitFileScope {
37         UNIT_FILE_SYSTEM,
38         UNIT_FILE_GLOBAL,
39         UNIT_FILE_USER,
40         _UNIT_FILE_SCOPE_MAX,
41         _UNIT_FILE_SCOPE_INVALID = -1
42 };
43
44 enum UnitFileState {
45         UNIT_FILE_ENABLED,
46         UNIT_FILE_ENABLED_RUNTIME,
47         UNIT_FILE_LINKED,
48         UNIT_FILE_LINKED_RUNTIME,
49         UNIT_FILE_MASKED,
50         UNIT_FILE_MASKED_RUNTIME,
51         UNIT_FILE_STATIC,
52         UNIT_FILE_DISABLED,
53         UNIT_FILE_INDIRECT,
54         UNIT_FILE_INVALID,
55         _UNIT_FILE_STATE_MAX,
56         _UNIT_FILE_STATE_INVALID = -1
57 };
58
59 enum UnitFilePresetMode {
60         UNIT_FILE_PRESET_FULL,
61         UNIT_FILE_PRESET_ENABLE_ONLY,
62         UNIT_FILE_PRESET_DISABLE_ONLY,
63         _UNIT_FILE_PRESET_MAX,
64         _UNIT_FILE_PRESET_INVALID = -1
65 };
66
67 enum UnitFileChangeType {
68         UNIT_FILE_SYMLINK,
69         UNIT_FILE_UNLINK,
70         _UNIT_FILE_CHANGE_TYPE_MAX,
71         _UNIT_FILE_CHANGE_TYPE_INVALID = -1
72 };
73
74 struct UnitFileChange {
75         UnitFileChangeType type;
76         char *path;
77         char *source;
78 };
79
80 struct UnitFileList {
81         char *path;
82         UnitFileState state;
83 };
84
85 struct UnitFileInstallInfo {
86         char *name;
87         char *path;
88         char *user;
89
90         char **aliases;
91         char **wanted_by;
92         char **required_by;
93         char **also;
94
95         char *default_instance;
96 };
97
98 int unit_file_enable(UnitFileScope scope, bool runtime, const char *root_dir, char **files, bool force, UnitFileChange **changes, unsigned *n_changes);
99 int unit_file_disable(UnitFileScope scope, bool runtime, const char *root_dir, char **files, UnitFileChange **changes, unsigned *n_changes);
100 int unit_file_reenable(UnitFileScope scope, bool runtime, const char *root_dir, char **files, bool force, UnitFileChange **changes, unsigned *n_changes);
101 int unit_file_link(UnitFileScope scope, bool runtime, const char *root_dir, char **files, bool force, UnitFileChange **changes, unsigned *n_changes);
102 int unit_file_preset(UnitFileScope scope, bool runtime, const char *root_dir, char **files, UnitFilePresetMode mode, bool force, UnitFileChange **changes, unsigned *n_changes);
103 int unit_file_preset_all(UnitFileScope scope, bool runtime, const char *root_dir, UnitFilePresetMode mode, bool force, UnitFileChange **changes, unsigned *n_changes);
104 int unit_file_mask(UnitFileScope scope, bool runtime, const char *root_dir, char **files, bool force, UnitFileChange **changes, unsigned *n_changes);
105 int unit_file_unmask(UnitFileScope scope, bool runtime, const char *root_dir, char **files, UnitFileChange **changes, unsigned *n_changes);
106 int unit_file_set_default(UnitFileScope scope, const char *root_dir, const char *file, bool force, UnitFileChange **changes, unsigned *n_changes);
107 int unit_file_get_default(UnitFileScope scope, const char *root_dir, char **name);
108 int unit_file_add_dependency(UnitFileScope scope, bool runtime, const char *root_dir, char **files, char *target, UnitDependency dep, bool force, UnitFileChange **changes, unsigned *n_changes);
109
110 UnitFileState unit_file_lookup_state(
111                 UnitFileScope scope,
112                 const char *root_dir,
113                 const LookupPaths *paths,
114                 const char *name);
115 UnitFileState unit_file_get_state(
116                 UnitFileScope scope,
117                 const char *root_dir,
118                 const char *filename);
119
120 int unit_file_get_list(UnitFileScope scope, const char *root_dir, Hashmap *h);
121
122 void unit_file_list_free(Hashmap *h);
123 int unit_file_changes_add(UnitFileChange **changes, unsigned *n_changes, UnitFileChangeType type, const char *path, const char *source);
124 void unit_file_changes_free(UnitFileChange *changes, unsigned n_changes);
125
126 int unit_file_query_preset(UnitFileScope scope, const char *root_dir, const char *name);
127
128 const char *unit_file_state_to_string(UnitFileState s) _const_;
129 UnitFileState unit_file_state_from_string(const char *s) _pure_;
130
131 const char *unit_file_change_type_to_string(UnitFileChangeType s) _const_;
132 UnitFileChangeType unit_file_change_type_from_string(const char *s) _pure_;
133
134 const char *unit_file_preset_mode_to_string(UnitFilePresetMode m) _const_;
135 UnitFilePresetMode unit_file_preset_mode_from_string(const char *s) _pure_;