about summary refs log tree commit diff
path: root/src/getfs_a.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2020-08-25 20:04:42 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2020-08-25 20:04:42 +0000
commitc43a9ae78220daadd71e00fc0596ceb839621e28 (patch)
treef263485ed0a09b31afe38be42e151cf9fc1dad9c /src/getfs_a.c
downloadlibfstab-master.tar.gz
libfstab-master.tar.xz
libfstab-master.zip
Initial commit. HEAD master
Diffstat (limited to 'src/getfs_a.c')
-rw-r--r--src/getfs_a.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/getfs_a.c b/src/getfs_a.c
new file mode 100644
index 0000000..22a18d2
--- /dev/null
+++ b/src/getfs_a.c
@@ -0,0 +1,29 @@
+#include <pthread.h>
+#include "fsent.h"
+
+int __getfs_a(char const *spec, char const *file, struct fstab *fstab, char **line, size_t *size)
+{
+	int r;
+	int cs;
+	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
+
+	FILE *f = fopen(_PATH_FSTAB, "rbe");
+	if (!f)
+	{
+		pthread_setcancelstate(cs, 0);
+		return 0;
+	}
+
+	for (;;)
+	{
+		r = __getfsent_a(f, fstab, line, size);
+		if (!r) break;
+		if (spec && !strcmp(spec, fstab->fs_spec)
+		 || file && !strcmp(file, fstab->fs_file))
+			break;
+	}
+
+	__fclose_keep_errno(f);
+	pthread_setcancelstate(cs, 0);
+	return r;
+}