Improve error reporting in diskinfo(8) by not displaying errno when
it doesn't make sense.
This commit is contained in:
parent
e521b5288a
commit
6b381ff332
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=232738
@ -99,13 +99,13 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
error = ioctl(fd, DIOCGMEDIASIZE, &mediasize);
|
error = ioctl(fd, DIOCGMEDIASIZE, &mediasize);
|
||||||
if (error) {
|
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;
|
exitval = 1;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
error = ioctl(fd, DIOCGSECTORSIZE, §orsize);
|
error = ioctl(fd, DIOCGSECTORSIZE, §orsize);
|
||||||
if (error) {
|
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;
|
exitval = 1;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -178,8 +178,10 @@ rdsect(int fd, off_t blockno, u_int sectorsize)
|
|||||||
|
|
||||||
lseek(fd, (off_t)blockno * sectorsize, SEEK_SET);
|
lseek(fd, (off_t)blockno * sectorsize, SEEK_SET);
|
||||||
error = read(fd, sector, sectorsize);
|
error = read(fd, sector, sectorsize);
|
||||||
|
if (error == -1)
|
||||||
|
err(1, "read");
|
||||||
if (error != (int)sectorsize)
|
if (error != (int)sectorsize)
|
||||||
err(1, "read error or disk too small for test.");
|
errx(1, "disk too small for test.");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -188,8 +190,10 @@ rdmega(int fd)
|
|||||||
int error;
|
int error;
|
||||||
|
|
||||||
error = read(fd, mega, sizeof(mega));
|
error = read(fd, mega, sizeof(mega));
|
||||||
|
if (error == -1)
|
||||||
|
err(1, "read");
|
||||||
if (error != sizeof(mega))
|
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;
|
static struct timeval tv1, tv2;
|
||||||
|
Loading…
Reference in New Issue
Block a user