mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-21 11:13:30 +00:00
Stop trying to zero UFS1 superblocks if we fall off the end of the disk.
This avoids a potentially many-hours-long loop of failed writes if newfs finds a partially-overwritten superblock (or, for that matter, random garbage which happens to have superblock magic bytes); on one occasion I found newfs trying to zero 800 million superblocks on a 50 MB disk. Reviewed by: mckusick MFC after: 1 week
This commit is contained in:
parent
6bb544780b
commit
c2805605f7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=221049
@ -516,9 +516,12 @@ mkfs(struct partition *pp, char *fsys)
|
|||||||
fsdummy.fs_magic = 0;
|
fsdummy.fs_magic = 0;
|
||||||
bwrite(&disk, part_ofs + SBLOCK_UFS1 / disk.d_bsize,
|
bwrite(&disk, part_ofs + SBLOCK_UFS1 / disk.d_bsize,
|
||||||
chdummy, SBLOCKSIZE);
|
chdummy, SBLOCKSIZE);
|
||||||
for (cg = 0; cg < fsdummy.fs_ncg; cg++)
|
for (cg = 0; cg < fsdummy.fs_ncg; cg++) {
|
||||||
|
if (fsbtodb(&fsdummy, cgsblock(&fsdummy, cg)) > fssize)
|
||||||
|
break;
|
||||||
bwrite(&disk, part_ofs + fsbtodb(&fsdummy,
|
bwrite(&disk, part_ofs + fsbtodb(&fsdummy,
|
||||||
cgsblock(&fsdummy, cg)), chdummy, SBLOCKSIZE);
|
cgsblock(&fsdummy, cg)), chdummy, SBLOCKSIZE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!Nflag)
|
if (!Nflag)
|
||||||
|
Loading…
Reference in New Issue
Block a user