diff --git a/plugins/bootmisc.c b/plugins/bootmisc.c index 280dbf4e..5e7a2d50 100644 --- a/plugins/bootmisc.c +++ b/plugins/bootmisc.c @@ -22,6 +22,7 @@ */ #include +#include #include #include @@ -31,6 +32,28 @@ #include "../plugin.h" #include "../utmp-api.h" +static int is_tmpfs(char *dir) +{ + int tmpfs = 0; + FILE *fp; + struct mntent *mnt; + + fp = setmntent("/proc/mounts", "r"); + if (!fp) + return 0; /* Dunno, maybe not */ + + while ((mnt = getmntent(fp))) { + if (!strcmp(dir, mnt->mnt_dir)) + break; + } + + if (mnt && !strcmp("tmpfs", mnt->mnt_type)) + tmpfs = 1; + endmntent(fp); + + return tmpfs; +} + static void create(char *path, mode_t mode, uid_t uid, gid_t gid) { if (touch(path) || chmod(path, mode) || chown(path, uid, gid)) @@ -48,6 +71,7 @@ static int do_clean(const char *fpath, const struct stat *UNUSED(sb), int UNUSED return 0; } +/* We can safely skip tmpfs, nothing to clean from previous boot there */ static void bootclean(void) { char *dir[] = { @@ -57,8 +81,12 @@ static void bootclean(void) NULL }; - for (int i = 0; dir[i]; i++) + for (int i = 0; dir[i]; i++) { + if (is_tmpfs(dir[i])) + continue; + nftw(dir[i], do_clean, 20, FTW_DEPTH); + } } /*