diff options
author | brian <brian@FreeBSD.org> | 2004-06-04 11:49:11 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 2004-06-04 11:49:11 +0000 |
commit | 1a106ea8b690010d54c842e06a1005b48c2b6443 (patch) | |
tree | 16383712c75aacfef9aa8bb791001bdadb145f64 /lib/libdisk | |
parent | 284de6b08c1bf421b8b558965caebde2da7816a4 (diff) | |
download | FreeBSD-src-1a106ea8b690010d54c842e06a1005b48c2b6443.zip FreeBSD-src-1a106ea8b690010d54c842e06a1005b48c2b6443.tar.gz |
Handle read_block() failures by ignoring the disk rather than
dumping core.
Diffstat (limited to 'lib/libdisk')
-rw-r--r-- | lib/libdisk/write_alpha_disk.c | 5 | ||||
-rw-r--r-- | lib/libdisk/write_amd64_disk.c | 13 | ||||
-rw-r--r-- | lib/libdisk/write_i386_disk.c | 13 | ||||
-rw-r--r-- | lib/libdisk/write_pc98_disk.c | 13 |
4 files changed, 34 insertions, 10 deletions
diff --git a/lib/libdisk/write_alpha_disk.c b/lib/libdisk/write_alpha_disk.c index 1e76c7c..251282e 100644 --- a/lib/libdisk/write_alpha_disk.c +++ b/lib/libdisk/write_alpha_disk.c @@ -51,7 +51,10 @@ Write_Disk(const struct disk *d1) } for (i = 0; i < BBSIZE/512; i++) { - p = read_block(fd, i + c1->offset, 512); + if (!(p = read_block(fd, i + c1->offset, 512))) { + close (fd); + return (1); + } memcpy(buf + 512 * i, p, 512); free(p); } diff --git a/lib/libdisk/write_amd64_disk.c b/lib/libdisk/write_amd64_disk.c index f409ae4..9899258 100644 --- a/lib/libdisk/write_amd64_disk.c +++ b/lib/libdisk/write_amd64_disk.c @@ -35,7 +35,8 @@ Write_FreeBSD(int fd, const struct disk *new, const struct chunk *c1) u_char buf[BBSIZE]; for (i = 0; i < BBSIZE/512; i++) { - p = read_block(fd, i + c1->offset, 512); + if (!(p = read_block(fd, i + c1->offset, 512))) + return (1); memcpy(buf + 512 * i, p, 512); free(p); } @@ -101,7 +102,10 @@ Write_Disk(const struct disk *d1) return 1; memset(s, 0, sizeof s); - mbr = read_block(fd, 0, d1->sector_size); + if (!(mbr = read_block(fd, 0, d1->sector_size))) { + close (fd); + return (1); + } dp = (struct dos_partition *)(mbr + DOSPARTOFF); memcpy(work, dp, sizeof work); dp = work; @@ -178,7 +182,10 @@ Write_Disk(const struct disk *d1) if (dp[i].dp_typ == 0xa5) dp[i].dp_flag = 0x80; - mbr = read_block(fd, 0, d1->sector_size); + if (!(mbr = read_block(fd, 0, d1->sector_size))) { + close (fd); + return (1); + } if (d1->bootmgr) { memcpy(mbr, d1->bootmgr, DOSPARTOFF); Cfg_Boot_Mgr(mbr, need_edd); diff --git a/lib/libdisk/write_i386_disk.c b/lib/libdisk/write_i386_disk.c index e0cac80..15317d3 100644 --- a/lib/libdisk/write_i386_disk.c +++ b/lib/libdisk/write_i386_disk.c @@ -35,7 +35,8 @@ Write_FreeBSD(int fd, const struct disk *new, const struct chunk *c1) u_char buf[BBSIZE]; for (i = 0; i < BBSIZE/512; i++) { - p = read_block(fd, i + c1->offset, 512); + if (!(p = read_block(fd, i + c1->offset, 512))) + return (1); memcpy(buf + 512 * i, p, 512); free(p); } @@ -101,7 +102,10 @@ Write_Disk(const struct disk *d1) return 1; memset(s, 0, sizeof s); - mbrblk = read_block(fd, 0, d1->sector_size); + if (!(mbrblk = read_block(fd, 0, d1->sector_size))) { + close (fd); + return (1); + } dp = (struct dos_partition *)(mbrblk + DOSPARTOFF); memcpy(work, dp, sizeof work); dp = work; @@ -178,7 +182,10 @@ Write_Disk(const struct disk *d1) if (dp[i].dp_typ == 0xa5) dp[i].dp_flag = 0x80; - mbrblk = read_block(fd, 0, d1->sector_size); + if (!(mbrblk = read_block(fd, 0, d1->sector_size))) { + close (fd); + return (1); + } if (d1->bootmgr) { memcpy(mbrblk, d1->bootmgr, DOSPARTOFF); Cfg_Boot_Mgr(mbrblk, need_edd); diff --git a/lib/libdisk/write_pc98_disk.c b/lib/libdisk/write_pc98_disk.c index 0602596..8f2a45d 100644 --- a/lib/libdisk/write_pc98_disk.c +++ b/lib/libdisk/write_pc98_disk.c @@ -37,7 +37,8 @@ Write_FreeBSD(int fd, const struct disk *new, const struct chunk *c1) u_char buf[BBSIZE]; for (i = 0; i < BBSIZE / 512; i++) { - p = read_block(fd, i + c1->offset, 512); + if (!(p = read_block(fd, i + c1->offset, 512))) + return (1); memcpy(buf + 512 * i, p, 512); free(p); } @@ -87,7 +88,10 @@ Write_Disk(const struct disk *d1) } memset(s, 0, sizeof s); - mbrblk = read_block(fd, 1, d1->sector_size); + if (!(mbrblk = read_block(fd, 1, d1->sector_size))) { + close (fd); + return (1); + } dp = (struct pc98_partition *)(mbrblk + DOSPARTOFF); memcpy(work, dp, sizeof work); dp = work; @@ -151,7 +155,10 @@ Write_Disk(const struct disk *d1) if (d1->bootipl) write_block(fd, 0, d1->bootipl, d1->sector_size); - mbrblk = read_block(fd, 1, d1->sector_size); + if (!(mbrblk = read_block(fd, 1, d1->sector_size))) { + close (fd); + return (1); + } memcpy(mbrblk + DOSPARTOFF, dp, sizeof *dp * NDOSPART); /* XXX - for entire FreeBSD(98) */ for (c1 = d1->chunks->part; c1; c1 = c1->next) |