Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/config Allow pseudo-devices to be declared with an ...



details:   https://anonhg.NetBSD.org/src/rev/7ee85b09d27d
branches:  trunk
changeset: 542363:7ee85b09d27d
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Mon Jan 27 05:00:54 2003 +0000

description:
Allow pseudo-devices to be declared with an interface attribute.  For
such pseudo-devices, create cfdrivers for them which carry the appropriate
attributes.  This allows devices in the config file to be attached to
pseudo-devices.

diffstat:

 usr.sbin/config/defs.h |   3 ++-
 usr.sbin/config/gram.y |   5 +++--
 usr.sbin/config/main.c |  26 +++++++++++++++++++++++++-
 usr.sbin/config/sem.c  |   5 ++---
 4 files changed, 32 insertions(+), 7 deletions(-)

diffs (110 lines):

diff -r 78ef778e4f26 -r 7ee85b09d27d usr.sbin/config/defs.h
--- a/usr.sbin/config/defs.h    Mon Jan 27 04:08:45 2003 +0000
+++ b/usr.sbin/config/defs.h    Mon Jan 27 05:00:54 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: defs.h,v 1.10 2003/01/23 15:03:44 gehenna Exp $        */
+/*     $NetBSD: defs.h,v 1.11 2003/01/27 05:00:54 thorpej Exp $        */
 
 /*
  * Copyright (c) 1992, 1993
@@ -365,6 +365,7 @@
 struct nvlist *mkoptions;      /* makeoptions */
 struct hashtab *devbasetab;    /* devbase lookup */
 struct hashtab *devatab;       /* devbase attachment lookup */
+struct hashtab *devitab;       /* device instance lookup */
 struct hashtab *selecttab;     /* selects things that are "optional foo" */
 struct hashtab *needcnttab;    /* retains names marked "needs-count" */
 struct hashtab *opttab;        /* table of configured options */
diff -r 78ef778e4f26 -r 7ee85b09d27d usr.sbin/config/gram.y
--- a/usr.sbin/config/gram.y    Mon Jan 27 04:08:45 2003 +0000
+++ b/usr.sbin/config/gram.y    Mon Jan 27 05:00:54 2003 +0000
@@ -1,5 +1,5 @@
 %{
-/*     $NetBSD: gram.y,v 1.40 2003/01/23 15:05:45 gehenna Exp $        */
+/*     $NetBSD: gram.y,v 1.41 2003/01/27 05:00:54 thorpej Exp $        */
 
 /*
  * Copyright (c) 1992, 1993
@@ -289,7 +289,8 @@
                                        { defdevattach($5, $2, $4, $6); } |
        MAXPARTITIONS NUMBER            { maxpartitions = $2; } |
        MAXUSERS NUMBER NUMBER NUMBER   { setdefmaxusers($2, $3, $4); } |
-       DEFPSEUDO devbase attrs_opt { defdev($2, NULL, $3, 1); } |
+       DEFPSEUDO devbase interface_opt attrs_opt
+                                       { defdev($2, $3, $4, 1); } |
        MAJOR '{' majorlist '}';
 
 atlist:
diff -r 78ef778e4f26 -r 7ee85b09d27d usr.sbin/config/main.c
--- a/usr.sbin/config/main.c    Mon Jan 27 04:08:45 2003 +0000
+++ b/usr.sbin/config/main.c    Mon Jan 27 05:00:54 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.74 2002/10/11 02:02:24 thorpej Exp $        */
+/*     $NetBSD: main.c,v 1.75 2003/01/27 05:00:54 thorpej Exp $        */
 
 /*
  * Copyright (c) 1992, 1993
@@ -206,6 +206,7 @@
        ident = NULL;
        devbasetab = ht_new();
        devatab = ht_new();
+       devitab = ht_new();
        selecttab = ht_new();
        needcnttab = ht_new();
        opttab = ht_new();
@@ -886,6 +887,29 @@
 {
        struct deva *da;
 
+       /*
+        * Pseudo-devices are a little special.  We consider them
+        * to have instances only if they are both:
+        *
+        *      1. Included in this kernel configuration.
+        *
+        *      2. Have one or more interface attributes.
+        */
+       if (dev->d_ispseudo) {
+               struct nvlist *nv;
+               struct attr *a;
+
+               if (ht_lookup(devitab, dev->d_name) == NULL)
+                       return (0);
+
+               for (nv = dev->d_attrs; nv != NULL; nv = nv->nv_next) {
+                       a = nv->nv_ptr;
+                       if (a->a_iattr)
+                               return (1);
+               }
+               return (0);
+       }
+
        for (da = dev->d_ahead; da != NULL; da = da->d_bsame)
                if (deva_has_instances(da, unit))
                        return (1);
diff -r 78ef778e4f26 -r 7ee85b09d27d usr.sbin/config/sem.c
--- a/usr.sbin/config/sem.c     Mon Jan 27 04:08:45 2003 +0000
+++ b/usr.sbin/config/sem.c     Mon Jan 27 05:00:54 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sem.c,v 1.36 2003/01/23 15:05:46 gehenna Exp $ */
+/*     $NetBSD: sem.c,v 1.37 2003/01/27 05:00:55 thorpej Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -63,7 +63,7 @@
 const char *s_none;
 
 static struct hashtab *cfhashtab;      /* for config lookup */
-static struct hashtab *devitab;                /* etc */
+struct hashtab *devitab;               /* etc */
 
 static struct attr errattr;
 static struct devbase errdev;
@@ -104,7 +104,6 @@
        cfhashtab = ht_new();
        TAILQ_INIT(&allcf);
 
-       devitab = ht_new();
        TAILQ_INIT(&alldevi);
        errdev.d_name = "<internal>";
 



Home | Main Index | Thread Index | Old Index