Module Name: src
Committed By: martin
Date: Wed Jun 3 17:53:23 UTC 2015
Modified Files:
src/sbin/fsck: partutil.c
Log Message:
Make querying the disk geometry fail silently if called for a non-exitent
disk.
XXX: DIOCGDISKINFO returns strange error codes
To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sbin/fsck/partutil.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sbin/fsck/partutil.c
diff -u src/sbin/fsck/partutil.c:1.14 src/sbin/fsck/partutil.c:1.15
--- src/sbin/fsck/partutil.c:1.14 Mon Dec 29 16:35:38 2014
+++ src/sbin/fsck/partutil.c Wed Jun 3 17:53:23 2015
@@ -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 @@ getdiskinfo(const char *s, int fd, const
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 @@ getdiskinfo(const char *s, int fd, const
}
/* 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 @@ getdiskinfo(const char *s, int fd, const
* 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);