Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Switch device database to cdb(5). Rework ttyname(3) and ttyn...



details:   https://anonhg.NetBSD.org/src/rev/42e4cd678f2c
branches:  trunk
changeset: 779578:42e4cd678f2c
user:      joerg <joerg%NetBSD.org@localhost>
date:      Sun Jun 03 21:42:44 2012 +0000

description:
Switch device database to cdb(5). Rework ttyname(3) and ttyname_r(3) to
depend on new devname_r(3) as heart. Add /dev/pts magic directly to
devname(3). While it can lead to returning non-existing paths, the
behavior is more consistent that way. Drop caching layer in devname(3),
it doesn't buy anything for the common case of having access to the
database. Teach devname(3) proper fallback behavior of scanning /dev.
Create both old-style and new-style database for now in /etc/rc.d/sysdb.

diffstat:

 bin/ps/ps.1                                 |    4 +-
 distrib/amd64/cdroms/install.sh             |    4 +-
 distrib/amd64/installimage/install.sh       |    4 +-
 distrib/i386/cdroms/install.sh              |    4 +-
 distrib/i386/installimage/install.sh        |    4 +-
 distrib/sparc64/cdroms/installcd/install.sh |    4 +-
 distrib/sparc64/instfs/dot.profile          |    4 +-
 etc/rc.d/sysdb                              |    3 +-
 include/paths.h                             |    3 +-
 include/stdlib.h                            |    3 +-
 lib/libc/gen/devname.3                      |   13 +-
 lib/libc/gen/devname.c                      |  275 +++++++++++--------------
 lib/libc/gen/ttyname.3                      |    6 +-
 lib/libc/gen/ttyname.c                      |   96 +--------
 lib/libc/include/namespace.h                |    3 +-
 share/man/man5/rc.conf.5                    |    8 +-
 tests/include/t_paths.c                     |    5 +-
 usr.sbin/dev_mkdb/Makefile                  |    5 +-
 usr.sbin/dev_mkdb/dev_mkdb.8                |   19 +-
 usr.sbin/dev_mkdb/dev_mkdb.c                |  303 ++++++++++++++++-----------
 20 files changed, 358 insertions(+), 412 deletions(-)

diffs (truncated from 1227 to 300 lines):

diff -r 6475bda8f105 -r 42e4cd678f2c bin/ps/ps.1
--- a/bin/ps/ps.1       Sun Jun 03 21:27:30 2012 +0000
+++ b/bin/ps/ps.1       Sun Jun 03 21:42:44 2012 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: ps.1,v 1.100 2012/04/15 21:20:16 wiz Exp $
+.\"    $NetBSD: ps.1,v 1.101 2012/06/03 21:42:44 joerg Exp $
 .\"
 .\" Copyright (c) 1980, 1990, 1991, 1993, 1994
 .\"    The Regents of the University of California.  All rights reserved.
@@ -682,7 +682,7 @@
 special files and device names
 .It Pa /dev/drum
 default swap device
-.It Pa /var/run/dev.db
+.It Pa /var/run/dev.cdb
 /dev name database
 .It Pa /var/db/kvm.db
 system name list database
diff -r 6475bda8f105 -r 42e4cd678f2c distrib/amd64/cdroms/install.sh
--- a/distrib/amd64/cdroms/install.sh   Sun Jun 03 21:27:30 2012 +0000
+++ b/distrib/amd64/cdroms/install.sh   Sun Jun 03 21:42:44 2012 +0000
@@ -1,5 +1,5 @@
 #! /bin/sh -m
-# $NetBSD: install.sh,v 1.2 2011/04/17 12:18:20 martin Exp $
+# $NetBSD: install.sh,v 1.3 2012/06/03 21:42:44 joerg Exp $
 #
 # -
 #  Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 
 # Check if we are on a framebuffer or on serial console and default
 # the terminal type accordingly.
-# There is no /var/db/dev.db, so sysctl might not map the devicename properly;
+# There is no /var/db/dev.cdb, so sysctl might not map the devicename properly;
 # ttyE0 is 90,0 -> 0x5a00
 case $(sysctl -nx kern.consdev) in
  002f000000000000)
diff -r 6475bda8f105 -r 42e4cd678f2c distrib/amd64/installimage/install.sh
--- a/distrib/amd64/installimage/install.sh     Sun Jun 03 21:27:30 2012 +0000
+++ b/distrib/amd64/installimage/install.sh     Sun Jun 03 21:42:44 2012 +0000
@@ -1,5 +1,5 @@
 #! /bin/sh -m
-# $NetBSD: install.sh,v 1.1 2012/01/22 03:53:29 tsutsui Exp $
+# $NetBSD: install.sh,v 1.2 2012/06/03 21:42:45 joerg Exp $
 #
 # -
 #  Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 
 # Check if we are on a framebuffer or on serial console and default
 # the terminal type accordingly.
