chiark / gitweb /
machined: beef up machined image listing with creation/modification times of subvolumes
[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 #include "hashmap.h"
25 #include "unit-name.h"
26
27 typedef enum UnitFileScope {
28         UNIT_FILE_SYSTEM,
29         UNIT_FILE_GLOBAL,
30         UNIT_FILE_USER,
31         _UNIT_FILE_SCOPE_MAX,
32         _UNIT_FILE_SCOPE_INVALID = -1
33 } UnitFileScope;
34
35 typedef enum UnitFileState {
36         UNIT_FILE_ENABLED,
37         UNIT_FILE_ENABLED_RUNTIME,
38         UNIT_FILE_LINKED,
39         UNIT_FILE_LINKED_RUNTIME,
40         UNIT_FILE_MASKED,
41         UNIT_FILE_MASKED_RUNTIME,
42         UNIT_FILE_STATIC,
43         UNIT_FILE_DISABLED,
44         UNIT_FILE_INDIRECT,
45         UNIT_FILE_INVALID,
46         _UNIT_FILE_STATE_MAX,
47         _UNIT_FILE_STATE_INVALID = -1
48 } UnitFileState;
49
50 typedef enum UnitFilePresetMode {
51         UNIT_FILE_PRESET_FULL,
52         UNIT_FILE_PRESET_ENABLE_ONLY,
53         UNIT_FILE_PRESET_DISABLE_ONLY,
54         _UNIT_FILE_PRESET_MAX,
55         _UNIT_FILE_PRESET_INVALID = -1
56 } UnitFilePresetMode;
57
58 typedef enum UnitFileChangeType {
59         UNIT_FILE_SYMLINK,
60         UNIT_FILE_UNLINK,
61         _UNIT_FILE_CHANGE_TYPE_MAX,
62         _UNIT_FILE_CHANGE_TYPE_INVALID = -1
63 } UnitFileChangeType;
64
65 typedef struct UnitFileChange {
66         UnitFileChangeType type;
67         char *path;
68         char *source;
69 } UnitFileChange;
70
71 typedef struct UnitFileList {
72         char *path;
73         UnitFileState state;
74 } UnitFileList;
75
76 typedef struct {
77         char *name;
78         char *path;
79         char *user;
80
81         char **aliases;
82         char **wanted_by;
83         char **required_by;
84         char **also;
85
86         char *default_instance;
87 } InstallInfo;
88
89 int unit_file_enable(UnitFileScope scope, bool runtime, const char *root_dir, char **files, bool force, UnitFileChange **changes, unsigned *n_changes);
90 int unit_file_disable(UnitFileScope scope, bool runtime, const char *root_dir, char **files, UnitFileChange **changes, unsigned *n_changes);
91 int unit_file_reenable(UnitFileScope scope, bool runtime, const char *root_dir, char **files, bool force, UnitFileChange **changes, unsigned *n_changes);
92 int unit_file_link(UnitFileScope scope, bool runtime, const char *root_dir, char **files, bool force, UnitFileChange **changes, unsigned *n_changes);
93 int unit_file_preset(UnitFileScope scope, bool runtime, const char *root_dir, char **files, UnitFilePresetMode mode, bool force, UnitFileChange **changes, unsigned *n_changes);
94 int unit_file_preset_all(UnitFileScope scope, bool runtime, const char *root_dir, UnitFilePresetMode mode, bool force, UnitFileChange **changes, unsigned *n_changes);
95 int unit_file_mask(UnitFileScope scope, bool runtime, const char *root_dir, char **files, bool force, UnitFileChange **changes, unsigned *n_changes);
96 int unit_file_unmask(UnitFileScope scope, bool runtime, const char *root_dir, char **files, UnitFileChange **changes, unsigned *n_changes);
97 int unit_file_set_default(UnitFileScope scope, const char *root_dir, const char *file, bool force, UnitFileChange **changes, unsigned *n_changes);
98 int unit_file_get_default(UnitFileScope scope, const char *root_dir, char **name);
99 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);
100
101 UnitFileState unit_file_get_state(UnitFileScope scope, const char *root_dir, const char *filename);
102
103 int unit_file_get_list(UnitFileScope scope, const char *root_dir, Hashmap *h);
104
105 void unit_file_list_free(Hashmap *h);
106 void unit_file_changes_free(UnitFileChange *changes, unsigned n_changes);
107
108 int unit_file_query_preset(UnitFileScope scope, const char *root_dir, const char *name);
109
110 const char *unit_file_state_to_string(UnitFileState s) _const_;
111 UnitFileState unit_file_state_from_string(const char *s) _pure_;
112
113 const char *unit_file_change_type_to_string(UnitFileChangeType s) _const_;
114 UnitFileChangeType unit_file_change_type_from_string(const char *s) _pure_;
115
116 const char *unit_file_preset_mode_to_string(UnitFilePresetMode m) _const_;
117 UnitFilePresetMode unit_file_preset_mode_from_string(const char *s) _pure_;