mirror of
https://github.com/troglobit/finit.git
synced 2026-10-02 14:02:52 +07:00
Export ismnt() and fismnt() helper functions, for modprobe plugin
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
-27
@@ -84,33 +84,6 @@ static void banner(void)
|
||||
print_banner(INIT_HEADING);
|
||||
}
|
||||
|
||||
static int ismnt(char *file, char *dir)
|
||||
{
|
||||
FILE *fp;
|
||||
int found = 0;
|
||||
struct mntent *mnt;
|
||||
|
||||
fp = setmntent(file, "r");
|
||||
if (!fp)
|
||||
return 0; /* Dunno, maybe not */
|
||||
|
||||
while ((mnt = getmntent(fp))) {
|
||||
if (!strcmp(mnt->mnt_dir, dir)) {
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
endmntent(fp);
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
/* Requires /proc to be mounted */
|
||||
static int fismnt(char *dir)
|
||||
{
|
||||
return ismnt("/proc/mounts", dir);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check all filesystems in /etc/fstab with a fs_passno > 0
|
||||
*/
|
||||
|
||||
@@ -429,6 +429,34 @@ void endfsent(void)
|
||||
}
|
||||
#endif /* HAVE_GETFSENT */
|
||||
|
||||
|
||||
int ismnt(char *file, char *dir)
|
||||
{
|
||||
FILE *fp;
|
||||
int found = 0;
|
||||
struct mntent *mnt;
|
||||
|
||||
fp = setmntent(file, "r");
|
||||
if (!fp)
|
||||
return 0; /* Dunno, maybe not */
|
||||
|
||||
while ((mnt = getmntent(fp))) {
|
||||
if (!strcmp(mnt->mnt_dir, dir)) {
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
endmntent(fp);
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
/* Requires /proc to be mounted */
|
||||
int fismnt(char *dir)
|
||||
{
|
||||
return ismnt("/proc/mounts", dir);
|
||||
}
|
||||
|
||||
/**
|
||||
* Local Variables:
|
||||
* indent-tabs-mode: t
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#ifndef FINIT_HELPERS_H_
|
||||
#define FINIT_HELPERS_H_
|
||||
|
||||
#include <mntent.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/types.h>
|
||||
@@ -83,6 +84,9 @@ static inline void create(char *path, mode_t mode, uid_t uid, gid_t gid)
|
||||
_w("Failed creating %s properly.", path);
|
||||
}
|
||||
|
||||
int ismnt (char *file, char *dir);
|
||||
int fismnt (char *dir);
|
||||
|
||||
#endif /* FINIT_HELPERS_H_ */
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user