summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorKay Sievers <kay@vrfy.org>2012-05-07 21:36:12 +0200
committerKay Sievers <kay@vrfy.org>2012-05-08 02:33:10 +0200
commit9eb977db5b89b44f254ab40c1876a76b7d7ea2d0 (patch)
treed73a79d15c67aea358006832a1187ce66486b940 /src/core
parentbbc98d32560cc456531bf254f7b69054921082bd (diff)
util: split-out path-util.[ch]
Diffstat (limited to 'src/core')
-rw-r--r--src/core/automount.c1
-rw-r--r--src/core/cgroup.c1
-rw-r--r--src/core/condition.c1
-rw-r--r--src/core/device.c1
-rw-r--r--src/core/execute.c7
-rw-r--r--src/core/load-fragment.c3
-rw-r--r--src/core/manager.c3
-rw-r--r--src/core/mount-setup.c1
-rw-r--r--src/core/mount.c1
-rw-r--r--src/core/namespace.c1
-rw-r--r--src/core/path.c1
-rw-r--r--src/core/service.c5
-rw-r--r--src/core/socket.c1
-rw-r--r--src/core/swap.c1
-rw-r--r--src/core/umount.c1
-rw-r--r--src/core/unit.c7
16 files changed, 26 insertions, 10 deletions
diff --git a/src/core/automount.c b/src/core/automount.c
index 11c217beb9..c31e3d8bac 100644
--- a/src/core/automount.c
+++ b/src/core/automount.c
@@ -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,
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index 713c1ca768..5513f6560c 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -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;
diff --git a/src/core/condition.c b/src/core/condition.c
index 5d44039e5d..e4080d569d 100644
--- a/src/core/condition.c
+++ b/src/core/condition.c
@@ -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;
diff --git a/src/core/device.c b/src/core/device.c
index 88ce0cdd18..f2bb656397 100644
--- a/src/core/device.c
+++ b/src/core/device.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,
diff --git a/src/core/execute.c b/src/core/execute.c
index 99a7881f1c..953cfa2baa 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -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;
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index d24919f998..c2efec6657 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -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)) {
diff --git a/src/core/manager.c b/src/core/manager.c
index 62222e6c7a..c6baf22ae5 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -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);
diff --git a/src/core/mount-setup.c b/src/core/mount-setup.c
index 6d37bbde3c..56ce2ae71a 100644
--- a/src/core/mount-setup.c
+++ b/src/core/mount-setup.c
@@ -38,6 +38,7 @@
#include "set.h"
#include "strv.h"
#include "mkdir.h"
+#include "path-util.h"
#ifndef TTY_GID
#define TTY_GID 5
diff --git a/src/core/mount.c b/src/core/mount.c
index 8bdd462ea1..01e9d78ad5 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -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"
diff --git a/src/core/namespace.c b/src/core/namespace.c
index 7ac6b381ab..ba1edbe512 100644
--- a/src/core/namespace.c
+++ b/src/core/namespace.c
@@ -33,6 +33,7 @@
#include "strv.h"
#include "util.h"
+#include "path-util.h"
#include "namespace.h"
#include "missing.h"
diff --git a/src/core/path.c b/src/core/path.c
index 0f23f1494d..d6fedc736a 100644
--- a/src/core/path.c
+++ b/src/core/path.c
@@ -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,
diff --git a/src/core/service.c b/src/core/service.c
index 40f1682784..e9a7000bae 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -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));
diff --git a/src/core/socket.c b/src/core/socket.c
index 60ea3cb25c..37e85d5fbe 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -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"
diff --git a/src/core/swap.c b/src/core/swap.c
index 3881d2831f..a7e2126edd 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -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,
diff --git a/src/core/umount.c b/src/core/umount.c
index 488e1e4a4d..71ad4b623d 100644
--- a/src/core/umount.c
+++ b/src/core/umount.c
@@ -32,6 +32,7 @@
#include "list.h"
#include "mount-setup.h"
#include "umount.h"
+#include "path-util.h"
#include "util.h"
typedef struct MountPoint {
diff --git a/src/core/unit.c b/src/core/unit.c
index fea75e88fe..68948574ed 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -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;
}