-# There is no /var/db/dev.db, so sysctl might not map the devicename properly;
+# There is no /var/db/dev.cdb, so sysctl might not map the devicename properly;
 # ttyE0 is 90,0 -> 0x5a00
 case $(sysctl -nx kern.consdev) in
  002f000000000000)
diff -r 6475bda8f105 -r 42e4cd678f2c distrib/i386/cdroms/install.sh
--- a/distrib/i386/cdroms/install.sh    Sun Jun 03 21:27:30 2012 +0000
+++ b/distrib/i386/cdroms/install.sh    Sun Jun 03 21:42:44 2012 +0000
@@ -1,5 +1,5 @@
 #! /bin/sh -m
-# $NetBSD: install.sh,v 1.2 2011/04/17 12:18:20 martin Exp $
+# $NetBSD: install.sh,v 1.3 2012/06/03 21:42:45 joerg Exp $
 #
 # -
 #  Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 
 # Check if we are on a framebuffer or on serial console and default
 # the terminal type accordingly.
-# There is no /var/db/dev.db, so sysctl might not map the devicename properly;
+# There is no /var/db/dev.cdb, so sysctl might not map the devicename properly;
 # ttyE0 is 90,0 -> 0x5a00
 case $(sysctl -nx kern.consdev) in
  002f000000000000)
diff -r 6475bda8f105 -r 42e4cd678f2c distrib/i386/installimage/install.sh
--- a/distrib/i386/installimage/install.sh      Sun Jun 03 21:27:30 2012 +0000
+++ b/distrib/i386/installimage/install.sh      Sun Jun 03 21:42:44 2012 +0000
@@ -1,5 +1,5 @@
 #! /bin/sh -m
-# $NetBSD: install.sh,v 1.1 2012/01/22 03:53:30 tsutsui Exp $
+# $NetBSD: install.sh,v 1.2 2012/06/03 21:42:45 joerg Exp $
 #
 # -
 #  Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 
 # Check if we are on a framebuffer or on serial console and default
 # the terminal type accordingly.
-# There is no /var/db/dev.db, so sysctl might not map the devicename properly;
+# There is no /var/db/dev.cdb, so sysctl might not map the devicename properly;
 # ttyE0 is 90,0 -> 0x5a00
 case $(sysctl -nx kern.consdev) in
  002f000000000000)
diff -r 6475bda8f105 -r 42e4cd678f2c distrib/sparc64/cdroms/installcd/install.sh
--- a/distrib/sparc64/cdroms/installcd/install.sh       Sun Jun 03 21:27:30 2012 +0000
+++ b/distrib/sparc64/cdroms/installcd/install.sh       Sun Jun 03 21:42:44 2012 +0000
@@ -1,5 +1,5 @@
 #! /bin/sh -m
-# $NetBSD: install.sh,v 1.2 2011/04/17 12:18:20 martin Exp $
+# $NetBSD: install.sh,v 1.3 2012/06/03 21:42:45 joerg Exp $
 #
 # -
 #  Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 
 # Check if we are on a framebuffer or on serial console and default
 # the terminal type accordingly.
-# There is no /var/db/dev.db, so sysctl might not map the devicename properly;
+# There is no /var/db/dev.cdb, so sysctl might not map the devicename properly;
 # ttyE0 is 90,0 -> 0x5a00
 case $(sysctl -nx kern.consdev) in
  0000000000005a0*)
diff -r 6475bda8f105 -r 42e4cd678f2c distrib/sparc64/instfs/dot.profile
--- a/distrib/sparc64/instfs/dot.profile        Sun Jun 03 21:27:30 2012 +0000
+++ b/distrib/sparc64/instfs/dot.profile        Sun Jun 03 21:42:44 2012 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: dot.profile,v 1.6 2011/04/17 12:18:20 martin Exp $
+# $NetBSD: dot.profile,v 1.7 2012/06/03 21:42:45 joerg Exp $
 #
 # Copyright (c) 1997 Perry E. Metzger
 # Copyright (c) 1994 Christopher G. Demetriou
@@ -38,7 +38,7 @@
 
 # Check if we are on a framebuffer or on serial console and default
 # the terminal type accordingly.
-# There is no /var/db/dev.db, so sysctl might not map the devicename properly;
+# There is no /var/db/dev.cdb, so sysctl might not map the devicename properly;
 # ttyE0 is 90,0 -> 0x5a00
 case $(sysctl -nx kern.consdev) in
  0000000000005a0*)
diff -r 6475bda8f105 -r 42e4cd678f2c etc/rc.d/sysdb
--- a/etc/rc.d/sysdb    Sun Jun 03 21:27:30 2012 +0000
+++ b/etc/rc.d/sysdb    Sun Jun 03 21:42:44 2012 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: sysdb,v 1.23 2012/02/21 12:30:32 nakayama Exp $
+# $NetBSD: sysdb,v 1.24 2012/06/03 21:42:45 joerg Exp $
 #
 
 # PROVIDE: sysdb
@@ -63,6 +63,7 @@
 build_devdb()
 {
        check_file /dev /var/run/dev.db dev_mkdb
+       check_file /dev /var/run/dev.cdb dev_mkdb
 }
 
 build_password()
