GC unused mount_* directories. mount_reiserfs was disconnected from build

with r158666.  mount_ext2fs and mount_std were disconnected with r164527.
This commit is contained in:
Jung-uk Kim 2013-03-05 23:53:37 +00:00
parent e8e60cfae2
commit 7eb5d3cfa5
9 changed files with 0 additions and 772 deletions

View File

@ -1,14 +0,0 @@
# @(#)Makefile 8.3 (Berkeley) 3/27/94
# $FreeBSD$
PROG= mount_ext2fs
SRCS= mount_ext2fs.c getmntopts.c
MAN= mount_ext2fs.8
WARNS?= 2
MOUNT= ${.CURDIR}/../mount
CFLAGS+= -I${MOUNT}
.PATH: ${MOUNT}
.include <bsd.prog.mk>

View File

@ -1,72 +0,0 @@
.\" 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.
.\" 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.
.\"
.\" $FreeBSD$
.\"
.Dd January 31, 1996
.Dt MOUNT_EXT2FS 8
.Os
.Sh NAME
.Nm mount_ext2fs
.Nd mount an ext2fs file system
.Sh SYNOPSIS
.Nm
.Op Fl o Ar options
.Ar special
.Ar node
.Sh DESCRIPTION
The
.Nm
utility attaches an ext2fs file system
.Ar special
device on to the file system tree at the point
.Ar node .
.Pp
This command is normally executed by
.Xr mount 8
at boot time.
.Pp
The options are as follows:
.Bl -tag -width indent
.It Fl o
Options are specified with a
.Fl o
flag followed by a comma separated string of options.
See the
.Xr mount 8
man page for possible options and their meanings.
.El
.Sh SEE ALSO
.Xr mount 2 ,
.Xr unmount 2 ,
.Xr fstab 5 ,
.Xr mount 8
.Sh HISTORY
The
.Nm
utility first appeared in
.Fx 2.2 .

View File

@ -1,125 +0,0 @@
/*-
* 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.
* 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 const char copyright[] =
"@(#) Copyright (c) 1993, 1994\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
/*
static char sccsid[] = "@(#)mount_lfs.c 8.3 (Berkeley) 3/27/94";
*/
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/uio.h>
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sysexits.h>
#include <unistd.h>
#include "mntopts.h"
static void usage(void);
int
main(int argc, char *argv[])
{
struct iovec *iov;
int ch, iovlen;
char *fs_name, *fspec, mntpath[MAXPATHLEN];
char *fstype;
fstype = strrchr(argv[0], '_');
if (fstype == NULL)
errx(EX_USAGE, "argv[0] must end in _fstype");
else
++fstype;
iov = NULL;
iovlen = 0;
while ((ch = getopt(argc, argv, "o:")) != -1)
switch (ch) {
case 'o': {
char *p = NULL;
char *val = strdup("");
p = strchr(optarg, '=');
if (p != NULL) {
free(val);
*p = '\0';
val = p + 1;
}
build_iovec(&iov, &iovlen, optarg, val, strlen(val)+1);
}
break;
case '?':
default:
usage();
}
argc -= optind;
argv += optind;
if (argc != 2)
usage();
fspec = argv[0]; /* the name of the device file */
fs_name = argv[1]; /* the mount point */
/*
* Resolve the mountpoint with realpath(3) and remove unnecessary
* slashes from the devicename if there are any.
*/
if (checkpath(fs_name, mntpath) != 0)
err(EX_USAGE, "%s", mntpath);
(void)rmslashes(fspec, fspec);
build_iovec(&iov, &iovlen, "fstype", fstype, strlen(fstype) + 1);
build_iovec(&iov, &iovlen, "fspath", mntpath, strlen(mntpath) + 1);
build_iovec(&iov, &iovlen, "from", fspec, strlen(fspec) + 1);
if (nmount(iov, iovlen, 0) < 0)
err(EX_OSERR, "%s", fspec);
return (0);
}
static void
usage()
{
(void)fprintf(stderr,
"usage: mount_ext2fs [-o options] special node\n");
exit(EX_USAGE);
}

View File

