version 1.17, 1999/01/24 19:51:16 |
version 1.22.4.1, 2001/10/27 19:19:14 |
Line 44 __RCSID("$NetBSD$"); |
|
Line 44 __RCSID("$NetBSD$"); |
|
|
|
#include "namespace.h" |
#include "namespace.h" |
#include <sys/types.h> |
#include <sys/types.h> |
|
|
|
#include <assert.h> |
#include <err.h> |
#include <err.h> |
#include <errno.h> |
#include <errno.h> |
#include <fstab.h> |
#include <fstab.h> |
Line 53 __RCSID("$NetBSD$"); |
|
Line 55 __RCSID("$NetBSD$"); |
|
#include <unistd.h> |
#include <unistd.h> |
|
|
#ifdef __weak_alias |
#ifdef __weak_alias |
__weak_alias(endfsent,_endfsent); |
__weak_alias(endfsent,_endfsent) |
__weak_alias(getfsent,_getfsent); |
__weak_alias(getfsent,_getfsent) |
__weak_alias(getfsfile,_getfsfile); |
__weak_alias(getfsfile,_getfsfile) |
__weak_alias(getfsspec,_getfsspec); |
__weak_alias(getfsspec,_getfsspec) |
__weak_alias(setfsent,_setfsent); |
__weak_alias(setfsent,_setfsent) |
#endif |
#endif |
|
|
static FILE *_fs_fp; |
static FILE *_fs_fp; |
Line 76 nextfld(str, sep) |
|
Line 78 nextfld(str, sep) |
|
const char *sep; |
const char *sep; |
{ |
{ |
char *ret; |
char *ret; |
|
|
|
_DIAGASSERT(str != NULL); |
|
_DIAGASSERT(sep != NULL); |
|
|
while ((ret = strsep(str, sep)) != NULL && *ret == '\0') |
while ((ret = strsep(str, sep)) != NULL && *ret == '\0') |
continue; |
continue; |
return ret; |
return ret; |
|
|
static const char sep[] = ":\n"; |
static const char sep[] = ":\n"; |
static const char ws[] = " \t\n"; |
static const char ws[] = " \t\n"; |
static char *fstab_type[] = { |
static char *fstab_type[] = { |
FSTAB_RW, FSTAB_RQ, FSTAB_RO, FSTAB_SW, FSTAB_XX, NULL |
FSTAB_RW, FSTAB_RQ, FSTAB_RO, FSTAB_SW, FSTAB_DP, FSTAB_XX, NULL |
}; |
}; |
|
|
|
(void)memset(&_fs_fstab, 0, sizeof(_fs_fstab)); |
for (;;) { |
for (;;) { |
if (!(lp = fgets(line, sizeof(line), _fs_fp))) |
if (!(lp = fgets(line, sizeof(line), _fs_fp))) |
return 0; |
return 0; |
|
|
if (*tp) |
if (*tp) |
break; |
break; |
} |
} |
|
if (_fs_fstab.fs_type == NULL) |
|
goto bad; |
if (strcmp(_fs_fstab.fs_type, FSTAB_XX) == 0) |
if (strcmp(_fs_fstab.fs_type, FSTAB_XX) == 0) |
continue; |
continue; |
if (cp != NULL) |
if (cp != NULL) |
return 1; |
return 1; |
|
|
bad: |
bad: |
warnx("%s, %d: Missing fields", _fs_file, _fs_lineno); |
warnx("%s, %lu: Missing fields", _fs_file, (u_long)_fs_lineno); |
} |
} |
/* NOTREACHED */ |
/* NOTREACHED */ |
} |
} |
|
|
getfsspec(name) |
getfsspec(name) |
const char *name; |
const char *name; |
{ |
{ |
|
|
|
_DIAGASSERT(name != NULL); |
|
|
if (setfsent()) |
if (setfsent()) |
while (fstabscan()) |
while (fstabscan()) |
if (!strcmp(_fs_fstab.fs_spec, name)) |
if (!strcmp(_fs_fstab.fs_spec, name)) |
|
|
getfsfile(name) |
getfsfile(name) |
const char *name; |
const char *name; |
{ |
{ |
|
|
|
_DIAGASSERT(name != NULL); |
|
|
if (setfsent()) |
if (setfsent()) |
while (fstabscan()) |
while (fstabscan()) |
if (!strcmp(_fs_fstab.fs_file, name)) |
if (!strcmp(_fs_fstab.fs_file, name)) |