mirror of
https://github.com/troglobit/finit.git
synced 2026-11-20 19:41:51 +00:00
Fix issue #42: Use ftw() to recursively clean up dirs.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
d423e6b774
commit
07d767e1af
1 file changed
+23
-1
@@ -25,6 +25,7 @@
|
|||||||
#include "config.h" /* Generated by configure script */
|
#include "config.h" /* Generated by configure script */
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <ftw.h>
|
||||||
#include <glob.h>
|
#include <glob.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#ifdef HAVE_FSTAB_H
|
#ifdef HAVE_FSTAB_H
|
||||||
@@ -117,6 +118,27 @@ static int fsck(int pass)
|
|||||||
return 0;
|
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)
|
static void networking(void)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
@@ -378,7 +400,7 @@ int main(int argc, char* argv[])
|
|||||||
umask(0022);
|
umask(0022);
|
||||||
|
|
||||||
/* Cleanup of stale files, if any still linger on. */
|
/* 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 */
|
/* Base FS up, enable standard SysV init signals */
|
||||||
sig_setup(&loop);
|
sig_setup(&loop);
|
||||||
|
|||||||
Reference in new issue
Block a user