Refactor mount utilities to provide a mount_fs_parseargs() routine.

Use this routine both in mount_fs and rump_fs to provide equivalent
command line parameters and therefore usage interchangeability.
While doing this, combine some common mountgoop to mountprog.h
This commit is contained in:
pooka 2008-08-05 20:57:45 +00:00
parent 2ce9976a92
commit 99fed7264c
58 changed files with 873 additions and 684 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: fattr.c,v 1.8 2008/04/28 20:23:09 martin Exp $ */
/* $NetBSD: fattr.c,v 1.9 2008/08/05 20:57:45 pooka Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: fattr.c,v 1.8 2008/04/28 20:23:09 martin Exp $");
__RCSID("$NetBSD: fattr.c,v 1.9 2008/08/05 20:57:45 pooka Exp $");
#endif /* not lint */
#include <sys/param.h>
@ -42,7 +42,7 @@ __RCSID("$NetBSD: fattr.c,v 1.8 2008/04/28 20:23:09 martin Exp $");
#include <string.h>
#include <unistd.h>
#include "fattr.h"
#include "mountprog.h"
int
a_num(const char *s, const char *id_type)

View File

@ -1,4 +1,4 @@
/* $NetBSD: mount.c,v 1.85 2008/07/20 01:20:22 lukem Exp $ */
/* $NetBSD: mount.c,v 1.86 2008/08/05 20:57:45 pooka Exp $ */
/*
* Copyright (c) 1980, 1989, 1993, 1994
@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1989, 1993, 1994\
#if 0
static char sccsid[] = "@(#)mount.c 8.25 (Berkeley) 5/8/95";
#else
__RCSID("$NetBSD: mount.c,v 1.85 2008/07/20 01:20:22 lukem Exp $");
__RCSID("$NetBSD: mount.c,v 1.86 2008/08/05 20:57:45 pooka Exp $");
#endif
#endif /* not lint */
@ -64,7 +64,7 @@ __RCSID("$NetBSD: mount.c,v 1.85 2008/07/20 01:20:22 lukem Exp $");
#include <sys/ioctl.h>
#include "pathnames.h"
#include "vfslist.h"
#include "mountprog.h"
static int debug, verbose;

View File

