From c3e956775fe5d7f57049b15283a62824d9e467e0 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 15 Jan 1996 22:28:56 +0000 Subject: (pokel_inherit, pokel_finalize): New functions. --- ext2fs/pokel.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) (limited to 'ext2fs') diff --git a/ext2fs/pokel.c b/ext2fs/pokel.c index a6d1c65a..85b4d2d1 100644 --- a/ext2fs/pokel.c +++ b/ext2fs/pokel.c @@ -22,7 +22,8 @@ #include "ext2fs.h" -void pokel_init (struct pokel *pokel, struct pager *pager, void *image) +void +pokel_init (struct pokel *pokel, struct pager *pager, void *image) { pokel->lock = SPIN_LOCK_INITIALIZER; pokel->pokes = NULL; @@ -31,6 +32,23 @@ void pokel_init (struct pokel *pokel, struct pager *pager, void *image) pokel->image = image; } +/* Clean up any state associated with POKEL (but don't free POKEL). */ +void +pokel_finalize (struct pokel *pokel) +{ + struct poke *pl, *next; + for (pl = pokel->pokes; pl; pl = next) + { + next = pl->next; + free (pl); + } + for (pl = pokel->free_pokes; pl; pl = next) + { + next = pl->next; + free (pl); + } +} + /* Remember that data here on the disk has been modified. */ void pokel_add (struct pokel *pokel, void *loc, vm_size_t length) @@ -81,7 +99,7 @@ pokel_add (struct pokel *pokel, void *loc, vm_size_t length) spin_unlock (&pokel->lock); } - + /* Move all pending pokes from POKEL into its free list. If SYNC is true, otherwise do nothing. */ void @@ -123,3 +141,32 @@ pokel_flush (struct pokel *pokel) { _pokel_exec (pokel, 0, 0); } + +/* Transfer all regions from FROM to POKEL, which must have the same pager. */ +void +pokel_inherit (struct pokel *pokel, struct pokel *from) +{ + struct poke *pokes, *last; + + assert (pokel->pager == from->pager); + assert (pokel->image == from->image); + + /* Take all pokes from FROM... */ + spin_lock (&from->lock); + pokes = from->pokes; + from->pokes = NULL; + spin_unlock (&from->lock); + + /* And put them in POKEL. */ + spin_lock (&pokel->lock); + last = pokel->pokes; + if (last) + { + while (last->next) + last = last->next; + last->next = pokes; + } + else + pokel->pokes = pokes; + spin_unlock (&pokel->lock); +} -- cgit v1.2.3