summaryrefslogtreecommitdiffstats
path: root/usr.sbin/diskinfo
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2011-02-08 11:32:22 +0000
committerdelphij <delphij@FreeBSD.org>2011-02-08 11:32:22 +0000
commit461f2c12fe23d67162780f5c935cc956e24b1f30 (patch)
treef73ebeaffb45af29788efccecd035803c1909688 /usr.sbin/diskinfo
parentcdf278387fe97643c1feb5180b4fc3cb872286a0 (diff)
downloadFreeBSD-src-461f2c12fe23d67162780f5c935cc956e24b1f30.zip
FreeBSD-src-461f2c12fe23d67162780f5c935cc956e24b1f30.tar.gz
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
Diffstat (limited to 'usr.sbin/diskinfo')
-rw-r--r--usr.sbin/diskinfo/diskinfo.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/usr.sbin/diskinfo/diskinfo.c b/usr.sbin/diskinfo/diskinfo.c
index 1f967b7..2f00936 100644
--- a/usr.sbin/diskinfo/diskinfo.c
+++ b/usr.sbin/diskinfo/diskinfo.c
@@ -56,7 +56,7 @@ static void commandtime(int fd, off_t mediasize, u_int sectorsize);
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);
}
OpenPOWER on IntegriCloud