diff options
author | julian <julian@FreeBSD.org> | 1995-08-28 09:19:25 +0000 |
---|---|---|
committer | julian <julian@FreeBSD.org> | 1995-08-28 09:19:25 +0000 |
commit | ebb726ec45c12268b6b931aa636809cc9cb99a90 (patch) | |
tree | 53b6da073fd58ab81ebf18bb0642954c76b642bd /sys/kern/vfs_mount.c | |
parent | 6f51a7615899188fd49e4446341be92684c778de (diff) | |
download | FreeBSD-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/kern/vfs_mount.c')
-rw-r--r-- | sys/kern/vfs_mount.c | 142 |
1 files changed, 137 insertions, 5 deletions
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 <sys/param.h> -#include <sys/mount.h> -#include <sys/vnode.h> +/* + * 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 <sys/param.h> /* dev_t (types.h)*/ +#include <sys/systm.h> /* rootvp*/ +#include <sys/proc.h> /* curproc*/ +#include <sys/vnode.h> /* NULLVP*/ +#include <sys/mount.h> /* struct mount*/ +#include <sys/malloc.h> /* 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 + * <no locks held> + * EXIT + * <no locks held> + * + * 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. + */ |