do not run past the end of the disk!
[ cherry-picked de6075ff0978108daea1d658425bcb37663a98a0 ] Conflicts: fs.c
This commit is contained in:
parent
f70ef994dc
commit
96b7da5f03
1 changed files with 1 additions and 1 deletions
2
fs.c
2
fs.c
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue