Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add the constant database reader (cdbr(3)) and writer ((cdbw...
details: https://anonhg.NetBSD.org/src/rev/9c191ce1b6d7
branches: trunk
changeset: 754252:9c191ce1b6d7
user: joerg <joerg%NetBSD.org@localhost>
date: Sun Apr 25 00:54:44 2010 +0000
description:
Add the constant database reader (cdbr(3)) and writer ((cdbw(3)).
They implement a space efficent write-once database with fast access
path. Switch the services(5) database to use cdb. The size of the
database file decreases from 2.1MB disk space to 307KB. Access
performance is about the same if setservent(0) is used and about an
order of magnitude faster otherwise. services_mkdb defaults to the new
format, but can optionally create the old db(3) format as well for
statically linked legacy applications.
diffstat:
distrib/sets/lists/base/ad.mips64eb | 6 +-
distrib/sets/lists/base/ad.mips64el | 6 +-
distrib/sets/lists/base/md.amd64 | 4 +-
distrib/sets/lists/base/md.sparc64 | 4 +-
distrib/sets/lists/base/shl.mi | 6 +-
distrib/sets/lists/comp/mi | 43 ++-
distrib/sets/lists/man/mi | 5 +-
include/Makefile | 4 +-
include/cdbr.h | 56 +++
include/cdbw.h | 58 +++
include/netdb.h | 5 +-
lib/libc/Makefile | 3 +-
lib/libc/cdb/Makefile.inc | 21 +
lib/libc/cdb/cdb.5 | 103 +++++
lib/libc/cdb/cdbr.3 | 119 ++++++
lib/libc/cdb/cdbr.c | 246 +++++++++++++
lib/libc/cdb/cdbw.3 | 130 +++++++
lib/libc/cdb/cdbw.c | 599 +++++++++++++++++++++++++++++++++
lib/libc/include/namespace.h | 12 +-
lib/libc/net/getservbyname_r.c | 73 ++-
lib/libc/net/getservbyport_r.c | 61 ++-
lib/libc/net/getservent_r.c | 237 +++++++++---
lib/libc/net/servent.h | 15 +-
lib/libc/shlib_version | 4 +-
usr.sbin/services_mkdb/Makefile | 4 +-
usr.sbin/services_mkdb/extern.h | 9 +
usr.sbin/services_mkdb/output_cdb.c | 163 ++++++++
usr.sbin/services_mkdb/output_db.c | 189 ++++++++++
usr.sbin/services_mkdb/services_mkdb.8 | 25 +-
usr.sbin/services_mkdb/services_mkdb.c | 187 ++-------
usr.sbin/services_mkdb/uniq.c | 16 +-
31 files changed, 2122 insertions(+), 291 deletions(-)
diffs (truncated from 3065 to 300 lines):
diff -r 6337c90c54a3 -r 9c191ce1b6d7 distrib/sets/lists/base/ad.mips64eb
--- a/distrib/sets/lists/base/ad.mips64eb Sun Apr 25 00:35:58 2010 +0000
+++ b/distrib/sets/lists/base/ad.mips64eb Sun Apr 25 00:54:44 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: ad.mips64eb,v 1.12 2010/03/13 23:33:52 agc Exp $
+# $NetBSD: ad.mips64eb,v 1.13 2010/04/25 00:54:44 joerg Exp $
./libexec/ld.elf_so-64 base-compat-shlib compat,pic
./libexec/ld.elf_so-o32 base-sysutil-bin compat,pic
./usr/lib/64 base-compat-lib compat
@@ -62,7 +62,7 @@
./usr/lib/64/libbz2.so.1 base-compat-shlib compat,pic
./usr/lib/64/libbz2.so.1.1 base-compat-shlib compat,pic
./usr/lib/64/libc.so.12 base-compat-shlib compat,pic
-./usr/lib/64/libc.so.12.171 base-compat-shlib compat,pic
+./usr/lib/64/libc.so.12.172 base-compat-shlib compat,pic
./usr/lib/64/libcom_err.so.6 base-compat-shlib compat,pic
./usr/lib/64/libcom_err.so.6.0 base-compat-shlib compat,pic
./usr/lib/64/libcrypt.so.1 base-compat-shlib compat,pic
@@ -294,7 +294,7 @@
./usr/lib/o32/libbz2.so.1 base-compat-shlib compat,pic
./usr/lib/o32/libbz2.so.1.1 base-compat-shlib compat,pic
./usr/lib/o32/libc.so.12 base-compat-shlib compat,pic
-./usr/lib/o32/libc.so.12.171 base-compat-shlib compat,pic
+./usr/lib/o32/libc.so.12.172 base-compat-shlib compat,pic
./usr/lib/o32/libcom_err.so.6 base-compat-shlib compat,pic
./usr/lib/o32/libcom_err.so.6.0 base-compat-shlib compat,pic
./usr/lib/o32/libcrypt.so.1 base-compat-shlib compat,pic
diff -r 6337c90c54a3 -r 9c191ce1b6d7 distrib/sets/lists/base/ad.mips64el
--- a/distrib/sets/lists/base/ad.mips64el Sun Apr 25 00:35:58 2010 +0000
+++ b/distrib/sets/lists/base/ad.mips64el Sun Apr 25 00:54:44 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: ad.mips64el,v 1.12 2010/03/13 23:33:52 agc Exp $
+# $NetBSD: ad.mips64el,v 1.13 2010/04/25 00:54:44 joerg Exp $
./libexec/ld.elf_so-64 base-compat-shlib compat,pic
./libexec/ld.elf_so-o32 base-sysutil-bin compat,pic
./usr/lib/64 base-compat-lib compat
@@ -62,7 +62,7 @@
./usr/lib/64/libbz2.so.1 base-compat-shlib compat,pic
./usr/lib/64/libbz2.so.1.1 base-compat-shlib compat,pic
./usr/lib/64/libc.so.12 base-compat-shlib compat,pic
-./usr/lib/64/libc.so.12.171 base-compat-shlib compat,pic
+./usr/lib/64/libc.so.12.172 base-compat-shlib compat,pic
./usr/lib/64/libcom_err.so.6 base-compat-shlib compat,pic
./usr/lib/64/libcom_err.so.6.0 base-compat-shlib compat,pic
./usr/lib/64/libcrypt.so.1 base-compat-shlib compat,pic
@@ -294,7 +294,7 @@
./usr/lib/o32/libbz2.so.1 base-compat-shlib compat,pic
./usr/lib/o32/libbz2.so.1.1 base-compat-shlib compat,pic
./usr/lib/o32/libc.so.12 base-compat-shlib compat,pic
-./usr/lib/o32/libc.so.12.171 base-compat-shlib compat,pic
+./usr/lib/o32/libc.so.12.172 base-compat-shlib compat,pic
./usr/lib/o32/libcom_err.so.6 base-compat-shlib compat,pic
./usr/lib/o32/libcom_err.so.6.0 base-compat-shlib compat,pic
./usr/lib/o32/libcrypt.so.1 base-compat-shlib compat,pic
diff -r 6337c90c54a3 -r 9c191ce1b6d7 distrib/sets/lists/base/md.amd64
--- a/distrib/sets/lists/base/md.amd64 Sun Apr 25 00:35:58 2010 +0000
+++ b/distrib/sets/lists/base/md.amd64 Sun Apr 25 00:54:44 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: md.amd64,v 1.86 2010/03/13 23:33:52 agc Exp $
+# $NetBSD: md.amd64,v 1.87 2010/04/25 00:54:44 joerg Exp $
./dev/lms0 base-obsolete obsolete
./dev/mms0 base-obsolete obsolete
./libexec/ld.elf_so-i386 base-sys-shlib compat,pic
@@ -65,7 +65,7 @@
./usr/lib/i386/libbz2.so.1 base-compat-shlib compat,pic
./usr/lib/i386/libbz2.so.1.1 base-compat-shlib compat,pic
./usr/lib/i386/libc.so.12 base-compat-shlib compat,pic
-./usr/lib/i386/libc.so.12.171 base-compat-shlib compat,pic
+./usr/lib/i386/libc.so.12.172 base-compat-shlib compat,pic
./usr/lib/i386/libcom_err.so.6 base-compat-shlib compat,pic,kerberos
./usr/lib/i386/libcom_err.so.6.0 base-compat-shlib compat,pic,kerberos
./usr/lib/i386/libcrypt.so.1 base-compat-shlib compat,pic
diff -r 6337c90c54a3 -r 9c191ce1b6d7 distrib/sets/lists/base/md.sparc64
--- a/distrib/sets/lists/base/md.sparc64 Sun Apr 25 00:35:58 2010 +0000
+++ b/distrib/sets/lists/base/md.sparc64 Sun Apr 25 00:54:44 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: md.sparc64,v 1.80 2010/03/13 23:33:52 agc Exp $
+# $NetBSD: md.sparc64,v 1.81 2010/04/25 00:54:44 joerg Exp $
./libexec/ld.elf_so-sparc base-sysutil-bin compat,pic
./sbin/edlabel base-sysutil-root obsolete
./usr/bin/fdformat base-util-bin
@@ -63,7 +63,7 @@
./usr/lib/sparc/libbz2.so.1 base-compat-shlib compat,pic
./usr/lib/sparc/libbz2.so.1.1 base-compat-shlib compat,pic
./usr/lib/sparc/libc.so.12 base-compat-shlib compat,pic
-./usr/lib/sparc/libc.so.12.171 base-compat-shlib compat,pic
+./usr/lib/sparc/libc.so.12.172 base-compat-shlib compat,pic
./usr/lib/sparc/libcom_err.so.6 base-compat-shlib compat,pic
./usr/lib/sparc/libcom_err.so.6.0 base-compat-shlib compat,pic
./usr/lib/sparc/libcrypt.so.1 base-compat-shlib compat,pic
diff -r 6337c90c54a3 -r 9c191ce1b6d7 distrib/sets/lists/base/shl.mi
--- a/distrib/sets/lists/base/shl.mi Sun Apr 25 00:35:58 2010 +0000
+++ b/distrib/sets/lists/base/shl.mi Sun Apr 25 00:54:44 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: shl.mi,v 1.534 2010/04/12 22:34:17 pooka Exp $
+# $NetBSD: shl.mi,v 1.535 2010/04/25 00:54:44 joerg Exp $
#
# Note: Don't delete entries from here - mark them as "obsolete" instead,
# unless otherwise stated below.
@@ -13,7 +13,7 @@
#
# Note: libtermcap and libtermlib are hardlinked and share the same version.
#
-./lib/libc.so.12.171 base-sys-shlib dynamicroot
+./lib/libc.so.12.172 base-sys-shlib dynamicroot
./lib/libcrypt.so.1.0 base-sys-shlib dynamicroot
./lib/libcrypto.so.6.1 base-crypto-shlib crypto,dynamicroot
./lib/libdevmapper.so.1.0 base-lvm-shlib lvm,dynamicroot
@@ -63,7 +63,7 @@
./usr/lib/libbluetooth.so.4.2 base-sys-shlib
./usr/lib/libbsdmalloc.so.0.0 base-sys-shlib
./usr/lib/libbz2.so.1.1 base-sys-shlib
-./usr/lib/libc.so.12.171 base-sys-shlib
+./usr/lib/libc.so.12.172 base-sys-shlib
./usr/lib/libcom_err.so.6.0 base-krb5-shlib kerberos
./usr/lib/libcrypt.so.1.0 base-sys-shlib
./usr/lib/libcrypto.so.6.1 base-crypto-shlib crypto
diff -r 6337c90c54a3 -r 9c191ce1b6d7 distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi Sun Apr 25 00:35:58 2010 +0000
+++ b/distrib/sets/lists/comp/mi Sun Apr 25 00:54:44 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1435 2010/04/22 06:48:28 jruoho Exp $
+# $NetBSD: mi,v 1.1436 2010/04/25 00:54:44 joerg Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -191,6 +191,8 @@
./usr/include/bluetooth.h comp-c-include
./usr/include/bm.h comp-c-include
./usr/include/bzlib.h comp-c-include
+./usr/include/cdbr.h comp-c-include
+./usr/include/cdbw.h comp-c-include
./usr/include/cdk/alphalist.h comp-obsolete obsolete
./usr/include/cdk/binding.h comp-obsolete obsolete
./usr/include/cdk/buttonbox.h comp-obsolete obsolete
@@ -5243,6 +5245,19 @@
./usr/share/man/cat3/ccosf.0 comp-c-catman .cat
./usr/share/man/cat3/ccosh.0 comp-c-catman .cat
./usr/share/man/cat3/ccoshf.0 comp-c-catman .cat
+./usr/share/man/cat3/cdbr.0 comp-c-catman .cat
+./usr/share/man/cat3/cdbr_close.0 comp-c-catman .cat
+./usr/share/man/cat3/cdbr_entries.0 comp-c-catman .cat
+./usr/share/man/cat3/cdbr_find.0 comp-c-catman .cat
+./usr/share/man/cat3/cdbr_get.0 comp-c-catman .cat
+./usr/share/man/cat3/cdbr_open.0 comp-c-catman .cat
+./usr/share/man/cat3/cdbw.0 comp-c-catman .cat
+./usr/share/man/cat3/cdbw_close.0 comp-c-catman .cat
+./usr/share/man/cat3/cdbw_output.0 comp-c-catman .cat
+./usr/share/man/cat3/cdbw_put.0 comp-c-catman .cat
+./usr/share/man/cat3/cdbw_put_data.0 comp-c-catman .cat
+./usr/share/man/cat3/cdbw_put_key.0 comp-c-catman .cat
+./usr/share/man/cat3/cdbw_open.0 comp-c-catman .cat
./usr/share/man/cat3/cdk.0 comp-obsolete obsolete
./usr/share/man/cat3/cdk_alphalist.0 comp-obsolete obsolete
./usr/share/man/cat3/cdk_binding.0 comp-obsolete obsolete
@@ -11097,6 +11112,19 @@
./usr/share/man/html3/ccosf.html comp-c-htmlman html
./usr/share/man/html3/ccosh.html comp-c-htmlman html
./usr/share/man/html3/ccoshf.html comp-c-htmlman html
+./usr/share/man/html3/cdbr.html comp-c-htmlman html
+./usr/share/man/html3/cdbr_close.html comp-c-htmlman html
+./usr/share/man/html3/cdbr_entries.html comp-c-htmlman html
+./usr/share/man/html3/cdbr_find.html comp-c-htmlman html
+./usr/share/man/html3/cdbr_get.html comp-c-htmlman html
+./usr/share/man/html3/cdbr_open.html comp-c-htmlman html
+./usr/share/man/html3/cdbw.html comp-c-htmlman html
+./usr/share/man/html3/cdbw_close.html comp-c-htmlman html
+./usr/share/man/html3/cdbw_output.html comp-c-htmlman html
+./usr/share/man/html3/cdbw_put.html comp-c-htmlman html
+./usr/share/man/html3/cdbw_put_data.html comp-c-htmlman html
+./usr/share/man/html3/cdbw_put_key.html comp-c-htmlman html
+./usr/share/man/html3/cdbw_open.html comp-c-htmlman html
./usr/share/man/html3/ceil.html comp-c-htmlman html
./usr/share/man/html3/ceilf.html comp-c-htmlman html
./usr/share/man/html3/cexp.html comp-c-htmlman html
@@ -16773,6 +16801,19 @@
./usr/share/man/man3/ccosf.3 comp-c-man .man
./usr/share/man/man3/ccosh.3 comp-c-man .man
./usr/share/man/man3/ccoshf.3 comp-c-man .man
+./usr/share/man/man3/cdbr.3 comp-c-man .man
+./usr/share/man/man3/cdbr_close.3 comp-c-man .man
+./usr/share/man/man3/cdbr_entries.3 comp-c-man .man
+./usr/share/man/man3/cdbr_find.3 comp-c-man .man
+./usr/share/man/man3/cdbr_get.3 comp-c-man .man
+./usr/share/man/man3/cdbr_open.3 comp-c-man .man
+./usr/share/man/man3/cdbw.3 comp-c-man .man
+./usr/share/man/man3/cdbw_close.3 comp-c-man .man
+./usr/share/man/man3/cdbw_output.3 comp-c-man .man
+./usr/share/man/man3/cdbw_put.3 comp-c-man .man
+./usr/share/man/man3/cdbw_put_data.3 comp-c-man .man
+./usr/share/man/man3/cdbw_put_key.3 comp-c-man .man
+./usr/share/man/man3/cdbw_open.3 comp-c-man .man
./usr/share/man/man3/cdk.3 comp-obsolete obsolete
./usr/share/man/man3/cdk_alphalist.3 comp-obsolete obsolete
./usr/share/man/man3/cdk_binding.3 comp-obsolete obsolete
diff -r 6337c90c54a3 -r 9c191ce1b6d7 distrib/sets/lists/man/mi
--- a/distrib/sets/lists/man/mi Sun Apr 25 00:35:58 2010 +0000
+++ b/distrib/sets/lists/man/mi Sun Apr 25 00:54:44 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1204 2010/04/22 06:48:28 jruoho Exp $
+# $NetBSD: mi,v 1.1205 2010/04/25 00:54:45 joerg Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -1746,6 +1746,7 @@
./usr/share/man/cat5/bounce.0 man-postfix-catman postfix,.cat
./usr/share/man/cat5/canonical.0 man-postfix-catman postfix,.cat
./usr/share/man/cat5/ccd.conf.0 man-sysutil-catman .cat
+./usr/share/man/cat5/cdb.0 man-sys-catman .cat
./usr/share/man/cat5/cidr_table.0 man-postfix-catman postfix,.cat
./usr/share/man/cat5/core.0 man-sys-catman .cat
./usr/share/man/cat5/crontab.0 man-cron-catman .cat
@@ -4321,6 +4322,7 @@
./usr/share/man/html5/bounce.html man-postfix-htmlman postfix,html
./usr/share/man/html5/canonical.html man-postfix-htmlman postfix,html
./usr/share/man/html5/ccd.conf.html man-sysutil-htmlman html
+./usr/share/man/html5/cdb.html man-sys-htmlman html
./usr/share/man/html5/cidr_table.html man-postfix-htmlman postfix,html
./usr/share/man/html5/core.html man-sys-htmlman html
./usr/share/man/html5/crontab.html man-cron-htmlman html
@@ -6836,6 +6838,7 @@
./usr/share/man/man5/bounce.5 man-postfix-man postfix,.man
./usr/share/man/man5/canonical.5 man-postfix-man postfix,.man
./usr/share/man/man5/ccd.conf.5 man-sysutil-man .man
+./usr/share/man/man5/cdb.5 man-sys-man .man
./usr/share/man/man5/cidr_table.5 man-postfix-man postfix,.man
./usr/share/man/man5/core.5 man-sys-man .man
./usr/share/man/man5/crontab.5 man-cron-man .man
diff -r 6337c90c54a3 -r 9c191ce1b6d7 include/Makefile
--- a/include/Makefile Sun Apr 25 00:35:58 2010 +0000
+++ b/include/Makefile Sun Apr 25 00:54:44 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.131 2008/05/28 12:28:12 ad Exp $
+# $NetBSD: Makefile,v 1.132 2010/04/25 00:54:45 joerg Exp $
# @(#)Makefile 8.2 (Berkeley) 1/4/94
# Doing a make includes builds /usr/include
@@ -8,7 +8,7 @@
# Missing: mp.h
INCS= a.out.h aio.h ar.h assert.h atomic.h \
- bitstring.h bm.h complex.h cpio.h ctype.h \
+ bitstring.h bm.h cdbr.h cdbw.h complex.h cpio.h ctype.h \
db.h dirent.h disktab.h dlfcn.h err.h errno.h fmtmsg.h fnmatch.h \
fstab.h fts.h ftw.h getopt.h glob.h grp.h ifaddrs.h iconv.h \
inttypes.h iso646.h kvm.h langinfo.h libgen.h \
diff -r 6337c90c54a3 -r 9c191ce1b6d7 include/cdbr.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/include/cdbr.h Sun Apr 25 00:54:44 2010 +0000
@@ -0,0 +1,56 @@
+/* $NetBSD: cdbr.h,v 1.1 2010/04/25 00:54:45 joerg Exp $ */
+/*-
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Joerg Sonnenberger.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``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
+ * COPYRIGHT HOLDERS OR CONTRIBUTORS 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.
+ */
+
+#ifndef _CDBR_H
+#define _CDBR_H
+
+#include <sys/cdefs.h>
+#include <inttypes.h>
+#include <stddef.h>
+
+#define CDBR_DEFAULT 0
+
+struct cdbr;
+
+__BEGIN_DECLS
+
+struct cdbr *cdbr_open(const char *, int);
+uint32_t cdbr_entries(struct cdbr *);
+int cdbr_get(struct cdbr *, uint32_t, const void **, size_t *);
+int cdbr_find(struct cdbr *, const void *, size_t,
Home |
Main Index |
Thread Index |
Old Index