@ -1,13 +0,0 @@
# $FreeBSD$
PROG = mount_reiserfs
SRCS = mount_reiserfs.c getmntopts.c
MAN = mount_reiserfs.8
# mount_reiserfs needs mntopts.h and getmntopts.c from src/sbin/mount/
MOUNT ?= ${.CURDIR}/../mount
CFLAGS += -I${MOUNT}
.PATH: ${MOUNT}
.include <bsd.prog.mk>

View File

@ -1,90 +0,0 @@
.\"
.\" Copyright (c) 1993,1994 Christopher G. Demetriou
.\" Copyright (c) 1999 Semen Ustimenko
.\" Copyright (c) 2005 Jean-Sébastien Pédron
.\" 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 acknowledgment:
.\" This product includes software developed by Christopher G. Demetriou.
.\" 3. The name of the author may not be used to endorse or promote products
.\" derived from this software without specific prior written permission
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
.\"
.\" $FreeBSD$
.\"
.Dd February 3, 2005
.Dt MOUNT_REISERFS 8
.Os
.Sh NAME
.Nm mount_reiserfs
.Nd "mount a ReiserFS file system"
.Sh SYNOPSIS
.Nm
.Ar special
.Ar node
.Sh DESCRIPTION
The
.Nm
utility attaches the ReiserFS file system residing on the device
.Ar special
to the global file system namespace at the location
indicated by
.Ar node .
.Pp
This command is normally executed by
.Xr mount 8
at boot time, but can be used by any user to mount a
ReiserFS file system on any directory that they own (provided,
of course, that they have appropriate access to the device that
contains the file system).
.Sh EXAMPLES
To mount a ReiserFS volume located in
.Pa /dev/ad1s1 :
.Pp
.Dl "mount_reiserfs /dev/ad1s1 /mnt"
.Sh SEE ALSO
.Xr mount 2 ,
.Xr unmount 2 ,
.Xr fstab 5 ,
.Xr mount 8
.Sh HISTORY
The
.Nm
utility first appeared in
.Fx 6.0 .
.Sh AUTHORS
.An -nosplit
The ReiserFS kernel implementation was written by
.An Hans Reiser
.Pq Pa http://www.namesys.com/ ,
and ported to
.Fx
by
.An Jean-S\['e]bastien P\['e]dron Aq dumbbell@FreeBSD.org .
.Pp
The
.Nm
utility and manual were written by
.An Jean-S\['e]bastien P\['e]dron Aq dumbbell@FreeBSD.org .
.Sh CAVEATS
This utility is primarily used for read access to a ReiserFS volume.
Writing to a volume is currently unsupported.

View File

@ -1,108 +0,0 @@
/*-
* Copyright (c) 2005 Jean-Sébastien Pédron
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*
* $FreeBSD$
*/
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/uio.h>
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sysexits.h>
#include <unistd.h>
#include "mntopts.h"
struct mntopt mopts[] = {
MOPT_STDOPTS,
MOPT_END
};
void usage(void);
int
main(int argc, char *argv[])
{
struct iovec *iov;
int ch, mntflags, iovlen;
char *dev, *dir, mntpath[MAXPATHLEN];
char fstype[] = "reiserfs";
mntflags = 0;
while ((ch = getopt(argc, argv, "o:")) != -1) {
switch(ch) {
case 'o':
getmntopts(optarg, mopts, &mntflags, NULL);
break;
case '?':
default:
usage();
}
}
argc -= optind;
argv += optind;
if (argc != 2)
usage();
dev = argv[0];
dir = argv[1];
/*
* Resolve the mountpoint with realpath(3) and remove unnecessary
* slashes from the devicename if there are any.
*/
if (checkpath(dir, mntpath) != 0)
err(EX_USAGE, "%s", mntpath);
(void)rmslashes(dev, dev);
/* Read-only support for now */
mntflags |= MNT_RDONLY;
/* Prepare the options vector for nmount(). build_iovec() is declared
* in mntopts.h. */
iov = NULL;
iovlen = 0;
build_iovec(&iov, &iovlen, "fstype", fstype, (size_t)-1);
build_iovec(&iov, &iovlen, "fspath", mntpath, (size_t)-1);
build_iovec(&iov, &iovlen, "from", dev, (size_t)-1);
if (nmount(iov, iovlen, mntflags) < 0)
err(EX_OSERR, "%s", dev);
exit(0);
}
void
usage(void)
{
fprintf(stderr,
"usage: mount_reiserfs [-o options] special node\n");
exit(EX_USAGE);
}

