提交 95c07f82 创建 作者: rsc's avatar rsc

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

上级 32eea766
......@@ -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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论