diff options
author | rsc <rsc> | 2007-08-08 09:53:46 +0000 |
---|---|---|
committer | rsc <rsc> | 2007-08-08 09:53:46 +0000 |
commit | 95c07f82670df0540fdb8fbb61f8d3fc335e6880 (patch) | |
tree | 36bd2887be5ad58b75ab11aaa847a24e6b0402f6 /fs.c | |
parent | 32eea7665a9349c507bcf31b5f0422827484f6cc (diff) | |
download | xv6-labs-95c07f82670df0540fdb8fbb61f8d3fc335e6880.tar.gz xv6-labs-95c07f82670df0540fdb8fbb61f8d3fc335e6880.tar.bz2 xv6-labs-95c07f82670df0540fdb8fbb61f8d3fc335e6880.zip |
move ialloc body up, avoiding double check for end of loop
Diffstat (limited to 'fs.c')
-rw-r--r-- | fs.c | 18 |
1 files changed, 7 insertions, 11 deletions
@@ -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. |