From c43a9ae78220daadd71e00fc0596ceb839621e28 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Tue, 25 Aug 2020 20:04:42 +0000 Subject: Initial commit. --- src/getfsent.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/getfsent.c (limited to 'src/getfsent.c') diff --git a/src/getfsent.c b/src/getfsent.c new file mode 100644 index 0000000..ccfc0d3 --- /dev/null +++ b/src/getfsent.c @@ -0,0 +1,35 @@ +#include "fsent.h" + +static FILE *f; +static char *line; +static struct fstab fstab; +static size_t size; + +void endfsent() +{ + if (f) __fclose_keep_errno(f); + f = 0; +} + +int setfsent() +{ + endfsent(); + return 1; +} + +struct fstab *getfsent() +{ + if (!f) f = fopen(_PATH_FSTAB, "rbe"); + if (!f) return 0; + return __getfsent_a(f, &fstab, &line, &size) ? &fstab : 0; +} + +struct fstab *getfsspec(char const *spec) +{ + return __getfs_a(spec, 0, &fstab, &line, &size) ? &fstab : 0; +} + +struct fstab *getfsfile(char const *file) +{ + return __getfs_a(0, file, &fstab, &line, &size) ? &fstab : 0; +} -- cgit 1.4.1