Merge from Lite2

- use new getvfsbyname() interface and mount(2) interface

**DANGER WILL ROBINSON!!**  You must be running a -current kernel
from within a week or so in order for this to work!
This commit is contained in:
Peter Wemm 1997-03-11 12:28:00 +00:00
parent e7b6972097
commit c06fe0a05e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=23678
14 changed files with 298 additions and 312 deletions

View File

@ -1,8 +1,9 @@
# @(#)Makefile 8.5 (Berkeley) 3/27/94 # @(#)Makefile 8.6 (Berkeley) 5/8/95
PROG= mount PROG= mount
SRCS= mount.c mount_ufs.c getmntopts.c SRCS= mount.c mount_ufs.c getmntopts.c vfslist.c
MAN8= mount.8 MAN8= mount.8
# We do NOT install the getmntopts.3 man page. # We do NOT install the getmntopts.3 man page.
CFLAGS+= -D_NEW_VFSCONF
.include <bsd.prog.mk> .include <bsd.prog.mk>

View File

@ -29,9 +29,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" @(#)getmntopts.3 8.1 (Berkeley) 3/27/94 .\" @(#)getmntopts.3 8.3 (Berkeley) 3/30/95
.\" .\"
.Dd March 27, 1994 .Dd March 30, 1995
.Dt GETMNTOPTS 3 .Dt GETMNTOPTS 3
.Os BSD 4.4 .Os BSD 4.4
.Sh NAME .Sh NAME
@ -62,7 +62,7 @@ or
.Dv m_altloc .Dv m_altloc
field of the option's table entry) field of the option's table entry)
are updated. are updated.
The flag word is not initialized by The flag words are not initialized by
.Nm getmntopt . .Nm getmntopt .
The table, The table,
.Dv mopts , .Dv mopts ,
@ -154,16 +154,21 @@ struct mntopt mopts[] = {
}; };
... ...
mntflags = 0; mntflags = mntaltflags = 0;
... ...
getmntopts(options, mopts, &mntflags) getmntopts(options, mopts, &mntflags, &mntaltflags);
... ...
.Ed .Ed
.Sh DIAGNOSTICS .Sh DIAGNOSTICS
The If the external integer variable
.Dv getmnt_silent
is non-zero then the
.Nm getmntopts .Nm getmntopts
function displays an error message and exits if an function displays an error message and exits if an
unrecognized option is encountered. unrecognized option is encountered.
By default
.Dv getmnt_silent
is zero.
.Sh SEE ALSO .Sh SEE ALSO
.Xr err 3 , .Xr err 3 ,
.Xr mount 8 .Xr mount 8

View File

@ -32,7 +32,7 @@
*/ */
#ifndef lint #ifndef lint
static char sccsid[] = "@(#)getmntopts.c 8.1 (Berkeley) 3/27/94"; static char sccsid[] = "@(#)getmntopts.c 8.3 (Berkeley) 3/29/95";
#endif /* not lint */ #endif /* not lint */
#include <sys/param.h> #include <sys/param.h>
@ -57,7 +57,7 @@ getmntopts(options, m0, flagp, altflagp)
{ {
const struct mntopt *m; const struct mntopt *m;
int negative, len; int negative, len;
char *opt, *optbuf; char *opt, *optbuf, *p;
int *thisflagp; int *thisflagp;
/* Copy option string, since it is about to be torn asunder... */ /* Copy option string, since it is about to be torn asunder... */
@ -72,6 +72,14 @@ getmntopts(options, m0, flagp, altflagp)
} else } else
negative = 0; negative = 0;
/*
* for options with assignments in them (ie. quotas)
* ignore the assignment as it's handled elsewhere
*/
p = strchr(opt, '=');
if (p)
*p = '\0';
/* Scan option table. */ /* Scan option table. */
for (m = m0; m->m_option != NULL; ++m) { for (m = m0; m->m_option != NULL; ++m) {
len = strlen(m->m_option); len = strlen(m->m_option);
@ -89,7 +97,7 @@ getmntopts(options, m0, flagp, altflagp)
*thisflagp |= m->m_flag; *thisflagp |= m->m_flag;
else else
*thisflagp &= ~m->m_flag; *thisflagp &= ~m->m_flag;
} else if(!getmnt_silent) { } else if (!getmnt_silent) {
errx(1, "-o %s: option not supported", opt); errx(1, "-o %s: option not supported", opt);
} }
} }

View File

