From 401895533496c6f7943c0cadf487c2cfa8f852ac Mon Sep 17 00:00:00 2001 From: adrian Date: Thu, 1 Mar 2001 21:00:17 +0000 Subject: Reviewed by: jlemon An initial tidyup of the mount() syscall and VFS mount code. This code replaces the earlier work done by jlemon in an attempt to make linux_mount() work. * the guts of the mount work has been moved into vfs_mount(). * move `type', `path' and `flags' from being userland variables into being kernel variables in vfs_mount(). `data' remains a pointer into userspace. * Attempt to verify the `type' and `path' strings passed to vfs_mount() aren't too long. * rework mount() and linux_mount() to take the userland parameters (besides data, as mentioned) and pass kernel variables to vfs_mount(). (linux_mount() already did this, I've just tidied it up a little more.) * remove the copyin*() stuff for `path'. `data' still requires copyin*() since its a pointer into userland. * set `mount->mnt_statf_mntonname' in vfs_mount() rather than in each filesystem. This variable is generally initialised with `path', and each filesystem can override it if they want to. * NOTE: f_mntonname is intiailised with "/" in the case of a root mount. --- sys/compat/linprocfs/linprocfs_vfsops.c | 3 --- sys/compat/linux/linux_file.c | 33 +++++++++++++++++---------------- 2 files changed, 17 insertions(+), 19 deletions(-) (limited to 'sys/compat') diff --git a/sys/compat/linprocfs/linprocfs_vfsops.c b/sys/compat/linprocfs/linprocfs_vfsops.c index 0caa113..1e4bc87 100644 --- a/sys/compat/linprocfs/linprocfs_vfsops.c +++ b/sys/compat/linprocfs/linprocfs_vfsops.c @@ -90,9 +90,6 @@ linprocfs_mount(mp, path, data, ndp, p) mp->mnt_data = 0; vfs_getnewfsid(mp); - (void) copyinstr(path, (caddr_t)mp->mnt_stat.f_mntonname, MNAMELEN, &size); - bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size); - size = sizeof("linprocfs") - 1; bcopy("linprocfs", mp->mnt_stat.f_mntfromname, size); bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c index 492742f..6f246af 100644 --- a/sys/compat/linux/linux_file.c +++ b/sys/compat/linux/linux_file.c @@ -901,14 +901,16 @@ linux_pwrite(p, uap) int linux_mount(struct proc *p, struct linux_mount_args *args) { - struct mount_args bsd_args; struct ufs_args ufs; char fstypename[MFSNAMELEN]; char mntonname[MNAMELEN], mntfromname[MNAMELEN]; - int error = 0; + int error; + int fsflags; + const char *fstype; + void *fsdata; - error = copyinstr(args->filesystemtype, fstypename, - MFSNAMELEN - 1, NULL); + error = copyinstr(args->filesystemtype, fstypename, MFSNAMELEN - 1, + NULL); if (error) return (error); error = copyinstr(args->specialfile, mntfromname, MFSNAMELEN - 1, NULL); @@ -925,22 +927,21 @@ linux_mount(struct proc *p, struct linux_mount_args *args) #endif if (strcmp(fstypename, "ext2") == 0) { - bsd_args.type = "ext2fs"; - bsd_args.data = (void *)&ufs; + fstype = "ext2fs"; + fsdata = &ufs; ufs.fspec = mntfromname; #define DEFAULT_ROOTID -2 ufs.export.ex_root = DEFAULT_ROOTID; ufs.export.ex_flags = args->rwflag & LINUX_MS_RDONLY ? MNT_EXRDONLY : 0; } else if (strcmp(fstypename, "proc") == 0) { - bsd_args.type = "linprocfs"; - bsd_args.data = NULL; + fstype = "linprocfs"; + fsdata = NULL; } else { return (ENODEV); } - bsd_args.path = mntonname; - bsd_args.flags = 0; + fsflags = 0; if ((args->rwflag & 0xffff0000) == 0xc0ed0000) { /* @@ -948,18 +949,18 @@ linux_mount(struct proc *p, struct linux_mount_args *args) * FreeBSD has is !ASYNC, which is our default. */ if (args->rwflag & LINUX_MS_RDONLY) - bsd_args.flags |= MNT_RDONLY; + fsflags |= MNT_RDONLY; if (args->rwflag & LINUX_MS_NOSUID) - bsd_args.flags |= MNT_NOSUID; + fsflags |= MNT_NOSUID; if (args->rwflag & LINUX_MS_NODEV) - bsd_args.flags |= MNT_NODEV; + fsflags |= MNT_NODEV; if (args->rwflag & LINUX_MS_NOEXEC) - bsd_args.flags |= MNT_NOEXEC; + fsflags |= MNT_NOEXEC; if (args->rwflag & LINUX_MS_REMOUNT) - bsd_args.flags |= MNT_UPDATE; + fsflags |= MNT_UPDATE; } - return (mount1(p, &bsd_args, UIO_SYSSPACE)); + return (vfs_mount(p, fstype, mntonname, fsflags, fsdata)); } int -- cgit v1.1