diff -r 6475bda8f105 -r 42e4cd678f2c include/paths.h
--- a/include/paths.h   Sun Jun 03 21:27:30 2012 +0000
+++ b/include/paths.h   Sun Jun 03 21:42:44 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: paths.h,v 1.40 2011/09/27 11:24:20 jruoho Exp $        */
+/*     $NetBSD: paths.h,v 1.41 2012/06/03 21:42:46 joerg Exp $ */
 
 /*
  * Copyright (c) 1989, 1993
@@ -64,6 +64,7 @@
 #define _PATH_CPUCTL   "/dev/cpuctl"
 #define        _PATH_CSMAPPER  "/usr/share/i18n/csmapper"
 #define        _PATH_DEFTAPE   "/dev/nrst0"
+#define        _PATH_DEVCDB    "/var/run/dev.cdb"
 #define        _PATH_DEVDB     "/var/run/dev.db"
 #define        _PATH_DEVNULL   "/dev/null"
 #define        _PATH_DRUM      "/dev/drum"
diff -r 6475bda8f105 -r 42e4cd678f2c include/stdlib.h
--- a/include/stdlib.h  Sun Jun 03 21:27:30 2012 +0000
+++ b/include/stdlib.h  Sun Jun 03 21:42:44 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: stdlib.h,v 1.98 2012/04/20 17:31:29 christos Exp $     */
+/*     $NetBSD: stdlib.h,v 1.99 2012/06/03 21:42:46 joerg Exp $        */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -269,6 +269,7 @@
 void    csetexpandtc(int);
 
 int     daemon(int, int);
+int     devname_r(dev_t, mode_t, char *, size_t);
 #ifndef __LIBC12_SOURCE__
 __aconst char *devname(dev_t, mode_t) __RENAME(__devname50);
 #endif
diff -r 6475bda8f105 -r 42e4cd678f2c lib/libc/gen/devname.3
--- a/lib/libc/gen/devname.3    Sun Jun 03 21:27:30 2012 +0000
+++ b/lib/libc/gen/devname.3    Sun Jun 03 21:42:44 2012 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: devname.3,v 1.11 2003/08/07 16:42:46 agc Exp $
+.\"    $NetBSD: devname.3,v 1.12 2012/06/03 21:42:46 joerg Exp $
 .\"
 .\" Copyright (c) 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"     @(#)devname.3  8.2 (Berkeley) 4/29/95
 .\"
-.Dd April 29, 1995
+.Dd June 3, 2012
 .Dt DEVNAME 3
 .Os
 .Sh NAME
@@ -53,11 +53,6 @@
 and a file type matching the one encoded in
 .Fa type
 which must be one of S_IFBLK or S_IFCHR.
-The device name is cached so that multiple calls with the same
-.Fa dev
-and
-.Fa type
-do not require additional queries of the device database file.
 If no device matches the specified values, or no information is
 available,
 .Dv NULL
@@ -67,8 +62,8 @@
 found is the string
 .Dq ?? .
 .Sh FILES
-.Bl -tag -width /var/run/dev.db -compact
-.It Pa /var/run/dev.db
+.Bl -tag -width /var/run/dev.cdb -compact
+.It Pa /var/run/dev.cdb
 Device database file.
 .El
 .Sh SEE ALSO
diff -r 6475bda8f105 -r 42e4cd678f2c lib/libc/gen/devname.c
--- a/lib/libc/gen/devname.c    Sun Jun 03 21:27:30 2012 +0000
+++ b/lib/libc/gen/devname.c    Sun Jun 03 21:42:44 2012 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: devname.c,v 1.21 2010/03/23 20:28:59 drochner Exp $    */
+/*     $NetBSD: devname.c,v 1.22 2012/06/03 21:42:46 joerg Exp $       */
 
 /*-
- * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -29,170 +29,139 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-/*-
- * Copyright (c) 1992 Keith Muller.
- * Copyright (c) 1989, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Keith Muller of the University of California, San Diego.
- *
- * 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. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- */
-
 #include <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-#if 0
-static char sccsid[] = "@(#)devname.c  8.2 (Berkeley) 4/29/95";
-#else
-__RCSID("$NetBSD: devname.c,v 1.21 2010/03/23 20:28:59 drochner Exp $");
-#endif
-#endif /* LIBC_SCCS and not lint */
+__RCSID("$NetBSD: devname.c,v 1.22 2012/06/03 21:42:46 joerg Exp $");
 
 #include "namespace.h"
-#include <sys/types.h>
+#include "reentrant.h"
 #include <sys/stat.h>
-#include <sys/param.h>
 
-#include <db.h>
-#include <fcntl.h>
+#include <cdbr.h>
+#include <errno.h>
+#include <fts.h>
+#include <limits.h>
 #include <paths.h>
 #include <stdio.h>
 #include <string.h>



Home | Main Index | Thread Index | Old Index