From 3f5ff0d33992204567bfa244a85aac811704fda6 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Sun, 26 Apr 2020 14:13:23 +0200 Subject: [PATCH] Export ismnt() and fismnt() helper functions, for modprobe plugin Signed-off-by: Joachim Nilsson --- src/finit.c | 27 --------------------------- src/helpers.c | 28 ++++++++++++++++++++++++++++ src/helpers.h | 4 ++++ 3 files changed, 32 insertions(+), 27 deletions(-) diff --git a/src/finit.c b/src/finit.c index eb6c6c19..9a8a675d 100644 --- a/src/finit.c +++ b/src/finit.c @@ -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 */ diff --git a/src/helpers.c b/src/helpers.c index 5ffe2619..cb0137b2 100644 --- a/src/helpers.c +++ b/src/helpers.c @@ -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 diff --git a/src/helpers.h b/src/helpers.h index dceccf7b..b5a7d04d 100644 --- a/src/helpers.h +++ b/src/helpers.h @@ -25,6 +25,7 @@ #ifndef FINIT_HELPERS_H_ #define FINIT_HELPERS_H_ +#include #include #include #include @@ -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_ */ /**