From ebb726ec45c12268b6b931aa636809cc9cb99a90 Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 28 Aug 1995 09:19:25 +0000 Subject: 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. --- sys/kern/vfs_mount.c | 142 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 137 insertions(+), 5 deletions(-) (limited to 'sys/kern/vfs_mount.c') diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 251d704..e8497f2 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -1,6 +1,7 @@ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. + * Copyright (c) 1995 Artisoft, Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -31,13 +32,144 @@ * SUCH DAMAGE. * * @(#)vfs_conf.c 8.8 (Berkeley) 3/31/94 - * $Id: vfs_conf.c,v 1.5 1994/09/21 03:46:47 wollman Exp $ + * $Id: vfs_conf.c,v 1.6 1994/11/12 01:47:43 phk Exp $ */ -#include -#include -#include +/* + * PURPOSE: This file abstracts the root mounting interface from + * the per file system semantics for handling mounts, + * the overall intent of which is to move the BSD + * internals dependence out of the FS code, both to + * make the FS code more portable and to free up some + * of the BSD internals so that they may more easily + * be changed. + * + * NOTE1: Code is single entry/single exit to aid debugging + * and conversion for kernel multithreading. + * + * NOTE2: Code notes lock state in headers on entry and exit + * as an aid to conversion for kernel multithreading + * on SMP reentrancy + */ +#include /* dev_t (types.h)*/ +#include /* rootvp*/ +#include /* curproc*/ +#include /* NULLVP*/ +#include /* struct mount*/ +#include /* M_MOUNT*/ -int (*mountroot) __P((void)); +/* + * GLOBALS + */ +int (*mountroot) __P((caddr_t)); struct vnode *rootvnode; +struct vfsops *mountrootvfsops; + + +/* + * Common root mount code shared by all filesystems + */ +#define ROOTDIR "/" +#define ROOTNAME "root_device" + + + +/* + * vfs_mountroot + * + * Common entry point for root mounts + * + * PARAMETERS: + * data pointer to the vfs_ops for the FS type mounting + * + * RETURNS: 0 Success + * !0 error number (errno.h) + * + * LOCK STATE: + * ENTRY + * + * EXIT + * + * + * NOTES: + * This code is currently supported only for use for + * the FFS file system type. This is a matter of + * fixing the other file systems, not this code! + */ +int +vfs_mountroot( data) +caddr_t *data; /* file system function table*/ +{ + struct mount *mp; + u_int size; + int err = 0; + struct proc *p = curproc; /* XXX */ + register struct fs *fs; + struct vfsops *mnt_op = (struct vfsops *)data; + + /* + * New root mount structure + */ + mp = malloc((u_long)sizeof(struct mount), M_MOUNT, M_WAITOK); + bzero((char *)mp, (u_long)sizeof(struct mount)); + mp->mnt_op = mnt_op; + mp->mnt_flag = MNT_ROOTFS; + mp->mnt_vnodecovered = NULLVP; + + /* + * Lock mount point + */ + if( ( err = vfs_lock(mp)) != 0) + goto error_1; + + /* Save "last mounted on" info for mount point (NULL pad)*/ + copystr( ROOTDIR, /* mount point*/ + mp->mnt_stat.f_mntonname, /* save area*/ + MNAMELEN - 1, /* max size*/ + &size); /* real size*/ + bzero( mp->mnt_stat.f_mntonname + size, MNAMELEN - size); + + /* Save "mounted from" info for mount point (NULL pad)*/ + copystr( ROOTNAME, /* device name*/ + mp->mnt_stat.f_mntfromname, /* save area*/ + MNAMELEN - 1, /* max size*/ + &size); /* real size*/ + bzero( mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); + + /* + * Attempt the mount + */ + err = VFS_MOUNT( mp, NULL, NULL, NULL, p); + if( err) + goto error_2; + + /* Add fs to list of mounted file systems*/ + CIRCLEQ_INSERT_TAIL( &mountlist, mp, mnt_list); + + /* Unlock mount point*/ + vfs_unlock(mp); + + /* root mount, update system time from FS specific data*/ + inittodr( mp->mnt_time); + + goto success; + +error_2: /* mount error*/ + + /* unlock before failing*/ + vfs_unlock( mp); + +error_1: /* lock error*/ + + /* free mount struct before failing*/ + free( mp, M_MOUNT); + +success: + return( err); +} + + +/* + * EOF -- This file has not been truncated. + */ -- cgit v1.1