Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/config Accept the block-device-only devices.



details:   https://anonhg.NetBSD.org/src/rev/97ee02bc907f
branches:  trunk
changeset: 542187:97ee02bc907f
user:      gehenna <gehenna%NetBSD.org@localhost>
date:      Thu Jan 23 15:05:45 2003 +0000

description:
Accept the block-device-only devices.

Reported by ragge.

diffstat:

 usr.sbin/config/files.c |  48 ++++++++++++++++++++++++------------------------
 usr.sbin/config/gram.y  |   5 +++--
 usr.sbin/config/sem.c   |   9 +++++++--
 3 files changed, 34 insertions(+), 28 deletions(-)

diffs (118 lines):

diff -r c95c194ab36a -r 97ee02bc907f usr.sbin/config/files.c
--- a/usr.sbin/config/files.c   Thu Jan 23 15:03:44 2003 +0000
+++ b/usr.sbin/config/files.c   Thu Jan 23 15:05:45 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: files.c,v 1.20 2003/01/23 15:03:44 gehenna Exp $       */
+/*     $NetBSD: files.c,v 1.21 2003/01/23 15:05:45 gehenna Exp $       */
 
 /*
  * Copyright (c) 1992, 1993
@@ -361,35 +361,35 @@
                                       dm->dm_cmajor);
                                return (1);
                        }
-               } else {
-                       if (ht_insert(fixdevmtab, intern(dm->dm_name), dm)) {
-                               panic("fixdevsw: %s char %d block %d",
-                                     dm->dm_name, dm->dm_cmajor,
-                                     dm->dm_bmajor);
-                       }
+               }
+               if (ht_insert(fixdevmtab, intern(dm->dm_name), dm)) {
+                       panic("fixdevsw: %s char %d block %d",
+                             dm->dm_name, dm->dm_cmajor, dm->dm_bmajor);
                }
 
                if (dm->dm_opts != NULL &&
                    !expr_eval(dm->dm_opts, fixsel, NULL))
                        continue;
 
-               if (ht_lookup(cdevmtab, intern(dm->dm_name)) != NULL) {
-                       xerror(dm->dm_srcfile, dm->dm_srcline,
-                              "device-major of character device '%s' is "
-                              "already defined", dm->dm_name);
-                       return (1);
-               }
-               (void)snprintf(mstr, sizeof(mstr), "%d", dm->dm_cmajor);
-               if (ht_lookup(cdevmtab, intern(mstr)) != NULL) {
-                       xerror(dm->dm_srcfile, dm->dm_srcline,
-                              "device-major of character major '%d' "
-                              "is already defined", dm->dm_cmajor);
-                       return (1);
-               }
-               if (ht_insert(cdevmtab, intern(dm->dm_name), dm) ||
-                   ht_insert(cdevmtab, intern(mstr), dm)) {
-                       panic("fixdevsw: %s character major %d",
-                             dm->dm_name, dm->dm_cmajor);
+               if (dm->dm_cmajor != -1) {
+                       if (ht_lookup(cdevmtab, intern(dm->dm_name)) != NULL) {
+                               xerror(dm->dm_srcfile, dm->dm_srcline,
+                                      "device-major of character device '%s' "
+                                      "is already defined", dm->dm_name);
+                               return (1);
+                       }
+                       (void)snprintf(mstr, sizeof(mstr), "%d", dm->dm_cmajor);
+                       if (ht_lookup(cdevmtab, intern(mstr)) != NULL) {
+                               xerror(dm->dm_srcfile, dm->dm_srcline,
+                                      "device-major of character major '%d' "
+                                      "is already defined", dm->dm_cmajor);
+                               return (1);
+                       }
+                       if (ht_insert(cdevmtab, intern(dm->dm_name), dm) ||
+                           ht_insert(cdevmtab, intern(mstr), dm)) {
+                               panic("fixdevsw: %s character major %d",
+                                     dm->dm_name, dm->dm_cmajor);
+                       }
                }
                if (dm->dm_bmajor != -1) {
                        if (ht_lookup(bdevmtab, intern(dm->dm_name)) != NULL) {
diff -r c95c194ab36a -r 97ee02bc907f usr.sbin/config/gram.y
--- a/usr.sbin/config/gram.y    Thu Jan 23 15:03:44 2003 +0000
+++ b/usr.sbin/config/gram.y    Thu Jan 23 15:05:45 2003 +0000
@@ -1,5 +1,5 @@
 %{
-/*     $NetBSD: gram.y,v 1.39 2002/11/17 23:36:19 thorpej Exp $        */
+/*     $NetBSD: gram.y,v 1.40 2003/01/23 15:05:45 gehenna Exp $        */
 
 /*
  * Copyright (c) 1992, 1993
@@ -205,7 +205,8 @@
        /* empty */                     { $$ = -1; };
 
 device_major_char:
-       CHAR NUMBER                     { $$ = $2; };
+       CHAR NUMBER                     { $$ = $2; } |
+       /* empty */                     { $$ = -1; };
 
 /* order of options is important, must use right recursion */
 fopts:
diff -r c95c194ab36a -r 97ee02bc907f usr.sbin/config/sem.c
--- a/usr.sbin/config/sem.c     Thu Jan 23 15:03:44 2003 +0000
+++ b/usr.sbin/config/sem.c     Thu Jan 23 15:05:45 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sem.c,v 1.35 2002/10/11 01:48:27 thorpej Exp $ */
+/*     $NetBSD: sem.c,v 1.36 2003/01/23 15:05:46 gehenna Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -1116,7 +1116,7 @@
 {
        struct devm *dm;
 
-       if (cmajor < 0 || cmajor >= 4096) {
+       if (cmajor < -1 || cmajor >= 4096) {
                error("character major %d is invalid", cmajor);
                nvfreel(options);
                return;
@@ -1127,6 +1127,11 @@
                nvfreel(options);
                return;
        }
+       if (cmajor == -1 && bmajor == -1) {
+               error("both character/block majors are not specified");
+               nvfreel(options);
+               return;
+       }
 
        dm = emalloc(sizeof(*dm));
        dm->dm_srcfile = yyfile;



Home | Main Index | Thread Index | Old Index