mirror of
https://github.com/troglobit/finit.git
synced 2026-10-14 10:19:36 +00:00
Add set/get/endfsent() support for musl libc
This patch adds support for the following /etc/fstab API's on systems that do not have them, e.g. musl libc on Alpine Linux. - setfsent() - getfsent(), and - endfsent() Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
7eac88b639
commit
c38b452ac4
4 files changed
+59
-1
No files matched your search
+2
-1
@@ -24,7 +24,8 @@ AC_PROG_INSTALL
|
||||
|
||||
# Configuration.
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_FUNCS(strstr getopt)
|
||||
AC_CHECK_HEADERS(fstaby.h)
|
||||
AC_CHECK_FUNCS(strstr getopt getfsenty)
|
||||
|
||||
# Check for uint[8,16,32]_t
|
||||
AC_TYPE_UINT8_T
|
||||
|
||||
@@ -27,7 +27,9 @@
|
||||
#include <ctype.h>
|
||||
#include <glob.h>
|
||||
#include <dirent.h>
|
||||
#ifdef HAVE_FSTAB_H
|
||||
#include <fstab.h>
|
||||
#endif
|
||||
#include <mntent.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/stat.h> /* umask(), mkdir() */
|
||||
|
||||
@@ -254,6 +254,45 @@ void set_hostname(char **hostname)
|
||||
sethostname(*hostname, strlen(*hostname));
|
||||
}
|
||||
|
||||
#ifndef HAVE_GETFSENT
|
||||
static lfile_t *fstab = NULL;
|
||||
|
||||
int setfsent(void)
|
||||
{
|
||||
if (fstab)
|
||||
lfclose(fstab);
|
||||
|
||||
fstab = lfopen("/etc/fstab", " \t\n");
|
||||
if (!fstab)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct fstab *getfsent(void)
|
||||
{
|
||||
static struct fstab fs;
|
||||
|
||||
fs.fs_spec = lftok(fstab);
|
||||
fs.fs_file = lftok(fstab);
|
||||
fs.fs_vfstype = lftok(fstab);
|
||||
fs.fs_mntops = lftok(fstab);
|
||||
fs.fs_type = (const char *)lftok(fstab);
|
||||
fs.fs_freq = atoi(lftok(fstab) ?: 0);
|
||||
fs.fs_passno = atoi(lftok(fstab) ?: 0);
|
||||
|
||||
return &fs;
|
||||
}
|
||||
|
||||
void endfsent(void)
|
||||
{
|
||||
if (fstab)
|
||||
lfclose(fstab);
|
||||
|
||||
fstab = NULL;
|
||||
}
|
||||
#endif /* HAVE_GETFSENT */
|
||||
|
||||
/**
|
||||
* Local Variables:
|
||||
* indent-tabs-mode: t
|
||||
|
||||
@@ -86,6 +86,22 @@ int run_interactive (char *cmd, char *fmt, ...);
|
||||
pid_t run_getty (char *tty, char *speed, char *term, int console);
|
||||
int run_parts (char *dir, char *cmd);
|
||||
|
||||
#ifndef HAVE_GETFSENT
|
||||
struct fstab {
|
||||
char *fs_spec; /* block device name */
|
||||
char *fs_file; /* mount point */
|
||||
char *fs_vfstype; /* file-system type */
|
||||
char *fs_mntops; /* mount options */
|
||||
const char *fs_type; /* rw/rq/ro/sw/xx option */
|
||||
int fs_freq; /* dump frequency, in days */
|
||||
int fs_passno; /* pass number on parallel dump */
|
||||
};
|
||||
|
||||
int setfsent(void);
|
||||
void endfsent(void);
|
||||
struct fstab *getfsent(void);
|
||||
#endif /* HAVE_GETFSENT */
|
||||
|
||||
#endif /* FINIT_HELPERS_H_ */
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user