<term><option>--prefix=PATH</option></term>
<listitem><para>Only apply rules that
apply to paths with the specified
- prefix.</para></listitem>
+ prefix. This option can be specified
+ multiple times.</para></listitem>
</varlistentry>
static bool arg_clean = false;
static bool arg_remove = false;
-static const char *arg_prefix = NULL;
+static char **include_prefixes = NULL;
static const char conf_file_dirs[] =
"/etc/tmpfiles.d\0"
return true;
}
+static bool should_include_path(const char *path) {
+ char **prefix;
+
+ /* no explicit paths specified for inclusion, so everything is valid */
+ if (strv_length(include_prefixes) == 0)
+ return true;
+
+ STRV_FOREACH(prefix, include_prefixes) {
+ if (path_startswith(path, *prefix))
+ return true;
+ }
+
+ return false;
+}
+
static int parse_line(const char *fname, unsigned line, const char *buffer) {
_cleanup_item_free_ Item *i = NULL;
Item *existing;
path_kill_slashes(i->path);
- if (arg_prefix && !path_startswith(i->path, arg_prefix))
+ if (!should_include_path(i->path))
return 0;
if (user && !streq(user, "-")) {
break;
case ARG_PREFIX:
- arg_prefix = optarg;
+ if (strv_extend(&include_prefixes, optarg) < 0)
+ return log_oom();
break;
case '?':
hashmap_free(items);
hashmap_free(globs);
+ strv_free(include_prefixes);
+
set_free_free(unix_sockets);
label_finish();