mirror of
https://github.com/troglobit/finit.git
synced 2026-10-01 05:22:48 +07:00
Run bootclean() from bootmisc plugin instead
This patch moves both the definition and the call to bootclean() from finit.c to the bootmisc plugin. We want to call bootclean() *after* any /run and /var file systems have been mounted. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
@@ -25,7 +25,6 @@
|
||||
#include "config.h" /* Generated by configure script */
|
||||
|
||||
#include <ctype.h>
|
||||
#include <ftw.h>
|
||||
#include <glob.h>
|
||||
#include <dirent.h>
|
||||
#ifdef HAVE_FSTAB_H
|
||||
@@ -118,29 +117,6 @@ static int fsck(int pass)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_clean(const char *fpath, const struct stat *UNUSED(sb), int UNUSED(tflag), struct FTW *ftwbuf)
|
||||
{
|
||||
if (ftwbuf->level == 0)
|
||||
return 1;
|
||||
|
||||
(void)remove(fpath);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void bootclean(void)
|
||||
{
|
||||
char *dir[] = {
|
||||
"/tmp/",
|
||||
"/var/run/",
|
||||
"/var/lock/",
|
||||
NULL
|
||||
};
|
||||
|
||||
for (int i = 0; dir[i]; i++)
|
||||
nftw(dir[i], do_clean, 20, FTW_DEPTH);
|
||||
}
|
||||
|
||||
static void networking(void)
|
||||
{
|
||||
size_t i;
|
||||
@@ -401,9 +377,6 @@ int main(int argc, char* argv[])
|
||||
run("/sbin/swapon -ea");
|
||||
umask(0022);
|
||||
|
||||
/* Cleanup of stale files, if any still linger on. */
|
||||
bootclean();
|
||||
|
||||
/* Base FS up, enable standard SysV init signals */
|
||||
sig_setup(&loop);
|
||||
|
||||
|
||||
+28
-1
@@ -21,6 +21,7 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <ftw.h>
|
||||
#include <string.h>
|
||||
#include <lite/lite.h>
|
||||
|
||||
@@ -36,6 +37,30 @@ static void create(char *path, mode_t mode, uid_t uid, gid_t gid)
|
||||
_w("Failed creating %s properl.", path);
|
||||
}
|
||||
|
||||
static int do_clean(const char *fpath, const struct stat *UNUSED(sb), int UNUSED(tflag), struct FTW *ftwbuf)
|
||||
{
|
||||
if (ftwbuf->level == 0)
|
||||
return 1;
|
||||
|
||||
_e("Removing %s ...", fpath);
|
||||
(void)remove(fpath);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void bootclean(void)
|
||||
{
|
||||
char *dir[] = {
|
||||
"/tmp/",
|
||||
"/var/run/",
|
||||
"/var/lock/",
|
||||
NULL
|
||||
};
|
||||
|
||||
for (int i = 0; dir[i]; i++)
|
||||
nftw(dir[i], do_clean, 20, FTW_DEPTH);
|
||||
}
|
||||
|
||||
/*
|
||||
* Setup standard FHS 2.3 structure in /var, and write runlevel to UTMP
|
||||
*/
|
||||
@@ -43,9 +68,11 @@ static void setup(void *UNUSED(arg))
|
||||
{
|
||||
int gid;
|
||||
|
||||
umask(0);
|
||||
/* Cleanup stale files, if any still linger on. */
|
||||
bootclean();
|
||||
|
||||
_d("Setting up FHS structure in /var ...");
|
||||
umask(0);
|
||||
makedir("/var/cache", 0755);
|
||||
makedir("/var/games", 0755);
|
||||
makedir("/var/lib", 0755);
|
||||
|
||||
Reference in New Issue
Block a user