version 1.24, 2002/04/16 19:07:00 |
version 1.29, 2011/10/15 23:00:01 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* 3. Neither the name of the University nor the names of its contributors |
* must display the following acknowledgement: |
|
* This product includes software developed by the University of |
|
* California, Berkeley and its contributors. |
|
* 4. Neither the name of the University nor the names of its contributors |
|
* may be used to endorse or promote products derived from this software |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* without specific prior written permission. |
* |
* |
Line 69 static struct fstab _fs_fstab; |
|
Line 65 static struct fstab _fs_fstab; |
|
|
|
static int fstabscan __P((void)); |
static int fstabscan __P((void)); |
|
|
static __inline char *nextfld __P((char **, const char *)); |
static char *nextfld(char **, const char *); |
|
static int fstabscan(void); |
|
|
|
|
static __inline char * |
static char * |
nextfld(str, sep) |
nextfld(char **str, const char *sep) |
char **str; |
|
const char *sep; |
|
{ |
{ |
char *ret; |
char *ret; |
|
|
_DIAGASSERT(str != NULL); |
_DIAGASSERT(str != NULL); |
_DIAGASSERT(sep != NULL); |
_DIAGASSERT(sep != NULL); |
|
|
while ((ret = strsep(str, sep)) != NULL && *ret == '\0') |
while ((ret = stresep(str, sep, '\\')) != NULL && *ret == '\0') |
continue; |
continue; |
return ret; |
return ret; |
} |
} |
|
|
|
|
static int |
static int |
fstabscan() |
fstabscan(void) |
{ |
{ |
char *cp, *lp, *sp; |
char *cp, *lp, *sp; |
#define MAXLINELENGTH 1024 |
#define MAXLINELENGTH 1024 |
|
|
char subline[MAXLINELENGTH]; |
char subline[MAXLINELENGTH]; |
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 const char *fstab_type[] = { |
FSTAB_RW, FSTAB_RQ, FSTAB_RO, FSTAB_SW, FSTAB_DP, FSTAB_XX, NULL |
FSTAB_RW, FSTAB_RQ, FSTAB_RO, FSTAB_SW, FSTAB_DP, FSTAB_XX, NULL |
}; |
}; |
|
|
|
|
continue; |
continue; |
_fs_fstab.fs_mntops = _fs_fstab.fs_type; |
_fs_fstab.fs_mntops = _fs_fstab.fs_type; |
_fs_fstab.fs_vfstype = |
_fs_fstab.fs_vfstype = |
|
__UNCONST( |
strcmp(_fs_fstab.fs_type, FSTAB_SW) ? |
strcmp(_fs_fstab.fs_type, FSTAB_SW) ? |
"ufs" : "swap"; |
"ufs" : "swap"); |
if ((cp = nextfld(&lp, sep)) != NULL) { |
if ((cp = nextfld(&lp, sep)) != NULL) { |
_fs_fstab.fs_freq = atoi(cp); |
_fs_fstab.fs_freq = atoi(cp); |
if ((cp = nextfld(&lp, sep)) != NULL) { |
if ((cp = nextfld(&lp, sep)) != NULL) { |
|
|
sp = subline; |
sp = subline; |
|
|
while ((cp = nextfld(&sp, ",")) != NULL) { |
while ((cp = nextfld(&sp, ",")) != NULL) { |
char **tp; |
const char **tp; |
|
|
if (strlen(cp) != 2) |
if (strlen(cp) != 2) |
continue; |
continue; |
|
|
for (tp = fstab_type; *tp; tp++) |
for (tp = fstab_type; *tp; tp++) |
if (strcmp(cp, *tp) == 0) { |
if (strcmp(cp, *tp) == 0) { |
_fs_fstab.fs_type = *tp; |
_fs_fstab.fs_type = __UNCONST(*tp); |
break; |
break; |
} |
} |
if (*tp) |
if (*tp) |
|
|
} |
} |
|
|
struct fstab * |
struct fstab * |
getfsent() |
getfsent(void) |
{ |
{ |
if ((!_fs_fp && !setfsent()) || !fstabscan()) |
if ((!_fs_fp && !setfsent()) || !fstabscan()) |
return NULL; |
return NULL; |
|
|
} |
} |
|
|
struct fstab * |
struct fstab * |
getfsspec(name) |
getfsspec(const char *name) |
const char *name; |
|
{ |
{ |
|
|
_DIAGASSERT(name != NULL); |
_DIAGASSERT(name != NULL); |
|
|
} |
} |
|
|
struct fstab * |
struct fstab * |
getfsfile(name) |
getfsfile(const char *name) |
const char *name; |
|
{ |
{ |
|
|
_DIAGASSERT(name != NULL); |
_DIAGASSERT(name != NULL); |
|
|
} |
} |
|
|
int |
int |
setfsent() |
setfsent(void) |
{ |
{ |
_fs_lineno = 0; |
_fs_lineno = 0; |
if (_fs_fp) { |
if (_fs_fp) { |
rewind(_fs_fp); |
rewind(_fs_fp); |
return 1; |
return 1; |
} |
} |
if ((_fs_fp = fopen(_PATH_FSTAB, "r")) == NULL) { |
if ((_fs_fp = fopen(_PATH_FSTAB, "re")) == NULL) { |
warn("Cannot open `%s'", _PATH_FSTAB); |
warn("Cannot open `%s'", _PATH_FSTAB); |
return 0; |
return 0; |
} |
} |
|
|
} |
} |
|
|
void |
void |
endfsent() |
endfsent(void) |
{ |
{ |
if (_fs_fp) { |
if (_fs_fp) { |
(void)fclose(_fs_fp); |
(void)fclose(_fs_fp); |