Check bytes read to prevent random error message.

This commit is contained in:
Robert Nordier 1998-04-20 14:09:40 +00:00
parent b4e7319708
commit 25ab4f55c1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=35341

View File

@ -107,15 +107,22 @@ int
dumpfs(name)
char *name;
{
ssize_t n;
int fd, c, i, j, k, size;
if ((fd = open(name, O_RDONLY, 0)) < 0)
goto err;
if (lseek(fd, (off_t)SBOFF, SEEK_SET) == (off_t)-1)
goto err;
if (read(fd, &afs, SBSIZE) != SBSIZE)
if ((n = read(fd, &afs, SBSIZE)) == -1)
goto err;
if (n != SBSIZE) {
warnx("%s: non-existent or truncated superblock, skipped",
name);
(void)close(fd);
return (1);
}
if (afs.fs_magic != FS_MAGIC) {
warnx("%s: superblock has bad magic number, skipped", name);
(void)close(fd);