diff --git a/finit.c b/finit.c index e1388a95..9a0c74bc 100644 --- a/finit.c +++ b/finit.c @@ -25,6 +25,7 @@ #include "config.h" /* Generated by configure script */ #include +#include #include #include #ifdef HAVE_FSTAB_H @@ -117,6 +118,27 @@ static int fsck(int pass) return 0; } +static int do_clean(const char *fpath, const struct stat *UNUSED(sb), int UNUSED(tflag), struct FTW *UNUSED(ftwbuf)) +{ + _d("Removing %s", fpath); + 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; @@ -378,7 +400,7 @@ int main(int argc, char* argv[]) umask(0022); /* Cleanup of stale files, if any still linger on. */ - run_interactive("rm -rf /tmp/* /tmp/.??* /var/run/* /var/lock/*", "Cleaning up temporary directories"); + bootclean(); /* Base FS up, enable standard SysV init signals */ sig_setup(&loop);