remove FFS mounting code from mount(8); there are now _no_ 'internal' mount
types. when using mount(8) with '-a', do _NOT_ remount file systems that have been mounted once already. (This cannot be 100% precisely determined (thanks to mfs, union fs, and similar file systems which don't use a 'real' mounted-from node), and changed options cannot be updated with mount -a. however, options wouldn't be updated with the old mount -a anyway, and this solves several annoyances.
This commit is contained in:
parent
e85da9ab29
commit
723ca902ed
|
@ -1,8 +1,8 @@
|
|||
# $NetBSD: Makefile,v 1.9 1995/03/18 14:56:53 cgd Exp $
|
||||
# $NetBSD: Makefile,v 1.10 1995/07/12 03:45:09 cgd Exp $
|
||||
# @(#)Makefile 8.5 (Berkeley) 3/27/94
|
||||
|
||||
PROG= mount
|
||||
SRCS= mount.c mount_ufs.c getmntopts.c
|
||||
SRCS= mount.c getmntopts.c
|
||||
MAN= mount.8
|
||||
# We do NOT install the getmntopts.3 man page.
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: mount.8,v 1.9 1995/04/30 20:42:12 briggs Exp $
|
||||
.\" $NetBSD: mount.8,v 1.10 1995/07/12 03:45:12 cgd Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1980, 1989, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
|
@ -42,24 +42,23 @@
|
|||
.Sh SYNOPSIS
|
||||
.Nm mount
|
||||
.Op Fl adfruvw
|
||||
.Op Fl t Ar ufs | lfs | external_type
|
||||
.Op Fl t Ar type
|
||||
.Nm mount
|
||||
.Op Fl dfruvw
|
||||
.Ar special | node
|
||||
.Nm mount
|
||||
.Op Fl dfruvw
|
||||
.Op Fl o Ar options
|
||||
.Op Fl t Ar ufs | lfs | external_type
|
||||
.Op Fl t Ar type
|
||||
.Ar special node
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm mount
|
||||
command
|
||||
calls the
|
||||
.Xr mount 2
|
||||
system call to prepare and graft a
|
||||
.Ar "special device"
|
||||
or the remote node (rhost:path) on to the file system tree at the point
|
||||
command invokes a filesystem-specific program to prepare
|
||||
and graft the
|
||||
.Ar special
|
||||
device or remote node (rhost:path) on to the file system
|
||||
tree at the point
|
||||
.Ar node .
|
||||
If either
|
||||
.Ar special
|
||||
|
@ -76,8 +75,21 @@ this list is printed.
|
|||
.Pp
|
||||
The options are as follows:
|
||||
.Bl -tag -width indent
|
||||
.It Fl a
|
||||
Causes
|
||||
.Nm mount
|
||||
to try to mount all of the file systems listed in the
|
||||
.Xr fstab
|
||||
table except those for which the
|
||||
.Dq noauto
|
||||
option is specified.
|
||||
If a file system (other than the root file system) is already
|
||||
mounted,
|
||||
.Nm mount
|
||||
will not try to mount it again.
|
||||
.It Fl d
|
||||
Causes everything to be done except for the actual system call.
|
||||
Causes everything to be done except for the invocation of
|
||||
the filesystem-specific program.
|
||||
This option is useful in conjunction with the
|
||||
.Fl v
|
||||
flag to
|
||||
|
@ -138,8 +150,7 @@ directory is then accessed.
|
|||
All creates are done in the mounted filesystem.
|
||||
.El
|
||||
.Pp
|
||||
Any additional options specific to a filesystem type that is not
|
||||
one of the internally known types (see the
|
||||
Any additional options specific to a given filesystem type (see the
|
||||
.Fl t
|
||||
option) may be passed as a comma separated list; these options are
|
||||
distinguished by a leading
|
||||
|
@ -165,12 +176,12 @@ The same as the
|
|||
argument to the
|
||||
.Fl o
|
||||
option.
|
||||
.It Fl t Ar "ufs \\*(Ba lfs \\*(Ba external type"
|
||||
.It Fl t Ar type
|
||||
The argument following the
|
||||
.Fl t
|
||||
is used to indicate the file system type.
|
||||
The type
|
||||
.Ar ufs
|
||||
.Ar ffs
|
||||
is the default.
|
||||
The \fI-t\fP option can be used
|
||||
to indicate that the actions should only be taken on
|
||||
|
@ -193,8 +204,8 @@ mounts all filesystems except those of type
|
|||
and
|
||||
.Tn MFS .
|
||||
.Pp
|
||||
If the type is not one of the internally known types,
|
||||
mount will attempt to execute a program in
|
||||
.Nm Mount
|
||||
will attempt to execute a program in
|
||||
.Pa /sbin/mount_ Ns Em XXX
|
||||
where
|
||||
.Em XXX
|
||||
|
@ -232,9 +243,14 @@ option.
|
|||
Verbose mode.
|
||||
.It Fl w
|
||||
The file system object is to be read and write.
|
||||
.El
|
||||
.Pp
|
||||
The options specific to NFS filesystems are described in the
|
||||
.Xr mount_nfs 8
|
||||
The options specific to the various file system types are
|
||||
described in the manual pages for those file systems'
|
||||
.Nm mount_XXX
|
||||
commands. For instance the options specific to Berkekely
|
||||
Fast File Systems are described in the
|
||||
.Xr mount_ffs 8
|
||||
manual page.
|
||||
.Sh FILES
|
||||
.Bl -tag -width /etc/fstab -compact
|
||||
|
@ -247,6 +263,7 @@ file system table
|
|||
.Xr mount_ados 8 ,
|
||||
.Xr mount_cd9660 8 ,
|
||||
.Xr mount_fdesc 8 ,
|
||||
.Xr mount_ffs 8 ,
|
||||
.Xr mount_kernfs 8 ,
|
||||
.Xr mount_lfs 8 ,
|
||||
.Xr mount_mfs 8 ,
|
||||
|
@ -258,8 +275,6 @@ file system table
|
|||
.Xr mount_umap 8 ,
|
||||
.Xr mount_union 8 ,
|
||||
.Xr umount 8
|
||||
.Sh BUGS
|
||||
It is possible for a corrupted file system to cause a crash.
|
||||
.Sh HISTORY
|
||||
A
|
||||
.Nm mount
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mount.c,v 1.20 1995/07/04 23:41:33 ghudson Exp $ */
|
||||
/* $NetBSD: mount.c,v 1.21 1995/07/12 03:45:14 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1989, 1993, 1994
|
||||
|
@ -43,7 +43,7 @@ static char copyright[] =
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)mount.c 8.19 (Berkeley) 4/19/94";
|
||||
#else
|
||||
static char rcsid[] = "$NetBSD: mount.c,v 1.20 1995/07/04 23:41:33 ghudson Exp $";
|
||||
static char rcsid[] = "$NetBSD: mount.c,v 1.21 1995/07/12 03:45:14 cgd Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -77,9 +77,6 @@ int mountfs __P((const char *, const char *, const char *,
|
|||
void prmount __P((struct statfs *));
|
||||
void usage __P((void));
|
||||
|
||||
/* From mount_ufs.c. */
|
||||
int mount_ufs __P((int, char * const *));
|
||||
|
||||
/* Map from mount otions to printable formats. */
|
||||
static struct opt {
|
||||
int o_opt;
|
||||
|
@ -308,6 +305,22 @@ mountfs(vfstype, spec, name, flags, options, mntopts)
|
|||
|
||||
if (strcmp(name, "/") == 0)
|
||||
flags |= MNT_UPDATE;
|
||||
else {
|
||||
if (statfs(name, &sf) < 0) {
|
||||
warn("statfs %s", name);
|
||||
return (1);
|
||||
}
|
||||
/* XXX can't check f_mntfromname, thanks to mfs, union, etc. */
|
||||
if (strncmp(name, sf.f_mntonname, MNAMELEN) == 0 &&
|
||||
strncmp(vfstype, sf.f_fstypename, MFSNAMELEN) == 0) {
|
||||
if (verbose)
|
||||
(void)printf("%s on %s type %.*s: %s\n",
|
||||
sf.f_mntfromname, sf.f_mntonname,
|
||||
MFSNAMELEN, sf.f_fstypename,
|
||||
"already mounted");
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
if (flags & MNT_FORCE)
|
||||
optbuf = catopt(optbuf, "force");
|
||||
if (flags & MNT_RDONLY)
|
||||
|
@ -342,9 +355,6 @@ mountfs(vfstype, spec, name, flags, options, mntopts)
|
|||
free(optbuf);
|
||||
return (1);
|
||||
case 0: /* Child. */
|
||||
if (strcmp(vfstype, "ufs") == 0)
|
||||
exit(mount_ufs(argc, (char * const *) argv));
|
||||
|
||||
/* Go find an executable. */
|
||||
edir = edirs;
|
||||
do {
|
||||
|
|
|
@ -1,138 +0,0 @@
|
|||
/* $NetBSD: mount_ufs.c,v 1.2 1995/03/18 14:57:04 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* 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
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char copyright[] =
|
||||
"@(#) Copyright (c) 1993, 1994\n\
|
||||
The Regents of the University of California. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)mount_ufs.c 8.2 (Berkeley) 3/27/94";
|
||||
#else
|
||||
static char rcsid[] = "$NetBSD: mount_ufs.c,v 1.2 1995/03/18 14:57:04 cgd Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "mntopts.h"
|
||||
|
||||
void ufs_usage __P((void));
|
||||
|
||||
static struct mntopt mopts[] = {
|
||||
MOPT_STDOPTS,
|
||||
MOPT_ASYNC,
|
||||
MOPT_SYNC,
|
||||
MOPT_UPDATE,
|
||||
MOPT_RELOAD,
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
int
|
||||
mount_ufs(argc, argv)
|
||||
int argc;
|
||||
char * const argv[];
|
||||
{
|
||||
extern int optreset;
|
||||
struct ufs_args args;
|
||||
int ch, mntflags;
|
||||
char *fs_name;
|
||||
|
||||
mntflags = 0;
|
||||
optind = optreset = 1; /* Reset for parse of new argv. */
|
||||
while ((ch = getopt(argc, argv, "o:")) != EOF)
|
||||
switch (ch) {
|
||||
case 'o':
|
||||
getmntopts(optarg, mopts, &mntflags);
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
ufs_usage();
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (argc != 2)
|
||||
ufs_usage();
|
||||
|
||||
args.fspec = argv[0]; /* The name of the device file. */
|
||||
fs_name = argv[1]; /* The mount point. */
|
||||
|
||||
#define DEFAULT_ROOTUID -2
|
||||
args.export.ex_root = DEFAULT_ROOTUID;
|
||||
if (mntflags & MNT_RDONLY)
|
||||
args.export.ex_flags = MNT_EXRDONLY;
|
||||
else
|
||||
args.export.ex_flags = 0;
|
||||
|
||||
if (mount(MOUNT_UFS, fs_name, mntflags, &args) < 0) {
|
||||
(void)fprintf(stderr, "%s on %s: ", args.fspec, fs_name);
|
||||
switch (errno) {
|
||||
case EMFILE:
|
||||
(void)fprintf(stderr, "mount table full.\n");
|
||||
break;
|
||||
case EINVAL:
|
||||
if (mntflags & MNT_UPDATE)
|
||||
(void)fprintf(stderr,
|
||||
"Specified device does not match mounted device.\n");
|
||||
else
|
||||
(void)fprintf(stderr,
|
||||
"Incorrect super block.\n");
|
||||
break;
|
||||
default:
|
||||
(void)fprintf(stderr, "%s\n", strerror(errno));
|
||||
break;
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
ufs_usage()
|
||||
{
|
||||
(void)fprintf(stderr, "usage: mount_ufs [-o options] special node\n");
|
||||
exit(1);
|
||||
}
|
Loading…
Reference in New Issue