summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-12-06 21:29:55 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-12-06 21:29:55 -0500
commit2b6bf07dd23bb467099d213c97b3875c5e453491 (patch)
tree2127e24f28714b48f6c00e92eaec351bcb57e5d5 /src/core
parentf4336098941f94d23f2f6c79bc8d055a0907c392 (diff)
Get rid of our reimplementation of basename
The only problem is that libgen.h #defines basename to point to it's own broken implementation instead of the GNU one. This can be fixed by #undefining basename.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/execute.c7
-rw-r--r--src/core/load-fragment.c2
-rw-r--r--src/core/manager.c2
-rw-r--r--src/core/service.c4
-rw-r--r--src/core/unit.c4
5 files changed, 10 insertions, 9 deletions
diff --git a/src/core/execute.c b/src/core/execute.c
index a0d63a41f9..55b8bb5bea 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -41,6 +41,7 @@
#include <linux/seccomp-bpf.h>
#include <glob.h>
#include <libgen.h>
+#undef basename
#ifdef HAVE_PAM
#include <security/pam_appl.h>
@@ -908,7 +909,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 = path_get_file_name(path);
+ p = basename(path);
if (isempty(p)) {
rename_process("(...)");
return;
@@ -1197,13 +1198,13 @@ int exec_spawn(ExecCommand *command,
goto fail_child;
}
- err = setup_output(context, STDOUT_FILENO, socket_fd, path_get_file_name(command->path), unit_id, apply_tty_stdin);
+ err = setup_output(context, STDOUT_FILENO, socket_fd, basename(command->path), unit_id, apply_tty_stdin);
if (err < 0) {
r = EXIT_STDOUT;
goto fail_child;
}
- err = setup_output(context, STDERR_FILENO, socket_fd, path_get_file_name(command->path), unit_id, apply_tty_stdin);
+ err = setup_output(context, STDERR_FILENO, socket_fd, basename(command->path), unit_id, 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 d43d1b4162..99cf20dcce 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -2431,7 +2431,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 = path_get_file_name(*filename);
+ name = basename(*filename);
if (unit_name_is_valid(name, true)) {
diff --git a/src/core/manager.c b/src/core/manager.c
index 0a3e840de7..f06df54d91 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -1078,7 +1078,7 @@ int manager_load_unit_prepare(
return sd_bus_error_setf(e, SD_BUS_ERROR_INVALID_ARGS, "Path %s is not absolute.", path);
if (!name)
- name = path_get_file_name(path);
+ name = basename(path);
t = unit_name_to_type(name);
diff --git a/src/core/service.c b/src/core/service.c
index 530a305b4b..702443d215 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -790,7 +790,7 @@ static int service_load_sysv_path(Service *s, const char *path) {
goto finish;
}
- r = sysv_translate_facility(n, path_get_file_name(path), &m);
+ r = sysv_translate_facility(n, basename(path), &m);
free(n);
if (r < 0)
@@ -842,7 +842,7 @@ static int service_load_sysv_path(Service *s, const char *path) {
goto finish;
}
- r = sysv_translate_facility(n, path_get_file_name(path), &m);
+ r = sysv_translate_facility(n, basename(path), &m);
if (r < 0) {
log_error_unit(u->id,
"[%s:%u] Failed to translate LSB dependency %s, ignoring: %s",
diff --git a/src/core/unit.c b/src/core/unit.c
index 81d21622d0..6458c7f570 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -1848,7 +1848,7 @@ static const char *resolve_template(Unit *u, const char *name, const char*path,
assert(p);
if (!name)
- name = path_get_file_name(path);
+ name = basename(path);
if (!unit_name_is_template(name)) {
*p = NULL;
@@ -2615,7 +2615,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 == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER,
- NULL, path_get_file_name(u->fragment_path));
+ NULL, basename(u->fragment_path));
return u->unit_file_state;
}