mirror of
https://github.com/troglobit/finit.git
synced 2026-11-07 16:01:08 +00:00
tmpfiles.d: add support for 'l' and 'l+', Finit extensions
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
11da93b759
commit
c81b722691
1 file changed
+25
-4
+25
-4
@@ -238,11 +238,11 @@ static void tmpfiles(char *line)
|
|||||||
{
|
{
|
||||||
char *type, *path, *token, *user, *group, *age, *arg;
|
char *type, *path, *token, *user, *group, *age, *arg;
|
||||||
char *dst = NULL, *opts = "";
|
char *dst = NULL, *opts = "";
|
||||||
|
struct stat st, ast;
|
||||||
int major, minor;
|
int major, minor;
|
||||||
int strc, rc = 0;
|
int strc, rc = 0;
|
||||||
mode_t mode = 0;
|
mode_t mode = 0;
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
struct stat st;
|
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
glob_t gl;
|
glob_t gl;
|
||||||
|
|
||||||
@@ -333,8 +333,6 @@ static void tmpfiles(char *line)
|
|||||||
rc = rsync(arg, path, LITE_FOPT_KEEP_MTIME, NULL);
|
rc = rsync(arg, path, LITE_FOPT_KEEP_MTIME, NULL);
|
||||||
if (rc && errno == ENOENT)
|
if (rc && errno == ENOENT)
|
||||||
rc = 0;
|
rc = 0;
|
||||||
if (dst)
|
|
||||||
free(dst);
|
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
case 'D':
|
case 'D':
|
||||||
@@ -369,11 +367,31 @@ static void tmpfiles(char *line)
|
|||||||
rc = fclose(fp);
|
rc = fclose(fp);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'l': /* Finit extension, like 'L' but only if target exists */
|
||||||
|
if (!arg) {
|
||||||
|
paste(buf, sizeof(buf), "/usr/share/factory", path);
|
||||||
|
if (stat(buf, &ast))
|
||||||
|
break;
|
||||||
|
} else if (arg[0] != '/') {
|
||||||
|
char *tmp;
|
||||||
|
|
||||||
|
tmp = dirname(strdupa(path));
|
||||||
|
paste(buf, sizeof(buf), tmp, arg);
|
||||||
|
dst = realpath(buf, NULL);
|
||||||
|
if (!dst)
|
||||||
|
break;
|
||||||
|
if (stat(dst, &ast))
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
if (stat(arg, &ast))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* fallthrough */
|
||||||
case 'L':
|
case 'L':
|
||||||
if (!strc) {
|
if (!strc) {
|
||||||
if (type[1] != '+')
|
if (type[1] != '+')
|
||||||
break;
|
break;
|
||||||
erase(path);
|
rmrf(path);
|
||||||
}
|
}
|
||||||
mkparent(path, 0755);
|
mkparent(path, 0755);
|
||||||
if (!arg) {
|
if (!arg) {
|
||||||
@@ -435,6 +453,9 @@ static void tmpfiles(char *line)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dst)
|
||||||
|
free(dst);
|
||||||
|
|
||||||
if (rc)
|
if (rc)
|
||||||
warn("Failed %s operation on path %s", type, path);
|
warn("Failed %s operation on path %s", type, path);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user