@ -30,48 +30,48 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* @(#)mntopts.h 8.3 (Berkeley) 3/27/94 * @(#)mntopts.h 8.7 (Berkeley) 3/29/95
*/ */
struct mntopt { struct mntopt {
const char *m_option; /* option name */ const char *m_option; /* option name */
int m_inverse; /* if a negative option, eg "dev" */ int m_inverse; /* if a negative option, eg "dev" */
int m_flag; /* bit to set, eg. MNT_RDONLY */ int m_flag; /* bit to set, eg. MNT_RDONLY */
int m_altloc; /* zero if this is a real mount flag */ int m_altloc; /* 1 => set bit in altflags */
}; };
/* User-visible MNT_ flags. */ /* User-visible MNT_ flags. */
#define MOPT_ASYNC { "async", 0, MNT_ASYNC, 0 } #define MOPT_ASYNC { "async", 0, MNT_ASYNC, 0 }
#define MOPT_NOATIME { "atime", 1, MNT_NOATIME, 0 } #define MOPT_NOATIME { "atime", 1, MNT_NOATIME, 0 }
#define MOPT_NOAUTO { "auto", 1, 0, 0 }
#define MOPT_NODEV { "dev", 1, MNT_NODEV, 0 } #define MOPT_NODEV { "dev", 1, MNT_NODEV, 0 }
#define MOPT_NOEXEC { "exec", 1, MNT_NOEXEC, 0 } #define MOPT_NOEXEC { "exec", 1, MNT_NOEXEC, 0 }
#define MOPT_NOSUID { "suid", 1, MNT_NOSUID, 0 } #define MOPT_NOSUID { "suid", 1, MNT_NOSUID, 0 }
#define MOPT_RDONLY { "rdonly", 0, MNT_RDONLY, 0 } #define MOPT_RDONLY { "rdonly", 0, MNT_RDONLY, 0 }
#define MOPT_SYNC { "sync", 0, MNT_SYNCHRONOUS, 0 } #define MOPT_SYNC { "sync", 0, MNT_SYNCHRONOUS, 0 }
#define MOPT_UNION { "union", 0, MNT_UNION, 0 } #define MOPT_UNION { "union", 0, MNT_UNION, 0 }
#define MOPT_USERQUOTA { "userquota", 0, 0, 0 }
/* Skip this options without any action (needed for checkquota/quotaon) */ #define MOPT_GROUPQUOTA { "groupquota", 0, 0, 0 }
#define MOPT_UQUOTA { "userquota", 0, 0, 0 }
#define MOPT_GQUOTA { "groupquota", 0, 0, 0 }
/* Control flags. */ /* Control flags. */
#define MOPT_FORCE { "force", 0, MNT_FORCE, 0 } #define MOPT_FORCE { "force", 0, MNT_FORCE, 0 }
#define MOPT_UPDATE { "update", 0, MNT_UPDATE, 0 } #define MOPT_UPDATE { "update", 0, MNT_UPDATE, 0 }
/* Support for old-style "ro", "rw" flags. */
#define MOPT_RO { "ro", 0, MNT_RDONLY, 0 } #define MOPT_RO { "ro", 0, MNT_RDONLY, 0 }
#define MOPT_RW { "rw", 1, MNT_RDONLY, 0 } #define MOPT_RW { "rw", 1, MNT_RDONLY, 0 }
/* This is parsed by mount(8), but is ignored by specific mount_*(8)s. */
#define MOPT_AUTO { "auto", 0, 0, 0 }
#define MOPT_FSTAB_COMPAT \ #define MOPT_FSTAB_COMPAT \
MOPT_RO, \ MOPT_RO, \
MOPT_RW MOPT_RW, \
MOPT_AUTO
/* Standard options which all mounts can understand. */ /* Standard options which all mounts can understand. */
#define MOPT_STDOPTS \ #define MOPT_STDOPTS \
MOPT_USERQUOTA, \
MOPT_GROUPQUOTA, \
MOPT_FSTAB_COMPAT, \ MOPT_FSTAB_COMPAT, \
MOPT_NOATIME, \ MOPT_NOATIME, \
MOPT_NOAUTO, \
MOPT_NODEV, \ MOPT_NODEV, \
MOPT_NOEXEC, \ MOPT_NOEXEC, \
MOPT_NOSUID, \ MOPT_NOSUID, \

View File

@ -29,10 +29,10 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" @(#)mount.8 8.7 (Berkeley) 3/27/94 .\" @(#)mount.8 8.8 (Berkeley) 6/16/94
.\" $Id$ .\" $Id: mount.8,v 1.14 1997/02/22 14:32:43 peter Exp $
.\" .\"
.Dd March 27, 1994 .Dd June 16, 1994
.Dt MOUNT 8 .Dt MOUNT 8
.Os BSD 4 .Os BSD 4
.Sh NAME .Sh NAME
@ -76,10 +76,12 @@ this list is printed.
The options are as follows: The options are as follows:
.Bl -tag -width indent .Bl -tag -width indent
.It Fl a .It Fl a
Causes all filesystems listed in All the filesystems described in
.Pa /etc/fstab .Xr fstab 5
(except those with the ``noauto'' option) to be mounted. This is normally are mounted.
done during system startup. Exceptions are those marked as ``noauto'' or are excluded by the
.Fl t
flag (see below).
.It Fl d .It Fl d
Causes everything to be done except for the actual system call. Causes everything to be done except for the actual system call.
This option is useful in conjunction with the This option is useful in conjunction with the
@ -120,6 +122,10 @@ is useful on filesystems where there are large numbers of files and
performance is more critical than updating the file access time (which is performance is more critical than updating the file access time (which is
rarely ever important). This option is currently only supported on local rarely ever important). This option is currently only supported on local
filesystems. filesystems.
.It noauto
This filesystem should be skipped when mount is run with the
.Fl a
flag.
.It nodev .It nodev
Do not interpret character or block special devices on the file system. Do not interpret character or block special devices on the file system.
This option is useful for a server that has file systems containing This option is useful for a server that has file systems containing

View File

@ -38,7 +38,7 @@ static char copyright[] =
#endif /* not lint */ #endif /* not lint */
#ifndef lint #ifndef lint
static char sccsid[] = "@(#)mount.c 8.19 (Berkeley) 4/19/94"; static char sccsid[] = "@(#)mount.c 8.25 (Berkeley) 5/8/95";
#endif /* not lint */ #endif /* not lint */
#include <sys/param.h> #include <sys/param.h>
@ -50,6 +50,7 @@ static char sccsid[] = "@(#)mount.c 8.19 (Berkeley) 4/19/94";
#include <err.h> #include <err.h>
#include <errno.h> #include <errno.h>
#include <fstab.h> #include <fstab.h>
#include <pwd.h>
#include <signal.h> #include <signal.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -58,22 +59,20 @@ static char sccsid[] = "@(#)mount.c 8.19 (Berkeley) 4/19/94";
#include "pathnames.h" #include "pathnames.h"
int debug, verbose, skipvfs; int debug, verbose;
int fstab_style = 0; int fstab_style = 0;
static char *mnttype[] = INITMOUNTNAMES; int checkvfsname __P((const char *, const char **));
int badvfsname __P((const char *, const char **));
int badvfstype __P((int, const char **));
char *catopt __P((char *, const char *)); char *catopt __P((char *, const char *));
struct statfs struct statfs
*getmntpt __P((const char *)); *getmntpt __P((const char *));
int hasopt __P((const char *, const char *));
const char const char
**makevfslist __P((char *)); **makevfslist __P((char *));
void mangle __P((char *, int *, const char **)); void mangle __P((char *, int *, const char **));
int mountfs __P((const char *, const char *, const char *, int mountfs __P((const char *, const char *, const char *,
int, const char *, const char *)); int, const char *, const char *));
void prmount __P((const char *, const char *, int)); void prmount __P((struct statfs *));
void usage __P((void)); void usage __P((void));
void putfsent __P((const struct statfs *)); void putfsent __P((const struct statfs *));
@ -96,7 +95,7 @@ static struct opt {
{ MNT_RDONLY, "read-only" }, { MNT_RDONLY, "read-only" },
{ MNT_SYNCHRONOUS, "synchronous" }, { MNT_SYNCHRONOUS, "synchronous" },
{ MNT_UNION, "union" }, { MNT_UNION, "union" },
{ MNT_USER, "user mount" }, { MNT_NOATIME, "noatime" },
{ NULL } { NULL }
}; };
@ -105,7 +104,7 @@ main(argc, argv)
int argc; int argc;
char * const argv[]; char * const argv[];
{ {
const char *mntonname, **vfslist, *vfstype; const char *mntfromname, **vfslist, *vfstype;
struct fstab *fs; struct fstab *fs;
struct statfs *mntbuf; struct statfs *mntbuf;
FILE *mountdfp; FILE *mountdfp;
@ -173,9 +172,9 @@ main(argc, argv)
while ((fs = getfsent()) != NULL) { while ((fs = getfsent()) != NULL) {
if (BADTYPE(fs->fs_type)) if (BADTYPE(fs->fs_type))
continue; continue;
if (badvfsname(fs->fs_vfstype, vfslist)) if (checkvfsname(fs->fs_vfstype, vfslist))
continue; continue;
if (strstr(fs->fs_mntops, "noauto")) if (hasopt(fs->fs_mntops, "noauto"))
continue; continue;
if (mountfs(fs->fs_vfstype, fs->fs_spec, if (mountfs(fs->fs_vfstype, fs->fs_spec,
fs->fs_file, init_flags, options, fs->fs_file, init_flags, options,
@ -186,7 +185,7 @@ main(argc, argv)
if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0) if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0)
err(1, "getmntinfo"); err(1, "getmntinfo");
for (i = 0; i < mntsize; i++) { for (i = 0; i < mntsize; i++) {
if (badvfstype(mntbuf[i].f_type, vfslist)) if (checkvfsname(mntbuf[i].f_fstypename, vfslist))
continue; continue;
putfsent (&mntbuf[i]); putfsent (&mntbuf[i]);
} }
@ -195,10 +194,9 @@ main(argc, argv)
if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0) if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0)
err(1, "getmntinfo"); err(1, "getmntinfo");
for (i = 0; i < mntsize; i++) { for (i = 0; i < mntsize; i++) {
if (badvfstype(mntbuf[i].f_type, vfslist)) if (checkvfsname(mntbuf[i].f_fstypename, vfslist))
continue; continue;
prmount(mntbuf[i].f_mntfromname, prmount(&mntbuf[i]);
mntbuf[i].f_mntonname, mntbuf[i].f_flags);
} }
} }
exit(rval); exit(rval);
@ -211,25 +209,23 @@ main(argc, argv)
errx(1, errx(1,
"unknown special file or file system %s.", "unknown special file or file system %s.",
*argv); *argv);
if ((fs = getfsfile(mntbuf->f_mntonname)) == NULL) if ((fs = getfsfile(mntbuf->f_mntonname)) != NULL)
errx(1, "can't find fstab entry for %s.", mntfromname = fs->fs_spec;
*argv); else
/* If it's an update, ignore the fstab file options. */ mntfromname = mntbuf->f_mntfromname;
fs->fs_mntops = NULL; rval = mountfs(mntbuf->f_fstypename, mntfromname,
mntonname = mntbuf->f_mntonname; mntbuf->f_mntonname, init_flags, options, 0);
} else { break;
if ((fs = getfsfile(*argv)) == NULL &&
(fs = getfsspec(*argv)) == NULL)
errx(1,
"%s: unknown special file or file system.",
*argv);
if (BADTYPE(fs->fs_type))
errx(1, "%s has unknown file system type.",
*argv);
mntonname = fs->fs_file;
} }
rval = mountfs(fs->fs_vfstype, fs->fs_spec, if ((fs = getfsfile(*argv)) == NULL &&
mntonname, init_flags, options, fs->fs_mntops); (fs = getfsspec(*argv)) == NULL)
errx(1, "%s: unknown special file or file system.",
*argv);
if (BADTYPE(fs->fs_type))
errx(1, "%s has unknown file system type.",
*argv);
rval = mountfs(fs->fs_vfstype, fs->fs_spec, fs->fs_file,
init_flags, options, fs->fs_mntops);
break; break;
case 2: case 2:
/* /*
@ -262,6 +258,31 @@ main(argc, argv)
exit(rval); exit(rval);
} }
int
hasopt(mntopts, option)
const char *mntopts, *option;
{
int negative, found;
char *opt, *optbuf;
if (option[0] == 'n' && option[1] == 'o') {
negative = 1;
option += 2;
} else
negative = 0;
optbuf = strdup(mntopts);
found = 0;
for (opt = optbuf; (opt = strtok(opt, ",")) != NULL; opt = NULL) {
if (opt[0] == 'n' && opt[1] == 'o') {
if (!strcasecmp(opt + 2, option))
found = negative;
} else if (!strcasecmp(opt, option))
found = !negative;
}
free(optbuf);
return (found);
}
int int
mountfs(vfstype, spec, name, flags, options, mntopts) mountfs(vfstype, spec, name, flags, options, mntopts)
const char *vfstype, *spec, *name, *options, *mntopts; const char *vfstype, *spec, *name, *options, *mntopts;
@ -296,12 +317,15 @@ mountfs(vfstype, spec, name, flags, options, mntopts)
name = mntpath; name = mntpath;
if (options == NULL) { if (mntopts == NULL)
if (*mntopts == '\0')
options = "rw";
else
options = mntopts;
mntopts = ""; mntopts = "";
if (options == NULL) {
if (*mntopts == '\0') {
options = "rw";
} else {
options = mntopts;
mntopts = "";
}
} }
optbuf = catopt(strdup(mntopts), options); optbuf = catopt(strdup(mntopts), options);
@ -387,15 +411,13 @@ mountfs(vfstype, spec, name, flags, options, mntopts)
if (verbose) { if (verbose) {
if (statfs(name, &sf) < 0) { if (statfs(name, &sf) < 0) {
warn("%s", name); warn("statfs %s", name);
return (1); return (1);
} }
if (fstab_style) if (fstab_style)
putfsent (&sf); putfsent (&sf);
else else
prmount (sf.f_mntfromname, prmount(&sf);
sf.f_mntonname, sf.f_flags);
} }
break; break;
} }
@ -404,21 +426,29 @@ mountfs(vfstype, spec, name, flags, options, mntopts)
} }
void void
prmount(spec, name, flags) prmount(sfp)
const char *spec, *name; struct statfs *sfp;
int flags;
{ {
int flags;
struct opt *o; struct opt *o;
struct passwd *pw;
int f; int f;
(void)printf("%s on %s", spec, name); (void)printf("%s on %s", sfp->f_mntfromname, sfp->f_mntonname);
flags &= MNT_VISFLAGMASK; flags = sfp->f_flags & MNT_VISFLAGMASK;
for (f = 0, o = optnames; flags && o->o_opt; o++) for (f = 0, o = optnames; flags && o->o_opt; o++)
if (flags & o->o_opt) { if (flags & o->o_opt) {
(void)printf("%s%s", !f++ ? " (" : ", ", o->o_name); (void)printf("%s%s", !f++ ? " (" : ", ", o->o_name);
flags &= ~o->o_opt; flags &= ~o->o_opt;
} }
if (sfp->f_owner) {
(void)printf("%smounted by ", !f++ ? " (" : ", ");
if ((pw = getpwuid(sfp->f_owner)) != NULL)
(void)printf("%s", pw->pw_name);
else
(void)printf("%d", sfp->f_owner);
}
(void)printf(f ? ")\n" : "\n"); (void)printf(f ? ")\n" : "\n");
} }
@ -437,68 +467,6 @@ getmntpt(name)
return (NULL); return (NULL);
} }
int
badvfsname(vfsname, vfslist)
const char *vfsname;
const char **vfslist;
{
if (vfslist == NULL)
return (0);
while (*vfslist != NULL) {
if (strcmp(vfsname, *vfslist) == 0)
return (skipvfs);
++vfslist;
}
return (!skipvfs);
}
int
badvfstype(vfstype, vfslist)
int vfstype;
const char **vfslist;
{
struct vfsconf *vfc;
vfc = getvfsbytype(vfstype);
if ( ! vfc )
return (0);
return (badvfsname(vfc->vfc_name, vfslist));
}
const char **
makevfslist(fslist)
char *fslist;
{
const char **av;
int i;
char *nextcp;
if (fslist == NULL)
return (NULL);
if (fslist[0] == 'n' && fslist[1] == 'o') {
fslist += 2;
skipvfs = 1;
}
for (i = 0, nextcp = fslist; *nextcp; nextcp++)
if (*nextcp == ',')
i++;
if ((av = malloc((size_t)(i + 2) * sizeof(char *))) == NULL) {
warn(NULL);
return (NULL);
}
nextcp = fslist;
i = 0;
av[i++] = nextcp;
while ((nextcp = strchr(nextcp, ',')) != NULL) {
*nextcp++ = '\0';
av[i++] = nextcp;
}
av[i++] = NULL;
return (av);
}
char * char *
catopt(s0, s1) catopt(s0, s1)
char *s0; char *s0;
@ -568,7 +536,7 @@ putfsent (ent)
printf ("%s\t%s\t%s %s", printf ("%s\t%s\t%s %s",
ent->f_mntfromname, ent->f_mntonname, ent->f_mntfromname, ent->f_mntonname,
mnttype[ent->f_type], ent->f_fstypename,
(ent->f_flags & MNT_RDONLY) ? "ro" : "rw"); (ent->f_flags & MNT_RDONLY) ? "ro" : "rw");
if (ent->f_flags & MNT_SYNCHRONOUS) if (ent->f_flags & MNT_SYNCHRONOUS)
@ -589,6 +557,9 @@ putfsent (ent)
if (ent->f_flags & MNT_ASYNC) if (ent->f_flags & MNT_ASYNC)
printf (",async"); printf (",async");
if (ent->f_flags & MNT_NOATIME)
printf (",noatime");
if (fst = getfsspec (ent->f_mntfromname)) if (fst = getfsspec (ent->f_mntfromname))
printf ("\t%u %u\n", fst->fs_freq, fst->fs_passno); printf ("\t%u %u\n", fst->fs_freq, fst->fs_passno);
else if (fst = getfsfile (ent->f_mntonname)) else if (fst = getfsfile (ent->f_mntonname))

View File

@ -38,7 +38,7 @@ static char copyright[] =
#endif /* not lint */ #endif /* not lint */
#ifndef lint #ifndef lint
static char sccsid[] = "@(#)mount_ufs.c 8.2 (Berkeley) 3/27/94"; static char sccsid[] = "@(#)mount_ufs.c 8.4 (Berkeley) 4/26/95";
#endif /* not lint */ #endif /* not lint */
#include <sys/param.h> #include <sys/param.h>
@ -51,6 +51,8 @@ static char sccsid[] = "@(#)mount_ufs.c 8.2 (Berkeley) 3/27/94";
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <ufs/ufs/ufsmount.h>
#include "mntopts.h" #include "mntopts.h"
void ufs_usage __P((void)); void ufs_usage __P((void));
@ -61,8 +63,7 @@ static struct mntopt mopts[] = {
MOPT_SYNC, MOPT_SYNC,
MOPT_FORCE, MOPT_FORCE,
MOPT_UPDATE, MOPT_UPDATE,
MOPT_UQUOTA, MOPT_FORCE,
MOPT_GQUOTA,
{ NULL } { NULL }
}; };
@ -75,7 +76,8 @@ mount_ufs(argc, argv)
struct ufs_args args; struct ufs_args args;
int ch, mntflags; int ch, mntflags;
char *fs_name; char *fs_name;
struct vfsconf *vfc; struct vfsconf vfc;
int error = 0;
mntflags = 0; mntflags = 0;
optind = optreset = 1; /* Reset for parse of new argv. */ optind = optreset = 1; /* Reset for parse of new argv. */
@ -104,21 +106,21 @@ mount_ufs(argc, argv)
else else
args.export.ex_flags = 0; args.export.ex_flags = 0;
setvfsent(0); error = getvfsbyname("ufs", &vfc);
if(!(vfc = getvfsbyname("ufs"))) { if (error && vfsisloadable("ufs")) {
if(vfsisloadable("ufs")) { if (vfsload("ufs")) {
if(vfsload("ufs")) { warn("vfsload(ufs)");
warn("vfsload(\"ufs\")"); return (1);
return 1;
}
endvfsent(); /* flush old table */
vfc = getvfsbyname("ufs");
} else {
/*warnx("ufs: filesystem not found");*/
} }
endvfsent(); /* flush old table */
error = getvfsbyname("ufs", &vfc);
}
if (error) {
warnx("ufs filesystem is not available");
return (1);
} }
if (mount(vfc ? vfc->vfc_index : MOUNT_UFS, fs_name, mntflags, &args) < 0) { if (mount(vfc.vfc_name, fs_name, mntflags, &args) < 0) {
(void)fprintf(stderr, "%s on %s: ", args.fspec, fs_name); (void)fprintf(stderr, "%s on %s: ", args.fspec, fs_name);
switch (errno) { switch (errno) {
case EMFILE: case EMFILE:

View File

@ -1,8 +1,9 @@
# @(#)Makefile 8.5 (Berkeley) 3/27/94 # @(#)Makefile 8.6 (Berkeley) 5/8/95
PROG= mount PROG= mount
SRCS= mount.c mount_ufs.c getmntopts.c SRCS= mount.c mount_ufs.c getmntopts.c vfslist.c
MAN8= mount.8 MAN8= mount.8
# We do NOT install the getmntopts.3 man page. # We do NOT install the getmntopts.3 man page.
CFLAGS+= -D_NEW_VFSCONF
.include <bsd.prog.mk> .include <bsd.prog.mk>

View File

@ -29,9 +29,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" @(#)getmntopts.3 8.1 (Berkeley) 3/27/94 .\" @(#)getmntopts.3 8.3 (Berkeley) 3/30/95
.\" .\"
.Dd March 27, 1994 .Dd March 30, 1995
.Dt GETMNTOPTS 3 .Dt GETMNTOPTS 3
.Os BSD 4.4 .Os BSD 4.4
.Sh NAME .Sh NAME
@ -62,7 +62,7 @@ or
.Dv m_altloc .Dv m_altloc
field of the option's table entry) field of the option's table entry)
are updated. are updated.
The flag word is not initialized by The flag words are not initialized by
.Nm getmntopt . .Nm getmntopt .
The table, The table,
.Dv mopts , .Dv mopts ,
@ -154,16 +154,21 @@ struct mntopt mopts[] = {
}; };
... ...
mntflags = 0; mntflags = mntaltflags = 0;
... ...
getmntopts(options, mopts, &mntflags) getmntopts(options, mopts, &mntflags, &mntaltflags);
... ...
.Ed .Ed
.Sh DIAGNOSTICS .Sh DIAGNOSTICS
The If the external integer variable
.Dv getmnt_silent
is non-zero then the
.Nm getmntopts .Nm getmntopts
function displays an error message and exits if an function displays an error message and exits if an
unrecognized option is encountered. unrecognized option is encountered.
By default
.Dv getmnt_silent
is zero.
.Sh SEE ALSO .Sh SEE ALSO
.Xr err 3 , .Xr err 3 ,
.Xr mount 8 .Xr mount 8

View File

@ -32,7 +32,7 @@
*/ */
#ifndef lint #ifndef lint
static char sccsid[] = "@(#)getmntopts.c 8.1 (Berkeley) 3/27/94"; static char sccsid[] = "@(#)getmntopts.c 8.3 (Berkeley) 3/29/95";
#endif /* not lint */ #endif /* not lint */
#include <sys/param.h> #include <sys/param.h>
@ -57,7 +57,7 @@ getmntopts(options, m0, flagp, altflagp)
{ {
const struct mntopt *m; const struct mntopt *m;
int negative, len; int negative, len;
char *opt, *optbuf; char *opt, *optbuf, *p;
int *thisflagp; int *thisflagp;
/* Copy option string, since it is about to be torn asunder... */ /* Copy option string, since it is about to be torn asunder... */
@ -72,6 +72,14 @@ getmntopts(options, m0, flagp, altflagp)
} else } else
negative = 0; negative = 0;
/*
* for options with assignments in them (ie. quotas)
* ignore the assignment as it's handled elsewhere
*/
p = strchr(opt, '=');
if (p)
*p = '\0';
/* Scan option table. */ /* Scan option table. */
for (m = m0; m->m_option != NULL; ++m) { for (m = m0; m->m_option != NULL; ++m) {
len = strlen(m->m_option); len = strlen(m->m_option);
@ -89,7 +97,7 @@ getmntopts(options, m0, flagp, altflagp)
*thisflagp |= m->m_flag; *thisflagp |= m->m_flag;
else else
*thisflagp &= ~m->m_flag; *thisflagp &= ~m->m_flag;
} else if(!getmnt_silent) { } else if (!getmnt_silent) {
errx(1, "-o %s: option not supported", opt); errx(1, "-o %s: option not supported", opt);
} }
} }

