Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Mar 2011 01:02:54 +0000 (UTC)
From:      Xin LI <delphij@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r219440 - in stable: 7/usr.sbin/diskinfo 8/usr.sbin/diskinfo
Message-ID:  <201103100102.p2A12sS3026152@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: delphij
Date: Thu Mar 10 01:02:53 2011
New Revision: 219440
URL: http://svn.freebsd.org/changeset/base/219440

Log:
  MFC r218432:
  
  Don't consider ioctl returning error as a fatal error and move on to next
  disk.  When multiple devices are specified, a non-supporting ioctl will
  cause diskinfo(8) to stop at the point which does not seem to be necessary.

Modified:
  stable/8/usr.sbin/diskinfo/diskinfo.c
Directory Properties:
  stable/8/usr.sbin/diskinfo/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/7/usr.sbin/diskinfo/diskinfo.c
Directory Properties:
  stable/7/usr.sbin/diskinfo/   (props changed)

Modified: stable/8/usr.sbin/diskinfo/diskinfo.c
==============================================================================
--- stable/8/usr.sbin/diskinfo/diskinfo.c	Wed Mar  9 23:11:30 2011	(r219439)
+++ stable/8/usr.sbin/diskinfo/diskinfo.c	Thu Mar 10 01:02:53 2011	(r219440)
@@ -56,7 +56,7 @@ static void commandtime(int fd, off_t me
 int
 main(int argc, char **argv)
 {
-	int i, ch, fd, error;
+	int i, ch, fd, error, exitval = 0;
 	char buf[BUFSIZ], ident[DISK_IDENT_SIZE];
 	off_t	mediasize, stripesize, stripeoffset;
 	u_int	sectorsize, fwsectors, fwheads;
@@ -90,14 +90,23 @@ main(int argc, char **argv)
 			sprintf(buf, "%s%s", _PATH_DEV, argv[i]);
 			fd = open(buf, O_RDONLY);
 		}
-		if (fd < 0)
-			err(1, argv[i]);
+		if (fd < 0) {
+			warn("%s", argv[i]);
+			exitval = 1;
+			goto out;
+		}
 		error = ioctl(fd, DIOCGMEDIASIZE, &mediasize);
-		if (error)
-			err(1, "%s: ioctl(DIOCGMEDIASIZE) failed, probably not a disk.", argv[i]);
+		if (error) {
+			warn("%s: ioctl(DIOCGMEDIASIZE) failed, probably not a disk.", argv[i]);
+			exitval = 1;
+			goto out;
+		}
 		error = ioctl(fd, DIOCGSECTORSIZE, &sectorsize);
-		if (error)
-			err(1, "%s: DIOCGSECTORSIZE failed, probably not a disk.", argv[i]);
+		if (error) {
+			warn("%s: DIOCGSECTORSIZE failed, probably not a disk.", argv[i]);
+			exitval = 1;
+			goto out;
+		}
 		error = ioctl(fd, DIOCGFWSECTORS, &fwsectors);
 		if (error)
 			fwsectors = 0;
@@ -148,9 +157,10 @@ main(int argc, char **argv)
 			commandtime(fd, mediasize, sectorsize);
 		if (opt_t)
 			speeddisk(fd, mediasize, sectorsize);
+out:
 		close(fd);
 	}
-	exit (0);
+	exit (exitval);
 }
 
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201103100102.p2A12sS3026152>