* properly owned directories beneath /tmp, /var/tmp, /run, which are
* volatile and hence need to be recreated on bootup. */
-enum {
+typedef enum ItemType {
/* These ones take file names */
CREATE_FILE = 'f',
TRUNCATE_FILE = 'F',
IGNORE_PATH = 'x',
REMOVE_PATH = 'r',
RECURSIVE_REMOVE_PATH = 'R'
-};
+} ItemType;
typedef struct Item {
- char type;
+ ItemType type;
char *path;
uid_t uid;
#define MAX_DEPTH 256
-static bool needs_glob(int t) {
+static bool needs_glob(ItemType t) {
return t == IGNORE_PATH || t == REMOVE_PATH || t == RECURSIVE_REMOVE_PATH;
}
}
}
+ fclose(f);
return;
fail:
return r;
}
-static int remove_item(Item *i, const char *instance) {
+static int remove_item_instance(Item *i, const char *instance) {
int r;
assert(i);
case TRUNCATE_DIRECTORY:
case RECURSIVE_REMOVE_PATH:
- if ((r = rm_rf(instance, false, i->type == RECURSIVE_REMOVE_PATH)) < 0 &&
+ if ((r = rm_rf(instance, false, i->type == RECURSIVE_REMOVE_PATH, false)) < 0 &&
r != -ENOENT) {
log_error("rm_rf(%s): %s", instance, strerror(-r));
return r;
return 0;
}
-static int remove_item_glob(Item *i) {
+static int remove_item(Item *i) {
assert(i);
switch (i->type) {
}
STRV_FOREACH(fn, g.gl_pathv)
- if ((k = remove_item(i, *fn)) < 0)
+ if ((k = remove_item_instance(i, *fn)) < 0)
r = k;
globfree(&g);
assert(i);
r = arg_create ? create_item(i) : 0;
- q = arg_remove ? remove_item_glob(i) : 0;
+ q = arg_remove ? remove_item(i) : 0;
p = arg_clean ? clean_item(i) : 0;
if (r < 0)
static int parse_line(const char *fname, unsigned line, const char *buffer) {
Item *i, *existing;
char *mode = NULL, *user = NULL, *group = NULL, *age = NULL;
+ char type;
Hashmap *h;
int r;
"%ms "
"%ms "
"%ms",
- &i->type,
+ &type,
&i->path,
&mode,
&user,
r = -EIO;
goto finish;
}
+ i->type = type;
if (i->type != CREATE_FILE &&
i->type != TRUNCATE_FILE &&