Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/sysinst Fix CD_NAMES against concrete instances com...



details:   https://anonhg.NetBSD.org/src/rev/99ff914304e4
branches:  trunk
changeset: 445648:99ff914304e4
user:      martin <martin%NetBSD.org@localhost>
date:      Wed Nov 07 21:59:30 2018 +0000

description:
Fix CD_NAMES against concrete instances comparision - if CD_NAMES
entries have a wildcard, strip device instance number off from both
comparands.

diffstat:

 usr.sbin/sysinst/disks.c |  23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)

diffs (43 lines):

diff -r d62fb8e9409f -r 99ff914304e4 usr.sbin/sysinst/disks.c
--- a/usr.sbin/sysinst/disks.c  Wed Nov 07 21:20:23 2018 +0000
+++ b/usr.sbin/sysinst/disks.c  Wed Nov 07 21:59:30 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: disks.c,v 1.18 2018/11/07 21:20:23 martin Exp $ */
+/*     $NetBSD: disks.c,v 1.19 2018/11/07 21:59:30 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -509,17 +509,28 @@
 is_cdrom_device(const char *dev)
 {
        static const char *cdrom_devices[] = { CD_NAMES, 0 };
-       char pat[SSTRSIZE], *star;
+       char pat[SSTRSIZE], comp[SSTRSIZE], *star, *p;
        const char **dev_pat;
 
+       /* trim device number off */
+       strcpy(comp, dev);
+       for (p = comp + strlen(comp) - 1; p != comp; p--)
+               if (!isdigit((unsigned char)*p))
+                       break;
+       if (p != comp)
+               p[1] = 0;
+
        for (dev_pat = cdrom_devices; *dev_pat; dev_pat++) {
                strcpy(pat, *dev_pat);
                star = strchr(pat, '*');
-               if (star)
+               if (star) {
                        *star = 0;
-
-               if (strcmp(dev, pat) == 0)
-                       return true;
+                       if (strcmp(comp, pat) == 0)
+                               return true;
+               } else {
+                       if (strcmp(dev, pat) == 0)
+                               return true;
+               }
        }
 
        return false;



Home | Main Index | Thread Index | Old Index