mirror of
https://github.com/troglobit/finit.git
synced 2026-11-23 20:11:44 +00:00
tmpfiles: add --cat-config, to show the files that would be read
With files in five directories, where one in /etc replaces the one
with the same name in /usr/lib, it is not easy to tell what tmpfiles
goes by. systemd-tmpfiles has --cat-config for this.
Add the option. It prints each file that would be read below a line
with its name, and exits:
/libexec/finit/tmpfiles --cat-config
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
4 files changed
+28
-2
No files matched your search
@@ -63,6 +63,7 @@ int clean_flag = 0;
|
||||
int remove_flag = 0;
|
||||
int boot_flag = 0;
|
||||
int dry_run = 0;
|
||||
int cat_config = 0;
|
||||
|
||||
/* Set for the first of two passes, the second one does the complaining */
|
||||
static int quiet;
|
||||
@@ -1941,6 +1942,14 @@ static void process_file(const char *fn)
|
||||
return;
|
||||
}
|
||||
|
||||
if (cat_config) {
|
||||
printf("# %s\n", fn);
|
||||
fcopyfile(fp, stdout);
|
||||
puts("");
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
while (!feof(fp)) {
|
||||
/* No comment character, a # is only a comment at the start of a line */
|
||||
const char delim[3] = { '\\', '\\', 0 };
|
||||
@@ -2020,6 +2029,7 @@ static int usage(int rc)
|
||||
"\n"
|
||||
"Options:\n"
|
||||
" --boot Also run boot-only entries, marked with !\n"
|
||||
" --cat-config Show the files that would be read, and exit\n"
|
||||
" -C, --clean Clean files and directories based on age\n"
|
||||
" -c, --create Create files and directories\n"
|
||||
" -d, --debug Show developer debug messages\n"
|
||||
@@ -2041,12 +2051,14 @@ enum {
|
||||
OPT_EXCLUDE_PREFIX = 256,
|
||||
OPT_BOOT,
|
||||
OPT_PREFIX,
|
||||
OPT_CAT_CONFIG,
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
struct option long_options[] = {
|
||||
{ "boot", 0, NULL, OPT_BOOT },
|
||||
{ "cat-config", 0, NULL, OPT_CAT_CONFIG },
|
||||
{ "clean", 0, NULL, 'C' },
|
||||
{ "create", 0, NULL, 'c' },
|
||||
{ "debug", 0, NULL, 'd' },
|
||||
@@ -2093,6 +2105,10 @@ int main(int argc, char *argv[])
|
||||
add_prefix(optarg);
|
||||
break;
|
||||
|
||||
case OPT_CAT_CONFIG:
|
||||
cat_config = 1;
|
||||
break;
|
||||
|
||||
case OPT_EXCLUDE_PREFIX:
|
||||
add_exclude_prefix(optarg);
|
||||
break;
|
||||
@@ -2110,6 +2126,11 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (cat_config) {
|
||||
process(argc - optind, &argv[optind]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (create_flag + clean_flag + remove_flag == 0) {
|
||||
fprintf(stderr, "You need to specify at least one of --clean, --create, or --remove.\n");
|
||||
return 1;
|
||||
|
||||
Reference in new issue
Block a user