mirror of
https://github.com/troglobit/finit.git
synced 2026-11-28 20:58:24 +00:00
bootclean: Resolve any symlinks in tmpfs check
Followup to issue #49. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
846692ca03
commit
47060c9738
1 file changed
+24
@@ -32,12 +32,36 @@
|
|||||||
#include "../plugin.h"
|
#include "../plugin.h"
|
||||||
#include "../utmp-api.h"
|
#include "../utmp-api.h"
|
||||||
|
|
||||||
|
/* Resolve symbolic links */
|
||||||
|
static char *desym(char *dir)
|
||||||
|
{
|
||||||
|
static char path[80]; /* Should be enough for our use-case */
|
||||||
|
struct stat st;
|
||||||
|
|
||||||
|
if (stat(dir, &st))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (S_ISLNK(st.st_mode)) {
|
||||||
|
if (-1 == readlink(dir, path, sizeof(path)))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return desym(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dir;
|
||||||
|
}
|
||||||
|
|
||||||
static int is_tmpfs(char *dir)
|
static int is_tmpfs(char *dir)
|
||||||
{
|
{
|
||||||
int tmpfs = 0;
|
int tmpfs = 0;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
struct mntent *mnt;
|
struct mntent *mnt;
|
||||||
|
|
||||||
|
/* If /var/run is a symlink, check what it resolves to */
|
||||||
|
dir = desym(dir);
|
||||||
|
if (!dir)
|
||||||
|
return 0; /* Outlook not so good */
|
||||||
|
|
||||||
fp = setmntent("/proc/mounts", "r");
|
fp = setmntent("/proc/mounts", "r");
|
||||||
if (!fp)
|
if (!fp)
|
||||||
return 0; /* Dunno, maybe not */
|
return 0; /* Dunno, maybe not */
|
||||||
|
|||||||
Reference in new issue
Block a user