View File

@ -30,48 +30,48 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* @(#)mntopts.h 8.3 (Berkeley) 3/27/94 * @(#)mntopts.h 8.7 (Berkeley) 3/29/95
*/ */
struct mntopt { struct mntopt {
const char *m_option; /* option name */ const char *m_option; /* option name */
int m_inverse; /* if a negative option, eg "dev" */ int m_inverse; /* if a negative option, eg "dev" */
int m_flag; /* bit to set, eg. MNT_RDONLY */ int m_flag; /* bit to set, eg. MNT_RDONLY */
int m_altloc; /* zero if this is a real mount flag */ int m_altloc; /* 1 => set bit in altflags */
}; };
/* User-visible MNT_ flags. */ /* User-visible MNT_ flags. */
#define MOPT_ASYNC { "async", 0, MNT_ASYNC, 0 } #define MOPT_ASYNC { "async", 0, MNT_ASYNC, 0 }
#define MOPT_NOATIME { "atime", 1, MNT_NOATIME, 0 } #define MOPT_NOATIME { "atime", 1, MNT_NOATIME, 0 }
#define MOPT_NOAUTO { "auto", 1, 0, 0 }
#define MOPT_NODEV { "dev", 1, MNT_NODEV, 0 } #define MOPT_NODEV { "dev", 1, MNT_NODEV, 0 }
#define MOPT_NOEXEC { "exec", 1, MNT_NOEXEC, 0 } #define MOPT_NOEXEC { "exec", 1, MNT_NOEXEC, 0 }
#define MOPT_NOSUID { "suid", 1, MNT_NOSUID, 0 } #define MOPT_NOSUID { "suid", 1, MNT_NOSUID, 0 }
#define MOPT_RDONLY { "rdonly", 0, MNT_RDONLY, 0 } #define MOPT_RDONLY { "rdonly", 0, MNT_RDONLY, 0 }
#define MOPT_SYNC { "sync", 0, MNT_SYNCHRONOUS, 0 } #define MOPT_SYNC { "sync", 0, MNT_SYNCHRONOUS, 0 }
#define MOPT_UNION { "union", 0, MNT_UNION, 0 } #define MOPT_UNION { "union", 0, MNT_UNION, 0 }
#define MOPT_USERQUOTA { "userquota", 0, 0, 0 }
/* Skip this options without any action (needed for checkquota/quotaon) */ #define MOPT_GROUPQUOTA { "groupquota", 0, 0, 0 }
#define MOPT_UQUOTA { "userquota", 0, 0, 0 }
#define MOPT_GQUOTA { "groupquota", 0, 0, 0 }
/* Control flags. */ /* Control flags. */
#define MOPT_FORCE { "force", 0, MNT_FORCE, 0 } #define MOPT_FORCE { "force", 0, MNT_FORCE, 0 }
#define MOPT_UPDATE { "update", 0, MNT_UPDATE, 0 } #define MOPT_UPDATE { "update", 0, MNT_UPDATE, 0 }
/* Support for old-style "ro", "rw" flags. */
#define MOPT_RO { "ro", 0, MNT_RDONLY, 0 } #define MOPT_RO { "ro", 0, MNT_RDONLY, 0 }
#define MOPT_RW { "rw", 1, MNT_RDONLY, 0 } #define MOPT_RW { "rw", 1, MNT_RDONLY, 0 }
/* This is parsed by mount(8), but is ignored by specific mount_*(8)s. */
#define MOPT_AUTO { "auto", 0, 0, 0 }
#define MOPT_FSTAB_COMPAT \ #define MOPT_FSTAB_COMPAT \
MOPT_RO, \ MOPT_RO, \
MOPT_RW MOPT_RW, \
MOPT_AUTO
/* Standard options which all mounts can understand. */ /* Standard options which all mounts can understand. */
#define MOPT_STDOPTS \ #define MOPT_STDOPTS \
MOPT_USERQUOTA, \
MOPT_GROUPQUOTA, \
MOPT_FSTAB_COMPAT, \ MOPT_FSTAB_COMPAT, \
MOPT_NOATIME, \ MOPT_NOATIME, \
MOPT_NOAUTO, \
MOPT_NODEV, \ MOPT_NODEV, \
MOPT_NOEXEC, \ MOPT_NOEXEC, \
MOPT_NOSUID, \ MOPT_NOSUID, \

View File

@ -29,10 +29,10 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" @(#)mount.8 8.7 (Berkeley) 3/27/94 .\" @(#)mount.8 8.8 (Berkeley) 6/16/94
.\" $Id$ .\" $Id: mount.8,v 1.14 1997/02/22 14:32:43 peter Exp $
.\" .\"
.Dd March 27, 1994 .Dd June 16, 1994
.Dt MOUNT 8 .Dt MOUNT 8
.Os BSD 4 .Os BSD 4
.Sh NAME .Sh NAME
@ -76,10 +76,12 @@ this list is printed.
The options are as follows: The options are as follows:
.Bl -tag -width indent .Bl -tag -width indent
.It Fl a .It Fl a
Causes all filesystems listed in All the filesystems described in
.Pa /etc/fstab .Xr fstab 5
(except those with the ``noauto'' option) to be mounted. This is normally are mounted.
done during system startup. Exceptions are those marked as ``noauto'' or are excluded by the
.Fl t
flag (see below).
.It Fl d .It Fl d
Causes everything to be done except for the actual system call. Causes everything to be done except for the actual system call.
This option is useful in conjunction with the This option is useful in conjunction with the
@ -120,6 +122,10 @@ is useful on filesystems where there are large numbers of files and
performance is more critical than updating the file access time (which is performance is more critical than updating the file access time (which is
rarely ever important). This option is currently only supported on local rarely ever important). This option is currently only supported on local
filesystems. filesystems.
.It noauto
This filesystem should be skipped when mount is run with the
.Fl a
flag.
.It nodev .It nodev
Do not interpret character or block special devices on the file system. Do not interpret character or block special devices on the file system.
This option is useful for a server that has file systems containing This option is useful for a server that has file systems containing

View File

@ -38,7 +38,7 @@ static char copyright[] =
#endif /* not lint */ #endif /* not lint */
#ifndef lint #ifndef lint
static char sccsid[] = "@(#)mount.c 8.19 (Berkeley) 4/19/94"; static char sccsid[] = "@(#)mount.c 8.25 (Berkeley) 5/8/95";
#endif /* not lint */ #endif /* not lint */
#include <sys/param.h> #include <sys/param.h>
@ -50,6 +50,7 @@ static char sccsid[] = "@(#)mount.c 8.19 (Berkeley) 4/19/94";
#include <err.h> #include <err.h>
#include <errno.h> #include <errno.h>
#include <fstab.h> #include <fstab.h>
#include <pwd.h>
#include <signal.h> #include <signal.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -58,22 +59,20 @@ static char sccsid[] = "@(#)mount.c 8.19 (Berkeley) 4/19/94";
#include "pathnames.h" #include "pathnames.h"
int debug, verbose, skipvfs; int debug, verbose;
int fstab_style = 0; int fstab_style = 0;
static char *mnttype[] = INITMOUNTNAMES; int checkvfsname __P((const char *, const char **));
int badvfsname __P((const char *, const char **));
int badvfstype __P((int, const char **));
char *catopt __P((char *, const char *)); char *catopt __P((char *, const char *));
struct statfs struct statfs
*getmntpt __P((const char *)); *getmntpt __P((const char *));
int hasopt __P((const char *, const char *));
const char const char
**makevfslist __P((char *)); **makevfslist __P((char *));
void mangle __P((char *, int *, const char **)); void mangle __P((char *, int *, const char **));
int mountfs __P((const char *, const char *, const char *, int mountfs __P((const char *, const char *, const char *,
int, const char *, const char *)); int, const char *, const char *));
void prmount __P((const char *, const char *, int)); void prmount __P((struct statfs *));
void usage __P((void)); void usage __P((void));
void putfsent __P((const struct statfs *)); void putfsent __P((const struct statfs *));
@ -96,7 +95,7 @@ static struct opt {
{ MNT_RDONLY, "read-only" }, { MNT_RDONLY, "read-only" },
{ MNT_SYNCHRONOUS, "synchronous" }, { MNT_SYNCHRONOUS, "synchronous" },
{ MNT_UNION, "union" }, { MNT_UNION, "union" },
{ MNT_USER, "user mount" }, { MNT_NOATIME, "noatime" },
{ NULL } { NULL }
}; };
@ -105,7 +104,7 @@ main(argc, argv)
int argc; int argc;
char * const argv[]; char * const argv[];
{ {
const char *mntonname, **vfslist, *vfstype; const char *mntfromname, **vfslist, *vfstype;
struct fstab *fs; struct fstab *fs;
struct statfs *mntbuf; struct statfs *mntbuf;
FILE *mountdfp; FILE *mountdfp;
@ -173,9 +172,9 @@ main(argc, argv)
while ((fs = getfsent()) != NULL) { while ((fs = getfsent()) != NULL) {
if (BADTYPE(fs->fs_type)) if (BADTYPE(fs->fs_type))
continue; continue;
if (badvfsname(fs->fs_vfstype, vfslist)) if (checkvfsname(fs->fs_vfstype, vfslist))
continue; continue;
if (strstr(fs->fs_mntops, "noauto")) if (hasopt(fs->fs_mntops, "noauto"))
continue; continue;
if (mountfs(fs->fs_vfstype, fs->fs_spec, if (mountfs(fs->fs_vfstype, fs->fs_spec,
fs->fs_file, init_flags, options, fs->fs_file, init_flags, options,
@ -186,7 +185,7 @@ main(argc, argv)
if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0) if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0)
err(1, "getmntinfo"); err(1, "getmntinfo");
for (i = 0; i < mntsize; i++) { for (i = 0; i < mntsize; i++) {
if (badvfstype(mntbuf[i].f_type, vfslist)) if (checkvfsname(mntbuf[i].f_fstypename, vfslist))
continue; continue;
putfsent (&mntbuf[i]); putfsent (&mntbuf[i]);
} }
@ -195,10 +194,9 @@ main(argc, argv)
if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0) if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0)
err(1, "getmntinfo"); err(1, "getmntinfo");
for (i = 0; i < mntsize; i++) { for (i = 0; i < mntsize; i++) {
if (badvfstype(mntbuf[i].f_type, vfslist)) if (checkvfsname(mntbuf[i].f_fstypename, vfslist))
continue; continue;
prmount(mntbuf[i].f_mntfromname, prmount(&mntbuf[i]);
mntbuf[i].f_mntonname, mntbuf[i].f_flags);
} }
} }
exit(rval); exit(rval);
@ -211,25 +209,23 @@ main(argc, argv)
errx(1, errx(1,
"unknown special file or file system %s.", "unknown special file or file system %s.",
*argv); *argv);
if ((fs = getfsfile(mntbuf->f_mntonname)) == NULL) if ((fs = getfsfile(mntbuf->f_mntonname)) != NULL)
errx(1, "can't find fstab entry for %s.", mntfromname = fs->fs_spec;
*argv); else
/* If it's an update, ignore the fstab file options. */ mntfromname = mntbuf->f_mntfromname;
fs->fs_mntops = NULL; rval = mountfs(mntbuf->f_fstypename, mntfromname,
mntonname = mntbuf->f_mntonname; mntbuf->f_mntonname, init_flags, options, 0);
} else { break;
if ((fs = getfsfile(*argv)) == NULL &&
(fs = getfsspec(*argv)) == NULL)
errx(1,
"%s: unknown special file or file system.",
*argv);
if (BADTYPE(fs->fs_type))
errx(1, "%s has unknown file system type.",
*argv);
mntonname = fs->fs_file;
} }
rval = mountfs(fs->fs_vfstype, fs->fs_spec, if ((fs = getfsfile(*argv)) == NULL &&
mntonname, init_flags, options, fs->fs_mntops); (fs = getfsspec(*argv)) == NULL)
errx(1, "%s: unknown special file or file system.",
*argv);
if (BADTYPE(fs->fs_type))
errx(1, "%s has unknown file system type.",
*argv);
rval = mountfs(fs->fs_vfstype, fs->fs_spec, fs->fs_file,
init_flags, options, fs->fs_mntops);
break; break;
case 2: case 2:
/* /*
@ -262,6 +258,31 @@ main(argc, argv)
exit(rval); exit(rval);
} }
int
hasopt(mntopts, option)
const char *mntopts, *option;
{
int negative, found;
char *opt, *optbuf;
if (option[0] == 'n' && option[1] == 'o') {
negative = 1;
option += 2;
} else
negative = 0;
optbuf = strdup(mntopts);
found = 0;
for (opt = optbuf; (opt = strtok(opt, ",")) != NULL; opt = NULL) {
if (opt[0] == 'n' && opt[1] == 'o') {
if (!strcasecmp(opt + 2, option))
found = negative;
} else if (!strcasecmp(opt, option))
found = !negative;
}
free(optbuf);
return (found);
}
int int
mountfs(vfstype, spec, name, flags, options, mntopts) mountfs(vfstype, spec, name, flags, options, mntopts)
const char *vfstype, *spec, *name, *options, *mntopts; const char *vfstype, *spec, *name, *options, *mntopts;
@ -296,12 +317,15 @@ mountfs(vfstype, spec, name, flags, options, mntopts)
name = mntpath; name = mntpath;
if (options == NULL) { if (mntopts == NULL)
if (*mntopts == '\0')
options = "rw";
else
options = mntopts;
mntopts = ""; mntopts = "";
if (options == NULL) {
if (*mntopts == '\0') {
options = "rw";
} else {
options = mntopts;
mntopts = "";
}
} }
optbuf = catopt(strdup(mntopts), options); optbuf = catopt(strdup(mntopts), options);
@ -387,15 +411,13 @@ mountfs(vfstype, spec, name, flags, options, mntopts)
if (verbose) { if (verbose) {
if (statfs(name, &sf) < 0) { if (statfs(name, &sf) < 0) {
warn("%s", name); warn("statfs %s", name);
return (1); return (1);
} }
if (fstab_style) if (fstab_style)
putfsent (&sf); putfsent (&sf);
else else
prmount (sf.f_mntfromname, prmount(&sf);
sf.f_mntonname, sf.f_flags);
} }
break; break;
} }
@ -404,21 +426,29 @@ mountfs(vfstype, spec, name, flags, options, mntopts)
} }
void void
prmount(spec, name, flags) prmount(sfp)
const char *spec, *name; struct statfs *sfp;
int flags;
{ {
int flags;
struct opt *o; struct opt *o;
struct passwd *pw;
int f; int f;
(void)printf("%s on %s", spec, name); (void)printf("%s on %s", sfp->f_mntfromname, sfp->f_mntonname);
flags &= MNT_VISFLAGMASK; flags = sfp->f_flags & MNT_VISFLAGMASK;
for (f = 0, o = optnames; flags && o->o_opt; o++) for (f = 0, o = optnames; flags && o->o_opt; o++)
if (flags & o->o_opt) { if (flags & o->o_opt) {
(void)printf("%s%s", !f++ ? " (" : ", ", o->o_name); (void)printf("%s%s", !f++ ? " (" : ", ", o->o_name);
flags &= ~o->o_opt; flags &= ~o->o_opt;
} }
if (sfp->f_owner) {
(void)printf("%smounted by ", !f++ ? " (" : ", ");
if ((pw = getpwuid(sfp->f_owner)) != NULL)
(void)printf("%s", pw->pw_name);
else
(void)printf("%d", sfp->f_owner);
}
(void)printf(f ? ")\n" : "\n"); (void)printf(f ? ")\n" : "\n");
} }
@ -437,68 +467,6 @@ getmntpt(name)
return (NULL); return (NULL);
} }
int
badvfsname(vfsname, vfslist)
const char *vfsname;
const char **vfslist;
{
if (vfslist == NULL)
return (0);
while (*vfslist != NULL) {
if (strcmp(vfsname, *vfslist) == 0)
return (skipvfs);
++vfslist;
}
return (!skipvfs);
}
int
badvfstype(vfstype, vfslist)
int vfstype;
const char **vfslist;
{
struct vfsconf *vfc;
vfc = getvfsbytype(vfstype);
if ( ! vfc )
return (0);
return (badvfsname(vfc->vfc_name, vfslist));
}
const char **
makevfslist(fslist)
char *fslist;
{
const char **av;
int i;
char *nextcp;
if (fslist == NULL)
return (NULL);
if (fslist[0] == 'n' && fslist[1] == 'o') {
fslist += 2;
skipvfs = 1;
}
for (i = 0, nextcp = fslist; *nextcp; nextcp++)
if (*nextcp == ',')
i++;
if ((av = malloc((size_t)(i + 2) * sizeof(char *))) == NULL) {
warn(NULL);
return (NULL);
}
nextcp = fslist;
i = 0;
av[i++] = nextcp;
while ((nextcp = strchr(nextcp, ',')) != NULL) {
*nextcp++ = '\0';
av[i++] = nextcp;
}
av[i++] = NULL;
return (av);
}
char * char *
catopt(s0, s1) catopt(s0, s1)
char *s0; char *s0;
@ -568,7 +536,7 @@ putfsent (ent)
printf ("%s\t%s\t%s %s", printf ("%s\t%s\t%s %s",
ent->f_mntfromname, ent->f_mntonname, ent->f_mntfromname, ent->f_mntonname,
mnttype[ent->f_type], ent->f_fstypename,
(ent->f_flags & MNT_RDONLY) ? "ro" : "rw"); (ent->f_flags & MNT_RDONLY) ? "ro" : "rw");
if (ent->f_flags & MNT_SYNCHRONOUS) if (ent->f_flags & MNT_SYNCHRONOUS)
@ -589,6 +557,9 @@ putfsent (ent)
if (ent->f_flags & MNT_ASYNC) if (ent->f_flags & MNT_ASYNC)
printf (",async"); printf (",async");
if (ent->f_flags & MNT_NOATIME)
printf (",noatime");
if (fst = getfsspec (ent->f_mntfromname)) if (fst = getfsspec (ent->f_mntfromname))
printf ("\t%u %u\n", fst->fs_freq, fst->fs_passno); printf ("\t%u %u\n", fst->fs_freq, fst->fs_passno);
else if (fst = getfsfile (ent->f_mntonname)) else if (fst = getfsfile (ent->f_mntonname))

View File

@ -38,7 +38,7 @@ static char copyright[] =
#endif /* not lint */ #endif /* not lint */
#ifndef lint #ifndef lint
static char sccsid[] = "@(#)mount_ufs.c 8.2 (Berkeley) 3/27/94"; static char sccsid[] = "@(#)mount_ufs.c 8.4 (Berkeley) 4/26/95";
#endif /* not lint */ #endif /* not lint */
#include <sys/param.h> #include <sys/param.h>
@ -51,6 +51,8 @@ static char sccsid[] = "@(#)mount_ufs.c 8.2 (Berkeley) 3/27/94";
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <ufs/ufs/ufsmount.h>
#include "mntopts.h" #include "mntopts.h"
void ufs_usage __P((void)); void ufs_usage __P((void));
@ -61,8 +63,7 @@ static struct mntopt mopts[] = {
MOPT_SYNC, MOPT_SYNC,
MOPT_FORCE, MOPT_FORCE,
MOPT_UPDATE, MOPT_UPDATE,
MOPT_UQUOTA, MOPT_FORCE,
MOPT_GQUOTA,
{ NULL } { NULL }
}; };
@ -75,7 +76,8 @@ mount_ufs(argc, argv)
struct ufs_args args; struct ufs_args args;
int ch, mntflags; int ch, mntflags;
char *fs_name; char *fs_name;
struct vfsconf *vfc; struct vfsconf vfc;
int error = 0;
mntflags = 0; mntflags = 0;
optind = optreset = 1; /* Reset for parse of new argv. */ optind = optreset = 1; /* Reset for parse of new argv. */
@ -104,21 +106,21 @@ mount_ufs(argc, argv)
else else
args.export.ex_flags = 0; args.export.ex_flags = 0;
setvfsent(0); error = getvfsbyname("ufs", &vfc);
if(!(vfc = getvfsbyname("ufs"))) { if (error && vfsisloadable("ufs")) {
if(vfsisloadable("ufs")) { if (vfsload("ufs")) {
if(vfsload("ufs")) { warn("vfsload(ufs)");
warn("vfsload(\"ufs\")"); return (1);
return 1;
}
endvfsent(); /* flush old table */
vfc = getvfsbyname("ufs");
} else {
/*warnx("ufs: filesystem not found");*/
} }
endvfsent(); /* flush old table */
error = getvfsbyname("ufs", &vfc);
}
if (error) {
warnx("ufs filesystem is not available");
return (1);
} }
if (mount(vfc ? vfc->vfc_index : MOUNT_UFS, fs_name, mntflags, &args) < 0) { if (mount(vfc.vfc_name, fs_name, mntflags, &args) < 0) {
(void)fprintf(stderr, "%s on %s: ", args.fspec, fs_name); (void)fprintf(stderr, "%s on %s: ", args.fspec, fs_name);
switch (errno) { switch (errno) {
case EMFILE: case EMFILE: