path.c revision 74051b9b5865586bf4d30b9075649af838fb92bd
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk This file is part of systemd.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk Copyright 2010 Lennart Poettering
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk systemd is free software; you can redistribute it and/or modify it
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk under the terms of the GNU Lesser General Public License as published by
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk the Free Software Foundation; either version 2.1 of the License, or
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk (at your option) any later version.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk systemd is distributed in the hope that it will be useful, but
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk WITHOUT ANY WARRANTY; without even the implied warranty of
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk Lesser General Public License for more details.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk You should have received a copy of the GNU Lesser General Public License
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk along with systemd; If not, see <http://www.gnu.org/licenses/>.
#include "unit.h"
#include "unit-name.h"
#include "path.h"
#include "mkdir.h"
#include "dbus-path.h"
#include "special.h"
#include "bus-errors.h"
#include "path-util.h"
[PATH_CHANGED] = IN_DELETE_SELF|IN_MOVE_SELF|IN_ATTRIB|IN_CLOSE_WRITE|IN_CREATE|IN_DELETE|IN_MOVED_FROM|IN_MOVED_TO,
[PATH_MODIFIED] = IN_DELETE_SELF|IN_MOVE_SELF|IN_ATTRIB|IN_CLOSE_WRITE|IN_CREATE|IN_DELETE|IN_MOVED_FROM|IN_MOVED_TO|IN_MODIFY,
bool exists = false;
char *k, *slash;
assert(u);
assert(s);
path_spec_unwatch(s, u);
return -ENOMEM;
r = -errno;
goto fail;
r = -errno;
goto fail;
if (s->primary_wd >= 0)
exists = true;
int flags;
if (!slash)
if (!exists)
exists = true;
} while (slash != k);
fail:
free(k);
path_spec_unwatch(s, u);
if (s->inotify_fd < 0)
struct inotify_event *e;
ssize_t k;
r = -EINVAL;
goto out;
r = -errno;
goto out;
assert(l > 0);
if (!buf) {
r = -errno;
goto out;
r = -errno;
goto out;
k -= step;
out:
bool good = false;
switch (s->type) {
case PATH_EXISTS:
case PATH_EXISTS_GLOB:
case PATH_DIRECTORY_NOT_EMPTY: {
case PATH_CHANGED:
case PATH_MODIFIED: {
s->previous_exists = b;
return good;
fprintf(f,
s->path);
assert(s);
assert(u);
PathSpec *s;
assert(p);
while ((s = p->specs)) {
path_spec_done(s);
free(s);
assert(p);
path_free_specs(p);
PathSpec *s;
assert(p);
assert(m);
assert(p);
assert(p);
if (!p->specs) {
return -EINVAL;
assert(p);
if ((r = unit_add_two_dependencies_by_name(UNIT(p), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SYSINIT_TARGET, NULL, true)) < 0)
return unit_add_two_dependencies_by_name(UNIT(p), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true);
assert(u);
if ((r = unit_load_fragment_and_dropin(u)) < 0)
Unit *x;
if ((r = path_add_mount_links(p)) < 0)
if ((r = path_add_default_dependencies(p)) < 0)
return path_verify(p);
PathSpec *s;
assert(p);
assert(f);
fprintf(f,
PathSpec *s;
assert(p);
PathSpec *s;
assert(p);
assert(p);
path_unwatch(p);
assert(p);
path_enter_waiting(p, true, true);
assert(p);
if (f != PATH_SUCCESS)
p->result = f;
assert(p);
if ((r = manager_add_job(UNIT(p)->manager, JOB_START, UNIT_DEREF(p->unit), JOB_REPLACE, true, &error, NULL)) < 0)
goto fail;
p->inotify_triggered = false;
if ((r = path_watch(p)) < 0)
goto fail;
fail:
PathSpec *s;
bool good = false;
assert(p);
if (good)
return good;
if (recheck)
if ((r = path_watch(p)) < 0)
goto fail;
if (recheck)
if (path_check_good(p, false)) {
fail:
PathSpec *s;
assert(p);
if (!p->make_directory)
assert(p);
return -ENOENT;
path_mkdir(p);
path_enter_waiting(p, true, true);
assert(p);
assert(u);
assert(f);
assert(u);
PathResult f;
else if (f != PATH_SUCCESS)
p->result = f;
assert(u);
assert(u);
PathSpec *s;
int changed;
assert(p);
goto fail;
if (changed < 0)
goto fail;
p->inotify_triggered = true;
if (changed)
path_enter_waiting(p, false, true);
fail:
Iterator i;
Unit *k;
Path *p;
p = PATH(k);
assert(p);
.sections =