1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-13 14:40:22 +00:00

Import of mount_reiserfs(8), used to mount a ReiserFS filesystem.

Approved by:	mux (mentor)
This commit is contained in:
Jean-Sébastien Pédron 2005-05-24 12:34:45 +00:00
parent e36734401f
commit 61a34594b1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=146568
3 changed files with 207 additions and 0 deletions

View File

@ -0,0 +1,13 @@
# $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

@ -0,0 +1,88 @@
.\"
.\" 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
.Pa special
.Pa node
.Sh DESCRIPTION
The
.Nm
utility attaches the ReiserFS file system residing on the device
.Pa special
to the global file system namespace at the location
indicated by
.Pa 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 CAVEATS
This utility is primarily used for read access to a ReiserFS volume.
Writing to a volume is currently unsupported.
.Sh HISTORY
The
.Nm
utility first appeared in
.Fx 6.0 .
.Sh AUTHORS
The ReiserFS kernel implementation was written by
.An Hans Reiser (http://www.namesys.com/) ,
and ported to
.Fx
by
.An Jean-Sébastien Pédron <dumbbell@FreeBSD.org> .
.Pp
The
.Nm
utility and manual were written by
.An Jean-Sébastien Pédron <dumbbell@FreeBSD.org> .

View File

@ -0,0 +1,106 @@
/*-
* 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,
{ NULL }
};
void usage(void);
int
main(int argc, char *argv[])
{
struct iovec *iov;
int ch, mntflags, iovlen;
char *dev, *dir, mntpath[MAXPATHLEN];
mntflags = 0;
while ((ch = getopt(argc, argv, "o:")) != -1) {
switch(ch) {
case 'o':
getmntopts(optarg, mopts, &mntflags, 0);
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.
*/
(void)checkpath(dir, 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", "reiserfs", -1);
build_iovec(&iov, &iovlen, "fspath", mntpath, -1);
build_iovec(&iov, &iovlen, "from", dev, -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);
}