install.c revision b5efdb8af40ea759a1ea584c1bc44ecc81dd00ce
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2011 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty <of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include <fcntl.h>
#include <fnmatch.h>
#include <string.h>
#include <unistd.h>
#include "alloc-util.h"
#include "conf-files.h"
#include "conf-parser.h"
#include "dirent-util.h"
#include "fd-util.h"
#include "fs-util.h"
#include "hashmap.h"
#include "install-printf.h"
#include "install.h"
#include "mkdir.h"
#include "path-lookup.h"
#include "path-util.h"
#include "set.h"
#include "special.h"
#include "stat-util.h"
#include "string-table.h"
#include "string-util.h"
#include "strv.h"
#include "unit-name.h"
#include "util.h"
typedef struct {
if (!parent)
return -ENOMEM;
}
char *p = NULL;
int r;
switch (scope) {
case UNIT_FILE_SYSTEM:
if (runtime)
else
break;
case UNIT_FILE_GLOBAL:
if (root_dir)
return -EINVAL;
if (runtime)
else
p = strdup(USER_CONFIG_UNIT_PATH);
break;
case UNIT_FILE_USER:
if (root_dir)
return -EINVAL;
if (runtime)
r = user_runtime_dir(&p);
else
r = user_config_home(&p);
if (r <= 0)
return r < 0 ? r : -ENOENT;
break;
default:
assert_not_reached("Bad scope");
}
if (!p)
return -ENOMEM;
*ret = p;
return 0;
}
static int mark_symlink_for_removal(
const char *p) {
char *n;
int r;
assert(p);
if (r < 0)
return r;
n = strdup(p);
if (!n)
return -ENOMEM;
r = set_consume(*remove_symlinks_to, n);
if (r < 0)
return r == -EEXIST ? 0 : r;
return 0;
}
static int remove_marked_symlinks_fd(
int fd,
const char *path,
const char *config_path,
bool *deleted,
unsigned *n_changes,
char** instance_whitelist) {
int r = 0;
if (!d) {
safe_close(fd);
return -errno;
}
rewinddir(d);
for (;;) {
errno = 0;
r = -errno;
break;
}
if (!de)
break;
continue;
dirent_ensure_type(d, de);
int nfd, q;
_cleanup_free_ char *p = NULL;
if (nfd < 0) {
continue;
if (r == 0)
r = -errno;
continue;
}
if (!p) {
return -ENOMEM;
}
/* This will close nfd, regardless whether it succeeds or not */
q = remove_marked_symlinks_fd(remove_symlinks_to, nfd, p, config_path, deleted, changes, n_changes, instance_whitelist);
if (q < 0 && r == 0)
r = q;
int q;
bool found;
continue;
_cleanup_free_ char *w = NULL;
/* OK, the file is not listed directly
* in the whitelist, so let's check if
* the template of it might be
* listed. */
if (r < 0)
return r;
if (!strv_contains(instance_whitelist, w))
continue;
}
if (!p)
return -ENOMEM;
q = readlink_and_canonicalize(p, &dest);
if (q < 0) {
if (q == -ENOENT)
continue;
if (r == 0)
r = q;
continue;
}
found =
if (!found)
continue;
if (r == 0)
r = -errno;
continue;
}
rmdir_parents(p, config_path);
if (!set_get(remove_symlinks_to, p)) {
q = mark_symlink_for_removal(&remove_symlinks_to, p);
if (q < 0) {
if (r == 0)
r = q;
} else
*deleted = true;
}
}
}
return r;
}
static int remove_marked_symlinks(
const char *config_path,
unsigned *n_changes,
char** instance_whitelist) {
int r = 0;
bool deleted;
if (set_size(remove_symlinks_to) <= 0)
return 0;
if (fd < 0)
return -errno;
do {
int q, cfd;
deleted = false;
if (cfd < 0) {
r = -errno;
break;
}
/* This takes possession of cfd and closes it */
q = remove_marked_symlinks_fd(remove_symlinks_to, cfd, config_path, config_path, &deleted, changes, n_changes, instance_whitelist);
if (r == 0)
r = q;
} while (deleted);
return r;
}
static int find_symlinks_fd(
const char *name,
int fd,
const char *path,
const char *config_path,
bool *same_name_link) {
int r = 0;
if (!d) {
safe_close(fd);
return -errno;
}
for (;;) {
errno = 0;
return -errno;
if (!de)
return r;
continue;
dirent_ensure_type(d, de);
int nfd, q;
_cleanup_free_ char *p = NULL;
if (nfd < 0) {
continue;
if (r == 0)
r = -errno;
continue;
}
if (!p) {
return -ENOMEM;
}
/* This will close nfd, regardless whether it succeeds or not */
if (q > 0)
return 1;
if (r == 0)
r = q;
bool found_path, found_dest, b = false;
int q;
/* Acquire symlink name */
if (!p)
return -ENOMEM;
/* Acquire symlink destination */
q = readlink_and_canonicalize(p, &dest);
if (q < 0) {
if (q == -ENOENT)
continue;
if (r == 0)
r = q;
continue;
}
/* Check if the symlink itself matches what we
* are looking for */
if (path_is_absolute(name))
else
/* Check if what the symlink points to
* matches what we are looking for */
if (path_is_absolute(name))
else
if (found_path && found_dest) {
_cleanup_free_ char *t = NULL;
/* Filter out same name links in the main
* config path */
if (!t)
return -ENOMEM;
b = path_equal(t, p);
}
if (b)
*same_name_link = true;
else if (found_path || found_dest)
return 1;
}
}
}
static int find_symlinks(
const char *name,
const char *config_path,
bool *same_name_link) {
int fd;
if (fd < 0) {
return 0;
return -errno;
}
/* This takes possession of fd and closes it */
}
static int find_symlinks_in_scope(
const char *root_dir,
const char *name,
UnitFileState *state) {
int r;
bool same_name_link_runtime = false, same_name_link = false;
/* First look in runtime config path */
if (r < 0)
return r;
if (r < 0)
return r;
else if (r > 0) {
return r;
}
/* Then look in the normal config path */
if (r < 0)
return r;
if (r < 0)
return r;
else if (r > 0) {
return r;
}
/* Hmm, we didn't find it, but maybe we found the same name
* link? */
if (same_name_link_runtime) {
return 1;
} else if (same_name_link) {
return 1;
}
return 0;
}
int unit_file_mask(
bool runtime,
const char *root_dir,
char **files,
bool force,
unsigned *n_changes) {
char **i;
int r;
if (r < 0)
return r;
STRV_FOREACH(i, files) {
if (!unit_name_is_valid(*i, UNIT_NAME_ANY)) {
if (r == 0)
r = -EINVAL;
continue;
}
if (!path) {
r = -ENOMEM;
break;
}
continue;
}
if (null_or_empty_path(path) > 0)
continue;
if (force) {
continue;
}
}
if (r == 0)
r = -EEXIST;
} else {
if (r == 0)
r = -errno;
}
}
return r;
}
int unit_file_unmask(
bool runtime,
const char *root_dir,
char **files,
unsigned *n_changes) {
char **i, *config_path = NULL;
int r, q;
if (r < 0)
goto finish;
STRV_FOREACH(i, files) {
if (!unit_name_is_valid(*i, UNIT_NAME_ANY)) {
if (r == 0)
r = -EINVAL;
continue;
}
if (!path) {
r = -ENOMEM;
break;
}
q = null_or_empty_path(path);
if (q > 0) {
q = -errno;
else {
}
}
if (q != -ENOENT && r == 0)
r = q;
}
if (r == 0)
r = q;
return r;
}
int unit_file_link(
bool runtime,
const char *root_dir,
char **files,
bool force,
unsigned *n_changes) {
char **i;
int r, q;
if (r < 0)
return r;
if (r < 0)
return r;
STRV_FOREACH(i, files) {
char *fn;
if (!path_is_absolute(*i) ||
if (r == 0)
r = -EINVAL;
continue;
}
if (r == 0)
r = -errno;
continue;
}
r = -ENOENT;
continue;
}
if (q < 0)
return q;
if (q > 0)
continue;
if (!path)
return -ENOMEM;
continue;
}
if (r == 0)
r = q;
continue;
}
if (q >= 0 && path_equal(dest, *i))
continue;
if (force) {
if (symlink_atomic(*i, path) >= 0) {
continue;
}
}
if (r == 0)
r = -EEXIST;
} else {
if (r == 0)
r = -errno;
}
}
return r;
}
void unit_file_list_free(Hashmap *h) {
UnitFileList *i;
while ((i = hashmap_steal_first(h))) {
free(i);
}
hashmap_free(h);
}
unsigned *n_changes,
const char *path,
const char *source) {
UnitFileChange *c;
unsigned i;
if (!changes)
return 0;
if (!c)
return -ENOMEM;
*changes = c;
i = *n_changes;
if (!c[i].path)
return -ENOMEM;
path_kill_slashes(c[i].path);
if (source) {
if (!c[i].source) {
return -ENOMEM;
}
path_kill_slashes(c[i].path);
} else
*n_changes = i+1;
return 0;
}
unsigned i;
if (!changes)
return;
for (i = 0; i < n_changes; i++) {
}
}
static void install_info_free(UnitFileInstallInfo *i) {
assert(i);
strv_free(i->required_by);
free(i->default_instance);
free(i);
}
static void install_info_hashmap_free(OrderedHashmap *m) {
if (!m)
return;
while ((i = ordered_hashmap_steal_first(m)))
}
static void install_context_done(InstallContext *c) {
assert(c);
}
static int install_info_add(
InstallContext *c,
const char *name,
const char *path) {
UnitFileInstallInfo *i = NULL;
int r;
assert(c);
if (!name)
return -EINVAL;
return 0;
if (r < 0)
return r;
if (!i)
return -ENOMEM;
if (!i->name) {
r = -ENOMEM;
goto fail;
}
if (path) {
if (!i->path) {
r = -ENOMEM;
goto fail;
}
}
if (r < 0)
goto fail;
return 0;
fail:
if (i)
return r;
}
static int install_info_add_auto(
InstallContext *c,
const char *name_or_path) {
assert(c);
if (path_is_absolute(name_or_path))
else
}
static int config_parse_also(
const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
size_t l;
InstallContext *c = data;
UnitFileInstallInfo *i = userdata;
_cleanup_free_ char *n;
int r;
if (!n)
return -ENOMEM;
r = install_info_add(c, n, NULL);
if (r < 0)
return r;
r = strv_extend(&i->also, n);
if (r < 0)
return r;
}
return 0;
}
static int config_parse_user(
const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
UnitFileInstallInfo *i = data;
char *printed;
int r;
if (r < 0)
return r;
return 0;
}
static int config_parse_default_instance(
const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
UnitFileInstallInfo *i = data;
char *printed;
int r;
if (r < 0)
return r;
if (!unit_instance_is_valid(printed)) {
return -EINVAL;
}
free(i->default_instance);
i->default_instance = printed;
return 0;
}
static int unit_file_load(
InstallContext *c,
const char *path,
const char *root_dir,
bool allow_symlink,
bool load,
bool *also) {
const ConfigTableItem items[] = {
{}
};
int fd, r;
assert(c);
if (!load) {
return r;
}
if (fd < 0)
return -errno;
if (!f) {
safe_close(fd);
return -ENOMEM;
}
NULL,
true, true, false, info);
if (r < 0)
return r;
if (also)
return
}
static int unit_file_search(
InstallContext *c,
const LookupPaths *paths,
const char *root_dir,
bool allow_symlink,
bool load,
bool *also) {
char **p;
int r;
assert(c);
if (!path)
return -ENOMEM;
if (r >= 0) {
return r;
}
return r;
}
/* Unit file doesn't exist, however instance
* enablement was requested. We will check if it is
* possible to load template unit file. */
if (r < 0)
return r;
if (!path)
return -ENOMEM;
if (r >= 0) {
return r;
}
return r;
}
}
return -ENOENT;
}
static int unit_file_can_install(
const LookupPaths *paths,
const char *root_dir,
const char *name,
bool allow_symlink,
bool *also) {
int r;
r = install_info_add_auto(&c, name);
if (r < 0)
return r;
if (r >= 0)
r =
(int) strv_length(i->aliases) +
(int) strv_length(i->wanted_by) +
(int) strv_length(i->required_by);
return r;
}
static int create_symlink(
const char *old_path,
const char *new_path,
bool force,
unsigned *n_changes) {
int r;
return 0;
}
return -errno;
if (r < 0)
return r;
return 0;
if (!force)
return -EEXIST;
if (r < 0)
return r;
return 0;
}
static int install_info_symlink_alias(
const char *config_path,
bool force,
unsigned *n_changes) {
char **s;
int r = 0, q;
assert(i);
STRV_FOREACH(s, i->aliases) {
q = install_full_printf(i, *s, &dst);
if (q < 0)
return q;
if (!alias_path)
return -ENOMEM;
if (r == 0)
r = q;
}
return r;
}
static int install_info_symlink_wants(
const char *config_path,
char **list,
const char *suffix,
bool force,
unsigned *n_changes) {
const char *n;
char **s;
int r = 0, q;
assert(i);
/* Don't install any symlink if there's no default
* instance configured */
if (!i->default_instance)
return 0;
if (r < 0)
return r;
n = buf;
} else
n = i->name;
STRV_FOREACH(s, list) {
q = install_full_printf(i, *s, &dst);
if (q < 0)
return q;
r = -EINVAL;
continue;
}
if (!path)
return -ENOMEM;
if (r == 0)
r = q;
}
return r;
}
static int install_info_symlink_link(
const LookupPaths *paths,
const char *config_path,
const char *root_dir,
bool force,
unsigned *n_changes) {
int r;
assert(i);
if (r != 0)
return r;
if (!path)
return -ENOMEM;
}
static int install_info_apply(
const LookupPaths *paths,
const char *config_path,
const char *root_dir,
bool force,
unsigned *n_changes) {
int r, q;
assert(i);
if (r == 0)
r = q;
q = install_info_symlink_wants(i, config_path, i->required_by, ".requires/", force, changes, n_changes);
if (r == 0)
r = q;
if (r == 0)
r = q;
return r;
}
static int install_context_apply(
InstallContext *c,
const LookupPaths *paths,
const char *config_path,
const char *root_dir,
bool force,
unsigned *n_changes) {
int r, q;
assert(c);
if (!ordered_hashmap_isempty(c->will_install)) {
if (r < 0)
return r;
if (r < 0)
return r;
}
r = 0;
while ((i = ordered_hashmap_first(c->will_install))) {
if (q < 0) {
if (r >= 0)
r = q;
return r;
} else if (r >= 0)
r += q;
if (r >= 0 && q < 0)
r = q;
}
return r;
}
static int install_context_mark_for_removal(
InstallContext *c,
const LookupPaths *paths,
const char *config_path,
const char *root_dir) {
int r, q;
assert(c);
/* Marks all items for removal */
if (!ordered_hashmap_isempty(c->will_install)) {
if (r < 0)
return r;
if (r < 0)
return r;
}
r = 0;
while ((i = ordered_hashmap_first(c->will_install))) {
if (q == -ENOENT) {
/* do nothing */
} else if (q < 0) {
if (r >= 0)
r = q;
return r;
} else if (r >= 0)
r += q;
char *unit_file;
if (i->path) {
/* unit file named as instance exists, thus all symlinks
* pointing to it will be removed */
else
/* does not exist, thus we will mark for removal symlinks
* to template unit file */
} else {
/* If i->path is not set, it means that we didn't actually find
* the unit file. But we can still remove symlinks to the
* nonexistent template. */
if (r < 0)
return r;
}
} else
if (r >= 0 && q < 0)
r = q;
}
return r;
}
bool runtime,
const char *root_dir,
char **files,
char *target,
bool force,
unsigned *n_changes) {
char **i;
int r;
if (r < 0)
return r;
if (r < 0)
return r;
STRV_FOREACH(i, files) {
if (state < 0)
log_error("Failed to enable unit: Unit %s is masked", *i);
return -EOPNOTSUPP;
}
r = install_info_add_auto(&c, *i);
if (r < 0)
return r;
}
if (!ordered_hashmap_isempty(c.will_install)) {
if (r < 0)
return r;
if (r < 0)
return r;
}
if (r < 0)
return r;
if (dep == UNIT_WANTS)
else if (dep == UNIT_REQUIRES)
else
r = -EINVAL;
if (r < 0)
return r;
if (r < 0)
return r;
}
return 0;
}
int unit_file_enable(
bool runtime,
const char *root_dir,
char **files,
bool force,
unsigned *n_changes) {
char **i;
int r;
if (r < 0)
return r;
if (r < 0)
return r;
STRV_FOREACH(i, files) {
/* We only want to know if this unit is masked, so we ignore
* errors from unit_file_get_state, deferring other checks.
* This allows templated units to be enabled on the fly. */
log_error("Failed to enable unit: Unit %s is masked", *i);
return -EOPNOTSUPP;
}
r = install_info_add_auto(&c, *i);
if (r < 0)
return r;
}
/* This will return the number of symlink rules that were
supposed to be created, not the ones actually created. This is
useful to determine whether the passed files had any
installation data at all. */
}
int unit_file_disable(
bool runtime,
const char *root_dir,
char **files,
unsigned *n_changes) {
char **i;
int r, q;
if (r < 0)
return r;
if (r < 0)
return r;
STRV_FOREACH(i, files) {
r = install_info_add_auto(&c, *i);
if (r < 0)
return r;
}
if (r >= 0)
r = q;
return r;
}
int unit_file_reenable(
bool runtime,
const char *root_dir,
char **files,
bool force,
unsigned *n_changes) {
int r;
if (r < 0)
return r;
}
const char *root_dir,
const char *file,
bool force,
unsigned *n_changes) {
char *path;
int r;
UnitFileInstallInfo *i = NULL;
return -EINVAL;
if (r < 0)
return r;
if (r < 0)
return r;
r = install_info_add_auto(&c, file);
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
return 0;
}
const char *root_dir,
char **name) {
char **p;
int r;
if (r < 0)
return r;
char *n;
if (!path)
return -ENOMEM;
if (r == -ENOENT)
continue;
else if (r == -EINVAL)
/* not a symlink */
n = strdup(SPECIAL_DEFAULT_TARGET);
else if (r < 0)
return r;
else
if (!n)
return -ENOMEM;
*name = n;
return 0;
}
return -ENOENT;
}
const char *root_dir,
const LookupPaths *paths,
const char *name) {
char **i;
int r = 0;
return -EINVAL;
char *partial;
bool also = false;
if (!path)
return -ENOMEM;
if (root_dir)
else
/*
* Search for a unit file in our default paths, to
* be sure, that there are no broken symlinks.
*/
r = -errno;
return r;
continue;
} else {
return -ENOENT;
r = null_or_empty_path(path);
if (r < 0 && r != -ENOENT)
return r;
else if (r > 0) {
return state;
}
}
if (r < 0)
return r;
else if (r > 0)
return state;
return r;
else if (r > 0)
return UNIT_FILE_DISABLED;
else if (r == 0) {
if (also)
return UNIT_FILE_INDIRECT;
return UNIT_FILE_STATIC;
}
}
return r < 0 ? r : state;
}
const char *root_dir,
const char *name) {
int r;
return -EINVAL;
if (r < 0)
return r;
}
char **p;
int r;
if (scope == UNIT_FILE_SYSTEM)
"/etc/systemd/system-preset",
"/usr/local/lib/systemd/system-preset",
"/usr/lib/systemd/system-preset",
#ifdef HAVE_SPLIT_USR
"/lib/systemd/system-preset",
#endif
NULL);
else if (scope == UNIT_FILE_GLOBAL)
"/etc/systemd/user-preset",
"/usr/local/lib/systemd/user-preset",
"/usr/lib/systemd/user-preset",
NULL);
else
return 1;
if (r < 0)
return r;
STRV_FOREACH(p, files) {
_cleanup_fclose_ FILE *f;
f = fopen(*p, "re");
if (!f) {
continue;
return -errno;
}
for (;;) {
break;
if (!*l)
continue;
continue;
if (first_word(l, "enable")) {
l += 6;
l += strspn(l, WHITESPACE);
return 1;
}
} else if (first_word(l, "disable")) {
l += 7;
l += strspn(l, WHITESPACE);
return 0;
}
} else
log_debug("Couldn't parse line '%s'", l);
}
}
/* Default is "enable" */
return 1;
}
int unit_file_preset(
bool runtime,
const char *root_dir,
char **files,
bool force,
unsigned *n_changes) {
char **i;
int r, q;
if (r < 0)
return r;
if (r < 0)
return r;
STRV_FOREACH(i, files) {
if (!unit_name_is_valid(*i, UNIT_NAME_ANY))
return -EINVAL;
if (r < 0)
return r;
if (r && mode != UNIT_FILE_PRESET_DISABLE_ONLY)
r = install_info_add_auto(&plus, *i);
else if (!r && mode != UNIT_FILE_PRESET_ENABLE_ONLY)
r = install_info_add_auto(&minus, *i);
else
r = 0;
if (r < 0)
return r;
}
r = 0;
if (mode != UNIT_FILE_PRESET_ENABLE_ONLY) {
if (r == 0)
r = q;
}
if (mode != UNIT_FILE_PRESET_DISABLE_ONLY) {
/* Returns number of symlinks that where supposed to be installed. */
if (r == 0)
r = q;
}
return r;
}
int unit_file_preset_all(
bool runtime,
const char *root_dir,
bool force,
unsigned *n_changes) {
char **i;
int r, q;
if (r < 0)
return r;
if (r < 0)
return r;
_cleanup_free_ char *units_dir;
if (!units_dir)
return -ENOMEM;
if (!d) {
continue;
return -errno;
}
for (;;) {
errno = 0;
return -errno;
if (!de)
break;
continue;
continue;
dirent_ensure_type(d, de);
continue;
if (r < 0)
return r;
if (r && mode != UNIT_FILE_PRESET_DISABLE_ONLY)
else if (!r && mode != UNIT_FILE_PRESET_ENABLE_ONLY)
else
r = 0;
if (r < 0)
return r;
}
}
r = 0;
if (mode != UNIT_FILE_PRESET_ENABLE_ONLY) {
if (r == 0)
r = q;
}
if (mode != UNIT_FILE_PRESET_DISABLE_ONLY) {
if (r == 0)
r = q;
}
return r;
}
static void unit_file_list_free_one(UnitFileList *f) {
if (!f)
return;
free(f);
}
int unit_file_get_list(
const char *root_dir,
Hashmap *h) {
char **i;
int r;
assert(h);
return -EINVAL;
if (root_dir) {
if (r < 0)
return -errno;
}
if (r < 0)
return r;
_cleanup_free_ char *units_dir;
if (!units_dir)
return -ENOMEM;
if (!d) {
continue;
return -errno;
}
for (;;) {
bool also = false;
errno = 0;
return -errno;
if (!de)
break;
continue;
continue;
continue;
dirent_ensure_type(d, de);
continue;
if (!f)
return -ENOMEM;
if (!f->path)
return -ENOMEM;
r = null_or_empty_path(f->path);
if (r < 0 && r != -ENOENT)
return r;
else if (r > 0) {
f->state =
path_startswith(*i, "/run") ?
goto found;
}
if (r < 0)
return r;
else if (r > 0) {
f->state = UNIT_FILE_ENABLED;
goto found;
}
if (!path)
return -ENOMEM;
if (r == -EINVAL || /* Invalid setting? */
r == -EBADMSG || /* Invalid format? */
r == -ENOENT /* Included file not found? */)
f->state = UNIT_FILE_INVALID;
else if (r < 0)
return r;
else if (r > 0)
f->state = UNIT_FILE_DISABLED;
else
if (r < 0)
return r;
f = NULL; /* prevent cleanup */
}
}
return 0;
}
static const char* const unit_file_state_table[_UNIT_FILE_STATE_MAX] = {
[UNIT_FILE_ENABLED] = "enabled",
[UNIT_FILE_ENABLED_RUNTIME] = "enabled-runtime",
[UNIT_FILE_LINKED] = "linked",
[UNIT_FILE_LINKED_RUNTIME] = "linked-runtime",
[UNIT_FILE_MASKED] = "masked",
[UNIT_FILE_MASKED_RUNTIME] = "masked-runtime",
[UNIT_FILE_STATIC] = "static",
[UNIT_FILE_DISABLED] = "disabled",
[UNIT_FILE_INDIRECT] = "indirect",
[UNIT_FILE_INVALID] = "invalid",
};
static const char* const unit_file_change_type_table[_UNIT_FILE_CHANGE_TYPE_MAX] = {
[UNIT_FILE_SYMLINK] = "symlink",
[UNIT_FILE_UNLINK] = "unlink",
};
static const char* const unit_file_preset_mode_table[_UNIT_FILE_PRESET_MAX] = {
[UNIT_FILE_PRESET_FULL] = "full",
[UNIT_FILE_PRESET_ENABLE_ONLY] = "enable-only",
[UNIT_FILE_PRESET_DISABLE_ONLY] = "disable-only",
};