diff options
author | Tobias Weingartner <weingart@cvs.openbsd.org> | 1997-07-12 22:50:07 +0000 |
---|---|---|
committer | Tobias Weingartner <weingart@cvs.openbsd.org> | 1997-07-12 22:50:07 +0000 |
commit | 2e15f8e3051d41c8c12d4f866aba6b95c95d8919 (patch) | |
tree | 5ffd7e387a98920c659230b0e73e37318d4d39d5 /sys/kern | |
parent | 7ca3a743be6033dff326884b186cc8e13f9962b7 (diff) |
Add some more extent stuff, in preperation of PnP. Huh? Did I
say PnP? Anyways, this stuff just adds the ability to register
the extents on creation, etc, etc...
Someone needs to add a DDB command "show extent", to make this
really usefull... ;-)
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/subr_extent.c | 63 |
1 files changed, 62 insertions, 1 deletions
diff --git a/sys/kern/subr_extent.c b/sys/kern/subr_extent.c index f26bca5a107..1bbb4cdbd6a 100644 --- a/sys/kern/subr_extent.c +++ b/sys/kern/subr_extent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_extent.c,v 1.2 1996/12/09 09:27:04 niklas Exp $ */ +/* $OpenBSD: subr_extent.c,v 1.3 1997/07/12 22:50:06 weingart Exp $ */ /* $NetBSD: subr_extent.c,v 1.7 1996/11/21 18:46:34 cgd Exp $ */ /*- @@ -48,12 +48,14 @@ #include <sys/time.h> #include <sys/systm.h> #include <sys/proc.h> +#include <sys/queue.h> #else /* * user-land definitions, so it can fit into a testing harness. */ #include <sys/param.h> #include <sys/extent.h> +#include <sys/queue.h> #include <errno.h> #include <stdlib.h> #include <stdio.h> @@ -70,6 +72,7 @@ static struct extent_region *extent_alloc_region_descriptor __P((struct extent *, int)); static void extent_free_region_descriptor __P((struct extent *, struct extent_region *)); +static void extent_register __P((struct extent *)); /* * Macro to align to an arbitrary power-of-two boundary. @@ -78,6 +81,62 @@ static void extent_free_region_descriptor __P((struct extent *, (((_start) + ((_align) - 1)) & (-(_align))) /* + * Register the extent on a doubly linked list. + * Should work, no? + */ +static LIST_HEAD(listhead, extent) ext_list; +static struct listhead *ext_listp; + +static void +extent_register(ex) + struct extent *ex; +{ + /* Is this redundant? */ + if(ext_listp == NULL){ + LIST_INIT(&ext_list); + ext_listp = &ext_list; + } + + /* Insert into list */ + LIST_INSERT_HEAD(ext_listp, ex, ex_link); +} + +/* + * Find a given extent, and return a pointer to + * it so that other extent functions can be used + * on it. + * + * Returns NULL on failure. + */ +struct extent * +extent_find(name) + char *name; +{ + struct extent *ep; + + for(ep = ext_listp->lh_first; ep != NULL; ep = ep->ex_link.le_next){ + if(!strcmp(ep->ex_name, name)) return(ep); + } + + return(NULL); +} + + +/* + * Print out all extents registered. This is used in + * DDB show extents + */ +void +extent_print_all(void) +{ + struct extent *ep; + + for(ep = ext_listp->lh_first; ep != NULL; ep = ep->ex_link.le_next){ + extent_print(ep); + } +} + +/* * Allocate and initialize an extent map. */ struct extent * @@ -156,6 +215,8 @@ extent_create(name, start, end, mtype, storage, storagesize, flags) ex->ex_flags |= EXF_FIXED; if (flags & EX_NOCOALESCE) ex->ex_flags |= EXF_NOCOALESCE; + + extent_register(ex); return (ex); } |