Commit 9eb977db authored by Kay Sievers's avatar Kay Sievers
Browse files

util: split-out path-util.[ch]

parent bbc98d32
......@@ -526,6 +526,8 @@ libsystemd_shared_la_SOURCES = \
src/shared/util.h \
src/shared/virt.c \
src/shared/virt.h \
src/shared/path-util.c \
src/shared/path-util.h \
src/shared/hashmap.c \
src/shared/hashmap.h \
src/shared/set.c \
......
......@@ -29,6 +29,7 @@
#include "cgroup-show.h"
#include "cgroup-util.h"
#include "log.h"
#include "path-util.h"
#include "util.h"
#include "pager.h"
#include "build.h"
......
......@@ -26,6 +26,7 @@
#include <alloca.h>
#include <getopt.h>
#include "path-util.h"
#include "util.h"
#include "hashmap.h"
#include "cgroup-util.h"
......
......@@ -39,6 +39,7 @@
#include "special.h"
#include "label.h"
#include "mkdir.h"
#include "path-util.h"
static const UnitActiveState state_translation_table[_AUTOMOUNT_STATE_MAX] = {
[AUTOMOUNT_DEAD] = UNIT_INACTIVE,
......
......@@ -31,6 +31,7 @@
#include "cgroup-util.h"
#include "log.h"
#include "strv.h"
#include "path-util.h"
int cgroup_bonding_realize(CGroupBonding *b) {
int r;
......
......@@ -33,6 +33,7 @@
#include "util.h"
#include "condition.h"
#include "virt.h"
#include "path-util.h"
Condition* condition_new(ConditionType type, const char *parameter, bool trigger, bool negate) {
Condition *c;
......
......@@ -30,6 +30,7 @@
#include "unit-name.h"
#include "dbus-device.h"
#include "def.h"
#include "path-util.h"
static const UnitActiveState state_translation_table[_DEVICE_STATE_MAX] = {
[DEVICE_DEAD] = UNIT_INACTIVE,
......
......@@ -59,6 +59,7 @@
#include "utmp-wtmp.h"
#include "def.h"
#include "loopback-setup.h"
#include "path-util.h"
/* This assumes there is a 'tty' group */
#define TTY_MODE 0620
......@@ -929,7 +930,7 @@ static void rename_process_from_path(const char *path) {
/* This resulting string must fit in 10 chars (i.e. the length
* of "/sbin/init") to look pretty in /bin/ps */
p = file_name_from_path(path);
p = path_get_file_name(path);
if (isempty(p)) {
rename_process("(...)");
return;
......@@ -1152,14 +1153,14 @@ int exec_spawn(ExecCommand *command,
}
if (!keep_stdout) {
err = setup_output(context, socket_fd, file_name_from_path(command->path), apply_tty_stdin);
err = setup_output(context, socket_fd, path_get_file_name(command->path), apply_tty_stdin);
if (err < 0) {
r = EXIT_STDOUT;
goto fail_child;
}
}
err = setup_error(context, socket_fd, file_name_from_path(command->path), apply_tty_stdin);
err = setup_error(context, socket_fd, path_get_file_name(command->path), apply_tty_stdin);
if (err < 0) {
r = EXIT_STDERR;
goto fail_child;
......
......@@ -44,6 +44,7 @@
#include "unit-name.h"
#include "bus-errors.h"
#include "utf8.h"
#include "path-util.h"
#ifndef HAVE_SYSV_COMPAT
int config_parse_warn_compat(
......@@ -2089,7 +2090,7 @@ static int open_follow(char **filename, FILE **_f, Set *names, char **_final) {
/* Add the file name we are currently looking at to
* the names of this unit, but only if it is a valid
* unit name. */
name = file_name_from_path(*filename);
name = path_get_file_name(*filename);
if (unit_name_is_valid(name, true)) {
......
......@@ -65,6 +65,7 @@
#include "virt.h"
#include "watchdog.h"
#include "cgroup-util.h"
#include "path-util.h"
/* As soon as 16 units are in our GC queue, make sure to run a gc sweep */
#define GC_QUEUE_ENTRIES_MAX 16
......@@ -785,7 +786,7 @@ int manager_load_unit_prepare(Manager *m, const char *name, const char *path, DB
}
if (!name)
name = file_name_from_path(path);
name = path_get_file_name(path);
t = unit_name_to_type(name);
......
......@@ -38,6 +38,7 @@
#include "set.h"
#include "strv.h"
#include "mkdir.h"
#include "path-util.h"
#ifndef TTY_GID
#define TTY_GID 5
......
......@@ -32,6 +32,7 @@
#include "log.h"
#include "strv.h"
#include "mkdir.h"
#include "path-util.h"
#include "mount-setup.h"
#include "unit-name.h"
#include "dbus-mount.h"
......
......@@ -33,6 +33,7 @@
#include "strv.h"
#include "util.h"
#include "path-util.h"
#include "namespace.h"
#include "missing.h"
......
......@@ -32,6 +32,7 @@
#include "dbus-path.h"
#include "special.h"
#include "bus-errors.h"
#include "path-util.h"
static const UnitActiveState state_translation_table[_PATH_STATE_MAX] = {
[PATH_DEAD] = UNIT_INACTIVE,
......
......@@ -38,6 +38,7 @@
#include "bus-errors.h"
#include "exit-status.h"
#include "def.h"
#include "path-util.h"
#include "util.h"
#include "utf8.h"
......@@ -722,7 +723,7 @@ static int service_load_sysv_path(Service *s, const char *path) {
goto finish;
}
r = sysv_translate_facility(n, file_name_from_path(path), &m);
r = sysv_translate_facility(n, path_get_file_name(path), &m);
free(n);
if (r < 0)
......@@ -772,7 +773,7 @@ static int service_load_sysv_path(Service *s, const char *path) {
goto finish;
}
r = sysv_translate_facility(n, file_name_from_path(path), &m);
r = sysv_translate_facility(n, path_get_file_name(path), &m);
if (r < 0) {
log_error("[%s:%u] Failed to translate LSB dependency %s, ignoring: %s", path, line, n, strerror(-r));
......
......@@ -37,6 +37,7 @@
#include "load-fragment.h"
#include "strv.h"
#include "mkdir.h"
#include "path-util.h"
#include "unit-name.h"
#include "dbus-socket.h"
#include "missing.h"
......
......@@ -38,6 +38,7 @@
#include "bus-errors.h"
#include "exit-status.h"
#include "def.h"
#include "path-util.h"
static const UnitActiveState state_translation_table[_SWAP_STATE_MAX] = {
[SWAP_DEAD] = UNIT_INACTIVE,
......
......@@ -32,6 +32,7 @@
#include "list.h"
#include "mount-setup.h"
#include "umount.h"
#include "path-util.h"
#include "util.h"
typedef struct MountPoint {
......
......@@ -33,6 +33,7 @@
#include "unit.h"
#include "macro.h"
#include "strv.h"
#include "path-util.h"
#include "load-fragment.h"
#include "load-dropin.h"
#include "log.h"
......@@ -1670,7 +1671,7 @@ static const char *resolve_template(Unit *u, const char *name, const char*path,
assert(name || path);
if (!name)
name = file_name_from_path(path);
name = path_get_file_name(path);
if (!unit_name_is_template(name)) {
*p = NULL;
......@@ -2179,7 +2180,7 @@ static char *specifier_cgroup_root(char specifier, void *data, void *userdata) {
if (specifier == 'r')
return strdup(u->manager->cgroup_hierarchy);
if (parent_of_path(u->manager->cgroup_hierarchy, &p) < 0)
if (path_get_parent(u->manager->cgroup_hierarchy, &p) < 0)
return strdup("");
if (streq(p, "/")) {
......@@ -2681,7 +2682,7 @@ UnitFileState unit_get_unit_file_state(Unit *u) {
if (u->unit_file_state < 0 && u->fragment_path)
u->unit_file_state = unit_file_get_state(
u->manager->running_as == MANAGER_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER,
NULL, file_name_from_path(u->fragment_path));
NULL, path_get_file_name(u->fragment_path));
return u->unit_file_state;
}
......
......@@ -29,6 +29,7 @@
#include "log.h"
#include "util.h"
#include "path-util.h"
#include "strv.h"
#include "ask-password-api.h"
#include "def.h"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment