diff options
author | Xin LI <delphij@FreeBSD.org> | 2009-03-28 07:31:02 +0000 |
---|---|---|
committer | Xin LI <delphij@FreeBSD.org> | 2009-03-28 07:31:02 +0000 |
commit | 9fc74a871c838bb10c1ba9b01a22e9df4aa2e55f (patch) | |
tree | ed6c7564fb2f2d25581d74c48ca0074066b16e39 /lib/libc/db/btree/bt_open.c | |
parent | 73590c342a2d1a23322e7c64295fd91c6a6294b9 (diff) |
Notes
Diffstat (limited to 'lib/libc/db/btree/bt_open.c')
-rw-r--r-- | lib/libc/db/btree/bt_open.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/libc/db/btree/bt_open.c b/lib/libc/db/btree/bt_open.c index 7422ca4ca4a0..47f3646ac46a 100644 --- a/lib/libc/db/btree/bt_open.c +++ b/lib/libc/db/btree/bt_open.c @@ -352,18 +352,25 @@ nroot(BTREE *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) |