View File

@ -1,23 +0,0 @@
# @(#)Makefile 8.2 (Berkeley) 3/27/94
# $FreeBSD$
PROG= mount_std
SRCS= mount_std.c getmntopts.c
MAN= mount_std.8
MLINKS= mount_std.8 mount_devfs.8 \
mount_std.8 mount_fdescfs.8 \
mount_std.8 mount_linprocfs.8 \
mount_std.8 mount_procfs.8
MOUNT= ${.CURDIR}/../mount
CFLAGS+= -I${MOUNT}
WARNS?= 3
.PATH: ${MOUNT}
LINKS= ${BINDIR}/mount_std ${BINDIR}/mount_devfs \
${BINDIR}/mount_std ${BINDIR}/mount_fdescfs \
${BINDIR}/mount_std ${BINDIR}/mount_linprocfs \
${BINDIR}/mount_std ${BINDIR}/mount_procfs
.include <bsd.prog.mk>

View File

@ -1,167 +0,0 @@
.\"
.\" Copyright (c) 1992, 1993, 1994
.\" The Regents of the University of California. All rights reserved.
.\" All rights reserved.
.\"
.\" This code is derived from software donated to Berkeley by
.\" Jan-Simon Pendry.
.\"
.\" 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.
.\" 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.
.\"
.\" $FreeBSD$
.\"
.Dd November 26, 2004
.Dt MOUNT_STD 8
.Os
.Sh NAME
.Nm mount_std ,
.Nm mount_devfs ,
.Nm mount_fdescfs ,
.Nm mount_linprocfs ,
.Nm mount_procfs
.Nd mount
.Dq standard
file systems
.Sh SYNOPSIS
.Nm mount_ Ns Ar fsname
.Op Fl o Ar options
.Ar "fs"
.Ar mount_point
.Sh DESCRIPTION
The
.Nm
utility is a generic mechanism for attaching ``standard'' file systems to
the file system.
The
.Nm
utility currently supports the following file systems:
.Nm devfs ,
.Nm fdescfs ,
.Nm linprocfs
and
.Nm procfs .
A ``standard'' file system is one which:
.Bl -enum -offset indent
.It
accepts only the standard
.Fl o
options
.Dq ro ,
.Dq rw ,
.Dq noexec ,
.Dq nosuid ,
and
.Dq union .
.It
has a kernel file system module name the same as its user-visible name.
.It
requires no other special processing on the part of the
.Nm
utility.
.El
.Pp
The options are as follows:
.Bl -tag -width indent
.It Fl o
Options are specified with a
.Fl o
flag followed by a comma separated string of options.
See the
.Xr mount 8
man page for possible options and their meanings.
.El
.Pp
The
.Nm
utility examines its zeroth command-line argument (the name by which
it was called) to determine the type of file system to be mounted.
If
it is called by a name which does not end in
.Dq Li _ Ns Ar fsname ,
.Nm
will assume (for compatibility
with
.Xr mount 8 )
that the zeroth argument contains only the name of the file system type.
The
.Nm
utility is normally installed with appropriate links to commands for
the distributed file systems which can be mounted in this way;
for information on the function of each file system, see the manual page
for that specific
.Nm mount_ Ns Ar fsname
utility.
.Pp
Refer to the following manual pages for detailed information
on these file systems:
.Xr devfs 5 ,
.Xr fdescfs 5 ,
.Xr linprocfs 5
and
.Xr procfs 5 .
.Sh DIAGNOSTICS
.Bl -diag
.It argv[0] must end in _fsname
The
.Nm
utility was called with a zeroth argument of
.Dq Li mount_std .
.It %s file system not available
The specified file system type was not present in the kernel and no
loadable module for it was found.
.El
.Sh SEE ALSO
.Xr mount 2 ,
.Xr unmount 2 ,
.Xr getvfsbyname 3 ,
.Xr devfs 5 ,
.Xr fdescfs 5 ,
.Xr fstab 5 ,
.Xr linprocfs 5 ,
.Xr procfs 5 ,
.Xr mount 8
.Sh HISTORY
The
.Nm
utility first appeared in
.Fx 2.2 .
Loadable file system modules first appeared in
.Fx 2.0 .
The
.Dq fdescfs
and
.Dq procfs
file system types first appeared in
.Fx 2.0 ;
the
.Dq devfs
file system type first appeared in
.Fx 2.2 ;
the
.Dq linprocfs
file system type first appeared in
.Fx 4.0 .
.Sh CAVEATS
None of the ``standard'' file systems may be NFS-exported.

