From ad841cb9b2f6089dd770ceefe6a4ea1557b52069 Mon Sep 17 00:00:00 2001 From: Maxime Henrion Date: Fri, 24 May 2002 17:38:01 +0000 Subject: [PATCH] Convert ext2fs to nmount(2). --- sys/gnu/ext2fs/ext2_mount.h | 8 ------ sys/gnu/ext2fs/ext2_vfsops.c | 47 ++++++++++++++++++++------------- sys/gnu/fs/ext2fs/ext2_mount.h | 8 ------ sys/gnu/fs/ext2fs/ext2_vfsops.c | 47 ++++++++++++++++++++------------- 4 files changed, 56 insertions(+), 54 deletions(-) diff --git a/sys/gnu/ext2fs/ext2_mount.h b/sys/gnu/ext2fs/ext2_mount.h index 35f1fb7d9a1e..4e4894f17ab2 100644 --- a/sys/gnu/ext2fs/ext2_mount.h +++ b/sys/gnu/ext2fs/ext2_mount.h @@ -37,14 +37,6 @@ #ifndef _SYS_GNU_EXT2FS_EXT2_MOUNT_H_ #define _SYS_GNU_EXT2FS_EXT2_MOUNT_H_ -/* - * Arguments to mount ext2fs filesystems - */ -struct ext2_args { - char *fspec; /* block special device to mount */ - struct export_args export; /* network export information */ -}; - #ifdef _KERNEL #ifdef MALLOC_DECLARE diff --git a/sys/gnu/ext2fs/ext2_vfsops.c b/sys/gnu/ext2fs/ext2_vfsops.c index f23a7c1e164c..e77630c8c200 100644 --- a/sys/gnu/ext2fs/ext2_vfsops.c +++ b/sys/gnu/ext2fs/ext2_vfsops.c @@ -66,8 +66,7 @@ static int ext2_fhtovp(struct mount *, struct fid *, struct vnode **); static int ext2_flushfiles(struct mount *mp, int flags, struct thread *td); static int ext2_init(struct vfsconf *); -static int ext2_mount(struct mount *, - char *, caddr_t, struct nameidata *, struct thread *); +static int ext2_mount(struct mount *, struct nameidata *, struct thread *); static int ext2_mountfs(struct vnode *, struct mount *, struct thread *); static int ext2_reload(struct mount *mountp, struct ucred *cred, struct thread *td); @@ -84,7 +83,7 @@ MALLOC_DEFINE(M_EXT2NODE, "EXT2 node", "EXT2 vnode private part"); static MALLOC_DEFINE(M_EXT2MNT, "EXT2 mount", "EXT2 mount structure"); static struct vfsops ext2fs_vfsops = { - ext2_mount, + NULL, vfs_stdstart, ext2_unmount, ext2_root, /* root inode via vget */ @@ -98,6 +97,7 @@ static struct vfsops ext2fs_vfsops = { ext2_init, ext2_uninit, vfs_stdextattrctl, + ext2_mount, }; VFS_SET(ext2fs_vfsops, ext2fs, 0); @@ -175,27 +175,33 @@ ext2_mountroot() * mount system call */ static int -ext2_mount(mp, path, data, ndp, td) +ext2_mount(mp, ndp, td) struct mount *mp; - char *path; - caddr_t data; /* this is actually a (struct ext2_args *) */ struct nameidata *ndp; struct thread *td; { + struct export_args *export; + struct vfsoptlist *opts; struct vnode *devvp; - struct ext2_args args; struct ext2mount *ump = 0; struct ext2_sb_info *fs; + char *path, *fspec; size_t size; - int error, flags; + int error, flags, len; mode_t accessmode; + opts = mp->mnt_optnew; + + vfs_getopt(opts, "fspath", (void **)&path, NULL); /* Double-check the length of path.. */ if (strlen(path) >= MAXMNTLEN - 1) return (ENAMETOOLONG); - error = copyin(data, (caddr_t)&args, sizeof (struct ext2_args)); - if (error != 0) - return (error); + + fspec = NULL; + error = vfs_getopt(opts, "from", (void **)&fspec, &len); + if (!error && fspec[len - 1] != '\0') + return (EINVAL); + /* * If updating, check whether changing from read-only to * read/write; if there is no device name, that's all we do. @@ -258,18 +264,22 @@ ext2_mount(mp, path, data, ndp, td) ext2_sbupdate(ump, MNT_WAIT); fs->s_rd_only = 0; } - if (args.fspec == 0) { - /* - * Process export requests. - */ - 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); + /* Process export requests. */ + return (vfs_export(mp, export)); } } /* * Not an update, or updating the name: look up the name * and verify that it refers to a sensible block device. */ - 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)) != 0) return (error); NDFREE(ndp, NDF_ONLY_PNBUF); @@ -316,8 +326,7 @@ ext2_mount(mp, path, data, ndp, td) */ strncpy(fs->fs_fsmnt, path, MAXMNTLEN); fs->fs_fsmnt[MAXMNTLEN - 1] = '\0'; - (void) copyinstr(args.fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, - &size); + (void)copystr(fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, &size); bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); (void)ext2_statfs(mp, &mp->mnt_stat, td); return (0); diff --git a/sys/gnu/fs/ext2fs/ext2_mount.h b/sys/gnu/fs/ext2fs/ext2_mount.h index 35f1fb7d9a1e..4e4894f17ab2 100644 --- a/sys/gnu/fs/ext2fs/ext2_mount.h +++ b/sys/gnu/fs/ext2fs/ext2_mount.h @@ -37,14 +37,6 @@ #ifndef _SYS_GNU_EXT2FS_EXT2_MOUNT_H_ #define _SYS_GNU_EXT2FS_EXT2_MOUNT_H_ -/* - * Arguments to mount ext2fs filesystems - */ -struct ext2_args { - char *fspec; /* block special device to mount */ - struct export_args export; /* network export information */ -}; - #ifdef _KERNEL #ifdef MALLOC_DECLARE diff --git a/sys/gnu/fs/ext2fs/ext2_vfsops.c b/sys/gnu/fs/ext2fs/ext2_vfsops.c index f23a7c1e164c..e77630c8c200 100644 --- a/sys/gnu/fs/ext2fs/ext2_vfsops.c +++ b/sys/gnu/fs/ext2fs/ext2_vfsops.c @@ -66,8 +66,7 @@ static int ext2_fhtovp(struct mount *, struct fid *, struct vnode **); static int ext2_flushfiles(struct mount *mp, int flags, struct thread *td); static int ext2_init(struct vfsconf *); -static int ext2_mount(struct mount *, - char *, caddr_t, struct nameidata *, struct thread *); +static int ext2_mount(struct mount *, struct nameidata *, struct thread *); static int ext2_mountfs(struct vnode *, struct mount *, struct thread *); static int ext2_reload(struct mount *mountp, struct ucred *cred, struct thread *td); @@ -84,7 +83,7 @@ MALLOC_DEFINE(M_EXT2NODE, "EXT2 node", "EXT2 vnode private part"); static MALLOC_DEFINE(M_EXT2MNT, "EXT2 mount", "EXT2 mount structure"); static struct vfsops ext2fs_vfsops = { - ext2_mount, + NULL, vfs_stdstart, ext2_unmount, ext2_root, /* root inode via vget */ @@ -98,6 +97,7 @@ static struct vfsops ext2fs_vfsops = { ext2_init, ext2_uninit, vfs_stdextattrctl, + ext2_mount, }; VFS_SET(ext2fs_vfsops, ext2fs, 0); @@ -175,27 +175,33 @@ ext2_mountroot() * mount system call */ static int -ext2_mount(mp, path, data, ndp, td) +ext2_mount(mp, ndp, td) struct mount *mp; - char *path; - caddr_t data; /* this is actually a (struct ext2_args *) */ struct nameidata *ndp; struct thread *td; { + struct export_args *export; + struct vfsoptlist *opts; struct vnode *devvp; - struct ext2_args args; struct ext2mount *ump = 0; struct ext2_sb_info *fs; + char *path, *fspec; size_t size; - int error, flags; + int error, flags, len; mode_t accessmode; + opts = mp->mnt_optnew; + + vfs_getopt(opts, "fspath", (void **)&path, NULL); /* Double-check the length of path.. */ if (strlen(path) >= MAXMNTLEN - 1) return (ENAMETOOLONG); - error = copyin(data, (caddr_t)&args, sizeof (struct ext2_args)); - if (error != 0) - return (error); + + fspec = NULL; + error = vfs_getopt(opts, "from", (void **)&fspec, &len); + if (!error && fspec[len - 1] != '\0') + return (EINVAL); + /* * If updating, check whether changing from read-only to * read/write; if there is no device name, that's all we do. @@ -258,18 +264,22 @@ ext2_mount(mp, path, data, ndp, td) ext2_sbupdate(ump, MNT_WAIT); fs->s_rd_only = 0; } - if (args.fspec == 0) { - /* - * Process export requests. - */ - 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); + /* Process export requests. */ + return (vfs_export(mp, export)); } } /* * Not an update, or updating the name: look up the name * and verify that it refers to a sensible block device. */ - 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)) != 0) return (error); NDFREE(ndp, NDF_ONLY_PNBUF); @@ -316,8 +326,7 @@ ext2_mount(mp, path, data, ndp, td) */ strncpy(fs->fs_fsmnt, path, MAXMNTLEN); fs->fs_fsmnt[MAXMNTLEN - 1] = '\0'; - (void) copyinstr(args.fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, - &size); + (void)copystr(fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, &size); bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); (void)ext2_statfs(mp, &mp->mnt_stat, td); return (0);