@ -1,7 +1,7 @@
/* $NetBSD: fattr.h,v 1.5 2008/04/28 20:23:09 martin Exp $ */
/* $NetBSD: mountprog.h,v 1.1 2008/08/05 20:57:45 pooka Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* Copyright (c) 2000, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -26,7 +26,12 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
int a_num(const char *, const char *);
gid_t a_gid(const char *);
uid_t a_uid(const char *);
mode_t a_mask(const char *);
int a_num(const char *, const char *);
gid_t a_gid(const char *);
uid_t a_uid(const char *);
mode_t a_mask(const char *);
int checkvfsname(const char *, const char **);
const char ** makevfslist(const char *);
void pathadj(const char *, char *);

46
sbin/mount/pathadj.c Normal file
View File

@ -0,0 +1,46 @@
/* $NetBSD: pathadj.c,v 1.1 2008/08/05 20:57:45 pooka Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation. 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 ``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.
*/
#include <sys/param.h>
#include <err.h>
#include <stdlib.h>
#include <string.h>
#include "mountprog.h"
void
pathadj(const char *input, char *adjusted)
{
if (realpath(input, adjusted) == NULL)
err(1, "realpath %s", input);
if (strncmp(input, adjusted, MAXPATHLEN)) {
warnx("\"%s\" is a non-resolved or relative path.", input);
warnx("using \"%s\" instead.", adjusted);
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: vfslist.c,v 1.6 2005/06/26 21:43:33 christos Exp $ */
/* $NetBSD: vfslist.c,v 1.7 2008/08/05 20:57:45 pooka Exp $ */
/*
* Copyright (c) 1995
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)vfslist.c 8.1 (Berkeley) 5/8/95";
#else
__RCSID("$NetBSD: vfslist.c,v 1.6 2005/06/26 21:43:33 christos Exp $");
__RCSID("$NetBSD: vfslist.c,v 1.7 2008/08/05 20:57:45 pooka Exp $");
#endif
#endif /* not lint */
@ -43,7 +43,7 @@ __RCSID("$NetBSD: vfslist.c,v 1.6 2005/06/26 21:43:33 christos Exp $");
#include <string.h>
#include <unistd.h>
#include "vfslist.h"
#include "mountprog.h"
static int skipvfs;

View File

@ -1,4 +1,4 @@
/* $NetBSD: mount_ados.c,v 1.27 2007/07/16 17:06:52 pooka Exp $ */
/* $NetBSD: mount_ados.c,v 1.28 2008/08/05 20:57:45 pooka Exp $ */
/*
* Copyright (c) 1994 Christopher G. Demetriou
@ -36,7 +36,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: mount_ados.c,v 1.27 2007/07/16 17:06:52 pooka Exp $");
__RCSID("$NetBSD: mount_ados.c,v 1.28 2008/08/05 20:57:45 pooka Exp $");
#endif /* not lint */
#include <sys/param.h>
@ -55,7 +55,8 @@ __RCSID("$NetBSD: mount_ados.c,v 1.27 2007/07/16 17:06:52 pooka Exp $");
#include <mntopts.h>
#include <errno.h>
#include <fattr.h>
#include "mountprog.h"
static const struct mntopt mopts[] = {
MOPT_STDOPTS,

View File

@ -1,13 +1,15 @@
# $NetBSD: Makefile,v 1.11 2005/06/27 01:00:05 christos Exp $
# $NetBSD: Makefile,v 1.12 2008/08/05 20:57:45 pooka Exp $
# @(#)Makefile 8.3 (Berkeley) 3/27/94
.include <bsd.own.mk>
PROG= mount_cd9660
SRCS= mount_cd9660.c
SRCS= mount_cd9660.c pathadj.c
MAN= mount_cd9660.8
MOUNT= ${NETBSDSRCDIR}/sbin/mount
CPPFLAGS+=-I${MOUNT}
.PATH: ${MOUNT}
DPADD+=${LIBUTIL}
LDADD+=-lutil

View File

@ -1,4 +1,4 @@
/* $NetBSD: mount_cd9660.c,v 1.27 2008/07/20 01:20:22 lukem Exp $ */
/* $NetBSD: mount_cd9660.c,v 1.28 2008/08/05 20:57:45 pooka Exp $ */
/*
* Copyright (c) 1992, 1993, 1994
@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993, 1994\
#if 0
static char sccsid[] = "@(#)mount_cd9660.c 8.7 (Berkeley) 5/1/95";
#else
__RCSID("$NetBSD: mount_cd9660.c,v 1.27 2008/07/20 01:20:22 lukem Exp $");
__RCSID("$NetBSD: mount_cd9660.c,v 1.28 2008/08/05 20:57:45 pooka Exp $");
#endif
#endif /* not lint */
@ -64,6 +64,9 @@ __RCSID("$NetBSD: mount_cd9660.c,v 1.27 2008/07/20 01:20:22 lukem Exp $");
#include <mntopts.h>
#include "mountprog.h"
#include "mount_cd9660.h"
static const struct mntopt mopts[] = {
MOPT_STDOPTS,
MOPT_UPDATE,
@ -78,26 +81,29 @@ static const struct mntopt mopts[] = {
MOPT_NULL,
};
int mount_cd9660(int argc, char **argv);
static void usage(void);
#ifndef MOUNT_NOMAIN
int
main(int argc, char **argv)
{
setprogname(argv[0]);
return mount_cd9660(argc, argv);
}
#endif
int
mount_cd9660(int argc, char **argv)
void
mount_cd9660_parseargs(int argc, char **argv,
struct iso_args *args, int *mntflags,
char *canon_dev, char *canon_dir)
{
struct iso_args args;
int ch, mntflags, opts;
int ch, opts;
mntoptparse_t mp;
char *dev, *dir, canon_dev[MAXPATHLEN], canon_dir[MAXPATHLEN];
char *dev, *dir;
mntflags = opts = 0;
*mntflags = opts = 0;
memset(args, 0, sizeof(*args));
while ((ch = getopt(argc, argv, "egijo:r")) != -1)
switch (ch) {
case 'e':
@ -116,7 +122,7 @@ mount_cd9660(int argc, char **argv)
opts |= ISOFSMNT_NOJOLIET;
break;
case 'o':
mp = getmntopts(optarg, mopts, &mntflags, &opts);
mp = getmntopts(optarg, mopts, mntflags, &opts);
if (mp == NULL)
err(1, "getmntopts");
freemntopts(mp);
@ -139,37 +145,36 @@ mount_cd9660(int argc, char **argv)
dev = argv[0];
dir = argv[1];
if (realpath(dev, canon_dev) == NULL) /* Check device path */
err(1, "realpath %s", dev);
if (strncmp(dev, canon_dev, MAXPATHLEN)) {
warnx("\"%s\" is a relative path.", dev);
dev = canon_dev;
warnx("using \"%s\" instead.", dev);
}
if (realpath(dir, canon_dir) == NULL) /* Check mounton path */
err(1, "realpath %s", dir);
if (strncmp(dir, canon_dir, MAXPATHLEN)) {
warnx("\"%s\" is a relative path.", dir);
dir = canon_dir;
warnx("using \"%s\" instead.", dir);
}
pathadj(dev, canon_dev);
pathadj(dir, canon_dir);
#define DEFAULT_ROOTUID -2
/*
* ISO 9660 filesystems are not writable.
*/
mntflags |= MNT_RDONLY;
args.fspec = dev;
args.flags = opts;
*mntflags |= MNT_RDONLY;
args->fspec = dev;
args->flags = opts;
}
if (mount(MOUNT_CD9660, dir, mntflags, &args, sizeof args) == -1)
err(1, "%s on %s", dev, dir);
int
mount_cd9660(int argc, char **argv)
{
struct iso_args args;
char canon_dev[MAXPATHLEN], canon_dir[MAXPATHLEN];
int mntflags;
mount_cd9660_parseargs(argc, argv, &args, &mntflags,
canon_dev, canon_dir);
if (mount(MOUNT_CD9660, canon_dir, mntflags, &args, sizeof args) == -1)
err(1, "%s on %s", canon_dev, canon_dir);
if (mntflags & MNT_GETARGS) {
char buf[2048];
(void)snprintb(buf, sizeof(buf), ISOFSMNT_BITS, args.flags);
printf("%s\n", buf);
}
exit(0);
}
@ -177,6 +182,6 @@ static void
usage(void)
{
(void)fprintf(stderr,
"usage: mount_cd9660 [-o options] special node\n");
"usage: %s [-o options] special node\n", getprogname());
exit(1);
}

View File

@ -0,0 +1,37 @@
/* $NetBSD: mount_cd9660.h,v 1.1 2008/08/05 20:57:45 pooka Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation. 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 ``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.
*/
#ifndef _SBIN_MOUNT_CD9660_MOUNT_CD9660_H_
#define _SBIN_MOUNT_CD9660_MOUNT_CD9660_H_
#include <isofs/cd9660/cd9660_mount.h>
int mount_cd9660(int, char **);
void mount_cd9660_parseargs(int, char **, struct iso_args *, int *,
char *, char *);
#endif /* _SBIN_MOUNT_CD9660_MOUNT_CD9660_H_ */

View File

@ -1,11 +1,15 @@
# $NetBSD: Makefile,v 1.1 2007/06/29 23:30:19 rumble Exp $
# $NetBSD: Makefile,v 1.2 2008/08/05 20:57:45 pooka Exp $
.include <bsd.own.mk>
PROG= mount_efs
SRCS= mount_efs.c
SRCS= mount_efs.c pathadj.c
MAN= mount_efs.8
MOUNT= ${NETBSDSRCDIR}/sbin/mount
CPPFLAGS+=-I${MOUNT}
.PATH: ${MOUNT}
DPADD+=${LIBUTIL}
LDADD+=-lutil

View File

@ -1,4 +1,4 @@
/* $NetBSD: mount_efs.c,v 1.3 2007/07/16 17:06:52 pooka Exp $ */
/* $NetBSD: mount_efs.c,v 1.4 2008/08/05 20:57:45 pooka Exp $ */
/*
* Copyright (c) 2006 Stephen M. Rumble <rumble@ephemeral.org>
@ -31,6 +31,9 @@
#include <mntopts.h>
#include "mountprog.h"
#include "mount_efs.h"
static const struct mntopt mopts[] = {
MOPT_STDOPTS,
MOPT_GETARGS,
@ -39,7 +42,6 @@ static const struct mntopt mopts[] = {
};
static void usage(void);
int mount_efs(int, char **);
static void
usage()
@ -49,24 +51,23 @@ usage()
exit(1);
}
int
mount_efs(int argc, char **argv)
void
mount_efs_parseargs(int argc, char **argv,
struct efs_args *args, int *mntflags,
char *canon_dev, char *canon_dir)
{
int ch, mntflags;
int ch;
extern int optind;
extern char *optarg;
struct efs_args args;
char special[MAXPATHLEN], node[MAXPATHLEN];
mntoptparse_t mp;
setprogname(argv[0]);
memset(&args, 0, sizeof(args));
mntflags = 0;
memset(args, 0, sizeof(*args));
*mntflags = 0;
while ((ch = getopt(argc, argv, "o:")) != -1) {
switch (ch) {
case 'o':
mp = getmntopts(optarg, mopts, &mntflags, NULL);
mp = getmntopts(optarg, mopts, mntflags, NULL);
if (mp == NULL)
err(1, "getmntopts");
freemntopts(mp);
@ -82,14 +83,22 @@ mount_efs(int argc, char **argv)
if (argc != 2)
usage();
if (realpath(argv[0], special) == NULL)
err(EXIT_FAILURE, "realpath %s", argv[0]);
pathadj(argv[0], canon_dev);
pathadj(argv[1], canon_dir);
if (realpath(argv[1], node) == NULL)
err(EXIT_FAILURE, "realpath %s", argv[1]);
args->fspec = canon_dev;
args->version = EFS_MNT_VERSION;
}
int
mount_efs(int argc, char **argv)
{
char special[MAXPATHLEN], node[MAXPATHLEN];
struct efs_args args;
int mntflags;
mount_efs_parseargs(argc, argv, &args, &mntflags, special, node);
args.fspec = special;
args.version = EFS_MNT_VERSION;
if (mount(MOUNT_EFS, node, mntflags, &args, sizeof args) == -1)
err(EXIT_FAILURE, "%s on %s", special, node);
@ -101,6 +110,7 @@ int
main(int argc, char **argv)
{
setprogname(argv[0]);
return (mount_efs(argc, argv));
}
#endif

View File

@ -0,0 +1,37 @@
/* $NetBSD: mount_efs.h,v 1.1 2008/08/05 20:57:45 pooka Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation. 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 ``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.
*/
#ifndef _SBIN_MOUNT_EFS_MOUNT_EFS_H_
#define _SBIN_MOUNT_EFS_MOUNT_EFS_H_
#include <fs/efs/efs_mount.h>
int mount_efs(int, char **);
void mount_efs_parseargs(int, char **, struct efs_args *, int *,
char *, char *);
#endif /* _SBIN_MOUNT_EFS_MOUNT_EFS_H_ */

View File

@ -1,13 +1,17 @@
# $NetBSD: Makefile,v 1.7 2005/06/27 01:00:05 christos Exp $
# $NetBSD: Makefile,v 1.8 2008/08/05 20:57:45 pooka Exp $
#
# $OpenBSD: Makefile,v 1.1 1996/06/27 07:20:28 downsj Exp $
.include <bsd.own.mk>
PROG= mount_ext2fs
SRCS= mount_ext2fs.c
SRCS= mount_ext2fs.c pathadj.c
MAN= mount_ext2fs.8
MOUNT= ${NETBSDSRCDIR}/sbin/mount
CPPFLAGS+=-I${MOUNT}
.PATH: ${MOUNT}
DPADD+=${LIBUTIL}
LDADD+=-lutil

View File

@ -1,4 +1,4 @@
/* $NetBSD: mount_ext2fs.c,v 1.20 2008/07/20 01:20:22 lukem Exp $ */
/* $NetBSD: mount_ext2fs.c,v 1.21 2008/08/05 20:57:45 pooka Exp $ */
/*-
* Copyright (c) 1993, 1994
@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1993, 1994\
#if 0
static char sccsid[] = "@(#)mount_ufs.c 8.4 (Berkeley) 4/26/95";
#else
__RCSID("$NetBSD: mount_ext2fs.c,v 1.20 2008/07/20 01:20:22 lukem Exp $");
__RCSID("$NetBSD: mount_ext2fs.c,v 1.21 2008/08/05 20:57:45 pooka Exp $");
#endif
#endif /* not lint */
@ -57,8 +57,10 @@ __RCSID("$NetBSD: mount_ext2fs.c,v 1.20 2008/07/20 01:20:22 lukem Exp $");
#include <mntopts.h>
#include "mountprog.h"
#include "mount_ext2fs.h"
static void ext2fs_usage(void);
int mount_ext2fs(int argc, char **argv);
static const struct mntopt mopts[] = {
MOPT_STDOPTS,
@ -76,25 +78,27 @@ static const struct mntopt mopts[] = {
int
main(int argc, char *argv[])
{
setprogname(argv[0]);
return mount_ext2fs(argc, argv);
}
#endif
int
mount_ext2fs(int argc, char *argv[])
void
mount_ext2fs_parseargs(int argc, char *argv[],
struct ufs_args *args, int *mntflags,
char *canon_dev, char *canon_dir)
{
struct ufs_args args; /* XXX ffs_args */
int ch, mntflags;
char fs_name[MAXPATHLEN], canon_dev[MAXPATHLEN];
const char *errcause;
int ch;
mntoptparse_t mp;
mntflags = 0;
memset(args, 0, sizeof(*args));
*mntflags = 0;
optind = optreset = 1; /* Reset for parse of new argv. */
while ((ch = getopt(argc, argv, "o:")) != -1)
switch (ch) {
case 'o':
mp = getmntopts(optarg, mopts, &mntflags, 0);
mp = getmntopts(optarg, mopts, mntflags, 0);
if (mp == NULL)
err(1, "getmntopts");
freemntopts(mp);
@ -109,20 +113,22 @@ mount_ext2fs(int argc, char *argv[])
if (argc != 2)
ext2fs_usage();
if (realpath(argv[0], canon_dev) == NULL) /* Check device path */
err(1, "realpath %s", argv[0]);
if (strncmp(argv[0], canon_dev, MAXPATHLEN)) {
warnx("\"%s\" is a relative path.", argv[0]);
warnx("using \"%s\" instead.", canon_dev);
}
args.fspec = canon_dev;
pathadj(argv[0], canon_dev);
args->fspec = canon_dev;
if (realpath(argv[1], fs_name) == NULL) /* Check mounton path */
err(1, "realpath %s", argv[1]);
if (strncmp(argv[1], fs_name, MAXPATHLEN)) {
warnx("\"%s\" is a relative path.", argv[1]);
warnx("using \"%s\" instead.", fs_name);
}
pathadj(argv[1], canon_dir);
}
int
mount_ext2fs(int argc, char *argv[])
{
struct ufs_args args; /* XXX ffs_args */
char fs_name[MAXPATHLEN], canon_dev[MAXPATHLEN];
const char *errcause;
int mntflags;
mount_ext2fs_parseargs(argc, argv, &args, &mntflags,
canon_dev, fs_name);
if (mount(MOUNT_EXT2FS, fs_name, mntflags, &args, sizeof args) == -1) {
switch (errno) {
@ -149,6 +155,6 @@ static void
ext2fs_usage(void)
{
(void)fprintf(stderr,
"usage: mount_ext2fs [-o options] special node\n");
"usage: %s [-o options] special node\n", getprogname());
exit(1);
}

View File

@ -0,0 +1,37 @@
/* $NetBSD: mount_ext2fs.h,v 1.1 2008/08/05 20:57:45 pooka Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation. 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 ``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.
*/
#ifndef _SBIN_MOUNT_EXT2FS_MOUNT_EXT2FS_H_
#define _SBIN_MOUNT_EXT2FS_MOUNT_EXT2FS_H_
#include <ufs/ufs/ufsmount.h>
int mount_ext2fs(int, char **);
void mount_ext2fs_parseargs(int, char **, struct ufs_args *, int *,
char *, char *);
#endif /* _SBIN_MOUNT_EXT2FS_MOUNT_EXT2FS_H_ */

View File

@ -1,14 +1,18 @@
# $NetBSD: Makefile,v 1.8 2005/06/27 01:00:05 christos Exp $
# $NetBSD: Makefile,v 1.9 2008/08/05 20:57:45 pooka Exp $
.include <bsd.own.mk>
PROG= mount_ffs
SRCS= mount_ffs.c
SRCS= mount_ffs.c pathadj.c
MAN= mount_ffs.8
MLINKS= mount_ffs.8 mount_ufs.8
LINKS= ${BINDIR}/mount_ffs ${BINDIR}/mount_ufs
MOUNT= ${NETBSDSRCDIR}/sbin/mount
CPPFLAGS=-I${MOUNT}
.PATH: ${MOUNT}
DPADD+=${LIBUTIL}
LDADD+=-lutil

View File

@ -1,4 +1,4 @@
/* $NetBSD: mount_ffs.c,v 1.24 2008/07/31 05:38:04 simonb Exp $ */
/* $NetBSD: mount_ffs.c,v 1.25 2008/08/05 20:57:45 pooka Exp $ */
/*-
* Copyright (c) 1993, 1994
@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1993, 1994\
#if 0
static char sccsid[] = "@(#)mount_ufs.c 8.4 (Berkeley) 4/26/95";
#else
__RCSID("$NetBSD: mount_ffs.c,v 1.24 2008/07/31 05:38:04 simonb Exp $");
__RCSID("$NetBSD: mount_ffs.c,v 1.25 2008/08/05 20:57:45 pooka Exp $");
#endif
#endif /* not lint */
@ -57,8 +57,10 @@ __RCSID("$NetBSD: mount_ffs.c,v 1.24 2008/07/31 05:38:04 simonb Exp $");
#include <mntopts.h>
#include "mountprog.h"
#include "mount_ffs.h"
static void ffs_usage(void);
int mount_ffs(int argc, char **argv);
static const struct mntopt mopts[] = {
MOPT_STDOPTS,
@ -79,25 +81,27 @@ static const struct mntopt mopts[] = {
int
main(int argc, char **argv)
{
setprogname(argv[0]);
return mount_ffs(argc, argv);
}
#endif
int
mount_ffs(int argc, char *argv[])
void
mount_ffs_parseargs(int argc, char *argv[],
struct ufs_args *args, int *mntflags,
char *canon_dev, char *canon_dir)
{
struct ufs_args args;
int ch, mntflags;
char fs_name[MAXPATHLEN], canon_dev[MAXPATHLEN];
const char *errcause;
int ch;
mntoptparse_t mp;
mntflags = 0;
memset(args, 0, sizeof(*args));
*mntflags = 0;
optind = optreset = 1; /* Reset for parse of new argv. */
while ((ch = getopt(argc, argv, "o:")) != -1)
switch (ch) {
case 'o':
mp = getmntopts(optarg, mopts, &mntflags, 0);
mp = getmntopts(optarg, mopts, mntflags, 0);
if (mp == NULL)
err(1, "getmntopts");
freemntopts(mp);
@ -112,20 +116,21 @@ mount_ffs(int argc, char *argv[])
if (argc != 2)
ffs_usage();
if (realpath(argv[0], canon_dev) == NULL) /* Check device path */
err(1, "realpath %s", argv[0]);
if (strncmp(argv[0], canon_dev, MAXPATHLEN)) {
warnx("\"%s\" is a relative path.", argv[0]);
warnx("using \"%s\" instead.", canon_dev);
}
args.fspec = canon_dev;
pathadj(argv[0], canon_dev);
args->fspec = canon_dev;
if (realpath(argv[1], fs_name) == NULL) /* Check mounton path */
err(1, "realpath %s", argv[1]);
if (strncmp(argv[1], fs_name, MAXPATHLEN)) {
warnx("\"%s\" is a relative path.", argv[1]);
warnx("using \"%s\" instead.", fs_name);
}
pathadj(argv[1], canon_dir);
}
int
mount_ffs(int argc, char *argv[])
{
char fs_name[MAXPATHLEN], canon_dev[MAXPATHLEN];
struct ufs_args args;
const char *errcause;
int mntflags;
mount_ffs_parseargs(argc, argv, &args, &mntflags, canon_dev, fs_name);
if (mount(MOUNT_FFS, fs_name, mntflags, &args, sizeof args) == -1) {
switch (errno) {
@ -151,6 +156,6 @@ mount_ffs(int argc, char *argv[])
static void
ffs_usage(void)
{
(void)fprintf(stderr, "usage: mount_ffs [-o options] special node\n");
fprintf(stderr, "usage: %s [-o options] special node\n", getprogname());
exit(1);
}

View File

@ -0,0 +1,37 @@
/* $NetBSD: mount_ffs.h,v 1.1 2008/08/05 20:57:45 pooka Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation. 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 ``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.
*/
#ifndef _SBIN_MOUNT_FFS_MOUNT_FFS_H_
#define _SBIN_MOUNT_FFS_MOUNT_FFS_H_
#include <ufs/ufs/ufsmount.h>
int mount_ffs(int, char **);
void mount_ffs_parseargs(int, char **, struct ufs_args *, int *,
char *, char *);
#endif /* _SBIN_MOUNT_FFS_MOUNT_FFS_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: mount_filecore.c,v 1.18 2008/07/20 01:20:22 lukem Exp $ */
/* $NetBSD: mount_filecore.c,v 1.19 2008/08/05 20:57:45 pooka Exp $ */
/*
* Copyright (c) 1992, 1993, 1994 The Regents of the University of California.
@ -93,7 +93,8 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993, 1994\
#include <filecorefs/filecore_mount.h>
#include <mntopts.h>
#include <fattr.h>
#include "mountprog.h"
static const struct mntopt mopts[] = {
MOPT_STDOPTS,

View File

@ -1,11 +1,15 @@
# $NetBSD: Makefile,v 1.2 2007/03/06 11:28:47 dillo Exp $
# $NetBSD: Makefile,v 1.3 2008/08/05 20:57:45 pooka Exp $
.include <bsd.own.mk>
PROG= mount_hfs
SRCS= mount_hfs.c
SRCS= mount_hfs.c pathadj.c
MAN= mount_hfs.8
MOUNT= ${NETBSDSRCDIR}/sbin/mount
CPPFLAGS=-I${MOUNT}
.PATH: ${MOUNT}
DPADD+=${LIBUTIL}
LDADD+=-lutil

View File

@ -1,4 +1,4 @@
/* $NetBSD: mount_hfs.c,v 1.7 2008/07/20 01:20:22 lukem Exp $ */
/* $NetBSD: mount_hfs.c,v 1.8 2008/08/05 20:57:45 pooka Exp $ */
/*-
* Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@ -64,12 +64,14 @@ __COPYRIGHT("@(#) Copyright (c) 2005 Yevgeny Binder. All rights reserved.");
#endif /* not lint */
#ifndef lint
__RCSID("$NetBSD: mount_hfs.c,v 1.7 2008/07/20 01:20:22 lukem Exp $");
__RCSID("$NetBSD: mount_hfs.c,v 1.8 2008/08/05 20:57:45 pooka Exp $");
#endif /* not lint */
#include <sys/param.h>
#include <sys/mount.h>
#include <fs/hfs/hfs.h>
#include <err.h>
#include <unistd.h>
#include <stdio.h>
@ -78,42 +80,42 @@ __RCSID("$NetBSD: mount_hfs.c,v 1.7 2008/07/20 01:20:22 lukem Exp $");
#include <mntopts.h>
#include <fs/hfs/hfs.h>
#include "mountprog.h"
#include "mount_hfs.h"
static const struct mntopt mopts[] = {
MOPT_STDOPTS,
MOPT_GETARGS,
MOPT_NULL,
};
int main(int, char *[]);
int mount_hfs(int argc, char **argv);
static void usage(void);
#ifndef MOUNT_NOMAIN
int
main(int argc, char **argv)
{
setprogname(argv[0]);
return mount_hfs(argc, argv);
}
#endif
int
mount_hfs(int argc, char *argv[])
void
mount_hfs_parseargs(int argc, char *argv[],
struct hfs_args *args, int *mntflags,
char *canon_dev, char *canon_dir)
{
struct hfs_args args;
mntoptparse_t optparse;
int ch, mntflags;
char *fs_name;
int ch;
args.fspec = NULL;
mntflags = 0;
memset(args, 0, sizeof(*args));
*mntflags = 0;
optind = optreset = 1; /* Reset for parse of new argv. */
while ((ch = getopt(argc, argv, "o:")) != -1)
switch (ch) {
case 'o':
optparse = getmntopts(optarg, mopts, &mntflags, 0);
optparse = getmntopts(optarg, mopts, mntflags, 0);
if (optparse == NULL)
err(1, "getmntopts");
freemntopts(optparse);
@ -127,13 +129,23 @@ mount_hfs(int argc, char *argv[])
if (argc != 2)
usage();
args.fspec = argv[0]; /* The name of the device file. */
fs_name = argv[1]; /* The mount point. */
pathadj(argv[0], canon_dev);
pathadj(argv[1], canon_dir);
args->fspec = canon_dev; /* The name of the device file. */
}
if (mount(MOUNT_HFS, fs_name, mntflags, &args, sizeof args) == -1)
err(1, "%s on %s", args.fspec, fs_name);
int
mount_hfs(int argc, char *argv[])
{
struct hfs_args args;
char canon_dev[MAXPATHLEN], canon_dir[MAXPATHLEN];
int mntflags;
mount_hfs_parseargs(argc, argv, &args, &mntflags, canon_dev, canon_dir);
if (mount(MOUNT_HFS, canon_dir, mntflags, &args, sizeof args) == -1)
err(1, "%s on %s", args.fspec, canon_dir);
exit(0);
}
@ -141,6 +153,6 @@ mount_hfs(int argc, char *argv[])
static void
usage(void)
{
(void)fprintf(stderr, "usage: mount_hfs [-o options] special node\n");
fprintf(stderr, "usage: %s [-o options] special node\n", getprogname());
exit(1);
}

View File

@ -0,0 +1,37 @@
/* $NetBSD: mount_hfs.h,v 1.1 2008/08/05 20:57:45 pooka Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation. 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 ``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.
*/
#ifndef _SBIN_MOUNT_HFS_MOUNT_HFS_H_
#define _SBIN_MOUNT_HFS_MOUNT_HFS_H_
#include <fs/hfs/hfs.h>
int mount_hfs(int, char **);
void mount_hfs_parseargs(int, char **, struct hfs_args *, int *,
char *, char *);
#endif /* _SBIN_MOUNT_HFS_MOUNT_HFS_H_ */

View File

@ -1,12 +1,16 @@
# $NetBSD: Makefile,v 1.8 2003/03/22 12:43:59 jdolecek Exp $
# $NetBSD: Makefile,v 1.9 2008/08/05 20:57:45 pooka Exp $
# @(#)Makefile 8.2 (Berkeley) 3/27/94
.include <bsd.own.mk>
PROG= mount_lfs
SRCS= mount_lfs.c
SRCS= mount_lfs.c pathadj.c
MAN= mount_lfs.8
MOUNT= ${NETBSDSRCDIR}/sbin/mount
CPPFLAGS+=-I${MOUNT} -DWANT_CLEANER
.PATH: ${MOUNT}
DPADD+=${LIBUTIL}
LDADD+=-lutil

View File

@ -1,4 +1,4 @@
/* $NetBSD: mount_lfs.c,v 1.32 2008/07/20 01:20:22 lukem Exp $ */
/* $NetBSD: mount_lfs.c,v 1.33 2008/08/05 20:57:45 pooka Exp $ */
/*-
* Copyright (c) 1993, 1994
@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1993, 1994\
#if 0
static char sccsid[] = "@(#)mount_lfs.c 8.4 (Berkeley) 4/26/95";
#else
__RCSID("$NetBSD: mount_lfs.c,v 1.32 2008/07/20 01:20:22 lukem Exp $");
__RCSID("$NetBSD: mount_lfs.c,v 1.33 2008/08/05 20:57:45 pooka Exp $");
#endif
#endif /* not lint */
@ -60,6 +60,8 @@ __RCSID("$NetBSD: mount_lfs.c,v 1.32 2008/07/20 01:20:22 lukem Exp $");
#include <mntopts.h>
#include "pathnames.h"
#include "mountprog.h"
#include "mount_lfs.h"
static const struct mntopt mopts[] = {
MOPT_STDOPTS,
@ -69,38 +71,40 @@ static const struct mntopt mopts[] = {
MOPT_NULL,
};
int mount_lfs(int, char *[]);
static void invoke_cleaner(char *);
static void usage(void);
#ifdef WANT_CLEANER
static void invoke_cleaner(char *);
static void kill_daemon(char *);
static void kill_cleaner(char *);
#endif /* WANT_CLEANER */
static int short_rds, cleaner_debug, cleaner_bytes, fs_idle;
static int short_rds, cleaner_debug, cleaner_bytes, fs_idle, noclean;
static const char *nsegs;
#ifndef MOUNT_NOMAIN
int
main(int argc, char **argv)
{
setprogname(argv[0]);
return mount_lfs(argc, argv);
}
#endif
int
mount_lfs(int argc, char *argv[])
void
mount_lfs_parseargs(int argc, char *argv[],
struct ufs_args *args, int *mntflags,
char *canon_dev, char *canon_dir)
{
struct ufs_args args;
int ch, mntflags, noclean, mntsize, oldflags, i;
char fs_name[MAXPATHLEN], canon_dev[MAXPATHLEN];
int ch;
char *options;
mntoptparse_t mp;
const char *errcause;
struct statvfs *mntbuf;
memset(args, 0, sizeof(*args));
options = NULL;
nsegs = "4";
mntflags = noclean = 0;
*mntflags = noclean = 0;
cleaner_bytes = 1;
while ((ch = getopt(argc, argv, "bdiN:no:s")) != -1)
switch (ch) {
@ -120,7 +124,7 @@ mount_lfs(int argc, char *argv[])
nsegs = optarg;
break;
case 'o':
mp = getmntopts(optarg, mopts, &mntflags, 0);
mp = getmntopts(optarg, mopts, mntflags, 0);
if (mp == NULL)
err(1, "getmntopts");
freemntopts(mp);
@ -138,20 +142,23 @@ mount_lfs(int argc, char *argv[])
if (argc != 2)
usage();
if (realpath(argv[0], canon_dev) == NULL) /* Check device path */
err(1, "realpath %s", argv[0]);
if (strncmp(argv[0], canon_dev, MAXPATHLEN)) {
warnx("\"%s\" is a relative path.", argv[0]);
warnx("using \"%s\" instead.", canon_dev);
}
args.fspec = canon_dev;
pathadj(argv[0], canon_dev);
args->fspec = canon_dev;
if (realpath(argv[1], fs_name) == NULL) /* Check mounton path */
err(1, "realpath %s", argv[1]);
if (strncmp(argv[1], fs_name, MAXPATHLEN)) {
warnx("\"%s\" is a relative path.", argv[1]);
warnx("using \"%s\" instead.", fs_name);
}
pathadj(argv[1], canon_dir);
}
int
mount_lfs(int argc, char *argv[])
{
struct ufs_args args;
int mntflags;
int mntsize, oldflags, i;
char fs_name[MAXPATHLEN], canon_dev[MAXPATHLEN];
struct statvfs *mntbuf;
const char *errcause;
mount_lfs_parseargs(argc, argv, &args, &mntflags, canon_dev, fs_name);
/*
* Record the previous status of this filesystem (if any) before
@ -189,6 +196,7 @@ mount_lfs(int argc, char *argv[])
errx(1, "%s on %s: %s", args.fspec, fs_name, errcause);
}
#ifdef WANT_CLEANER
/* Not mounting fresh or upgrading to r/w; don't start the cleaner */
if (!(oldflags & MNT_RDONLY) || (mntflags & MNT_RDONLY)
|| (mntflags & MNT_GETARGS))
@ -200,10 +208,12 @@ mount_lfs(int argc, char *argv[])
/* Downgrade to r/o; kill the cleaner */
if ((mntflags & MNT_RDONLY) && !(oldflags & MNT_RDONLY))
kill_cleaner(fs_name);
#endif /* WANT_CLEANER */
exit(0);
}
#ifdef WANT_CLEANER
static void
kill_daemon(char *pidname)
{
@ -274,6 +284,7 @@ invoke_cleaner(char *name)
execv(args[0], __UNCONST(args));
err(1, "exec %s", _PATH_LFS_CLEANERD);
}
#endif /* WANT_CLEANER */
static void
usage(void)

View File

@ -0,0 +1,37 @@
/* $NetBSD: mount_lfs.h,v 1.1 2008/08/05 20:57:45 pooka Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation. 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 ``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.
*/
#ifndef _SBIN_MOUNT_LFS_MOUNT_LFS_H_
#define _SBIN_MOUNT_LFS_MOUNT_LFS_H_
#include <ufs/ufs/ufsmount.h>
int mount_lfs(int, char **);
void mount_lfs_parseargs(int, char **, struct ufs_args *, int *,
char *, char *);
#endif /* _SBIN_MOUNT_LFS_MOUNT_LFS_H_ */

View File

@ -1,9 +1,9 @@
# $NetBSD: Makefile,v 1.20 2005/06/27 01:00:06 christos Exp $
# $NetBSD: Makefile,v 1.21 2008/08/05 20:57:45 pooka Exp $
.include <bsd.own.mk>
PROG= mount_msdos
SRCS= mount_msdos.c fattr.c
SRCS= mount_msdos.c fattr.c pathadj.c
MAN= mount_msdos.8
MOUNT= ${NETBSDSRCDIR}/sbin/mount

View File

@ -1,4 +1,4 @@
/* $NetBSD: mount_msdos.c,v 1.45 2008/07/29 16:05:05 pooka Exp $ */
/* $NetBSD: mount_msdos.c,v 1.46 2008/08/05 20:57:45 pooka Exp $ */
/*
* Copyright (c) 1994 Christopher G. Demetriou
@ -36,7 +36,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: mount_msdos.c,v 1.45 2008/07/29 16:05:05 pooka Exp $");
__RCSID("$NetBSD: mount_msdos.c,v 1.46 2008/08/05 20:57:45 pooka Exp $");
#endif /* not lint */
#include <sys/param.h>
@ -54,8 +54,8 @@ __RCSID("$NetBSD: mount_msdos.c,v 1.45 2008/07/29 16:05:05 pooka Exp $");
#include <util.h>
#include <mntopts.h>
#include <fattr.h>
#include "mountprog.h"
#include "mount_msdos.h"
static const struct mntopt mopts[] = {
@ -155,19 +155,8 @@ mount_msdos_parseargs(int argc, char **argv,
dev = argv[optind];
dir = argv[optind + 1];
if (realpath(dev, canon_dev) == NULL) /* Check device path */
err(1, "realpath %s", dev);
if (strncmp(dev, canon_dev, MAXPATHLEN)) {
warnx("\"%s\" is a non-resolved or relative path.", dev);
warnx("using \"%s\" instead.", canon_dev);
}
if (realpath(dir, canon_dir) == NULL) /* Check mounton path */
err(1, "realpath %s", dir);
if (strncmp(dir, canon_dir, MAXPATHLEN)) {
warnx("\"%s\" is a non-resolved or relative path.", dir);
warnx("using \"%s\" instead.", canon_dir);
}
pathadj(dev, canon_dev);
pathadj(dir, canon_dir);
args->fspec = dev;
if (!set_gid || !set_uid || !set_mask) {

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.9 2005/06/27 01:00:06 christos Exp $
# $NetBSD: Makefile,v 1.10 2008/08/05 20:57:45 pooka Exp $
#
# Id: Makefile,v 1.1.1.1 1999/02/03 03:51:19 semenu Exp
#
@ -6,7 +6,7 @@
.include <bsd.own.mk>
PROG= mount_ntfs
SRCS= mount_ntfs.c fattr.c
SRCS= mount_ntfs.c fattr.c pathadj.c
MAN= mount_ntfs.8
MOUNT= ${NETBSDSRCDIR}/sbin/mount

View File

@ -1,4 +1,4 @@
/* $NetBSD: mount_ntfs.c,v 1.20 2007/12/15 19:44:46 perry Exp $ */
/* $NetBSD: mount_ntfs.c,v 1.21 2008/08/05 20:57:45 pooka Exp $ */
/*
* Copyright (c) 1994 Christopher G. Demetriou
@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: mount_ntfs.c,v 1.20 2007/12/15 19:44:46 perry Exp $");
__RCSID("$NetBSD: mount_ntfs.c,v 1.21 2008/08/05 20:57:45 pooka Exp $");
#endif
#include <sys/param.h>
@ -53,7 +53,9 @@ __RCSID("$NetBSD: mount_ntfs.c,v 1.20 2007/12/15 19:44:46 perry Exp $");
#include <util.h>
#include <mntopts.h>
#include <fattr.h>
#include "mountprog.h"
#include "mount_ntfs.h"
static const struct mntopt mopts[] = {
MOPT_STDOPTS,
@ -62,50 +64,52 @@ static const struct mntopt mopts[] = {
};
static void usage(void) __dead;
int mount_ntfs(int argc, char **argv);
#ifndef MOUNT_NOMAIN
int
main(int argc, char **argv)
{
setprogname(argv[0]);
return mount_ntfs(argc, argv);
}
#endif
int
mount_ntfs(int argc, char **argv)
void
mount_ntfs_parseargs(int argc, char **argv,
struct ntfs_args *args, int *mntflags,
char *canon_dev, char *canon_dir)
{
struct ntfs_args args;
struct stat sb;
int c, mntflags, set_gid, set_uid, set_mask;
char *dev, *dir, canon_dev[MAXPATHLEN], canon_dir[MAXPATHLEN];
int c, set_gid, set_uid, set_mask;
char *dev, *dir;
mntoptparse_t mp;
mntflags = set_gid = set_uid = set_mask = 0;
(void)memset(&args, '\0', sizeof(args));
*mntflags = set_gid = set_uid = set_mask = 0;
(void)memset(args, '\0', sizeof(*args));
while ((c = getopt(argc, argv, "aiu:g:m:o:")) != -1) {
switch (c) {
case 'u':
args.uid = a_uid(optarg);
args->uid = a_uid(optarg);
set_uid = 1;
break;
case 'g':
args.gid = a_gid(optarg);
args->gid = a_gid(optarg);
set_gid = 1;
break;
case 'm':
args.mode = a_mask(optarg);
args->mode = a_mask(optarg);
set_mask = 1;
break;
case 'i':
args.flag |= NTFS_MFLAG_CASEINS;
args->flag |= NTFS_MFLAG_CASEINS;
break;
case 'a':
args.flag |= NTFS_MFLAG_ALLNAMES;
args->flag |= NTFS_MFLAG_ALLNAMES;
break;
case 'o':
mp = getmntopts(optarg, mopts, &mntflags, 0);
mp = getmntopts(optarg, mopts, mntflags, 0);
if (mp == NULL)
err(1, "getmntopts");
freemntopts(mp);
@ -123,37 +127,35 @@ mount_ntfs(int argc, char **argv)
dev = argv[optind];
dir = argv[optind + 1];
if (realpath(dev, canon_dev) == NULL) /* Check device path */
err(1, "realpath %s", dev);
if (strncmp(dev, canon_dev, MAXPATHLEN)) {
warnx("\"%s\" is a relative path.", dev);
dev = canon_dev;
warnx("using \"%s\" instead.", dev);
}
pathadj(dev, canon_dev);
pathadj(dir, canon_dir);
if (realpath(dir, canon_dir) == NULL) /* Check mounton path */
err(1, "realpath %s", dir);
if (strncmp(dir, canon_dir, MAXPATHLEN)) {
warnx("\"%s\" is a relative path.", dir);
dir = canon_dir;
warnx("using \"%s\" instead.", dir);
}
args.fspec = dev;
args->fspec = dev;
if (!set_gid || !set_uid || !set_mask) {
if (stat(dir, &sb) == -1)
err(EX_OSERR, "stat %s", dir);
if (!set_uid)
args.uid = sb.st_uid;
args->uid = sb.st_uid;
if (!set_gid)
args.gid = sb.st_gid;
args->gid = sb.st_gid;
if (!set_mask)
args.mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
args->mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
}
}
if (mount(MOUNT_NTFS, dir, mntflags, &args, sizeof args) == -1)
err(EX_OSERR, "%s on %s", dev, dir);
int
mount_ntfs(int argc, char *argv[])
{
struct ntfs_args args;
int mntflags;
char canon_dev[MAXPATHLEN], canon_dir[MAXPATHLEN];
mount_ntfs_parseargs(argc, argv, &args, &mntflags,
canon_dev, canon_dir);
if (mount(MOUNT_NTFS, canon_dir, mntflags, &args, sizeof args) == -1)
err(EX_OSERR, "%s on %s", canon_dev, canon_dir);
if (mntflags & MNT_GETARGS) {
char buf[1024];
@ -167,6 +169,7 @@ mount_ntfs(int argc, char **argv)
static void
usage(void)
{
fprintf(stderr, "usage: mount_ntfs [-a] [-i] [-u user] [-g group] [-m mask] bdev dir\n");
fprintf(stderr, "usage: %s [-a] [-i] [-u user] [-g group] [-m mask] "
"bdev dir\n", getprogname());
exit(EX_USAGE);
}

View File

@ -1,8 +1,7 @@
/* $NetBSD: vfslist.h,v 1.4 2005/06/26 21:43:33 christos Exp $ */
/* $NetBSD: mount_ntfs.h,v 1.1 2008/08/05 20:57:45 pooka Exp $ */
/*
* Copyright (c) 1995
* The Regents of the University of California. All rights reserved.
* Copyright (c) 2008 The NetBSD Foundation. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -12,22 +11,27 @@
* 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. 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
* 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 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)
* 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.
*/
int checkvfsname(const char *, const char **);
const char **makevfslist(const char *);
#ifndef _SBIN_MOUNT_NTFS_MOUNT_NTFS_H_
#define _SBIN_MOUNT_NTFS_MOUNT_NTFS_H_
#include <ntfs/ntfsmount.h>
int mount_ntfs(int, char **);
void mount_ntfs_parseargs(int, char **, struct ntfs_args *, int *,
char *, char *);
#endif /* _SBIN_MOUNT_NTFS_MOUNT_NTFS_H_ */

View File

@ -1,9 +1,9 @@
# $NetBSD: Makefile,v 1.3 2008/07/28 12:42:12 pooka Exp $
# $NetBSD: Makefile,v 1.4 2008/08/05 20:57:45 pooka Exp $
.include <bsd.own.mk>
PROG= mount_tmpfs
SRCS= mount_tmpfs.c fattr.c
SRCS= mount_tmpfs.c fattr.c pathadj.c
MAN= mount_tmpfs.8
MOUNT= ${NETBSDSRCDIR}/sbin/mount

View File

@ -1,4 +1,4 @@
/* $NetBSD: mount_tmpfs.c,v 1.23 2008/07/28 12:42:12 pooka Exp $ */
/* $NetBSD: mount_tmpfs.c,v 1.24 2008/08/05 20:57:45 pooka Exp $ */
/*
* Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
@ -32,7 +32,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: mount_tmpfs.c,v 1.23 2008/07/28 12:42:12 pooka Exp $");
__RCSID("$NetBSD: mount_tmpfs.c,v 1.24 2008/08/05 20:57:45 pooka Exp $");
#endif /* not lint */
#include <sys/param.h>
@ -51,7 +51,9 @@ __RCSID("$NetBSD: mount_tmpfs.c,v 1.23 2008/07/28 12:42:12 pooka Exp $");
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "fattr.h"
#include "mountprog.h"
#include "mount_tmpfs.h"
/* --------------------------------------------------------------------- */
@ -63,32 +65,30 @@ static const struct mntopt mopts[] = {
/* --------------------------------------------------------------------- */
static int mount_tmpfs(int argc, char **argv);
static void usage(void) __dead;
/* --------------------------------------------------------------------- */
int
mount_tmpfs(int argc, char *argv[])
void
mount_tmpfs_parseargs(int argc, char *argv[],
struct tmpfs_args *args, int *mntflags,
char *canon_dev, char *canon_dir)
{
char canon_dir[MAXPATHLEN];
int gidset, modeset, uidset; /* Ought to be 'bool'. */
int ch, mntflags;
int ch;
gid_t gid;
uid_t uid;
mode_t mode;
int64_t tmpnumber;
mntoptparse_t mp;
struct tmpfs_args args;
struct stat sb;
setprogname(argv[0]);
/* Set default values for mount point arguments. */
args.ta_version = TMPFS_ARGS_VERSION;
args.ta_size_max = 0;
args.ta_nodes_max = 0;
mntflags = 0;
memset(args, 0, sizeof(*args));
args->ta_version = TMPFS_ARGS_VERSION;
args->ta_size_max = 0;
args->ta_nodes_max = 0;
*mntflags = 0;
gidset = 0; gid = 0;
uidset = 0; uid = 0;
@ -111,11 +111,11 @@ mount_tmpfs(int argc, char *argv[])
if (dehumanize_number(optarg, &tmpnumber) == -1)
err(EXIT_FAILURE, "failed to parse nodes `%s'",
optarg);
args.ta_nodes_max = tmpnumber;
args->ta_nodes_max = tmpnumber;
break;
case 'o':
mp = getmntopts(optarg, mopts, &mntflags, 0);
mp = getmntopts(optarg, mopts, mntflags, 0);
if (mp == NULL)
err(EXIT_FAILURE, "getmntopts");
freemntopts(mp);
@ -125,7 +125,7 @@ mount_tmpfs(int argc, char *argv[])
if (dehumanize_number(optarg, &tmpnumber) == -1)
err(EXIT_FAILURE, "failed to parse size `%s'",
optarg);
args.ta_size_max = tmpnumber;
args->ta_size_max = tmpnumber;
break;
case 'u':
@ -144,20 +144,39 @@ mount_tmpfs(int argc, char *argv[])
if (argc != 2)
usage();
if (realpath(argv[1], canon_dir) == NULL)
err(EXIT_FAILURE, "realpath %s", argv[1]);
if (strncmp(argv[1], canon_dir, MAXPATHLEN) != 0) {
warnx("\"%s\" is a relative path", argv[1]);
warnx("using \"%s\" instead", canon_dir);
}
strlcpy(canon_dev, argv[0], MAXPATHLEN);
pathadj(argv[1], canon_dir);
if (stat(canon_dir, &sb) == -1)
err(EXIT_FAILURE, "cannot stat `%s'", canon_dir);
args.ta_root_uid = uidset ? uid : sb.st_uid;
args.ta_root_gid = gidset ? gid : sb.st_gid;
args.ta_root_mode = modeset ? mode : sb.st_mode;
args->ta_root_uid = uidset ? uid : sb.st_uid;
args->ta_root_gid = gidset ? gid : sb.st_gid;
args->ta_root_mode = modeset ? mode : sb.st_mode;
}
/* --------------------------------------------------------------------- */
static void
usage(void)
{
(void)fprintf(stderr,
"Usage: %s [-g group] [-m mode] [-n nodes] [-o options] [-s size]\n"
" [-u user] tmpfs mountpoint\n", getprogname());
exit(1);
}
/* --------------------------------------------------------------------- */
int
mount_tmpfs(int argc, char *argv[])
{
struct tmpfs_args args;
char canon_dev[MAXPATHLEN], canon_dir[MAXPATHLEN];
int mntflags;
mount_tmpfs_parseargs(argc, argv, &args, &mntflags,
canon_dev, canon_dir);
if (mount(MOUNT_TMPFS, canon_dir, mntflags, &args, sizeof args) == -1)
err(EXIT_FAILURE, "tmpfs on %s", canon_dir);
@ -192,24 +211,12 @@ mount_tmpfs(int argc, char *argv[])
return EXIT_SUCCESS;
}
/* --------------------------------------------------------------------- */
static void
usage(void)
{
(void)fprintf(stderr,
"Usage: %s [-g group] [-m mode] [-n nodes] [-o options] [-s size]\n"
" [-u user] tmpfs mountpoint\n", getprogname());
exit(1);
}
/* --------------------------------------------------------------------- */
#ifndef MOUNT_NOMAIN
int
main(int argc, char *argv[])
{
setprogname(argv[0]);
return mount_tmpfs(argc, argv);
}
#endif

View File

@ -0,0 +1,37 @@
/* $NetBSD: mount_tmpfs.h,v 1.1 2008/08/05 20:57:45 pooka Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation. 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 ``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.
*/
#ifndef _SBIN_MOUNT_TMPFS_MOUNT_TMPFS_H_
#define _SBIN_MOUNT_TMPFS_MOUNT_TMPFS_H_
#include <fs/tmpfs/tmpfs_args.h>
int mount_tmpfs(int, char **);
void mount_tmpfs_parseargs(int, char **, struct tmpfs_args *, int *,
char *, char *);
#endif /* _SBIN_MOUNT_TMPFS_MOUNT_TMPFS_H_ */

View File

@ -1,10 +1,10 @@
# $NetBSD: Makefile,v 1.1 2006/02/02 15:21:29 reinoud Exp $
# $NetBSD: Makefile,v 1.2 2008/08/05 20:57:45 pooka Exp $
.include <bsd.own.mk>
WARNS= 4
PROG= mount_udf
SRCS= mount_udf.c fattr.c
SRCS= mount_udf.c fattr.c pathadj.c
MAN= mount_udf.8
MOUNT= ${NETBSDSRCDIR}/sbin/mount

View File

@ -1,4 +1,4 @@
/* $NetBSD: mount_udf.c,v 1.11 2007/12/15 19:44:46 perry Exp $ */
/* $NetBSD: mount_udf.c,v 1.12 2008/08/05 20:57:45 pooka Exp $ */
/*
* Copyright (c) 2006 Reinoud Zandijk
@ -36,7 +36,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: mount_udf.c,v 1.11 2007/12/15 19:44:46 perry Exp $");
__RCSID("$NetBSD: mount_udf.c,v 1.12 2008/08/05 20:57:45 pooka Exp $");
#endif /* not lint */
@ -60,8 +60,9 @@ __RCSID("$NetBSD: mount_udf.c,v 1.11 2007/12/15 19:44:46 perry Exp $");
/* mount specific options */
#include <fs/udf/udf_mount.h>
#include <mntopts.h>
#include <fattr.h>
#include "mountprog.h"
#include "mount_udf.h"
/* options to pass on to the `mount' call */
static const struct mntopt mopts[] = {
@ -75,7 +76,6 @@ static const struct mntopt mopts[] = {
/* prototypes */
int mount_udf(int argc, char **argv);
static void usage(void) __dead;
@ -90,37 +90,35 @@ usage(void)
}
/* copied from mount_msdos; is it necessary still? */
#ifndef MOUNT_NOMAIN
int
main(int argc, char **argv)
{
setprogname(argv[0]);
return mount_udf(argc, argv);
}
#endif
/* main routine */
int
mount_udf(int argc, char **argv)
void
mount_udf_parseargs(int argc, char **argv,
struct udf_args *args, int *mntflags,
char *canon_dev, char *canon_dir)
{
struct udf_args args;
struct tm *tm;
time_t now;
uid_t anon_uid, nobody_uid;
gid_t anon_gid, nobody_gid;
char *dev, *dir;
int ch, mntflags, set_gmtoff;
int ch, set_gmtoff;
uint32_t sector_size;
mntoptparse_t mp;
/* set program name for error messages */
setprogname(argv[0]);
/* initialise */
(void)memset(&args, 0, sizeof(args));
(void)memset(args, 0, sizeof(*args));
set_gmtoff = mntflags = 0;
set_gmtoff = *mntflags = 0;
sector_size = 0;
/* get nobody */
@ -135,7 +133,7 @@ mount_udf(int argc, char **argv)
switch (ch) {
#ifdef notyet
case 'c' :
args.udfmflags |= UDFMNT_CLOSESESSION;
args->udfmflags |= UDFMNT_CLOSESESSION;
break;
#endif
case 'g' :
@ -148,16 +146,16 @@ mount_udf(int argc, char **argv)
break;
case 'o' :
/* process generic mount options */
mp = getmntopts(optarg, mopts, &mntflags, 0);
mp = getmntopts(optarg, mopts, mntflags, 0);
if (mp == NULL)
err(EXIT_FAILURE, "getmntopts");
freemntopts(mp);
break;
case 's' :
args.sessionnr = a_num(optarg, "session number");
args->sessionnr = a_num(optarg, "session number");
break;
case 't' :
args.gmtoff = a_num(optarg, "gmtoff");
args->gmtoff = a_num(optarg, "gmtoff");
set_gmtoff = 1;
break;
default :
@ -173,24 +171,34 @@ mount_udf(int argc, char **argv)
/* use user's time zone as default */
(void)time(&now);
tm = localtime(&now);
args.gmtoff = tm->tm_gmtoff;
args->gmtoff = tm->tm_gmtoff;
}
/* get device and directory specifier */
dev = argv[optind];
dir = argv[optind + 1];
pathadj(argv[optind], canon_dev);
pathadj(argv[optind+1], canon_dir);
args.version = UDFMNT_VERSION;
args.fspec = dev;
args.anon_uid = anon_uid;
args.anon_gid = anon_gid;
args.nobody_uid = nobody_uid;
args.nobody_gid = nobody_gid;
args.sector_size = sector_size; /* invalid */
args->version = UDFMNT_VERSION;
args->fspec = canon_dev;
args->anon_uid = anon_uid;
args->anon_gid = anon_gid;
args->nobody_uid = nobody_uid;
args->nobody_gid = nobody_gid;
args->sector_size = sector_size; /* invalid */
}
int
mount_udf(int argc, char *argv[])
{
struct udf_args args;
char canon_dev[MAXPATHLEN], canon_dir[MAXPATHLEN];
int mntflags;
mount_udf_parseargs(argc, argv, &args, &mntflags, canon_dev, canon_dir);
/* mount it! :) */
if (mount(MOUNT_UDF, dir, mntflags, &args, sizeof args) == -1)
err(EXIT_FAILURE, "Cannot mount %s on %s", dev, dir);
if (mount(MOUNT_UDF, canon_dir, mntflags, &args, sizeof args) == -1)
err(EXIT_FAILURE, "Cannot mount %s on %s", canon_dev,canon_dir);
if (mntflags & MNT_GETARGS) {
char buf[1024];

View File

@ -0,0 +1,37 @@
/* $NetBSD: mount_udf.h,v 1.1 2008/08/05 20:57:45 pooka Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation. 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 ``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.
*/
#ifndef _SBIN_MOUNT_UDF_MOUNT_UDF_H_
#define _SBIN_MOUNT_UDF_MOUNT_UDF_H_
#include <fs/udf/udf_mount.h>
int mount_udf(int, char **);
void mount_udf_parseargs(int, char **, struct udf_args *, int *,
char *, char *);
#endif /* _SBIN_MOUNT_UDF_MOUNT_UDF_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: newfs_udf.c,v 1.4 2008/07/26 20:20:56 reinoud Exp $ */
/* $NetBSD: newfs_udf.c,v 1.5 2008/08/05 20:57:45 pooka Exp $ */
/*
* Copyright (c) 2006, 2008 Reinoud Zandijk
@ -47,7 +47,6 @@
#include <fcntl.h>
#include <unistd.h>
#include <util.h>
#include <fattr.h>
#include <time.h>
#include <assert.h>
#include <err.h>
@ -63,6 +62,8 @@
#include <fs/udf/ecma167-udf.h>
#include <fs/udf/udf_mount.h>
#include "mountprog.h"
#include "udf_create.h"
/* general settings */

View File

@ -1,4 +1,4 @@
/* $NetBSD: umount.c,v 1.42 2008/07/20 01:20:23 lukem Exp $ */
/* $NetBSD: umount.c,v 1.43 2008/08/05 20:57:45 pooka Exp $ */
/*-
* Copyright (c) 1980, 1989, 1993
@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1989, 1993\
#if 0
static char sccsid[] = "@(#)umount.c 8.8 (Berkeley) 5/8/95";
#else
__RCSID("$NetBSD: umount.c,v 1.42 2008/07/20 01:20:23 lukem Exp $");
__RCSID("$NetBSD: umount.c,v 1.43 2008/08/05 20:57:45 pooka Exp $");
#endif
#endif /* not lint */
@ -67,7 +67,7 @@ __RCSID("$NetBSD: umount.c,v 1.42 2008/07/20 01:20:23 lukem Exp $");
typedef enum { MNTANY, MNTON, MNTFROM } mntwhat;
#ifndef SMALL
#include "vfslist.h"
#include "mountprog.h"
static int fake, verbose;
static char *nfshost;

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile.inc,v 1.3 2008/07/29 13:17:47 pooka Exp $
# $NetBSD: Makefile.inc,v 1.4 2008/08/05 20:57:45 pooka Exp $
USE_FORT?= yes # network client
@ -7,9 +7,21 @@ USE_FORT?= yes # network client
.endif
.ifdef(ISRUMP)
.ifdef(MOUNTNAME)
LDADD+= -lrumpfs_${MOUNTNAME}
PROG= rump_${MOUNTNAME}
MOUNTDIR= ${.CURDIR}/../../../sbin
MOUNT= ${MOUNTDIR}/mount
CPPFLAGS+= -I${MOUNTDIR}/mount_${MOUNTNAME} -I${MOUNT} -DMOUNT_NOMAIN
SRCS+= mount_${MOUNTNAME}.c rump_${MOUNTNAME}.c pathadj.c fattr.c
.PATH: ${MOUNT} ${MOUNTDIR}/mount_${MOUNTNAME}
.endif # MOUNTNAME
LDADD+= -lp2k -lukfs -lrump -lrumpuser -lpuffs -lutil -lpthread
DPADD+= ${LIBP2K} ${LIBUKFS} ${LIBRUMP} ${LIBRUMPUSER} ${LIBPUFFS}
DPADD+= ${LIBUTIL} ${LIBPTHREAD}
LDFLAGS+= -Wl,--wrap=malloc
NOMAN= # temporary
.endif
.endif # ISRUMP

View File

@ -1,11 +1,7 @@
# $NetBSD: Makefile,v 1.1 2008/07/29 13:17:47 pooka Exp $
# $NetBSD: Makefile,v 1.2 2008/08/05 20:57:45 pooka Exp $
#
PROG= rump_cd9660
NOMAN= 1
LDADD+= -lrumpfs_cd9660fs
DPADD+= ${LIBRUMPFS_CD9660FS}
MOUNTNAME= cd9660
ISRUMP= # yes

View File

@ -1,4 +1,4 @@
/* $NetBSD: rump_cd9660.c,v 1.1 2008/07/29 13:17:47 pooka Exp $ */
/* $NetBSD: rump_cd9660.c,v 1.2 2008/08/05 20:57:45 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@ -38,20 +38,20 @@
#include <stdlib.h>
#include <string.h>
#include "mount_cd9660.h"
int
main(int argc, char *argv[])
{
struct iso_args args;
int rv;
char canon_dev[MAXPATHLEN], canon_dir[MAXPATHLEN];
int rv, mntflags;
setprogname(argv[0]);
if (argc != 3)
errx(1, "usage: %s dev mountpath", getprogname());
memset(&args, 0, sizeof(args));
args.fspec = argv[1];
rv = p2k_run_fs(MOUNT_CD9660, argv[1], argv[2], MNT_RDONLY,
mount_cd9660_parseargs(argc, argv, &args, &mntflags,
canon_dev, canon_dir);
rv = p2k_run_fs(MOUNT_CD9660, canon_dev, canon_dir, MNT_RDONLY,
&args, sizeof(args), 0);
if (rv)
err(1, "mount");

View File

@ -1,10 +1,7 @@
# $NetBSD: Makefile,v 1.1 2008/07/29 13:17:47 pooka Exp $
# $NetBSD: Makefile,v 1.2 2008/08/05 20:57:45 pooka Exp $
#
PROG= rump_efs
LDADD+= -lrumpfs_efs
DPADD+= ${LIBRUMPFS_EFS}
MOUNTNAME= efs
ISRUMP= # gracie, padre

View File

@ -1,4 +1,4 @@
/* $NetBSD: rump_efs.c,v 1.1 2008/07/29 13:17:47 pooka Exp $ */
/* $NetBSD: rump_efs.c,v 1.2 2008/08/05 20:57:45 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@ -39,47 +39,21 @@
#include <rump/p2k.h>
static void
usage(void)
{
errx(1, "usage: %s [-o opts] dev mountpath", getprogname());
}
#include "mount_efs.h"
int
main(int argc, char *argv[])
{
struct efs_args args;
mntoptparse_t mp;
int mntflags, pflags;
int rv, ch;
char canon_dev[MAXPATHLEN], canon_dir[MAXPATHLEN];
int mntflags;
int rv;
setprogname(argv[0]);
mntflags = pflags = 0;
while ((ch = getopt(argc, argv, "o:")) != -1) {
switch (ch) {
case 'o':
mp = getmntopts(optarg, puffsmopts, &mntflags, &pflags);
if (mp == NULL)
err(1, "getmntops");
freemntopts(mp);
break;
default:
usage();
/* NOTREACHED */
}
}
argc -= optind;
argv += optind;
if (argc != 2)
usage();
memset(&args, 0, sizeof(args));
args.fspec = argv[0];
rv = p2k_run_fs(MOUNT_EFS, argv[0], argv[1], mntflags | MNT_RDONLY,
&args, sizeof(args), pflags);
mount_efs_parseargs(argc, argv, &args, &mntflags, canon_dev, canon_dir);
rv = p2k_run_fs(MOUNT_EFS, canon_dev, canon_dir, mntflags,
&args, sizeof(args), 0);
if (rv)
err(1, "mount");

View File

@ -1,7 +1,7 @@
# $NetBSD: Makefile,v 1.1 2008/07/29 13:17:47 pooka Exp $
# $NetBSD: Makefile,v 1.2 2008/08/05 20:57:46 pooka Exp $
#
PROG= rump_ext2fs
MOUNTNAME= ext2fs
LDADD+= -lrumpfs_ext2fs -lrumpfs_ufs -lrumpfs_ffs
DPADD+= ${LIBRUMPFS_EXT2FS} ${LIBRUMPFS_UFS} ${LIBRUMPFS_FFS}

View File

@ -1,4 +1,4 @@
/* $NetBSD: rump_ext2fs.c,v 1.1 2008/07/29 13:17:47 pooka Exp $ */
/* $NetBSD: rump_ext2fs.c,v 1.2 2008/08/05 20:57:46 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@ -39,47 +39,22 @@
#include <rump/p2k.h>
static void
usage(void)
{
errx(1, "usage: %s [-o opts] dev mountpath", getprogname());
}
#include "mount_ext2fs.h"
int
main(int argc, char *argv[])
{
struct ufs_args args;
mntoptparse_t mp;
int mntflags, pflags;
int rv, ch;
char canon_dev[MAXPATHLEN], canon_dir[MAXPATHLEN];
int mntflags;
int rv;
setprogname(argv[0]);
mntflags = pflags = 0;
while ((ch = getopt(argc, argv, "o:")) != -1) {
switch (ch) {
case 'o':
mp = getmntopts(optarg, puffsmopts, &mntflags, &pflags);
if (mp == NULL)
err(1, "getmntops");
freemntopts(mp);
break;
default:
usage();
/* NOTREACHED */
}
}
argc -= optind;
argv += optind;
if (argc != 2)
usage();
memset(&args, 0, sizeof(args));
args.fspec = argv[0];
rv = p2k_run_fs(MOUNT_EXT2FS, argv[0], argv[1], mntflags,
&args, sizeof(args), pflags);
mount_ext2fs_parseargs(argc, argv, &args, &mntflags,
canon_dev, canon_dir);
rv = p2k_run_fs(MOUNT_EXT2FS, canon_dev, canon_dir, mntflags,
&args, sizeof(args), 0);
if (rv)
err(1, "mount");

View File

@ -1,7 +1,7 @@
# $NetBSD: Makefile,v 1.1 2008/07/29 13:17:47 pooka Exp $
# $NetBSD: Makefile,v 1.2 2008/08/05 20:57:46 pooka Exp $
#
PROG= rump_ffs
MOUNTNAME= ffs
LDADD+= -lrumpfs_ffs -lrumpfs_ufs
DPADD+= ${LIBRUMPFS_FFS} ${LIBRUMPFS_UFS}

View File

@ -1,4 +1,4 @@
/* $NetBSD: rump_ffs.c,v 1.1 2008/07/29 13:17:47 pooka Exp $ */
/* $NetBSD: rump_ffs.c,v 1.2 2008/08/05 20:57:46 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@ -39,66 +39,21 @@
#include <rump/p2k.h>
/* XXX: figure out a proper way to share code/integrate with mount_ffs */
static const struct mntopt ffsmopts[] = {
MOPT_STDOPTS,
MOPT_ASYNC,
MOPT_SYNC,
MOPT_UPDATE,
MOPT_RELOAD,
MOPT_NOATIME,
MOPT_NODEVMTIME,
MOPT_FORCE,
MOPT_SOFTDEP,
MOPT_GETARGS,
MOPT_NULL,
};
static void
usage(void)
{
errx(1, "usage: %s [-o opts] dev mountpath", getprogname());
}
#include "mount_ffs.h"
int
main(int argc, char *argv[])
{
struct ufs_args args;
mntoptparse_t mp;
int mntflags, pflags;
int rv, ch;
char canon_dev[MAXPATHLEN], canon_dir[MAXPATHLEN];
int mntflags;
int rv;
setprogname(argv[0]);
getmnt_silent = 1;
mntflags = pflags = 0;
while ((ch = getopt(argc, argv, "o:")) != -1) {
switch (ch) {
case 'o':
mp = getmntopts(optarg, puffsmopts, &mntflags, &pflags);
if (mp == NULL) {
mp = getmntopts(optarg, ffsmopts, &mntflags, 0);
if (mp == NULL)
err(1, "getmntops");
}
freemntopts(mp);
break;
default:
usage();
/* NOTREACHED */
}
}
argc -= optind;
argv += optind;
if (argc != 2)
usage();
memset(&args, 0, sizeof(args));
args.fspec = argv[0];
rv = p2k_run_fs(MOUNT_FFS, argv[0], argv[1], mntflags,
&args, sizeof(args), pflags);
mount_ffs_parseargs(argc, argv, &args, &mntflags, canon_dev, canon_dir);
rv = p2k_run_fs(MOUNT_FFS, canon_dev, canon_dir, mntflags,
&args, sizeof(args), 0);
if (rv)
err(1, "mount");

View File

@ -1,11 +1,9 @@
# $NetBSD: Makefile,v 1.1 2008/07/29 13:17:48 pooka Exp $
# $NetBSD: Makefile,v 1.2 2008/08/05 20:57:46 pooka Exp $
#
PROG= rump_hfs
MOUNTNAME= hfs
LDADD+= -lrumpfs_hfs
DPADD+= ${LIBRUMPFS_HFS}
ISRUMP= # rump roast
.include <bsd.prog.mk>

View File

@ -1,4 +1,4 @@
/* $NetBSD: rump_hfs.c,v 1.1 2008/07/29 13:17:48 pooka Exp $ */
/* $NetBSD: rump_hfs.c,v 1.2 2008/08/05 20:57:46 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@ -39,47 +39,21 @@
#include <rump/p2k.h>
static void
usage(void)
{
errx(1, "usage: %s [-o opts] dev mountpath", getprogname());
}
#include "mount_hfs.h"
int
main(int argc, char *argv[])
{
struct hfs_args args;
mntoptparse_t mp;
int mntflags, pflags;
int rv, ch;
char canon_dev[MAXPATHLEN], canon_dir[MAXPATHLEN];
int mntflags;
int rv;
setprogname(argv[0]);
mntflags = pflags = 0;
while ((ch = getopt(argc, argv, "o:")) != -1) {
switch (ch) {
case 'o':
mp = getmntopts(optarg, puffsmopts, &mntflags, &pflags);
if (mp == NULL)
err(1, "getmntops");
freemntopts(mp);
break;
default:
usage();
/* NOTREACHED */
}
}
argc -= optind;
argv += optind;
if (argc != 2)
usage();
memset(&args, 0, sizeof(args));
args.fspec = argv[0];
rv = p2k_run_fs(MOUNT_HFS, argv[0], argv[1], mntflags,
&args, sizeof(args), pflags);
mount_hfs_parseargs(argc, argv, &args, &mntflags, canon_dev, canon_dir);
rv = p2k_run_fs(MOUNT_HFS, canon_dev, canon_dir, mntflags,
&args, sizeof(args), 0);
if (rv)
err(1, "mount");

View File

@ -1,7 +1,7 @@
# $NetBSD: Makefile,v 1.1 2008/07/29 13:17:48 pooka Exp $
# $NetBSD: Makefile,v 1.2 2008/08/05 20:57:46 pooka Exp $
#
PROG= rump_lfs
MOUNTNAME= lfs
LDADD+= -lrumpfs_lfs -lrumpfs_ufs -lrumpfs_ffs
DPADD+= ${LIBRUMPFS_LFS} ${LIBRUMPFS_UFS} ${LIBRUMPFS_FFS}

View File

@ -1,4 +1,4 @@
/* $NetBSD: rump_lfs.c,v 1.1 2008/07/29 13:17:48 pooka Exp $ */
/* $NetBSD: rump_lfs.c,v 1.2 2008/08/05 20:57:46 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@ -39,47 +39,21 @@
#include <rump/p2k.h>
static void
usage(void)
{
errx(1, "usage: %s [-o opts] dev mountpath", getprogname());
}
#include "mount_lfs.h"
int
main(int argc, char *argv[])
{
struct ufs_args args;
mntoptparse_t mp;
int mntflags, pflags;
int rv, ch;
char canon_dev[MAXPATHLEN], canon_dir[MAXPATHLEN];
int mntflags;
int rv;
setprogname(argv[0]);
mntflags = pflags = 0;
while ((ch = getopt(argc, argv, "o:")) != -1) {
switch (ch) {
case 'o':
mp = getmntopts(optarg, puffsmopts, &mntflags, &pflags);
if (mp == NULL)
err(1, "getmntops");
freemntopts(mp);
break;
default:
usage();
/* NOTREACHED */
}
}
argc -= optind;
argv += optind;
if (argc != 2)
usage();
memset(&args, 0, sizeof(args));
args.fspec = argv[0];
rv = p2k_run_fs(MOUNT_LFS, argv[0], argv[1], mntflags,
&args, sizeof(args), pflags);
mount_lfs_parseargs(argc, argv, &args, &mntflags, canon_dev, canon_dir);
rv = p2k_run_fs(MOUNT_LFS, canon_dev, canon_dir, mntflags,
&args, sizeof(args), 0);
if (rv)
err(1, "mount");

View File

@ -1,17 +1,7 @@
# $NetBSD: Makefile,v 1.2 2008/07/29 16:06:18 pooka Exp $
# $NetBSD: Makefile,v 1.3 2008/08/05 20:57:46 pooka Exp $
#
PROG= rump_msdos
MOUNT= ${.CURDIR}/../../../sbin/mount
MOUNTMSDOS= ${.CURDIR}/../../../sbin/mount_msdos
.PATH: ${MOUNT} ${MOUNTMSDOS}
SRCS= rump_msdos.c mount_msdos.c fattr.c
LDADD+= -lrumpfs_msdosfs
DPADD+= ${LIBRUMPFS_MSDOSFS}
CPPFLAGS+= -DMOUNT_NOMAIN -I${MOUNT} -I${MOUNTMSDOS}
MOUNTNAME= msdos
ISRUMP= # rump, si

View File

@ -1,10 +1,7 @@
# $NetBSD: Makefile,v 1.1 2008/07/29 13:17:48 pooka Exp $
# $NetBSD: Makefile,v 1.2 2008/08/05 20:57:46 pooka Exp $
#
PROG= rump_ntfs
LDADD+= -lrumpfs_ntfs
DPADD+= ${LIBRUMPFS_NTFS}
MOUNTNAME= ntfs
ISRUMP= # only for you sir, only for you

View File

@ -1,4 +1,4 @@
/* $NetBSD: rump_ntfs.c,v 1.1 2008/07/29 13:17:48 pooka Exp $ */
/* $NetBSD: rump_ntfs.c,v 1.2 2008/08/05 20:57:46 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@ -39,48 +39,22 @@
#include <rump/p2k.h>
static void
usage(void)
{
errx(1, "usage: %s [-o opts] dev mountpath", getprogname());
}
#include "mount_ntfs.h"
int
main(int argc, char *argv[])
{
struct ntfs_args args;
mntoptparse_t mp;
int mntflags, pflags;
int rv, ch;
char canon_dev[MAXPATHLEN], canon_dir[MAXPATHLEN];
int mntflags;
int rv;
setprogname(argv[0]);
mntflags = pflags = 0;
while ((ch = getopt(argc, argv, "o:")) != -1) {
switch (ch) {
case 'o':
mp = getmntopts(optarg, puffsmopts, &mntflags, &pflags);
if (mp == NULL)
err(1, "getmntops");
freemntopts(mp);
break;
default:
usage();
/* NOTREACHED */
}
}
argc -= optind;
argv += optind;
if (argc != 2)
usage();
memset(&args, 0, sizeof(args));
args.fspec = argv[0];
args.uid = getuid();
args.mode = 0777;
rv = p2k_run_fs(MOUNT_NTFS, argv[0], argv[1], mntflags,
&args, sizeof(args), pflags);
mount_ntfs_parseargs(argc, argv, &args, &mntflags,
canon_dev, canon_dir);
rv = p2k_run_fs(MOUNT_NTFS, canon_dev, canon_dir, mntflags,
&args, sizeof(args), 0);
if (rv)
err(1, "mount");

View File

@ -1,10 +1,7 @@
# $NetBSD: Makefile,v 1.1 2008/07/29 13:17:48 pooka Exp $
# $NetBSD: Makefile,v 1.2 2008/08/05 20:57:46 pooka Exp $
#
PROG= rump_tmpfs
LDADD+= -lrumpfs_tmpfs
DPADD+= ${LIBRUMPFS_TMPFS}
MOUNTNAME= tmpfs
ISRUMP= # the cock of the walk, baby

View File

@ -1,4 +1,4 @@
/* $NetBSD: rump_tmpfs.c,v 1.1 2008/07/29 13:17:48 pooka Exp $ */
/* $NetBSD: rump_tmpfs.c,v 1.2 2008/08/05 20:57:46 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@ -39,48 +39,22 @@
#include <rump/p2k.h>
static void
usage(void)
{
errx(1, "usage: %s [-o opts] dev mountpath", getprogname());
}
#include "mount_tmpfs.h"
int
main(int argc, char *argv[])
{
struct tmpfs_args args;
mntoptparse_t mp;
int mntflags, pflags;
int rv, ch;
char canon_dev[MAXPATHLEN], canon_dir[MAXPATHLEN];
int mntflags;
int rv;
setprogname(argv[0]);
mntflags = pflags = 0;
while ((ch = getopt(argc, argv, "o:")) != -1) {
switch (ch) {
case 'o':
mp = getmntopts(optarg, puffsmopts, &mntflags, &pflags);
if (mp == NULL)
err(1, "getmntops");
freemntopts(mp);
break;
default:
usage();
/* NOTREACHED */
}
}
argc -= optind;
argv += optind;
if (argc != 2)
usage();
memset(&args, 0, sizeof(args));
args.ta_version = TMPFS_ARGS_VERSION;
args.ta_root_mode = 0777;
rv = p2k_run_fs(MOUNT_TMPFS, argv[0], argv[1], mntflags,
&args, sizeof(args), pflags | PUFFS_KFLAG_NOCACHE_PAGE);
mount_tmpfs_parseargs(argc, argv, &args, &mntflags,
canon_dev, canon_dir);
rv = p2k_run_fs(MOUNT_TMPFS, canon_dev, canon_dir, mntflags,
&args, sizeof(args), PUFFS_KFLAG_NOCACHE_PAGE);
if (rv)
err(1, "mount");

View File

@ -1,10 +1,7 @@
# $NetBSD: Makefile,v 1.1 2008/07/29 13:17:48 pooka Exp $
# $NetBSD: Makefile,v 1.2 2008/08/05 20:57:46 pooka Exp $
#
PROG= rump_udf
LDADD+= -lrumpfs_udf
DPADD+= ${LIBRUMPFS_UDF}
MOUNTNAME= udf
ISRUMP= # more cowbell

View File

@ -1,4 +1,4 @@
/* $NetBSD: rump_udf.c,v 1.1 2008/07/29 13:17:48 pooka Exp $ */
/* $NetBSD: rump_udf.c,v 1.2 2008/08/05 20:57:46 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@ -39,48 +39,21 @@
#include <rump/p2k.h>
static void
usage(void)
{
errx(1, "usage: %s [-o opts] dev mountpath", getprogname());
}
#include "mount_udf.h"
int
main(int argc, char *argv[])
{
struct udf_args args;
mntoptparse_t mp;
int mntflags, pflags;
int rv, ch;
char canon_dev[MAXPATHLEN], canon_dir[MAXPATHLEN];
int mntflags;
int rv;
setprogname(argv[0]);
mntflags = pflags = 0;
while ((ch = getopt(argc, argv, "o:")) != -1) {
switch (ch) {
case 'o':
mp = getmntopts(optarg, puffsmopts, &mntflags, &pflags);
if (mp == NULL)
err(1, "getmntops");
freemntopts(mp);
break;
default:
usage();
/* NOTREACHED */
}
}
argc -= optind;
argv += optind;
if (argc != 2)
usage();
memset(&args, 0, sizeof(args));
args.version = UDFMNT_VERSION;
args.fspec = argv[0];
rv = p2k_run_fs(MOUNT_UDF, argv[0], argv[1], mntflags,
&args, sizeof(args), pflags);
mount_udf_parseargs(argc, argv, &args, &mntflags, canon_dev, canon_dir);
rv = p2k_run_fs(MOUNT_UDF, canon_dev, canon_dir, mntflags,
&args, sizeof(args), 0);
if (rv)
err(1, "mount");