Convert UDF to nmount.

Reviewed by:	scottl
This commit is contained in:
Maxime Henrion 2002-06-15 22:40:13 +00:00
parent 58f3c42e6d
commit c3210a83c0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=98265
3 changed files with 43 additions and 62 deletions

View File

@ -48,7 +48,6 @@
#include <sys/file.h>
#include <sys/param.h>
#include <sys/mount.h>
#include <fs/udf/udf_mount.h>
#include <err.h>
#include <errno.h>
@ -71,15 +70,13 @@ void usage(void);
int
main(int argc, char **argv)
{
struct udf_args args;
struct iovec iov[6];
int ch, mntflags, opts;
char *dev, *dir, mntpath[MAXPATHLEN];
struct vfsconf vfc;
int error, verbose;
mntflags = opts = verbose = 0;
memset(&args, 0, sizeof args);
args.ssector = -1;
while ((ch = getopt(argc, argv, "o:v")) != -1)
switch (ch) {
case 'o':
@ -108,16 +105,10 @@ main(int argc, char **argv)
(void)checkpath(dir, mntpath);
(void)rmslashes(dev, dev);
#define DEFAULT_ROOTUID -2
/*
* UDF filesystems are not writeable.
*/
mntflags |= MNT_RDONLY;
args.export.ex_flags = MNT_EXRDONLY;
args.fspec = dev;
args.export.ex_root = DEFAULT_ROOTUID;
args.flags = opts;
error = getvfsbyname("udf", &vfc);
if (error && vfsisloadable("udf")) {
if (vfsload("udf"))
@ -128,8 +119,20 @@ main(int argc, char **argv)
if (error)
errx(1, "udf filesystem is not available");
if (mount(vfc.vfc_name, mntpath, mntflags, &args) < 0)
err(1, "%s", args.fspec);
iov[0].iov_base = "fstype";
iov[0].iov_len = sizeof("fstype");
iov[1].iov_base = vfc.vfc_name;
iov[1].iov_len = strlen(vfc.vfc_name) + 1;
iov[2].iov_base = "fspath";
iov[2].iov_len = sizeof("fspath");
iov[3].iov_base = mntpath;
iov[3].iov_len = strlen(mntpath) + 1;
iov[4].iov_base = "from";
iov[4].iov_len = sizeof("from");
iov[5].iov_base = dev;
iov[5].iov_len = strlen(dev) + 1;
if (nmount(iov, 6, mntflags) < 0)
err(1, "%s", dev);
exit(0);
}

View File

@ -1,34 +0,0 @@
/*-
* Copyright (c) 2001, 2002 Scott Long <scottl@freebsd.org>
* 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$
*/
struct udf_args {
char *fspec;
struct export_args export;
int flags;
int ssector;
};

View File

@ -91,7 +91,6 @@
#include <fs/udf/ecma167-udf.h>
#include <fs/udf/udf.h>
#include <fs/udf/udf_mount.h>
#include <fs/udf/osta.h>
MALLOC_DEFINE(M_UDFMOUNT, "UDF mount", "UDF mount structure");
@ -104,8 +103,7 @@ uma_zone_t udf_zone_node = NULL;
static int udf_init(struct vfsconf *);
static int udf_uninit(struct vfsconf *);
static int udf_mount(struct mount *, char *, caddr_t, struct nameidata *,
struct thread *);
static int udf_mount(struct mount *, struct nameidata *, struct thread *);
static int udf_unmount(struct mount *, int, struct thread *);
static int udf_root(struct mount *, struct vnode **);
static int udf_statfs(struct mount *, struct statfs *, struct thread *);
@ -114,7 +112,7 @@ static int udf_vptofh(struct vnode *, struct fid *);
static int udf_find_partmaps(struct udf_mnt *, struct logvol_desc *);
static struct vfsops udf_vfsops = {
udf_mount,
NULL,
vfs_stdstart,
udf_unmount,
udf_root,
@ -128,10 +126,11 @@ static struct vfsops udf_vfsops = {
udf_init,
udf_uninit,
vfs_stdextattrctl,
udf_mount,
};
VFS_SET(udf_vfsops, udf, VFCF_READONLY);
static int udf_mountfs(struct vnode *, struct mount *, struct thread *, struct udf_args *);
static int udf_mountfs(struct vnode *, struct mount *, struct thread *);
static int
udf_init(struct vfsconf *foo)
@ -174,13 +173,17 @@ udf_uninit(struct vfsconf *foo)
}
static int
udf_mount(struct mount *mp, char *path, caddr_t data, struct nameidata *ndp, struct thread *td)
udf_mount(struct mount *mp, struct nameidata *ndp, struct thread *td)
{
struct vnode *devvp; /* vnode of the mount device */
struct udf_args args;
struct udf_mnt *imp = 0;
struct export_args *export;
struct vfsoptlist *opts;
char *fspec;
size_t size;
int error;
int error, len;
opts = mp->mnt_optnew;
if ((mp->mnt_flag & MNT_RDONLY) == 0)
return (EROFS);
@ -192,17 +195,26 @@ udf_mount(struct mount *mp, char *path, caddr_t data, struct nameidata *ndp, str
if (mp->mnt_flag & MNT_ROOTFS)
return (ENOTSUP);
if ((error = copyin(data, (caddr_t)&args, sizeof(struct udf_args))))
return (error);
fspec = NULL;
error = vfs_getopt(opts, "from", (void **)&fspec, &len);
if (!error && fspec[len - 1] != '\0')
return (EINVAL);
if (mp->mnt_flag & MNT_UPDATE) {
imp = VFSTOUDFFS(mp);
if (args.fspec == 0)
return (vfs_export(mp, &args.export));
if (fspec == NULL) {
error = vfs_getopt(opts, "export", (void **)&export,
&len);
if (error || len != sizeof(struct export_args))
return (EINVAL);
return (vfs_export(mp, export));
}
}
/* Check that the mount device exists */
NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, td);
if (fspec == NULL)
return (EINVAL);
NDINIT(ndp, LOOKUP, FOLLOW, UIO_SYSSPACE, fspec, td);
if ((error = namei(ndp)))
return (error);
NDFREE(ndp, NDF_ONLY_PNBUF);
@ -224,13 +236,13 @@ udf_mount(struct mount *mp, char *path, caddr_t data, struct nameidata *ndp, str
}
VOP_UNLOCK(devvp, 0, td);
if ((error = udf_mountfs(devvp, mp, td, &args))) {
if ((error = udf_mountfs(devvp, mp, td))) {
vrele(devvp);
return (error);
}
imp = VFSTOUDFFS(mp);
copyinstr(args.fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, &size);
copystr(fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, &size);
bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
udf_statfs(mp, &mp->mnt_stat, td);
return 0;
@ -262,7 +274,7 @@ udf_checktag(struct desc_tag *tag, uint16_t id)
}
static int
udf_mountfs(struct vnode *devvp, struct mount *mp, struct thread *td, struct udf_args *argp) {
udf_mountfs(struct vnode *devvp, struct mount *mp, struct thread *td) {
struct buf *bp = NULL;
struct anchor_vdp avdp;
struct udf_mnt *udfmp = NULL;