mirror of
https://github.com/troglobit/finit.git
synced 2026-09-30 13:02:37 +07:00
plugins: call bootmisc:bootclean() in HOOK_MOUNT_POST
Before this patch bootclean() ran first in setup() which caused to to
remove the entire /var/run/finit directory, and other files as well,
created earlier. Only possible fix is to split clean and setup in
two and make sure to call clean as soon as we've mounted everything.
Note: this introduces a new behavior, and anyone hooking into the
same point to do good-stuff(tm) may be affected by this.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
+12
-10
@@ -65,7 +65,7 @@ static int is_tmpfs(char *path)
|
||||
return tmpfs;
|
||||
}
|
||||
|
||||
static int do_clean(const char *fpath, const struct stat *sb, int tflag, struct FTW *ftw)
|
||||
static int bootclean(const char *fpath, const struct stat *sb, int tflag, struct FTW *ftw)
|
||||
{
|
||||
if (ftw->level == 0)
|
||||
return 1;
|
||||
@@ -76,8 +76,14 @@ static int do_clean(const char *fpath, const struct stat *sb, int tflag, struct
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* We can safely skip tmpfs, nothing to clean from previous boot there */
|
||||
static void bootclean(void)
|
||||
/*
|
||||
* Cleanup stale files from previous boot, if any still linger on.
|
||||
* Some systems, e.g. Alpine Linux, still have a persistent /run and
|
||||
* /tmp, i.e. not tmpfs.
|
||||
*
|
||||
* We can safely skip tmpfs, nothing to clean there.
|
||||
*/
|
||||
static void clean(void *arg)
|
||||
{
|
||||
char *dir[] = {
|
||||
"/tmp/",
|
||||
@@ -90,7 +96,7 @@ static void bootclean(void)
|
||||
if (is_tmpfs(dir[i]))
|
||||
continue;
|
||||
|
||||
nftw(dir[i], do_clean, 20, FTW_DEPTH);
|
||||
nftw(dir[i], bootclean, 20, FTW_DEPTH);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,9 +107,6 @@ static void setup(void *arg)
|
||||
{
|
||||
mode_t prev;
|
||||
|
||||
/* Cleanup stale files, if any still linger on. */
|
||||
bootclean();
|
||||
|
||||
prev = umask(0);
|
||||
|
||||
_d("Setting up FHS structure in /var ...");
|
||||
@@ -185,9 +188,8 @@ static void setup(void *arg)
|
||||
|
||||
static plugin_t plugin = {
|
||||
.name = __FILE__,
|
||||
.hook[HOOK_BASEFS_UP] = {
|
||||
.cb = setup
|
||||
},
|
||||
.hook[HOOK_MOUNT_POST] = { .cb = clean },
|
||||
.hook[HOOK_BASEFS_UP] = { .cb = setup },
|
||||
.depends = { "pidfile" },
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user