diff options
Diffstat (limited to 'lib/libc')
44 files changed, 515 insertions, 156 deletions
diff --git a/lib/libc/db/README b/lib/libc/db/README index 8303c99f370..3484ae6e227 100644 --- a/lib/libc/db/README +++ b/lib/libc/db/README @@ -1,4 +1,5 @@ -# $OpenBSD: README,v 1.3 1996/08/19 08:19:56 tholo Exp $ +# $OpenBSD: README,v 1.4 1999/02/15 05:11:22 millert Exp $ +# @(#)README 8.27 (Berkeley) 9/1/94 This is version 1.85 of the Berkeley DB code. diff --git a/lib/libc/db/btree/bt_close.c b/lib/libc/db/btree/bt_close.c index 3153f308ac3..492155b0efc 100644 --- a/lib/libc/db/btree/bt_close.c +++ b/lib/libc/db/btree/bt_close.c @@ -1,3 +1,5 @@ +/* $OpenBSD: bt_close.c,v 1.4 1999/02/15 05:11:22 millert Exp $ */ + /*- * Copyright (c) 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -35,7 +37,11 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: bt_close.c,v 1.3 1996/08/19 08:20:01 tholo Exp $"; +#if 0 +static char sccsid[] = "@(#)bt_close.c 8.7 (Berkeley) 8/17/94"; +#else +static char rcsid[] = "$OpenBSD: bt_close.c,v 1.4 1999/02/15 05:11:22 millert Exp $"; +#endif #endif /* LIBC_SCCS and not lint */ #include <sys/param.h> diff --git a/lib/libc/db/btree/bt_conv.c b/lib/libc/db/btree/bt_conv.c index eaf1032efa2..7272a69278e 100644 --- a/lib/libc/db/btree/bt_conv.c +++ b/lib/libc/db/btree/bt_conv.c @@ -1,3 +1,5 @@ +/* $OpenBSD: bt_conv.c,v 1.4 1999/02/15 05:11:22 millert Exp $ */ + /*- * Copyright (c) 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -35,7 +37,11 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: bt_conv.c,v 1.3 1996/08/19 08:20:03 tholo Exp $"; +#if 0 +static char sccsid[] = "@(#)bt_conv.c 8.5 (Berkeley) 8/17/94"; +#else +static char rcsid[] = "$OpenBSD: bt_conv.c,v 1.4 1999/02/15 05:11:22 millert Exp $"; +#endif #endif /* LIBC_SCCS and not lint */ #include <sys/param.h> diff --git a/lib/libc/db/btree/bt_debug.c b/lib/libc/db/btree/bt_debug.c index 6d424e9fa5a..d09bb9e93c5 100644 --- a/lib/libc/db/btree/bt_debug.c +++ b/lib/libc/db/btree/bt_debug.c @@ -1,3 +1,5 @@ +/* $OpenBSD: bt_debug.c,v 1.4 1999/02/15 05:11:22 millert Exp $ */ + /*- * Copyright (c) 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -35,7 +37,11 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: bt_debug.c,v 1.3 1996/08/19 08:20:04 tholo Exp $"; +#if 0 +static char sccsid[] = "@(#)bt_debug.c 8.5 (Berkeley) 8/17/94"; +#else +static char rcsid[] = "$OpenBSD: bt_debug.c,v 1.4 1999/02/15 05:11:22 millert Exp $"; +#endif #endif /* LIBC_SCCS and not lint */ #include <sys/param.h> @@ -86,10 +92,9 @@ __bt_dump(dbp) } #undef X - for (i = P_ROOT; (h = mpool_get(t->bt_mp, i, 0)) != NULL; ++i) { + for (i = P_ROOT; + (h = mpool_get(t->bt_mp, i, MPOOL_IGNOREPIN)) != NULL; ++i) __bt_dpage(h); - (void)mpool_put(t->bt_mp, h, 0); - } } /* @@ -141,10 +146,8 @@ __bt_dnpage(dbp, pgno) PAGE *h; t = dbp->internal; - if ((h = mpool_get(t->bt_mp, pgno, 0)) != NULL) { + if ((h = mpool_get(t->bt_mp, pgno, MPOOL_IGNOREPIN)) != NULL) __bt_dpage(h); - (void)mpool_put(t->bt_mp, h, 0); - } } /* @@ -264,7 +267,8 @@ __bt_stat(dbp) t = dbp->internal; pcont = pinternal = pleaf = 0; nkeys = ifree = lfree = 0; - for (i = P_ROOT; (h = mpool_get(t->bt_mp, i, 0)) != NULL; ++i) { + for (i = P_ROOT; + (h = mpool_get(t->bt_mp, i, MPOOL_IGNOREPIN)) != NULL; ++i) switch (h->flags & P_TYPE) { case P_BINTERNAL: case P_RINTERNAL: @@ -281,22 +285,18 @@ __bt_stat(dbp) ++pcont; break; } - (void)mpool_put(t->bt_mp, h, 0); - } /* Count the levels of the tree. */ for (i = P_ROOT, levels = 0 ;; ++levels) { - h = mpool_get(t->bt_mp, i, 0); + h = mpool_get(t->bt_mp, i, MPOOL_IGNOREPIN); if (h->flags & (P_BLEAF|P_RLEAF)) { if (levels == 0) levels = 1; - (void)mpool_put(t->bt_mp, h, 0); break; } i = F_ISSET(t, R_RECNO) ? GETRINTERNAL(h, 0)->pgno : GETBINTERNAL(h, 0)->pgno; - (void)mpool_put(t->bt_mp, h, 0); } (void)fprintf(stderr, "%d level%s with %ld keys", diff --git a/lib/libc/db/btree/bt_delete.c b/lib/libc/db/btree/bt_delete.c index cc8c175d5fe..a000bdba5e0 100644 --- a/lib/libc/db/btree/bt_delete.c +++ b/lib/libc/db/btree/bt_delete.c @@ -1,3 +1,5 @@ +/* $OpenBSD: bt_delete.c,v 1.5 1999/02/15 05:11:22 millert Exp $ */ + /*- * Copyright (c) 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -35,7 +37,11 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: bt_delete.c,v 1.4 1998/03/19 00:29:51 millert Exp $"; +#if 0 +static char sccsid[] = "@(#)bt_delete.c 8.13 (Berkeley) 7/28/94"; +#else +static char rcsid[] = "$OpenBSD: bt_delete.c,v 1.5 1999/02/15 05:11:22 millert Exp $"; +#endif #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> diff --git a/lib/libc/db/btree/bt_get.c b/lib/libc/db/btree/bt_get.c index b6d4bf1e580..0f8e99680a4 100644 --- a/lib/libc/db/btree/bt_get.c +++ b/lib/libc/db/btree/bt_get.c @@ -1,3 +1,5 @@ +/* $OpenBSD: bt_get.c,v 1.4 1999/02/15 05:11:22 millert Exp $ */ + /*- * Copyright (c) 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -35,7 +37,11 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: bt_get.c,v 1.3 1996/08/19 08:20:06 tholo Exp $"; +#if 0 +static char sccsid[] = "@(#)bt_get.c 8.6 (Berkeley) 7/20/94"; +#else +static char rcsid[] = "$OpenBSD: bt_get.c,v 1.4 1999/02/15 05:11:22 millert Exp $"; +#endif #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> diff --git a/lib/libc/db/btree/bt_open.c b/lib/libc/db/btree/bt_open.c index 7fb01943bb1..62a62803d30 100644 --- a/lib/libc/db/btree/bt_open.c +++ b/lib/libc/db/btree/bt_open.c @@ -1,3 +1,5 @@ +/* $OpenBSD: bt_open.c,v 1.6 1999/02/15 05:11:22 millert Exp $ */ + /*- * Copyright (c) 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -35,7 +37,11 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: bt_open.c,v 1.5 1997/07/23 21:00:25 kstailey Exp $"; +#if 0 +static char sccsid[] = "@(#)bt_open.c 8.11 (Berkeley) 11/2/95"; +#else +static char rcsid[] = "$OpenBSD: bt_open.c,v 1.6 1999/02/15 05:11:22 millert Exp $"; +#endif #endif /* LIBC_SCCS and not lint */ /* @@ -356,18 +362,25 @@ nroot(t) PAGE *meta, *root; pgno_t npg; - if ((meta = mpool_get(t->bt_mp, 0, 0)) != NULL) { - mpool_put(t->bt_mp, meta, 0); - return (RET_SUCCESS); + if ((root = mpool_get(t->bt_mp, 1, 0)) != NULL) { + if (root->lower == 0 && + root->pgno == 0 && + root->linp[0] == 0) { + mpool_delete(t->bt_mp, root); + errno = EINVAL; + } else { + mpool_put(t->bt_mp, root, 0); + return (RET_SUCCESS); + } } if (errno != EINVAL) /* It's OK to not exist. */ return (RET_ERROR); errno = 0; - if ((meta = mpool_new(t->bt_mp, &npg)) == NULL) + if ((meta = mpool_new(t->bt_mp, &npg, MPOOL_PAGE_NEXT)) == NULL) return (RET_ERROR); - if ((root = mpool_new(t->bt_mp, &npg)) == NULL) + if ((root = mpool_new(t->bt_mp, &npg, MPOOL_PAGE_NEXT)) == NULL) return (RET_ERROR); if (npg != P_ROOT) diff --git a/lib/libc/db/btree/bt_overflow.c b/lib/libc/db/btree/bt_overflow.c index 23876f1d6fe..1faaa79a503 100644 --- a/lib/libc/db/btree/bt_overflow.c +++ b/lib/libc/db/btree/bt_overflow.c @@ -1,3 +1,5 @@ +/* $OpenBSD: bt_overflow.c,v 1.5 1999/02/15 05:11:23 millert Exp $ */ + /*- * Copyright (c) 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -35,7 +37,11 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: bt_overflow.c,v 1.4 1998/08/14 21:39:18 deraadt Exp $"; +#if 0 +static char sccsid[] = "@(#)bt_overflow.c 8.5 (Berkeley) 7/16/94"; +#else +static char rcsid[] = "$OpenBSD: bt_overflow.c,v 1.5 1999/02/15 05:11:23 millert Exp $"; +#endif #endif /* LIBC_SCCS and not lint */ #include <sys/param.h> diff --git a/lib/libc/db/btree/bt_page.c b/lib/libc/db/btree/bt_page.c index 2552ef2d1fe..e9f7996126e 100644 --- a/lib/libc/db/btree/bt_page.c +++ b/lib/libc/db/btree/bt_page.c @@ -1,3 +1,5 @@ +/* $OpenBSD: bt_page.c,v 1.5 1999/02/15 05:11:23 millert Exp $ */ + /*- * Copyright (c) 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -32,7 +34,11 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: bt_page.c,v 1.4 1997/11/13 06:35:06 deraadt Exp $"; +#if 0 +static char sccsid[] = "@(#)bt_page.c 8.3 (Berkeley) 7/14/94"; +#else +static char rcsid[] = "$OpenBSD: bt_page.c,v 1.5 1999/02/15 05:11:23 millert Exp $"; +#endif #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -96,5 +102,5 @@ __bt_new(t, npg) F_SET(t, B_METADIRTY); return (h); } - return (mpool_new(t->bt_mp, npg)); + return (mpool_new(t->bt_mp, npg, MPOOL_PAGE_NEXT)); } diff --git a/lib/libc/db/btree/bt_put.c b/lib/libc/db/btree/bt_put.c index 3304ccdb5c5..91535e1fa0d 100644 --- a/lib/libc/db/btree/bt_put.c +++ b/lib/libc/db/btree/bt_put.c @@ -1,3 +1,5 @@ +/* $OpenBSD: bt_put.c,v 1.6 1999/02/15 05:11:23 millert Exp $ */ + /*- * Copyright (c) 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -35,7 +37,11 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: bt_put.c,v 1.5 1998/03/19 00:29:53 millert Exp $"; +#if 0 +static char sccsid[] = "@(#)bt_put.c 8.8 (Berkeley) 7/26/94"; +#else +static char rcsid[] = "$OpenBSD: bt_put.c,v 1.6 1999/02/15 05:11:23 millert Exp $"; +#endif #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> diff --git a/lib/libc/db/btree/bt_search.c b/lib/libc/db/btree/bt_search.c index 8bf43da0c93..b1d6ee75294 100644 --- a/lib/libc/db/btree/bt_search.c +++ b/lib/libc/db/btree/bt_search.c @@ -1,3 +1,5 @@ +/* $OpenBSD: bt_search.c,v 1.4 1999/02/15 05:11:23 millert Exp $ */ + /*- * Copyright (c) 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -35,7 +37,11 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: bt_search.c,v 1.3 1996/08/19 08:20:13 tholo Exp $"; +#if 0 +static char sccsid[] = "@(#)bt_search.c 8.8 (Berkeley) 7/31/94"; +#else +static char rcsid[] = "$OpenBSD: bt_search.c,v 1.4 1999/02/15 05:11:23 millert Exp $"; +#endif #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> diff --git a/lib/libc/db/btree/bt_seq.c b/lib/libc/db/btree/bt_seq.c index c30e8eda889..17cfef69432 100644 --- a/lib/libc/db/btree/bt_seq.c +++ b/lib/libc/db/btree/bt_seq.c @@ -1,3 +1,5 @@ +/* $OpenBSD: bt_seq.c,v 1.4 1999/02/15 05:11:23 millert Exp $ */ + /*- * Copyright (c) 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -35,7 +37,11 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: bt_seq.c,v 1.3 1996/08/19 08:20:14 tholo Exp $"; +#if 0 +static char sccsid[] = "@(#)bt_seq.c 8.7 (Berkeley) 7/20/94"; +#else +static char rcsid[] = "$OpenBSD: bt_seq.c,v 1.4 1999/02/15 05:11:23 millert Exp $"; +#endif #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> diff --git a/lib/libc/db/btree/bt_split.c b/lib/libc/db/btree/bt_split.c index 240af9349a1..43cd217af6a 100644 --- a/lib/libc/db/btree/bt_split.c +++ b/lib/libc/db/btree/bt_split.c @@ -1,3 +1,5 @@ +/* $OpenBSD: bt_split.c,v 1.6 1999/02/15 05:11:23 millert Exp $ */ + /*- * Copyright (c) 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -35,7 +37,11 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: bt_split.c,v 1.5 1998/08/28 20:49:07 deraadt Exp $"; +#if 0 +static char rcsid[] = "$OpenBSD: bt_split.c,v 1.6 1999/02/15 05:11:23 millert Exp $"; +#else +static char sccsid[] = "@(#)bt_split.c 8.10 (Berkeley) 1/9/95"; +#endif #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> diff --git a/lib/libc/db/btree/bt_utils.c b/lib/libc/db/btree/bt_utils.c index 2ec3fcd8878..093901f5e5f 100644 --- a/lib/libc/db/btree/bt_utils.c +++ b/lib/libc/db/btree/bt_utils.c @@ -1,3 +1,5 @@ +/* $OpenBSD: bt_utils.c,v 1.4 1999/02/15 05:11:23 millert Exp $ */ + /*- * Copyright (c) 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -35,7 +37,11 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: bt_utils.c,v 1.3 1996/08/19 08:20:17 tholo Exp $"; +#if 0 +static char sccsid[] = "@(#)bt_utils.c 8.8 (Berkeley) 7/20/94"; +#else +static char rcsid[] = "$OpenBSD: bt_utils.c,v 1.4 1999/02/15 05:11:23 millert Exp $"; +#endif #endif /* LIBC_SCCS and not lint */ #include <sys/param.h> diff --git a/lib/libc/db/btree/btree.h b/lib/libc/db/btree/btree.h index 09021e6a564..5baeea5d9ea 100644 --- a/lib/libc/db/btree/btree.h +++ b/lib/libc/db/btree/btree.h @@ -1,3 +1,5 @@ +/* $OpenBSD: btree.h,v 1.4 1999/02/15 05:11:23 millert Exp $ */ + /*- * Copyright (c) 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -33,7 +35,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: btree.h,v 1.3 1996/08/19 08:20:19 tholo Exp $ + * @(#)btree.h 8.11 (Berkeley) 8/17/94 */ /* Macros to set/clear/test flags. */ diff --git a/lib/libc/db/btree/extern.h b/lib/libc/db/btree/extern.h index f83b1f39467..2abb91dabc7 100644 --- a/lib/libc/db/btree/extern.h +++ b/lib/libc/db/btree/extern.h @@ -1,3 +1,5 @@ +/* $OpenBSD: extern.h,v 1.4 1999/02/15 05:11:23 millert Exp $ */ + /*- * Copyright (c) 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -30,7 +32,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: extern.h,v 1.3 1996/08/19 08:20:21 tholo Exp $ + * @(#)extern.h 8.10 (Berkeley) 7/20/94 */ int __bt_close __P((DB *)); diff --git a/lib/libc/db/db/db.c b/lib/libc/db/db/db.c index 41304771425..59a8604aef8 100644 --- a/lib/libc/db/db/db.c +++ b/lib/libc/db/db/db.c @@ -1,3 +1,5 @@ +/* $OpenBSD: db.c,v 1.3 1999/02/15 05:11:23 millert Exp $ */ + /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -32,7 +34,11 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: db.c,v 1.2 1996/08/19 08:20:25 tholo Exp $"; +#if 0 +static char sccsid[] = "@(#)db.c 8.4 (Berkeley) 2/21/94"; +#else +static char rcsid[] = "$OpenBSD: db.c,v 1.3 1999/02/15 05:11:23 millert Exp $"; +#endif #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> diff --git a/lib/libc/db/hash/extern.h b/lib/libc/db/hash/extern.h index baa5749eeb7..eae7a00deb3 100644 --- a/lib/libc/db/hash/extern.h +++ b/lib/libc/db/hash/extern.h @@ -1,3 +1,5 @@ +/* $OpenBSD: extern.h,v 1.4 1999/02/15 05:11:23 millert Exp $ */ + /*- * Copyright (c) 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -30,7 +32,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: extern.h,v 1.3 1996/08/19 08:20:29 tholo Exp $ + * @(#)extern.h 8.4 (Berkeley) 6/16/94 */ BUFHEAD *__add_ovflpage __P((HTAB *, BUFHEAD *)); diff --git a/lib/libc/db/hash/hash.c b/lib/libc/db/hash/hash.c index 8b1140b9af3..bfa79e61546 100644 --- a/lib/libc/db/hash/hash.c +++ b/lib/libc/db/hash/hash.c @@ -1,3 +1,5 @@ +/* $OpenBSD: hash.c,v 1.7 1999/02/15 05:11:23 millert Exp $ */ + /*- * Copyright (c) 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -35,7 +37,11 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: hash.c,v 1.6 1998/03/19 00:29:55 millert Exp $"; +#if 0 +static char sccsid[] = "@(#)hash.c 8.9 (Berkeley) 6/16/94"; +#else +static char rcsid[] = "$OpenBSD: hash.c,v 1.7 1999/02/15 05:11:23 millert Exp $"; +#endif #endif /* LIBC_SCCS and not lint */ #include <sys/param.h> diff --git a/lib/libc/db/hash/hash.h b/lib/libc/db/hash/hash.h index 00b437c1e43..08998f3f1fa 100644 --- a/lib/libc/db/hash/hash.h +++ b/lib/libc/db/hash/hash.h @@ -1,3 +1,5 @@ +/* $OpenBSD: hash.h,v 1.4 1999/02/15 05:11:24 millert Exp $ */ + /*- * Copyright (c) 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -33,7 +35,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: hash.h,v 1.3 1996/08/19 08:20:32 tholo Exp $ + * @(#)hash.h 8.3 (Berkeley) 5/31/94 */ /* Operations */ diff --git a/lib/libc/db/hash/hash_bigkey.c b/lib/libc/db/hash/hash_bigkey.c index 7e51158980c..9e88d55deb5 100644 --- a/lib/libc/db/hash/hash_bigkey.c +++ b/lib/libc/db/hash/hash_bigkey.c @@ -1,3 +1,5 @@ +/* $OpenBSD: hash_bigkey.c,v 1.6 1999/02/15 05:11:24 millert Exp $ */ + /*- * Copyright (c) 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -35,7 +37,11 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: hash_bigkey.c,v 1.5 1998/03/19 00:29:56 millert Exp $"; +#if 0 +static char sccsid[] = "@(#)hash_bigkey.c 8.3 (Berkeley) 5/31/94"; +#else +static char rcsid[] = "$OpenBSD: hash_bigkey.c,v 1.6 1999/02/15 05:11:24 millert Exp $"; +#endif #endif /* LIBC_SCCS and not lint */ /* diff --git a/lib/libc/db/hash/hash_buf.c b/lib/libc/db/hash/hash_buf.c index dc9631814d9..def35a5ede1 100644 --- a/lib/libc/db/hash/hash_buf.c +++ b/lib/libc/db/hash/hash_buf.c @@ -1,3 +1,5 @@ +/* $OpenBSD: hash_buf.c,v 1.7 1999/02/15 05:11:24 millert Exp $ */ + /*- * Copyright (c) 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -35,7 +37,11 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: hash_buf.c,v 1.6 1998/08/28 20:49:10 deraadt Exp $"; +#if 0 +static char sccsid[] = "@(#)hash_buf.c 8.5 (Berkeley) 7/15/94"; +#else +static char rcsid[] = "$OpenBSD: hash_buf.c,v 1.7 1999/02/15 05:11:24 millert Exp $"; +#endif #endif /* LIBC_SCCS and not lint */ /* diff --git a/lib/libc/db/hash/hash_func.c b/lib/libc/db/hash/hash_func.c index 5c8b52604c6..b24fc5eb466 100644 --- a/lib/libc/db/hash/hash_func.c +++ b/lib/libc/db/hash/hash_func.c @@ -1,3 +1,5 @@ +/* $OpenBSD: hash_func.c,v 1.5 1999/02/15 05:11:24 millert Exp $ */ + /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -35,7 +37,11 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: hash_func.c,v 1.4 1996/09/15 09:30:49 tholo Exp $"; +#if 0 +static char sccsid[] = "@(#)hash_func.c 8.4 (Berkeley) 11/7/95"; +#else +static char rcsid[] = "$OpenBSD: hash_func.c,v 1.5 1999/02/15 05:11:24 millert Exp $"; +#endif #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -52,58 +58,54 @@ static u_int32_t hash3 __P((const void *, size_t)); #endif static u_int32_t hash4 __P((const void *, size_t)); -/* Global default hash function */ +/* Default hash function. */ u_int32_t (*__default_hash) __P((const void *, size_t)) = hash4; +#ifdef notdef /* - * HASH FUNCTIONS - * * Assume that we've already split the bucket to which this key hashes, * calculate that bucket, and check that in fact we did already split it. * - * This came from ejb's hsearch. + * EJB's original hsearch hash. */ - -#ifdef notdef - - #define PRIME1 37 #define PRIME2 1048583 -static u_int32_t -hash1(keyarg, len) - const void *keyarg; - register size_t len; +u_int32_t +hash1(key, len) + const void *key; + size_t len; { - register const u_char *key; - register u_int32_t h; + u_int32_t h; + u_int8_t *k; + h = 0; + k = (u_int8_t *)key; /* Convert string to integer */ - for (key = keyarg, h = 0; len--;) - h = h * PRIME1 ^ (*key++ - ' '); + while (len--) + h = h * PRIME1 ^ (*k++ - ' '); h %= PRIME2; return (h); } /* - * Phong's linear congruential hash + * Phong Vo's linear congruential hash */ #define dcharhash(h, c) ((h) = 0x63c63cd9*(h) + 0x9c39c33d + (c)) -static u_int32_t -hash2(keyarg, len) - const void *keyarg; +u_int32_t +hash2(key, len) + const void *key; size_t len; { - register const u_char *e, *key; - register u_int32_t h; - register u_char c; - - key = keyarg; - e = key + len; - for (h = 0; key != e;) { - c = *key++; - if (!c && key > e) + u_int32_t h; + u_int8_t *e, c, *k; + + k = (u_int8_t *)key; + e = k + len; + for (h = 0; k != e;) { + c = *k++; + if (!c && k > e) break; dcharhash(h, c); } @@ -117,102 +119,88 @@ hash2(keyarg, len) * all 8 bytes. Essentially, this saves us 7 cmp & branch instructions. If * this routine is heavily used enough, it's worth the ugly coding. * - * OZ's original sdbm hash + * Ozan Yigit's original sdbm hash. */ -static u_int32_t -hash3(keyarg, len) - const void *keyarg; - register size_t len; +u_int32_t +hash3(key, len) + const void *key; + size_t len; { - register const u_char *key; - register size_t loop; - register u_int32_t h; + u_int32_t n, loop; + u_int8_t *k; -#define HASHC h = *key++ + 65599 * h +#define HASHC n = *k++ + 65599 * n - h = 0; - key = keyarg; + n = 0; + k = (u_int8_t *)key; if (len > 0) { loop = (len + 8 - 1) >> 3; switch (len & (8 - 1)) { case 0: - do { + do { /* All fall throughs */ HASHC; - /* FALLTHROUGH */ case 7: HASHC; - /* FALLTHROUGH */ case 6: HASHC; - /* FALLTHROUGH */ case 5: HASHC; - /* FALLTHROUGH */ case 4: HASHC; - /* FALLTHROUGH */ case 3: HASHC; - /* FALLTHROUGH */ case 2: HASHC; - /* FALLTHROUGH */ case 1: HASHC; } while (--loop); } + } - return (h); + return (n); } -#endif +#endif /* notdef */ -/* Hash function from Chris Torek. */ -static u_int32_t -hash4(keyarg, len) - const void *keyarg; - register size_t len; +/* Chris Torek's hash function. */ +u_int32_t +hash4(key, len) + const void *key; + size_t len; { - register const u_char *key; - register size_t loop; - register u_int32_t h; + u_int32_t h, loop; + u_int8_t *k; -#define HASH4a h = (h << 5) - h + *key++; -#define HASH4b h = (h << 5) + h + *key++; +#define HASH4a h = (h << 5) - h + *k++; +#define HASH4b h = (h << 5) + h + *k++; #define HASH4 HASH4b h = 0; - key = keyarg; + k = (u_int8_t *)key; if (len > 0) { loop = (len + 8 - 1) >> 3; switch (len & (8 - 1)) { case 0: - do { + do { /* All fall throughs */ HASH4; - /* FALLTHROUGH */ case 7: HASH4; - /* FALLTHROUGH */ case 6: HASH4; - /* FALLTHROUGH */ case 5: HASH4; - /* FALLTHROUGH */ case 4: HASH4; - /* FALLTHROUGH */ case 3: HASH4; - /* FALLTHROUGH */ case 2: HASH4; - /* FALLTHROUGH */ case 1: HASH4; } while (--loop); } + } return (h); } diff --git a/lib/libc/db/hash/hash_log2.c b/lib/libc/db/hash/hash_log2.c index 0a9817df653..244560c0870 100644 --- a/lib/libc/db/hash/hash_log2.c +++ b/lib/libc/db/hash/hash_log2.c @@ -1,3 +1,5 @@ +/* $OpenBSD: hash_log2.c,v 1.4 1999/02/15 05:11:24 millert Exp $ */ + /*- * Copyright (c) 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -35,18 +37,20 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: hash_log2.c,v 1.3 1996/08/19 08:20:38 tholo Exp $"; +#if 0 +static char sccsid[] = "@(#)hash_log2.c 8.4 (Berkeley) 11/7/95"; +#else +static char rcsid[] = "$OpenBSD: hash_log2.c,v 1.4 1999/02/15 05:11:24 millert Exp $"; +#endif #endif /* LIBC_SCCS and not lint */ -#include <sys/types.h> - #include <db.h> u_int32_t __log2(num) u_int32_t num; { - register u_int32_t i, limit; + u_int32_t i, limit; limit = 1; for (i = 0; limit < num; limit = limit << 1, i++); diff --git a/lib/libc/db/hash/hash_page.c b/lib/libc/db/hash/hash_page.c index 9081f231789..80d6c0a81eb 100644 --- a/lib/libc/db/hash/hash_page.c +++ b/lib/libc/db/hash/hash_page.c @@ -1,3 +1,5 @@ +/* $OpenBSD: hash_page.c,v 1.7 1999/02/15 05:11:24 millert Exp $ */ + /*- * Copyright (c) 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -35,7 +37,11 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: hash_page.c,v 1.6 1998/07/27 15:35:40 millert Exp $"; +#if 0 +static char sccsid[] = "@(#)hash_page.c 8.7 (Berkeley) 8/16/94"; +#else +static char rcsid[] = "$OpenBSD: hash_page.c,v 1.7 1999/02/15 05:11:24 millert Exp $"; +#endif #endif /* LIBC_SCCS and not lint */ /* diff --git a/lib/libc/db/hash/hsearch.c b/lib/libc/db/hash/hsearch.c index 65fbf9c56e0..9a75a7411c5 100644 --- a/lib/libc/db/hash/hsearch.c +++ b/lib/libc/db/hash/hsearch.c @@ -1,3 +1,5 @@ +/* $OpenBSD: hsearch.c,v 1.4 1999/02/15 05:11:24 millert Exp $ */ + /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -35,7 +37,11 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: hsearch.c,v 1.3 1996/08/19 08:20:41 tholo Exp $"; +#if 0 +static char sccsid[] = "@(#)hsearch.c 8.5 (Berkeley) 9/21/94"; +#else +static char rcsid[] = "$OpenBSD: hsearch.c,v 1.4 1999/02/15 05:11:24 millert Exp $"; +#endif #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> diff --git a/lib/libc/db/hash/ndbm.c b/lib/libc/db/hash/ndbm.c index f18ad49dec5..b7bc85f88aa 100644 --- a/lib/libc/db/hash/ndbm.c +++ b/lib/libc/db/hash/ndbm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ndbm.c,v 1.7 1999/02/12 04:57:51 millert Exp $ */ +/* $OpenBSD: ndbm.c,v 1.8 1999/02/15 05:11:24 millert Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -40,7 +40,7 @@ #if 0 static char sccsid[] = "@(#)dbm.c 8.6 (Berkeley) 11/7/95"; #else -static char rcsid[] = "$OpenBSD: ndbm.c,v 1.7 1999/02/12 04:57:51 millert Exp $"; +static char rcsid[] = "$OpenBSD: ndbm.c,v 1.8 1999/02/15 05:11:24 millert Exp $"; #endif #endif /* LIBC_SCCS and not lint */ @@ -66,7 +66,7 @@ static void no_open_db __P((void)); int dbminit(file) - char *file; + const char *file; { if (__cur_db != NULL) (void)dbm_close(__cur_db); diff --git a/lib/libc/db/hash/page.h b/lib/libc/db/hash/page.h index 54831fc0d89..13bdc449b6f 100644 --- a/lib/libc/db/hash/page.h +++ b/lib/libc/db/hash/page.h @@ -1,3 +1,5 @@ +/* $OpenBSD: page.h,v 1.5 1999/02/15 05:11:24 millert Exp $ */ + /*- * Copyright (c) 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -33,7 +35,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: page.h,v 1.4 1997/07/23 21:00:28 kstailey Exp $ + * @(#)page.h 8.2 (Berkeley) 5/31/94 */ /* diff --git a/lib/libc/db/hash/search.h b/lib/libc/db/hash/search.h index a57c982973b..956094166b4 100644 --- a/lib/libc/db/hash/search.h +++ b/lib/libc/db/hash/search.h @@ -1,3 +1,5 @@ +/* $OpenBSD: search.h,v 1.4 1999/02/15 05:11:24 millert Exp $ */ + /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -33,7 +35,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: search.h,v 1.3 1996/08/19 08:20:44 tholo Exp $ + * @(#)search.h 8.1 (Berkeley) 6/4/93 */ /* Backward compatibility to hsearch interface. */ diff --git a/lib/libc/db/man/Makefile.inc b/lib/libc/db/man/Makefile.inc index 8683e93b17b..efd058ce94d 100644 --- a/lib/libc/db/man/Makefile.inc +++ b/lib/libc/db/man/Makefile.inc @@ -1,7 +1,6 @@ -# $OpenBSD: Makefile.inc,v 1.7 1998/11/20 11:18:35 d Exp $ +# $OpenBSD: Makefile.inc,v 1.8 1999/02/15 05:11:24 millert Exp $ .PATH: ${LIBCSRCDIR}/db/man -MAN+= btree.3 dbopen.3 hash.3 recno.3 ndbm.3 mpool.3 +MAN+= btree.3 dbm.3 dbopen.3 hash.3 mpool.3 ndbm.3 recno.3 MLINKS+= dbopen.3 db.3 -MLINKS+= ndbm.3 dbm.3 diff --git a/lib/libc/db/man/dbm.3 b/lib/libc/db/man/dbm.3 new file mode 100644 index 00000000000..799170cb12e --- /dev/null +++ b/lib/libc/db/man/dbm.3 @@ -0,0 +1,145 @@ +.\" $OpenBSD: dbm.3,v 1.1 1999/02/15 05:11:24 millert Exp $ +.\" +.\" Copyright (c) 1999 Todd C. Miller <Todd.Miller@courtesan.com> +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. The name of the author may not be used to endorse or promote products +.\" derived from this software without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, +.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +.\" AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +.\" THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +.\" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +.\" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +.\" OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd Feb 14, 1999 +.Os OpenBSD +.Dt DBM 3 +.Sh NAME +.Nm dbm , +.Nm dbminit , +.Nm fetch , +.Nm store , +.Nm delete , +.Nm firstkey , +.Nm nextkey , +.Nm dbmclose +.Nd database subroutines +.Sh SYNOPSIS +.Fd #include <dbm.h> +.Ft int +.Fn dbminit "const char *file" +.Ft int +.Fn dbmclose "void" +.Ft datum +.Fn fetch "datum key" +.Ft int +.Fn store "datum key" "datum content" +.Ft int +.Fn delete "datum key" +.Ft datum +.Fn firstkey "void" +.Ft datum +.Fn nextkey "datum key" +.Sh DESCRIPTION +These functions provide a dbm-compatible interface to the +database access methods described in +.Xr db 3 . +Each unique record in the database is a key/content pair, +the components of which may be any arbitrary binary data. +The key and the content data are described by the +.Ft datum +data structure: +.Bd -literal -offset indent +typedef struct { + char *dptr; + int dsize; +} datum +.Ed +.Pp +The +.Fn dbminit +function is used to open a database in the file named by +.Fa file , +suffixed with +.Dv DBM_SUFFIX +.Pq Sq Pa .db . +The file is created if it does not already exist. +.Pp +Once the database is open, +.Fn fetch +is used to retrieve the data content associated with the key +.Fa key . +Similarly, +.Fn store +is used to store the +.Fa content +data with the key +.Fa key . +.Pp +The +.Fn delete +function removes the key +.Fa key +and its associated content from the database. +.Pp +The functions +.Fn firstkey +and +.Fn nextkey +are used to iterate over all of the records in the database. +Each record will be reached exactly once, but in no particular order. +The +.Fn firstkey +function returns the first record of the database, and thereafter +.Fn nextkey +returns the following records. +The following code traverses the entire database: +.Bd -literal + for (key = firstkey(); key.dptr != NULL; key = nextkey(key)) +.Ed +.Pp +The behaviour of +.Fn nextkey +is undefined if the database is modified after a call to +.Fn firstkey . +.Pp +The database is closed with the +.Fn dbmclose +function (you must close a database before opening a new one). +.Ss Implementation notes +The underlying database is a +.Xr hash 3 +database with a +bucket size of 4096, +a filling factor of 40, +default hashing function and cache size, +and uses the host's native byte order. +.Sh RETURN VALUES +Upon successful completion, all functions that return +.Ft int +return a value of 0, otherwise a negative value is returned. +.Pp +Functions that return a +.Ft datum +indicate errors by setting the +.Va dptr +field set to +.Dv NULL . +.Sh SEE ALSO +.Xr db 3 , +.Xr ndbm 3 , +.Xr hash 3 diff --git a/lib/libc/db/man/ndbm.3 b/lib/libc/db/man/ndbm.3 index 4e755b52051..e28fc7eb111 100644 --- a/lib/libc/db/man/ndbm.3 +++ b/lib/libc/db/man/ndbm.3 @@ -1,5 +1,5 @@ .\" David Leonard, 1998. Placed in the public domain. -.\" $OpenBSD: ndbm.3,v 1.3 1998/05/15 14:30:15 d Exp $ +.\" $OpenBSD: ndbm.3,v 1.4 1999/02/15 05:11:25 millert Exp $ .Dd May 13, 1998 .Os OpenBSD .Dt NDBM 3 @@ -31,7 +31,7 @@ .Ft int .Fn dbm_store "DBM *db" "datum key" "datum content" "int store_mode" .Sh DESCRIPTION -These functions provide a dbm- and ndbm-compatible interface to the +These functions provide a ndbm-compatible interface to the database access methods described in .Xr db 3 . Each unique record in the database is a key/content pair, @@ -188,4 +188,4 @@ and corresponds to those errors described in .Sh SEE ALSO .Xr db 3 , .Xr hash 3 , -.Xr open 2 . +.Xr open 2 diff --git a/lib/libc/db/mpool/README b/lib/libc/db/mpool/README index 916ea935ef6..b8b2eaf4ec9 100644 --- a/lib/libc/db/mpool/README +++ b/lib/libc/db/mpool/README @@ -1,4 +1,5 @@ -# $OpenBSD: README,v 1.2 1996/08/19 08:20:51 tholo Exp $ +# $OpenBSD: README,v 1.3 1999/02/15 05:11:25 millert Exp $ +# @(#)README 8.1 (Berkeley) 6/4/93 These are the current memory pool routines. They aren't ready for prime time, yet, and diff --git a/lib/libc/db/mpool/mpool.c b/lib/libc/db/mpool/mpool.c index ab98c8e5c59..008132644f1 100644 --- a/lib/libc/db/mpool/mpool.c +++ b/lib/libc/db/mpool/mpool.c @@ -1,3 +1,5 @@ +/* $OpenBSD: mpool.c,v 1.6 1999/02/15 05:11:25 millert Exp $ */ + /*- * Copyright (c) 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -32,7 +34,11 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: mpool.c,v 1.5 1998/08/28 20:49:11 deraadt Exp $"; +#if 0 +static char sccsid[] = "@(#)mpool.c 8.7 (Berkeley) 11/2/95"; +#else +static char rcsid[] = "$OpenBSD: mpool.c,v 1.6 1999/02/15 05:11:25 millert Exp $"; +#endif #endif /* LIBC_SCCS and not lint */ #include <sys/param.h> @@ -116,9 +122,10 @@ mpool_filter(mp, pgin, pgout, pgcookie) * Get a new page of memory. */ void * -mpool_new(mp, pgnoaddr) +mpool_new(mp, pgnoaddr, flags) MPOOL *mp; pgno_t *pgnoaddr; + u_int flags; { struct _hqh *head; BKT *bp; @@ -137,8 +144,13 @@ mpool_new(mp, pgnoaddr) */ if ((bp = mpool_bkt(mp)) == NULL) return (NULL); - *pgnoaddr = bp->pgno = mp->npages++; - bp->flags = MPOOL_PINNED; + if (flags == MPOOL_PAGE_REQUEST) { + mp->npages++; + bp->pgno = *pgnoaddr; + } else + bp->pgno = *pgnoaddr = mp->npages++; + + bp->flags = MPOOL_PINNED | MPOOL_INUSE; head = &mp->hqh[HASHKEY(bp->pgno)]; CIRCLEQ_INSERT_HEAD(head, bp, hq); @@ -146,6 +158,33 @@ mpool_new(mp, pgnoaddr) return (bp->page); } +int +mpool_delete(mp, page) + MPOOL *mp; + void *page; +{ + struct _hqh *head; + BKT *bp; + + bp = (BKT *)((char *)page - sizeof(BKT)); + +#ifdef DEBUG + if (!(bp->flags & MPOOL_PINNED)) { + (void)fprintf(stderr, + "mpool_delete: page %d not pinned\n", bp->pgno); + abort(); + } +#endif + + /* Remove from the hash and lru queues. */ + head = &mp->hqh[HASHKEY(bp->pgno)]; + CIRCLEQ_REMOVE(head, bp, hq); + CIRCLEQ_REMOVE(&mp->lqh, bp, q); + + free(bp); + return (RET_SUCCESS); +} + /* * mpool_get * Get a page. @@ -162,12 +201,6 @@ mpool_get(mp, pgno, flags) off_t off; int nr; - /* Check for attempt to retrieve a non-existent page. */ - if (pgno >= mp->npages) { - errno = EINVAL; - return (NULL); - } - #ifdef STATISTICS ++mp->pageget; #endif @@ -175,7 +208,7 @@ mpool_get(mp, pgno, flags) /* Check for a page that is cached. */ if ((bp = mpool_look(mp, pgno)) != NULL) { #ifdef DEBUG - if (bp->flags & MPOOL_PINNED) { + if (!(flags & MPOOL_IGNOREPIN) && bp->flags & MPOOL_PINNED) { (void)fprintf(stderr, "mpool_get: page %d already pinned\n", bp->pgno); abort(); @@ -207,15 +240,26 @@ mpool_get(mp, pgno, flags) off = mp->pagesize * pgno; if (lseek(mp->fd, off, SEEK_SET) != off) return (NULL); + if ((nr = read(mp->fd, bp->page, mp->pagesize)) != mp->pagesize) { - if (nr >= 0) - errno = EFTYPE; - return (NULL); + if (nr > 0) { + /* A partial read is definitely bad. */ + errno = EINVAL; + return (NULL); + } else { + /* + * A zero-length reads, means you need to create a + * new page. + */ + memset(bp->page, 0, mp->pagesize); + } } /* Set the page number, pin the page. */ bp->pgno = pgno; - bp->flags = MPOOL_PINNED; + if (!(flags & MPOOL_IGNOREPIN)) + bp->flags = MPOOL_PINNED; + bp->flags |= MPOOL_INUSE; /* * Add the page to the head of the hash chain and the tail @@ -257,7 +301,8 @@ mpool_put(mp, page, flags) } #endif bp->flags &= ~MPOOL_PINNED; - bp->flags |= flags & MPOOL_DIRTY; + if (flags & MPOOL_DIRTY) + bp->flags |= flags & MPOOL_DIRTY; return (RET_SUCCESS); } @@ -345,6 +390,7 @@ mpool_bkt(mp) bp->page = spage; } #endif + bp->flags = 0; return (bp); } @@ -355,6 +401,7 @@ new: if ((bp = (BKT *)malloc(sizeof(BKT) + mp->pagesize)) == NULL) #endif memset(bp, 0xff, sizeof(BKT) + mp->pagesize); bp->page = (char *)bp + sizeof(BKT); + bp->flags = 0; ++mp->curcache; return (bp); } @@ -402,7 +449,8 @@ mpool_look(mp, pgno) head = &mp->hqh[HASHKEY(pgno)]; for (bp = head->cqh_first; bp != (void *)head; bp = bp->hq.cqe_next) - if (bp->pgno == pgno) { + if ((bp->pgno == pgno) && + (bp->flags & MPOOL_INUSE == MPOOL_INUSE)) { #ifdef STATISTICS ++mp->cachehit; #endif diff --git a/lib/libc/db/mpool/mpool.libtp b/lib/libc/db/mpool/mpool.libtp index 8eb7715b0d2..160f7369a8a 100644 --- a/lib/libc/db/mpool/mpool.libtp +++ b/lib/libc/db/mpool/mpool.libtp @@ -1,6 +1,6 @@ /****************************************************************************** -VERSION $Id: mpool.libtp,v 1.2 1998/07/13 02:11:10 millert Exp $ +VERSION $OpenBSD: mpool.libtp,v 1.3 1999/02/15 05:11:25 millert Exp $ PACKAGE: User Level Shared Memory Manager DESCRIPTION: diff --git a/lib/libc/db/recno/extern.h b/lib/libc/db/recno/extern.h index 295308286df..8860878e2bd 100644 --- a/lib/libc/db/recno/extern.h +++ b/lib/libc/db/recno/extern.h @@ -1,3 +1,5 @@ +/* $OpenBSD: extern.h,v 1.4 1999/02/15 05:11:25 millert Exp $ */ + /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -30,7 +32,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: extern.h,v 1.3 1996/08/19 08:20:56 tholo Exp $ + * @(#)extern.h 8.3 (Berkeley) 6/4/94 */ #include "../btree/extern.h" diff --git a/lib/libc/db/recno/rec_close.c b/lib/libc/db/recno/rec_close.c index 88aea2e7583..c621e038b50 100644 --- a/lib/libc/db/recno/rec_close.c +++ b/lib/libc/db/recno/rec_close.c @@ -1,3 +1,5 @@ +/* $OpenBSD: rec_close.c,v 1.6 1999/02/15 05:11:25 millert Exp $ */ + /*- * Copyright (c) 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -32,7 +34,11 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: rec_close.c,v 1.5 1998/03/19 00:29:58 millert Exp $"; +#if 0 +static char sccsid[] = "@(#)rec_close.c 8.6 (Berkeley) 8/18/94"; +#else +static char rcsid[] = "$OpenBSD: rec_close.c,v 1.6 1999/02/15 05:11:25 millert Exp $"; +#endif #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -155,7 +161,7 @@ __rec_sync(dbp, flags) status = (dbp->seq)(dbp, &key, &data, R_NEXT); } } else { - iov[1].iov_base = (char *) &t->bt_bval; + iov[1].iov_base = (void *) &t->bt_bval; iov[1].iov_len = 1; status = (dbp->seq)(dbp, &key, &data, R_FIRST); diff --git a/lib/libc/db/recno/rec_delete.c b/lib/libc/db/recno/rec_delete.c index f90c328ea11..a331b5e427f 100644 --- a/lib/libc/db/recno/rec_delete.c +++ b/lib/libc/db/recno/rec_delete.c @@ -1,3 +1,5 @@ +/* $OpenBSD: rec_delete.c,v 1.4 1999/02/15 05:11:25 millert Exp $ */ + /*- * Copyright (c) 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -35,7 +37,11 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: rec_delete.c,v 1.3 1996/08/19 08:21:00 tholo Exp $"; +#if 0 +static char sccsid[] = "@(#)rec_delete.c 8.7 (Berkeley) 7/14/94"; +#else +static char rcsid[] = "$OpenBSD: rec_delete.c,v 1.4 1999/02/15 05:11:25 millert Exp $"; +#endif #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> diff --git a/lib/libc/db/recno/rec_get.c b/lib/libc/db/recno/rec_get.c index d043174a174..a5c61de4b1d 100644 --- a/lib/libc/db/recno/rec_get.c +++ b/lib/libc/db/recno/rec_get.c @@ -1,3 +1,5 @@ +/* $OpenBSD: rec_get.c,v 1.5 1999/02/15 05:11:25 millert Exp $ */ + /*- * Copyright (c) 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -32,7 +34,11 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: rec_get.c,v 1.4 1998/08/14 21:39:20 deraadt Exp $"; +#if 0 +static char sccsid[] = "@(#)rec_get.c 8.9 (Berkeley) 8/18/94"; +#else +static char rcsid[] = "$OpenBSD: rec_get.c,v 1.5 1999/02/15 05:11:25 millert Exp $"; +#endif #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> diff --git a/lib/libc/db/recno/rec_open.c b/lib/libc/db/recno/rec_open.c index b29adb671e1..500e4b41003 100644 --- a/lib/libc/db/recno/rec_open.c +++ b/lib/libc/db/recno/rec_open.c @@ -1,3 +1,5 @@ +/* $OpenBSD: rec_open.c,v 1.5 1999/02/15 05:11:25 millert Exp $ */ + /*- * Copyright (c) 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -35,7 +37,11 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: rec_open.c,v 1.4 1997/07/23 21:00:29 kstailey Exp $"; +#if 0 +static char sccsid[] = "@(#)rec_open.c 8.10 (Berkeley) 9/1/94"; +#else +static char rcsid[] = "$OpenBSD: rec_open.c,v 1.5 1999/02/15 05:11:25 millert Exp $"; +#endif #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> diff --git a/lib/libc/db/recno/rec_put.c b/lib/libc/db/recno/rec_put.c index 1cb617b46cc..9db96f208fd 100644 --- a/lib/libc/db/recno/rec_put.c +++ b/lib/libc/db/recno/rec_put.c @@ -1,3 +1,5 @@ +/* $OpenBSD: rec_put.c,v 1.5 1999/02/15 05:11:25 millert Exp $ */ + /*- * Copyright (c) 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -32,7 +34,11 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: rec_put.c,v 1.4 1998/08/14 21:39:21 deraadt Exp $"; +#if 0 +static char sccsid[] = "@(#)rec_put.c 8.7 (Berkeley) 8/18/94"; +#else +static char rcsid[] = "$OpenBSD: rec_put.c,v 1.5 1999/02/15 05:11:25 millert Exp $"; +#endif #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> diff --git a/lib/libc/db/recno/rec_search.c b/lib/libc/db/recno/rec_search.c index d554bb673a6..aac2643209b 100644 --- a/lib/libc/db/recno/rec_search.c +++ b/lib/libc/db/recno/rec_search.c @@ -1,3 +1,5 @@ +/* $OpenBSD: rec_search.c,v 1.5 1999/02/15 05:11:25 millert Exp $ */ + /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -32,7 +34,11 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: rec_search.c,v 1.4 1997/07/23 21:00:30 kstailey Exp $"; +#if 0 +static char sccsid[] = "@(#)rec_search.c 8.4 (Berkeley) 7/14/94"; +#else +static char rcsid[] = "$OpenBSD: rec_search.c,v 1.5 1999/02/15 05:11:25 millert Exp $"; +#endif #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> diff --git a/lib/libc/db/recno/rec_seq.c b/lib/libc/db/recno/rec_seq.c index 2caaafa67ee..b1d1ed73fb9 100644 --- a/lib/libc/db/recno/rec_seq.c +++ b/lib/libc/db/recno/rec_seq.c @@ -1,3 +1,5 @@ +/* $OpenBSD: rec_seq.c,v 1.4 1999/02/15 05:11:25 millert Exp $ */ + /*- * Copyright (c) 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -32,7 +34,11 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: rec_seq.c,v 1.3 1996/08/19 08:21:10 tholo Exp $"; +#if 0 +static char sccsid[] = "@(#)rec_utils.c 8.6 (Berkeley) 7/16/94"; +#else +static char rcsid[] = "$OpenBSD: rec_seq.c,v 1.4 1999/02/15 05:11:25 millert Exp $"; +#endif #endif /* not lint */ #include <sys/types.h> diff --git a/lib/libc/db/recno/recno.h b/lib/libc/db/recno/recno.h index e12c26ee39f..c656d7b3508 100644 --- a/lib/libc/db/recno/recno.h +++ b/lib/libc/db/recno/recno.h @@ -1,3 +1,5 @@ +/* $OpenBSD: recno.h,v 1.4 1999/02/15 05:11:25 millert Exp $ */ + /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -30,7 +32,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: recno.h,v 1.3 1996/08/19 08:21:13 tholo Exp $ + * @(#)recno.h 8.1 (Berkeley) 6/4/93 */ enum SRCHOP { SDELETE, SINSERT, SEARCH}; /* Rec_search operation. */ |