svn commit: r232738 - head/usr.sbin/diskinfo
Edward Tomasz Napierala
trasz at FreeBSD.org
Fri Mar 9 18:34:15 UTC 2012
Author: trasz
Date: Fri Mar 9 18:34:14 2012
New Revision: 232738
URL: http://svn.freebsd.org/changeset/base/232738
Log:
Improve error reporting in diskinfo(8) by not displaying errno when
it doesn't make sense.
Modified:
head/usr.sbin/diskinfo/diskinfo.c
Modified: head/usr.sbin/diskinfo/diskinfo.c
==============================================================================
--- head/usr.sbin/diskinfo/diskinfo.c Fri Mar 9 18:26:35 2012 (r232737)
+++ head/usr.sbin/diskinfo/diskinfo.c Fri Mar 9 18:34:14 2012 (r232738)
@@ -99,13 +99,13 @@ main(int argc, char **argv)
}
error = ioctl(fd, DIOCGMEDIASIZE, &mediasize);
if (error) {
- warn("%s: ioctl(DIOCGMEDIASIZE) failed, probably not a disk.", argv[i]);
+ warnx("%s: ioctl(DIOCGMEDIASIZE) failed, probably not a disk.", argv[i]);
exitval = 1;
goto out;
}
error = ioctl(fd, DIOCGSECTORSIZE, §orsize);
if (error) {
- warn("%s: DIOCGSECTORSIZE failed, probably not a disk.", argv[i]);
+ warnx("%s: ioctl(DIOCGSECTORSIZE) failed, probably not a disk.", argv[i]);
exitval = 1;
goto out;
}
@@ -178,8 +178,10 @@ rdsect(int fd, off_t blockno, u_int sect
lseek(fd, (off_t)blockno * sectorsize, SEEK_SET);
error = read(fd, sector, sectorsize);
+ if (error == -1)
+ err(1, "read");
if (error != (int)sectorsize)
- err(1, "read error or disk too small for test.");
+ errx(1, "disk too small for test.");
}
static void
@@ -188,8 +190,10 @@ rdmega(int fd)
int error;
error = read(fd, mega, sizeof(mega));
+ if (error == -1)
+ err(1, "read");
if (error != sizeof(mega))
- err(1, "read error or disk too small for test.");
+ errx(1, "disk too small for test.");
}
static struct timeval tv1, tv2;
More information about the svn-src-head
mailing list