Export ismnt() and fismnt() helper functions, for modprobe plugin

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2020-04-26 14:55:38 +02:00
1 parent 37d92e87bc
commit 3f5ff0d339
3 files changed
+32 -27

No files matched your search

-27
View File
@@ -84,33 +84,6 @@ static void banner(void)
print_banner(INIT_HEADING); 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 * Check all filesystems in /etc/fstab with a fs_passno > 0
*/ */
+28
View File
@@ -429,6 +429,34 @@ void endfsent(void)
} }
#endif /* HAVE_GETFSENT */ #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: * Local Variables:
* indent-tabs-mode: t * indent-tabs-mode: t
+4
View File
@@ -25,6 +25,7 @@
#ifndef FINIT_HELPERS_H_ #ifndef FINIT_HELPERS_H_
#define FINIT_HELPERS_H_ #define FINIT_HELPERS_H_
#include <mntent.h>
#include <stdarg.h> #include <stdarg.h>
#include <sys/resource.h> #include <sys/resource.h>
#include <sys/types.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); _w("Failed creating %s properly.", path);
} }
int ismnt (char *file, char *dir);
int fismnt (char *dir);
#endif /* FINIT_HELPERS_H_ */ #endif /* FINIT_HELPERS_H_ */
/** /**