Since checkmntlist() and getmntentry() return a struct statfs that

includes the filesystem type name, remove the "type" output parameter.
This commit is contained in:
Ian Dowse 2003-07-18 08:01:10 +00:00
parent da60560610
commit 1add162c97

View File

@ -73,10 +73,9 @@ struct addrinfo *nfshost_ai = NULL;
int fflag, vflag; int fflag, vflag;
char *nfshost; char *nfshost;
struct statfs *checkmntlist (char *, char **); struct statfs *checkmntlist(char *);
int checkvfsname (const char *, char **); int checkvfsname (const char *, char **);
struct statfs *getmntentry (const char *, const char *, mntwhat, char **, struct statfs *getmntentry(const char *, const char *, mntwhat, dowhat);
dowhat);
char *getrealname(char *, char *resolved_path); char *getrealname(char *, char *resolved_path);
char **makevfslist (const char *); char **makevfslist (const char *);
size_t mntinfo (struct statfs **); size_t mntinfo (struct statfs **);
@ -176,7 +175,7 @@ main(int argc, char *argv[])
errs = 1; errs = 1;
break; break;
} }
(void)getmntentry(NULL, NULL, NOTHING, NULL, FREE); (void)getmntentry(NULL, NULL, NOTHING, FREE);
exit(errs); exit(errs);
} }
@ -239,7 +238,7 @@ checkname(char *name, char **typelist)
size_t len; size_t len;
int speclen; int speclen;
char *resolved, realname[MAXPATHLEN]; char *resolved, realname[MAXPATHLEN];
char *type, *hostp, *delimp, *origname; char *hostp, *delimp, *origname;
struct statfs *sfs; struct statfs *sfs;
len = 0; len = 0;
@ -249,7 +248,7 @@ checkname(char *name, char **typelist)
/* /*
* 1. Check if the name exists in the mounttable. * 1. Check if the name exists in the mounttable.
*/ */
sfs = checkmntlist(name, &type); sfs = checkmntlist(name);
/* /*
* 2. Remove trailing slashes if there are any. After that * 2. Remove trailing slashes if there are any. After that
* we look up the name in the mounttable again. * we look up the name in the mounttable again.
@ -260,7 +259,7 @@ checkname(char *name, char **typelist)
speclen > 1 && name[speclen - 1] == '/'; speclen > 1 && name[speclen - 1] == '/';
speclen--) speclen--)
name[speclen - 1] = '\0'; name[speclen - 1] = '\0';
sfs = checkmntlist(name, &type); sfs = checkmntlist(name);
resolved = name; resolved = name;
/* Save off original name in origname */ /* Save off original name in origname */
if ((origname = strdup(name)) == NULL) if ((origname = strdup(name)) == NULL)
@ -293,7 +292,7 @@ checkname(char *name, char **typelist)
speclen--) speclen--)
name[speclen - 1] = '\0'; name[speclen - 1] = '\0';
name[len + speclen + 1] = '\0'; name[len + speclen + 1] = '\0';
sfs = checkmntlist(name, &type); sfs = checkmntlist(name);
resolved = name; resolved = name;
} }
/* /*
@ -307,7 +306,7 @@ checkname(char *name, char **typelist)
if (sfs == NULL) { if (sfs == NULL) {
(void)strcpy(name, origname); (void)strcpy(name, origname);
if ((getrealname(name, realname)) != NULL) { if ((getrealname(name, realname)) != NULL) {
sfs = checkmntlist(realname, &type); sfs = checkmntlist(realname);
resolved = realname; resolved = realname;
} }
/* /*
@ -341,16 +340,15 @@ checkname(char *name, char **typelist)
} else } else
resolved = name; resolved = name;
if (checkvfsname(type, typelist)) if (checkvfsname(sfs->f_fstypename, typelist))
return (1); return (1);
/* /*
* Mark the uppermost mount as unmounted. * Mark the uppermost mount as unmounted.
*/ */
(void)getmntentry(sfs->f_mntfromname, sfs->f_mntonname, NOTHING, &type, (void)getmntentry(sfs->f_mntfromname, sfs->f_mntonname, NOTHING, MARK);
MARK);
return (umountfs(sfs->f_mntfromname, sfs->f_mntonname, &sfs->f_fsid, return (umountfs(sfs->f_mntfromname, sfs->f_mntonname, &sfs->f_fsid,
type)); sfs->f_fstypename));
} }
/* /*
@ -397,8 +395,7 @@ umountfs(char *mntfromname, char *mntonname, fsid_t *fsid, char *type)
* A non-NULL return means that this is the last * A non-NULL return means that this is the last
* mount from mntfromname that is still mounted. * mount from mntfromname that is still mounted.
*/ */
if (getmntentry(mntfromname, NULL, NOTHING, &type, COUNT) if (getmntentry(mntfromname, NULL, NOTHING, COUNT) != NULL)
!= NULL)
do_rpc = 1; do_rpc = 1;
} }
@ -462,8 +459,7 @@ umountfs(char *mntfromname, char *mntonname, fsid_t *fsid, char *type)
} }
struct statfs * struct statfs *
getmntentry(const char *fromname, const char *onname, mntwhat what, getmntentry(const char *fromname, const char *onname, mntwhat what, dowhat mark)
char **type, dowhat mark)
{ {
static struct statfs *mntbuf; static struct statfs *mntbuf;
static size_t mntsize = 0; static size_t mntsize = 0;
@ -496,11 +492,8 @@ getmntentry(const char *fromname, const char *onname, mntwhat what,
for (i = mntsize - 1; i >= 0; i--) { for (i = mntsize - 1; i >= 0; i--) {
if (fromname != NULL && !strcmp((what == MNTFROM) ? if (fromname != NULL && !strcmp((what == MNTFROM) ?
mntbuf[i].f_mntfromname : mntbuf[i].f_mntonname, mntbuf[i].f_mntfromname : mntbuf[i].f_mntonname,
fromname) && mntcheck[i] != 1) { fromname) && mntcheck[i] != 1)
if (type)
*type = mntbuf[i].f_fstypename;
return (&mntbuf[i]); return (&mntbuf[i]);
}
} }
return (NULL); return (NULL);
@ -612,13 +605,13 @@ namematch(struct addrinfo *ai)
} }
struct statfs * struct statfs *
checkmntlist(char *name, char **type) checkmntlist(char *name)
{ {
struct statfs *sfs; struct statfs *sfs;
sfs = getmntentry(name, NULL, MNTON, type, NAME); sfs = getmntentry(name, NULL, MNTON, NAME);
if (sfs == NULL) if (sfs == NULL)
sfs = getmntentry(name, NULL, MNTFROM, type, NAME); sfs = getmntentry(name, NULL, MNTFROM, NAME);
return (sfs); return (sfs);
} }