summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>1998-04-19 23:32:49 +0000
committerjulian <julian@FreeBSD.org>1998-04-19 23:32:49 +0000
commit0796a5c56ed9d1eaf2c8691327b581fcfa3cd05b (patch)
tree9c3ff4ea4ec1cc8aeb30628a4e4452193f1d12cb /sys/kern
parent64e2dfa0bb7dd8d4a7affdfbf920764d02d2b02c (diff)
downloadFreeBSD-src-0796a5c56ed9d1eaf2c8691327b581fcfa3cd05b.zip
FreeBSD-src-0796a5c56ed9d1eaf2c8691327b581fcfa3cd05b.tar.gz
Add changes and code to implement a functional DEVFS.
This code will be turned on with the TWO options DEVFS and SLICE. (see LINT) Two labels PRE_DEVFS_SLICE and POST_DEVFS_SLICE will deliniate these changes. /dev will be automatically mounted by init (thanks phk) on bootup. See /sys/dev/slice/slice.4 for more info. All code should act the same without these options enabled. Mike Smith, Poul Henning Kamp, Soeren, and a few dozen others This code does not support the following: bad144 handling. Persistance. (My head is still hurting from the last time we discussed this) ATAPI flopies are not handled by the SLICE code yet. When this code is running, all major numbers are arbitrary and COULD be dynamically assigned. (this is not done, for POLA only) Minor numbers for disk slices ARE arbitray and dynamically assigned.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/init_main.c4
-rw-r--r--sys/kern/subr_diskslice.c5
-rw-r--r--sys/kern/vfs_conf.c7
-rw-r--r--sys/kern/vfs_export.c31
-rw-r--r--sys/kern/vfs_mount.c7
-rw-r--r--sys/kern/vfs_subr.c31
6 files changed, 72 insertions, 13 deletions
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
index 3de881d..c6659bf 100644
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -39,7 +39,7 @@
* SUCH DAMAGE.
*
* @(#)init_main.c 8.9 (Berkeley) 1/21/94
- * $Id: init_main.c,v 1.89 1998/04/11 17:24:06 phk Exp $
+ * $Id: init_main.c,v 1.90 1998/04/17 22:36:49 des Exp $
*/
#include "opt_devfs.h"
@@ -582,7 +582,7 @@ start_init(p)
options = 1;
#endif
-#if defined(DEVFS) && defined(DEVFS_ROOT)
+#if defined(DEVFS) && defined(SLICE)
(void)subyte(--ucp, 'd');
options = 1;
#endif
diff --git a/sys/kern/subr_diskslice.c b/sys/kern/subr_diskslice.c
index 5ffb5db..4b11dc6 100644
--- a/sys/kern/subr_diskslice.c
+++ b/sys/kern/subr_diskslice.c
@@ -1,3 +1,6 @@
+#ifdef SLICE
+#undef DEVFS
+#endif
/*-
* Copyright (c) 1994 Bruce D. Evans.
* All rights reserved.
@@ -43,7 +46,7 @@
* from: wd.c,v 1.55 1994/10/22 01:57:12 phk Exp $
* from: @(#)ufs_disksubr.c 7.16 (Berkeley) 5/4/91
* from: ufs_disksubr.c,v 1.8 1994/06/07 01:21:39 phk Exp $
- * $Id: subr_diskslice.c,v 1.41 1998/01/24 02:54:34 eivind Exp $
+ * $Id: subr_diskslice.c,v 1.42 1998/02/15 05:41:31 bde Exp $
*/
#include "opt_devfs.h"
diff --git a/sys/kern/vfs_conf.c b/sys/kern/vfs_conf.c
index a42a89a..ffe86ce 100644
--- a/sys/kern/vfs_conf.c
+++ b/sys/kern/vfs_conf.c
@@ -32,7 +32,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_conf.c 8.8 (Berkeley) 3/31/94
- * $Id: vfs_conf.c,v 1.21 1998/02/09 06:09:32 eivind Exp $
+ * $Id: vfs_conf.c,v 1.22 1998/03/11 00:10:31 msmith Exp $
*/
/*
@@ -73,9 +73,12 @@ MALLOC_DEFINE(M_MOUNT, "mount", "vfs mount struct");
static struct mount *rootfs;
struct vnode *rootvnode;
char *mountrootfsname;
+#ifdef SLICE
+char rootdevice[32];
+#endif /* SLICE */
#ifdef BOOTP
extern void bootpc_init __P((void));
-#endif
+#endif /* BOOTP */
/*
* vfs_init() will set maxvfsconf
diff --git a/sys/kern/vfs_export.c b/sys/kern/vfs_export.c
index 8e6c9dc..5e6386e 100644
--- a/sys/kern/vfs_export.c
+++ b/sys/kern/vfs_export.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95
- * $Id: vfs_subr.c,v 1.150 1998/04/16 03:31:26 peter Exp $
+ * $Id: vfs_subr.c,v 1.151 1998/04/18 06:26:16 peter Exp $
*/
/*
@@ -71,6 +71,9 @@
#include <vm/vm_zone.h>
#include <sys/sysctl.h>
+#if defined(DEVFS)
+#include <sys/devfsext.h>
+#endif /* DEVFS */
#include <miscfs/specfs/specdev.h>
static MALLOC_DEFINE(M_NETADDR, "Export Host", "Export host address structure");
@@ -1090,7 +1093,7 @@ reassignbuf(bp, newvp)
splx(s);
}
-#ifndef DEVFS_ROOT
+#ifndef SLICE
/*
* Create a vnode for a block device.
* Used for mounting the root file system.
@@ -1120,7 +1123,7 @@ bdevvp(dev, vpp)
*vpp = vp;
return (0);
}
-#endif /* !DEVFS_ROOT */
+#endif /* !SLICE */
/*
* Check to see if the new vnode represents a special device
@@ -1151,6 +1154,8 @@ loop:
continue;
/*
* Alias, but not in use, so flush it out.
+ * Only alias active device nodes.
+ * Not sure why we don't re-use this like we do below.
*/
simple_lock(&vp->v_interlock);
if (vp->v_usecount == 0) {
@@ -1159,12 +1164,26 @@ loop:
goto loop;
}
if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p)) {
+ /*
+ * It dissappeared, and we may have slept.
+ * Restart from the beginning
+ */
simple_unlock(&spechash_slock);
goto loop;
}
break;
}
+ /*
+ * It would be a lot clearer what is going on here if
+ * this had been expressed as:
+ * if ( vp && (vp->v_tag == VT_NULL))
+ * and the clauses had been swapped.
+ */
if (vp == NULL || vp->v_tag != VT_NON) {
+ /*
+ * Put the new vnode into the hash chain.
+ * and if there was an alias, connect them.
+ */
MALLOC(nvp->v_specinfo, struct specinfo *,
sizeof(struct specinfo), M_VNODE, M_WAITOK);
nvp->v_rdev = nvp_rdev;
@@ -1180,6 +1199,12 @@ loop:
}
return (NULLVP);
}
+ /*
+ * if ( vp && (vp->v_tag == VT_NULL))
+ * We have a vnode alias, but it is a trashed.
+ * Make it look like it's newley allocated. (by getnewvnode())
+ * The caller should use this instead.
+ */
simple_unlock(&spechash_slock);
VOP_UNLOCK(vp, 0, p);
simple_lock(&vp->v_interlock);
diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c
index a42a89a..ffe86ce 100644
--- a/sys/kern/vfs_mount.c
+++ b/sys/kern/vfs_mount.c
@@ -32,7 +32,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_conf.c 8.8 (Berkeley) 3/31/94
- * $Id: vfs_conf.c,v 1.21 1998/02/09 06:09:32 eivind Exp $
+ * $Id: vfs_conf.c,v 1.22 1998/03/11 00:10:31 msmith Exp $
*/
/*
@@ -73,9 +73,12 @@ MALLOC_DEFINE(M_MOUNT, "mount", "vfs mount struct");
static struct mount *rootfs;
struct vnode *rootvnode;
char *mountrootfsname;
+#ifdef SLICE
+char rootdevice[32];
+#endif /* SLICE */
#ifdef BOOTP
extern void bootpc_init __P((void));
-#endif
+#endif /* BOOTP */
/*
* vfs_init() will set maxvfsconf
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index 8e6c9dc..5e6386e 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95
- * $Id: vfs_subr.c,v 1.150 1998/04/16 03:31:26 peter Exp $
+ * $Id: vfs_subr.c,v 1.151 1998/04/18 06:26:16 peter Exp $
*/
/*
@@ -71,6 +71,9 @@
#include <vm/vm_zone.h>
#include <sys/sysctl.h>
+#if defined(DEVFS)
+#include <sys/devfsext.h>
+#endif /* DEVFS */
#include <miscfs/specfs/specdev.h>
static MALLOC_DEFINE(M_NETADDR, "Export Host", "Export host address structure");
@@ -1090,7 +1093,7 @@ reassignbuf(bp, newvp)
splx(s);
}
-#ifndef DEVFS_ROOT
+#ifndef SLICE
/*
* Create a vnode for a block device.
* Used for mounting the root file system.
@@ -1120,7 +1123,7 @@ bdevvp(dev, vpp)
*vpp = vp;
return (0);
}
-#endif /* !DEVFS_ROOT */
+#endif /* !SLICE */
/*
* Check to see if the new vnode represents a special device
@@ -1151,6 +1154,8 @@ loop:
continue;
/*
* Alias, but not in use, so flush it out.
+ * Only alias active device nodes.
+ * Not sure why we don't re-use this like we do below.
*/
simple_lock(&vp->v_interlock);
if (vp->v_usecount == 0) {
@@ -1159,12 +1164,26 @@ loop:
goto loop;
}
if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p)) {
+ /*
+ * It dissappeared, and we may have slept.
+ * Restart from the beginning
+ */
simple_unlock(&spechash_slock);
goto loop;
}
break;
}
+ /*
+ * It would be a lot clearer what is going on here if
+ * this had been expressed as:
+ * if ( vp && (vp->v_tag == VT_NULL))
+ * and the clauses had been swapped.
+ */
if (vp == NULL || vp->v_tag != VT_NON) {
+ /*
+ * Put the new vnode into the hash chain.
+ * and if there was an alias, connect them.
+ */
MALLOC(nvp->v_specinfo, struct specinfo *,
sizeof(struct specinfo), M_VNODE, M_WAITOK);
nvp->v_rdev = nvp_rdev;
@@ -1180,6 +1199,12 @@ loop:
}
return (NULLVP);
}
+ /*
+ * if ( vp && (vp->v_tag == VT_NULL))
+ * We have a vnode alias, but it is a trashed.
+ * Make it look like it's newley allocated. (by getnewvnode())
+ * The caller should use this instead.
+ */
simple_unlock(&spechash_slock);
VOP_UNLOCK(vp, 0, p);
simple_lock(&vp->v_interlock);
OpenPOWER on IntegriCloud