View File

@ -1,160 +0,0 @@
/*
* Copyright (c) 1990, 1992 Jan-Simon Pendry
* Copyright (c) 1992, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Jan-Simon Pendry.
*
* 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.
* 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 const char copyright[] =
"@(#) Copyright (c) 1992, 1993, 1994\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/uio.h>
#include <err.h>
#include <errno.h>
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <sysexits.h>
#include <unistd.h>
#include "mntopts.h"
static struct mntopt mopts[] = {
MOPT_STDOPTS,
MOPT_END
};
static char *fsname;
static volatile sig_atomic_t caughtsig;
static void usage(void) __dead2;
static void
catchsig(int s __unused)
{
caughtsig = 1;
}
int
main(int argc, char *argv[])
{
int ch, mntflags;
char mntpath[MAXPATHLEN];
struct iovec iov[4];
int error;
/*
* XXX
* mount(8) calls the mount programs with an argv[0] which is
* /just/ the file system name. So, if there is no underscore
* in argv[0], we assume that we are being called from mount(8)
* and that argv[0] is thus the name of the file system type.
*/
fsname = strrchr(argv[0], '_');
if (fsname) {
if (strcmp(fsname, "_std") == 0)
errx(EX_USAGE, "argv[0] must end in _fsname");
fsname++;
} else {
fsname = argv[0];
}
mntflags = 0;
while ((ch = getopt(argc, argv, "o:")) != -1)
switch (ch) {
case 'o':
getmntopts(optarg, mopts, &mntflags, NULL);
break;
case '?':
default:
usage();
}
argc -= optind;
argv += optind;
if (argc != 2)
usage();
/* resolve the mountpoint with realpath(3) */
if (checkpath(argv[1], mntpath) != 0)
err(EX_USAGE, "%s", mntpath);
iov[0].iov_base = "fstype";
iov[0].iov_len = sizeof("fstype");
iov[1].iov_base = fsname;
iov[1].iov_len = strlen(iov[1].iov_base) + 1;
iov[2].iov_base = "fspath";
iov[2].iov_len = sizeof("fspath");
iov[3].iov_base = mntpath;
iov[3].iov_len = strlen(mntpath) + 1;
/*
* nmount(2) would kill us with SIGSYS if the kernel doesn't have it.
* This design bug is inconvenient. We must catch the signal and not
* just ignore it because of a plain bug: nmount(2) would return
* EINVAL instead of the correct ENOSYS if the kernel doesn't have it
* and we don't let the signal kill us. EINVAL is too ambiguous.
* This bug in 4.4BSD-Lite1 was fixed in 4.4BSD-Lite2 but is still in
* FreeBSD-5.0.
*/
signal(SIGSYS, catchsig);
error = nmount(iov, 4, mntflags);
signal(SIGSYS, SIG_DFL);
/*
* Try with the old mount syscall in the case
* this file system has not been converted yet,
* or the user didn't recompile his kernel.
*/
if (error && (errno == EOPNOTSUPP || errno == ENOSYS || caughtsig))
error = mount(fsname, mntpath, mntflags, NULL);
if (error)
err(EX_OSERR, NULL);
exit(0);
}
void
usage(void)
{
(void)fprintf(stderr,
"usage: mount_%s [-o options] what_to_mount mount_point\n",
fsname);
exit(EX_USAGE);
}