about summary refs log tree commit diff
path: root/src/getfs_a.c
blob: 22a18d28d1c1da4780c1bb83dc094f62d66bcb50 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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;
}