2020-02-21
作者:互联网
文件系统低级API之辅助函数之得到一个指定的inode
#define NINODE 50
struct {
struct spinlock lock;
struct inode inode[NINODE];
}icache;
static struct inode*
iget(uint dev, uint inum)
{
struct inode *ip, *empty;
empty = 0;
for (ip=&icache.inode[0]; ip<&icache.inode[INODE];ip++) {
if(ip->ref>0 && ip->dev == dev && ip->inum == inun) {
ip->ref++;
return ip;
}
if(empty == 0 && ip->ref == 0)
empty = ip;
}
ip=empty;
ip->dev=dev;
ip->inum=inum;
ip->ref=1;
ip->valid=0;
return ip;
}
qq_41224661
发布了28 篇原创文章 · 获赞 0 · 访问量 219
私信
关注
标签:02,21,ip,dev,2020,inum,inode,empty,struct 来源: https://blog.csdn.net/qq_41224661/article/details/104422475