summaryrefslogtreecommitdiffstats
path: root/sys/ufs/lfs/lfs_vfsops.c
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>1995-08-28 09:19:25 +0000
committerjulian <julian@FreeBSD.org>1995-08-28 09:19:25 +0000
commitebb726ec45c12268b6b931aa636809cc9cb99a90 (patch)
tree53b6da073fd58ab81ebf18bb0642954c76b642bd /sys/ufs/lfs/lfs_vfsops.c
parent6f51a7615899188fd49e4446341be92684c778de (diff)
downloadFreeBSD-src-ebb726ec45c12268b6b931aa636809cc9cb99a90.zip
FreeBSD-src-ebb726ec45c12268b6b931aa636809cc9cb99a90.tar.gz
Reviewed by: julian with quick glances by bruce and others
Submitted by: terry (terry lambert) This is a composite of 3 patch sets submitted by terry. they are: New low-level init code that supports loadbal modules better some cleanups in the namei code to help terry in 16-bit character support some changes to the mount-root code to make it a little more modular.. NOTE: mounting root off cdrom or NFS MIGHT be broken as I haven't been able to test those cases.. certainly mounting root of disk still works just fine.. mfs should work but is untested. (tomorrows task) The low level init stuff includes a total rewrite of init_main.c to make it possible for new modules to have an init phase by simply adding an entry to a TEXT_SET (or is it DATA_SET) list. thus a new module can be added to the kernel without editing any other files other than the 'files' file.
Diffstat (limited to 'sys/ufs/lfs/lfs_vfsops.c')
-rw-r--r--sys/ufs/lfs/lfs_vfsops.c118
1 files changed, 91 insertions, 27 deletions
diff --git a/sys/ufs/lfs/lfs_vfsops.c b/sys/ufs/lfs/lfs_vfsops.c
index e571dcd..80fb731 100644
--- a/sys/ufs/lfs/lfs_vfsops.c
+++ b/sys/ufs/lfs/lfs_vfsops.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)lfs_vfsops.c 8.7 (Berkeley) 4/16/94
- * $Id: lfs_vfsops.c,v 1.10 1995/03/16 18:16:48 bde Exp $
+ * $Id: lfs_vfsops.c,v 1.11 1995/03/19 14:29:20 davidg Exp $
*/
#include <sys/param.h>
@@ -78,16 +78,45 @@ struct vfsops lfs_vfsops = {
VFS_SET(lfs_vfsops, lfs, MOUNT_LFS, 0);
-int
-lfs_mountroot()
-{
- panic("lfs_mountroot"); /* XXX -- implement */
-}
/*
- * VFS Operations.
+ * lfs_mount
+ *
+ * Called when mounting local physical media
+ *
+ * PARAMETERS:
+ * mountroot
+ * mp mount point structure
+ * path NULL (flag for root mount!!!)
+ * data <unused>
+ * ndp <unused>
+ * p process (user credentials check [statfs])
+ *
+ * mount
+ * mp mount point structure
+ * path path to mount point
+ * data pointer to argument struct in user space
+ * ndp mount point namei() return (used for
+ * credentials on reload), reused to look
+ * up block device.
+ * p process (user credentials check)
+ *
+ * RETURNS: 0 Success
+ * !0 error number (errno.h)
+ *
+ * LOCK STATE:
*
- * mount system call
+ * ENTRY
+ * mount point is locked
+ * EXIT
+ * mount point is locked
+ *
+ * NOTES:
+ * A NULL path can be used for a flag since the mount
+ * system call will fail with EFAULT in copyinstr in
+ * namei() if it is a genuine NULL from the user.
+ *
+ * Root mounts are not currently supported.
*/
int
lfs_mount(mp, path, data, ndp, p)
@@ -102,14 +131,37 @@ lfs_mount(mp, path, data, ndp, p)
struct ufsmount *ump = 0;
register struct lfs *fs; /* LFS */
u_int size;
- int error;
+ int err;
- if (error = copyin(data, (caddr_t)&args, sizeof (struct ufs_args)))
- return (error);
+ /*
+ * Use NULL path to flag a root mount
+ */
+ if( path == NULL) {
+ /*
+ ***
+ * Mounting root file system
+ ***
+ */
+
+ /* XXX -- implement*/
+ panic("lfs_mountroot: can't setup bdevvp for root");
+ }
+
+ /*
+ ***
+ * Mounting non-root file system or updating a file system
+ ***
+ */
+
+ /* copy in user arguments*/
+ if (err = copyin(data, (caddr_t)&args, sizeof (struct ufs_args)))
+ goto error_1;
/* Until LFS can do NFS right. XXX */
- if (args.export.ex_flags & MNT_EXPORTED)
- return (EINVAL);
+ if (args.export.ex_flags & MNT_EXPORTED) {
+ err = EINVAL;
+ goto error_1;
+ }
/*
* If updating, check whether changing from read-only to
@@ -128,9 +180,11 @@ lfs_mount(mp, path, data, ndp, p)
#endif
if (args.fspec == 0) {
/*
- * Process export requests.
+ * Process export requests. Jumping to "success"
+ * will return the vfs_export() error code.
*/
- return (vfs_export(mp, &ump->um_export, &args.export));
+ err = vfs_export(mp, &ump->um_export, &args.export);
+ goto success;
}
}
/*
@@ -138,28 +192,27 @@ lfs_mount(mp, path, data, ndp, p)
* and verify that it refers to a sensible block device.
*/
NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, p);
- if (error = namei(ndp))
- return (error);
+ if (err = namei(ndp))
+ goto error_1;
devvp = ndp->ni_vp;
if (devvp->v_type != VBLK) {
- vrele(devvp);
- return (ENOTBLK);
+ err = ENOTBLK;
+ goto error_2;
}
if (major(devvp->v_rdev) >= nblkdev) {
- vrele(devvp);
- return (ENXIO);
+ err = ENXIO;
+ goto error_2;
}
if ((mp->mnt_flag & MNT_UPDATE) == 0)
- error = lfs_mountfs(devvp, mp, p); /* LFS */
+ err = lfs_mountfs(devvp, mp, p); /* LFS */
else {
if (devvp != ump->um_devvp)
- error = EINVAL; /* needs translation */
+ err = EINVAL; /* needs translation */
else
vrele(devvp);
}
- if (error) {
- vrele(devvp);
- return (error);
+ if (err) {
+ goto error_2;
}
ump = VFSTOUFS(mp);
fs = ump->um_lfs; /* LFS */
@@ -182,7 +235,18 @@ lfs_mount(mp, path, data, ndp, p)
bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
(void) lfs_statfs(mp, &mp->mnt_stat, p);
#endif
- return (0);
+
+
+
+error_2: /* error with devvp held*/
+
+ /* release devvp before failing*/
+ vrele(devvp);
+
+error_1: /* no state to back out*/
+
+success:
+ return( err);
}
/*
OpenPOWER on IntegriCloud