summaryrefslogtreecommitdiff
path: root/src/path.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-07-07 02:07:39 +0200
committerLennart Poettering <lennart@poettering.net>2011-07-07 02:07:39 +0200
commit8092a428d40ac682df9e80c36988043854579679 (patch)
tree789262689c0eddf1deabfc01294b36140bee65a6 /src/path.c
parent31a5f880cf7a742e63a81bacef681939ee4e6616 (diff)
path,unit: support globbing in conditions and path units
Diffstat (limited to 'src/path.c')
-rw-r--r--src/path.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/path.c b/src/path.c
index 1c20dcfed6..200fc2bdcb 100644
--- a/src/path.c
+++ b/src/path.c
@@ -197,6 +197,7 @@ static void path_dump(Unit *u, FILE *f, const char *prefix) {
static int path_watch_one(Path *p, PathSpec *s) {
static const int flags_table[_PATH_TYPE_MAX] = {
[PATH_EXISTS] = IN_DELETE_SELF|IN_MOVE_SELF|IN_ATTRIB,
+ [PATH_EXISTS_GLOB] = IN_DELETE_SELF|IN_MOVE_SELF|IN_ATTRIB,
[PATH_CHANGED] = IN_DELETE_SELF|IN_MOVE_SELF|IN_ATTRIB|IN_CLOSE_WRITE|IN_CREATE|IN_DELETE|IN_MOVED_FROM|IN_MOVED_TO,
[PATH_DIRECTORY_NOT_EMPTY] = IN_DELETE_SELF|IN_MOVE_SELF|IN_ATTRIB|IN_CREATE|IN_MOVED_TO
};
@@ -367,6 +368,10 @@ static bool path_check_good(Path *p, bool initial) {
good = access(s->path, F_OK) >= 0;
break;
+ case PATH_EXISTS_GLOB:
+ good = glob_exists(s->path) > 0;
+ break;
+
case PATH_DIRECTORY_NOT_EMPTY: {
int k;
@@ -438,7 +443,7 @@ static void path_mkdir(Path *p) {
LIST_FOREACH(spec, s, p->specs) {
int r;
- if (s->type == PATH_EXISTS)
+ if (s->type == PATH_EXISTS || s->type == PATH_EXISTS_GLOB)
continue;
if ((r = mkdir_p(s->path, p->directory_mode)) < 0)
@@ -672,6 +677,7 @@ DEFINE_STRING_TABLE_LOOKUP(path_state, PathState);
static const char* const path_type_table[_PATH_TYPE_MAX] = {
[PATH_EXISTS] = "PathExists",
+ [PATH_EXISTS_GLOB] = "PathExistsGlob",
[PATH_CHANGED] = "PathChanged",
[PATH_DIRECTORY_NOT_EMPTY] = "DirectoryNotEmpty"
};