Source-Changes-HG archive

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

[src/trunk]: src/sbin/fsck Make querying the disk geometry fail silently if c...



details:   https://anonhg.NetBSD.org/src/rev/12dc6e8ff3b9
branches:  trunk
changeset: 338679:12dc6e8ff3b9
user:      martin <martin%NetBSD.org@localhost>
date:      Wed Jun 03 17:53:23 2015 +0000

description:
Make querying the disk geometry fail silently if called for a non-exitent
disk.
XXX: DIOCGDISKINFO returns strange error codes

diffstat:

 sbin/fsck/partutil.c |  17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diffs (52 lines):

diff -r 1fbb70c3fd48 -r 12dc6e8ff3b9 sbin/fsck/partutil.c
--- a/sbin/fsck/partutil.c      Wed Jun 03 15:13:15 2015 +0000
+++ b/sbin/fsck/partutil.c      Wed Jun 03 17:53:23 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: partutil.c,v 1.14 2014/12/29 16:35:38 christos Exp $   */
+/*     $NetBSD: partutil.c,v 1.15 2015/06/03 17:53:23 martin Exp $     */
 
 /*-
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: partutil.c,v 1.14 2014/12/29 16:35:38 christos Exp $");
+__RCSID("$NetBSD: partutil.c,v 1.15 2015/06/03 17:53:23 martin Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -99,7 +99,7 @@
        prop_dictionary_t disk_dict, geom_dict;
        struct stat sb;
        const struct partition *pp;
-       int ptn;
+       int ptn, error;
 
        if (dt) {
                lp = getdiskbyname(dt);
@@ -108,7 +108,13 @@
        }
 
        /* Get disk description dictionary */
-       if (prop_dictionary_recv_ioctl(fd, DIOCGDISKINFO, &disk_dict)) {
+       error = prop_dictionary_recv_ioctl(fd, DIOCGDISKINFO, &disk_dict);
+
+       /* fail quickly if the device does not exist at all */
+       if (error == ENXIO)
+               return -1;
+
+       if (error) {
                /*
                 * Ask for disklabel if DIOCGDISKINFO failed. This is
                 * compatibility call and can be removed when all devices
@@ -116,7 +122,8 @@
                 * cgd, ccd pseudo disk drives doesn't support DIOCGDDISKINFO
                 */
                if (ioctl(fd, DIOCGDINFO, lp) == -1) {
-                       warn("DIOCGDINFO on %s failed", s);
+                       if (errno != ENXIO)
+                               warn("DIOCGDINFO on %s failed", s);
                        return -1;
                }
                label2geom(geo, lp);



Home | Main Index | Thread Index | Old Index