Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
0d6bbd31
提交
0d6bbd31
9月 07, 2006
创建
作者:
rsc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
clean namei search loop
上级
7a054598
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
23 行增加
和
22 行删除
+23
-22
fs.c
fs.c
+23
-22
没有找到文件。
fs.c
浏览文件 @
0d6bbd31
...
...
@@ -122,7 +122,7 @@ iget(uint dev, uint inum)
loop:
nip
=
0
;
for
(
ip
=
&
inode
[
0
];
ip
<
&
inode
[
NINODE
];
ip
++
){
if
(
ip
->
count
>
0
&&
ip
->
dev
==
dev
&&
ip
->
inum
==
inum
){
if
(
ip
->
ref
>
0
&&
ip
->
dev
==
dev
&&
ip
->
inum
==
inum
){
if
(
ip
->
busy
){
sleep
(
ip
,
&
inode_table_lock
);
// Since we droped inode_table_lock, ip might have been reused
...
...
@@ -131,12 +131,12 @@ iget(uint dev, uint inum)
// and it will not be busy.
goto
loop
;
}
ip
->
count
++
;
ip
->
ref
++
;
ip
->
busy
=
1
;
release
(
&
inode_table_lock
);
return
ip
;
}
if
(
nip
==
0
&&
ip
->
count
==
0
)
if
(
nip
==
0
&&
ip
->
ref
==
0
)
nip
=
ip
;
}
...
...
@@ -145,7 +145,7 @@ iget(uint dev, uint inum)
nip
->
dev
=
dev
;
nip
->
inum
=
inum
;
nip
->
count
=
1
;
nip
->
ref
=
1
;
nip
->
busy
=
1
;
release
(
&
inode_table_lock
);
...
...
@@ -236,7 +236,7 @@ ifree(struct inode *ip)
void
ilock
(
struct
inode
*
ip
)
{
if
(
ip
->
count
<
1
)
if
(
ip
->
ref
<
1
)
panic
(
"ilock"
);
acquire
(
&
inode_table_lock
);
...
...
@@ -254,7 +254,7 @@ ilock(struct inode *ip)
void
iunlock
(
struct
inode
*
ip
)
{
if
(
ip
->
busy
!=
1
||
ip
->
count
<
1
)
if
(
ip
->
busy
!=
1
||
ip
->
ref
<
1
)
panic
(
"iunlock"
);
acquire
(
&
inode_table_lock
);
...
...
@@ -326,17 +326,17 @@ itrunc(struct inode *ip)
void
iput
(
struct
inode
*
ip
)
{
if
(
ip
->
count
<
1
||
ip
->
busy
!=
1
)
if
(
ip
->
ref
<
1
||
ip
->
busy
!=
1
)
panic
(
"iput"
);
if
((
ip
->
count
==
1
)
&&
(
ip
->
nlink
==
0
))
{
if
((
ip
->
ref
==
1
)
&&
(
ip
->
nlink
==
0
))
{
itrunc
(
ip
);
ifree
(
ip
);
}
acquire
(
&
inode_table_lock
);
ip
->
count
-=
1
;
ip
->
ref
-=
1
;
ip
->
busy
=
0
;
wakeup
(
ip
);
...
...
@@ -357,7 +357,7 @@ void
iincref
(
struct
inode
*
ip
)
{
ilock
(
ip
);
ip
->
count
++
;
ip
->
ref
++
;
iunlock
(
ip
);
}
...
...
@@ -522,10 +522,10 @@ namei(char *path, int mode, uint *ret_off,
ilock
(
dp
);
}
while
(
*
cp
==
'/'
)
cp
++
;
for
(;;){
while
(
*
cp
==
'/'
)
cp
++
;
if
(
*
cp
==
'\0'
){
if
(
mode
==
NAMEI_LOOKUP
)
return
dp
;
...
...
@@ -542,6 +542,13 @@ namei(char *path, int mode, uint *ret_off,
return
0
;
}
for
(
i
=
0
;
cp
[
i
]
!=
0
&&
cp
[
i
]
!=
'/'
;
i
++
)
;
if
(
i
>
DIRSIZ
){
iput
(
dp
);
return
0
;
}
for
(
off
=
0
;
off
<
dp
->
size
;
off
+=
BSIZE
){
bp
=
bread
(
dp
->
dev
,
bmap
(
dp
,
off
/
BSIZE
));
for
(
ep
=
(
struct
dirent
*
)
bp
->
data
;
...
...
@@ -549,13 +556,9 @@ namei(char *path, int mode, uint *ret_off,
ep
++
){
if
(
ep
->
inum
==
0
)
continue
;
for
(
i
=
0
;
i
<
DIRSIZ
&&
cp
[
i
]
!=
'/'
&&
cp
[
i
];
i
++
)
if
(
cp
[
i
]
!=
ep
->
name
[
i
])
break
;
if
((
cp
[
i
]
==
'\0'
||
cp
[
i
]
==
'/'
||
i
>=
DIRSIZ
)
&&
(
i
>=
DIRSIZ
||
ep
->
name
[
i
]
==
'\0'
)){
while
(
cp
[
i
]
!=
'\0'
&&
cp
[
i
]
!=
'/'
)
i
++
;
if
(
memcmp
(
cp
,
ep
->
name
,
i
)
==
0
&&
(
i
==
DIRSIZ
||
ep
->
name
[
i
]
==
0
)){
// entry matches path element
off
+=
(
uchar
*
)
ep
-
bp
->
data
;
ninum
=
ep
->
inum
;
brelse
(
bp
);
...
...
@@ -591,8 +594,6 @@ namei(char *path, int mode, uint *ret_off,
dp
=
iget
(
dev
,
ninum
);
if
(
dp
->
type
==
0
||
dp
->
nlink
<
1
)
panic
(
"namei"
);
while
(
*
cp
==
'/'
)
cp
++
;
}
}
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论