mirror of
https://github.com/troglobit/finit.git
synced 2026-11-06 15:51:03 +00:00
tmpfiles: split up create & remove logic
The tmpfiles.d spec contains entry types that should be acted upon in different modes of operation: create, clean, remove, and purge - split up create & remove logic to clarify the modes of operation finit supports.
This commit is contained in:
1 parent
1921b3f2c5
commit
ff95ebeb91
1 file changed
+37
-5
+37
-5
@@ -315,6 +315,43 @@ static void tmpfiles(char *line)
|
|||||||
|
|
||||||
strc = stat(path, &st);
|
strc = stat(path, &st);
|
||||||
|
|
||||||
|
// file and directory removal logic
|
||||||
|
switch (type[0]) {
|
||||||
|
case 'b':
|
||||||
|
case 'c':
|
||||||
|
case 'C':
|
||||||
|
case 'd':
|
||||||
|
case 'D':
|
||||||
|
case 'e':
|
||||||
|
case 'f':
|
||||||
|
case 'F':
|
||||||
|
case 'l': /* Finit extension, like 'L' but only if target exists */
|
||||||
|
case 'L':
|
||||||
|
case 'p':
|
||||||
|
break;
|
||||||
|
case 'r':
|
||||||
|
rc = glob_do(path, erase);
|
||||||
|
if (rc && errno == ENOENT)
|
||||||
|
rc = 0;
|
||||||
|
break;
|
||||||
|
case 'R':
|
||||||
|
rc = glob_do(path, rmrf);
|
||||||
|
break;
|
||||||
|
case 'w':
|
||||||
|
break;
|
||||||
|
case 'X':
|
||||||
|
case 'x':
|
||||||
|
dbg("Unsupported x/X command, ignoring %s, no support for clean at runtime.", path);
|
||||||
|
break;
|
||||||
|
case 'Z':
|
||||||
|
case 'z':
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
errx(1, "Unsupported tmpfiles command '%s'", type);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// file & directory creation logic
|
||||||
switch (type[0]) {
|
switch (type[0]) {
|
||||||
case 'b':
|
case 'b':
|
||||||
rc = parse_mm(arg, &major, &minor);
|
rc = parse_mm(arg, &major, &minor);
|
||||||
@@ -448,12 +485,7 @@ static void tmpfiles(char *line)
|
|||||||
rc = mkfifo(path, mode ?: 0644);
|
rc = mkfifo(path, mode ?: 0644);
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
rc = glob_do(path, erase);
|
|
||||||
if (rc && errno == ENOENT)
|
|
||||||
rc = 0;
|
|
||||||
break;
|
|
||||||
case 'R':
|
case 'R':
|
||||||
rc = glob_do(path, rmrf);
|
|
||||||
break;
|
break;
|
||||||
case 'w':
|
case 'w':
|
||||||
if (!arg)
|
if (!arg)
|
||||||
|
|||||||
Reference in new issue
Block a user