do not run past the end of the disk!

[ cherry-picked de6075ff0978108daea1d658425bcb37663a98a0 ]

Conflicts:

	fs.c
This commit is contained in:
Nickolai Zeldovich 2011-06-24 05:26:57 -04:00
parent f70ef994dc
commit 96b7da5f03

2
fs.c
View file

@ -61,7 +61,7 @@ balloc(uint dev)
readsb(dev, &sb);
for(b = 0; b < sb.size; b += BPB){
bp = bread(dev, BBLOCK(b, sb.ninodes));
for(bi = 0; bi < BPB; bi++){
for(bi = 0; bi < BPB && bi < (sb.size - b); bi++){
m = 1 << (bi % 8);
if((bp->data[bi/8] & m) == 0){ // Is block free?
bp->data[bi/8] |= m; // Mark block in use on disk.