chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
units: for all unit settings that take lists, allow the empty string for resetting...
[elogind.git]
/
src
/
core
/
path.c
diff --git
a/src/core/path.c
b/src/core/path.c
index 0f23f1494d1a859dec6a47536b216128c4c06de6..3775577bcf87031b27682f265536b858d040f8b6 100644
(file)
--- 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 "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,
static const UnitActiveState state_translation_table[_PATH_STATE_MAX] = {
[PATH_DEAD] = UNIT_INACTIVE,
@@
-72,14
+73,16
@@
int path_spec_watch(PathSpec *s, Unit *u) {
goto fail;
}
goto fail;
}
- if ((s->primary_wd = inotify_add_watch(s->inotify_fd, k, flags_table[s->type])) >= 0)
+ s->primary_wd = inotify_add_watch(s->inotify_fd, k, flags_table[s->type]);
+ if (s->primary_wd >= 0)
exists = true;
do {
int flags;
/* This assumes the path was passed through path_kill_slashes()! */
exists = true;
do {
int flags;
/* This assumes the path was passed through path_kill_slashes()! */
- if (!(slash = strrchr(k, '/')))
+ slash = strrchr(k, '/');
+ if (!slash)
break;
/* Trim the path at the last slash. Keep the slash if it's the root dir. */
break;
/* Trim the path at the last slash. Keep the slash if it's the root dir. */
@@
-121,7
+124,7
@@
int path_spec_fd_event(PathSpec *s, uint32_t events) {
int r = 0;
if (events != EPOLLIN) {
int r = 0;
if (events != EPOLLIN) {
- log_error("Got
I
nvalid poll event on inotify.");
+ log_error("Got
i
nvalid poll event on inotify.");
r = -EINVAL;
goto out;
}
r = -EINVAL;
goto out;
}
@@
-134,13
+137,15
@@
int path_spec_fd_event(PathSpec *s, uint32_t events) {
assert(l > 0);
assert(l > 0);
- if (!(buf = malloc(l))) {
+ buf = malloc(l);
+ if (!buf) {
log_error("Failed to allocate buffer: %m");
r = -errno;
goto out;
}
log_error("Failed to allocate buffer: %m");
r = -errno;
goto out;
}
- if ((k = read(s->inotify_fd, buf, l)) < 0) {
+ k = read(s->inotify_fd, buf, l);
+ if (k < 0) {
log_error("Failed to read inotify event: %m");
r = -errno;
goto out;
log_error("Failed to read inotify event: %m");
r = -errno;
goto out;
@@
-214,7
+219,8
@@
static void path_spec_mkdir(PathSpec *s, mode_t mode) {
if (s->type == PATH_EXISTS || s->type == PATH_EXISTS_GLOB)
return;
if (s->type == PATH_EXISTS || s->type == PATH_EXISTS_GLOB)
return;
- if ((r = mkdir_p(s->path, mode)) < 0)
+ r = mkdir_p_label(s->path, mode);
+ if (r < 0)
log_warning("mkdir(%s) failed: %s", s->path, strerror(-r));
}
log_warning("mkdir(%s) failed: %s", s->path, strerror(-r));
}
@@
-242,22
+248,28
@@
static void path_init(Unit *u) {
p->directory_mode = 0755;
}
p->directory_mode = 0755;
}
-static void path_done(Unit *u) {
- Path *p = PATH(u);
+void path_free_specs(Path *p) {
PathSpec *s;
assert(p);
PathSpec *s;
assert(p);
- unit_ref_unset(&p->unit);
-
while ((s = p->specs)) {
while ((s = p->specs)) {
- path_spec_unwatch(s,
u
);
+ path_spec_unwatch(s,
UNIT(p)
);
LIST_REMOVE(PathSpec, spec, p->specs, s);
path_spec_done(s);
free(s);
}
}
LIST_REMOVE(PathSpec, spec, p->specs, s);
path_spec_done(s);
free(s);
}
}
+static void path_done(Unit *u) {
+ Path *p = PATH(u);
+
+ assert(p);
+
+ unit_ref_unset(&p->unit);
+ path_free_specs(p);
+}
+
int path_add_one_mount_link(Path *p, Mount *m) {
PathSpec *s;
int r;
int path_add_one_mount_link(Path *p, Mount *m) {
PathSpec *s;
int r;
@@
-301,7
+313,8
@@
static int path_verify(Path *p) {
return 0;
if (!p->specs) {
return 0;
if (!p->specs) {
- log_error("%s lacks path setting. Refusing.", UNIT(p)->id);
+ log_error_unit(UNIT(p)->id,
+ "%s lacks path setting. Refusing.", UNIT(p)->id);
return -EINVAL;
}
return -EINVAL;
}
@@
-313,7
+326,7
@@
static int path_add_default_dependencies(Path *p) {
assert(p);
assert(p);
- if (UNIT(p)->manager->running_as ==
MANAGER
_SYSTEM) {
+ if (UNIT(p)->manager->running_as ==
SYSTEMD
_SYSTEM) {
if ((r = unit_add_dependency_by_name(UNIT(p), UNIT_BEFORE, SPECIAL_BASIC_TARGET, NULL, true)) < 0)
return r;
if ((r = unit_add_dependency_by_name(UNIT(p), UNIT_BEFORE, SPECIAL_BASIC_TARGET, NULL, true)) < 0)
return r;
@@
-737,7
+750,6
@@
static const char* const path_result_table[_PATH_RESULT_MAX] = {
DEFINE_STRING_TABLE_LOOKUP(path_result, PathResult);
const UnitVTable path_vtable = {
DEFINE_STRING_TABLE_LOOKUP(path_result, PathResult);
const UnitVTable path_vtable = {
- .suffix = ".path",
.object_size = sizeof(Path),
.sections =
"Unit\0"
.object_size = sizeof(Path),
.sections =
"Unit\0"