From owner-svn-src-all@FreeBSD.ORG Tue Feb 8 11:32:23 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 47BAD106564A; Tue, 8 Feb 2011 11:32:23 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1D4058FC08; Tue, 8 Feb 2011 11:32:23 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p18BWNQX044283; Tue, 8 Feb 2011 11:32:23 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p18BWMPj044281; Tue, 8 Feb 2011 11:32:23 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201102081132.p18BWMPj044281@svn.freebsd.org> From: Xin LI Date: Tue, 8 Feb 2011 11:32:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r218432 - head/usr.sbin/diskinfo X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Feb 2011 11:32:23 -0000 Author: delphij Date: Tue Feb 8 11:32:22 2011 New Revision: 218432 URL: http://svn.freebsd.org/changeset/base/218432 Log: 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. Ok'ed by: phk MFC after: 1 month Modified: head/usr.sbin/diskinfo/diskinfo.c Modified: head/usr.sbin/diskinfo/diskinfo.c ============================================================================== --- head/usr.sbin/diskinfo/diskinfo.c Tue Feb 8 09:28:28 2011 (r218431) +++ head/usr.sbin/diskinfo/diskinfo.c Tue Feb 8 11:32:22 2011 (r218432) @@ -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, §orsize); - 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); }