Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/lib/libc/gen/fstab.c,v retrieving revision 1.17 retrieving revision 1.23 diff -u -p -r1.17 -r1.23 --- src/lib/libc/gen/fstab.c 1999/01/24 19:51:16 1.17 +++ src/lib/libc/gen/fstab.c 2001/08/31 00:31:07 1.23 @@ -1,4 +1,4 @@ -/* $NetBSD: fstab.c,v 1.17 1999/01/24 19:51:16 christos Exp $ */ +/* $NetBSD: fstab.c,v 1.23 2001/08/31 00:31:07 lukem Exp $ */ /* * Copyright (c) 1980, 1988, 1993 @@ -38,12 +38,14 @@ #if 0 static char sccsid[] = "@(#)fstab.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: fstab.c,v 1.17 1999/01/24 19:51:16 christos Exp $"); +__RCSID("$NetBSD: fstab.c,v 1.23 2001/08/31 00:31:07 lukem Exp $"); #endif #endif /* LIBC_SCCS and not lint */ #include "namespace.h" #include + +#include #include #include #include @@ -53,11 +55,11 @@ __RCSID("$NetBSD: fstab.c,v 1.17 1999/01 #include #ifdef __weak_alias -__weak_alias(endfsent,_endfsent); -__weak_alias(getfsent,_getfsent); -__weak_alias(getfsfile,_getfsfile); -__weak_alias(getfsspec,_getfsspec); -__weak_alias(setfsent,_setfsent); +__weak_alias(endfsent,_endfsent) +__weak_alias(getfsent,_getfsent) +__weak_alias(getfsfile,_getfsfile) +__weak_alias(getfsspec,_getfsspec) +__weak_alias(setfsent,_setfsent) #endif static FILE *_fs_fp; @@ -76,6 +78,10 @@ nextfld(str, sep) const char *sep; { char *ret; + + _DIAGASSERT(str != NULL); + _DIAGASSERT(sep != NULL); + while ((ret = strsep(str, sep)) != NULL && *ret == '\0') continue; return ret; @@ -92,9 +98,10 @@ fstabscan() static const char sep[] = ":\n"; static const char ws[] = " \t\n"; 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 (;;) { if (!(lp = fgets(line, sizeof(line), _fs_fp))) return 0; @@ -154,13 +161,15 @@ fstabscan() if (*tp) break; } + if (_fs_fstab.fs_type == NULL) + goto bad; if (strcmp(_fs_fstab.fs_type, FSTAB_XX) == 0) continue; if (cp != NULL) return 1; bad: - warnx("%s, %d: Missing fields", _fs_file, _fs_lineno); + warnx("%s, %lu: Missing fields", _fs_file, (u_long)_fs_lineno); } /* NOTREACHED */ } @@ -177,6 +186,9 @@ struct fstab * getfsspec(name) const char *name; { + + _DIAGASSERT(name != NULL); + if (setfsent()) while (fstabscan()) if (!strcmp(_fs_fstab.fs_spec, name)) @@ -188,6 +200,9 @@ struct fstab * getfsfile(name) const char *name; { + + _DIAGASSERT(name != NULL); + if (setfsent()) while (fstabscan()) if (!strcmp(_fs_fstab.fs_file, name))