Skip to content
Snippets Groups Projects
Commit 95c07f82 authored by rsc's avatar rsc
Browse files

move ialloc body up, avoiding double check for end of loop

parent 32eea766
No related branches found
No related tags found
No related merge requests found
......@@ -201,20 +201,16 @@ ialloc(uint dev, short type)
bp = bread(dev, IBLOCK(inum));
dip = &((struct dinode*)(bp->data))[inum % IPB];
if(dip->type == 0) { // a free inode
break;
memset(dip, 0, sizeof(*dip));
dip->type = type;
bwrite(bp, IBLOCK(inum)); // mark it allocated on the disk
brelse(bp);
ip = iget(dev, inum);
return ip;
}
brelse(bp);
}
if(inum >= ninodes)
panic("ialloc: no inodes left");
memset(dip, 0, sizeof(*dip));
dip->type = type;
bwrite(bp, IBLOCK(inum)); // mark it allocated on the disk
brelse(bp);
ip = iget(dev, inum);
return ip;
panic("ialloc: no inodes");
}
// Free the given inode from its file system.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment