summaryrefslogtreecommitdiffstats
path: root/usr.sbin/diskinfo
diff options
context:
space:
mode:
authortrasz <trasz@FreeBSD.org>2012-03-09 18:34:14 +0000
committertrasz <trasz@FreeBSD.org>2012-03-09 18:34:14 +0000
commitf4c01e5c172807e185b31531a0f217324baca521 (patch)
treef19d5dcc81a4c95cfc07cc4ec7e534e47c592c8b /usr.sbin/diskinfo
parentaae0696a6a0a090a1fb535b3b6156c13cc6b272b (diff)
downloadFreeBSD-src-f4c01e5c172807e185b31531a0f217324baca521.zip
FreeBSD-src-f4c01e5c172807e185b31531a0f217324baca521.tar.gz
Improve error reporting in diskinfo(8) by not displaying errno when
it doesn't make sense.
Diffstat (limited to 'usr.sbin/diskinfo')
-rw-r--r--usr.sbin/diskinfo/diskinfo.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/usr.sbin/diskinfo/diskinfo.c b/usr.sbin/diskinfo/diskinfo.c
index 554b09e..fa23443 100644
--- a/usr.sbin/diskinfo/diskinfo.c
+++ b/usr.sbin/diskinfo/diskinfo.c
@@ -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, &sectorsize);
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 sectorsize)
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;
OpenPOWER on IntegriCloud