Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
7fe2e84a
提交
7fe2e84a
4月 26, 2012
创建
作者:
Silas Boyd-Wickizer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
__nameiparent, __namei, and __namex don't acquire refs
上级
7f44eed2
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
56 行增加
和
14 行删除
+56
-14
kernel.hh
include/kernel.hh
+3
-0
fs.cc
kernel/fs.cc
+53
-14
没有找到文件。
include/kernel.hh
浏览文件 @
7fe2e84a
...
...
@@ -102,6 +102,9 @@ struct inode* nameiparent(inode *cwd, const char*, char*);
int
dirlink
(
struct
inode
*
,
const
char
*
,
u32
);
void
dir_init
(
struct
inode
*
dp
);
void
dir_flush
(
struct
inode
*
dp
);
inode
*
__nameiparent
(
inode
*
cwd
,
const
char
*
path
,
char
*
name
,
bool
*
haveref
);
inode
*
__namei
(
inode
*
cwd
,
const
char
*
path
,
bool
*
haveref
);
// futex.cc
typedef
u64
*
futexkey_t
;
...
...
kernel/fs.cc
浏览文件 @
7fe2e84a
...
...
@@ -318,12 +318,14 @@ iget(u32 dev, u32 inum)
bool
haveref
;
inode
*
ip
;
scoped_gc_epoch
e
;
retry
:
{
scoped_gc_epoch
e
;
ip
=
__iget
(
dev
,
inum
,
&
haveref
);
if
(
!
haveref
)
if
(
!
ip
->
tryinc
())
goto
retry
;
}
return
ip
;
}
...
...
@@ -828,13 +830,16 @@ skipelem(const char **rpath, char *name)
// If parent != 0, return the inode for the parent and copy the final
// path element into name, which must have room for DIRSIZ bytes.
static
struct
inode
*
namex
(
inode
*
cwd
,
const
char
*
path
,
int
nameiparent
,
char
*
name
)
__namex
(
inode
*
cwd
,
const
char
*
path
,
int
nameiparent
,
char
*
name
,
bool
*
retref
)
{
// Assumes caller is holding a gc_epoch
struct
inode
*
ip
,
*
next
;
bool
haveref
;
int
r
;
scoped_gc_epoch
e
;
if
(
*
path
==
'/'
)
ip
=
the_root
;
else
...
...
@@ -858,8 +863,7 @@ namex(inode *cwd, const char *path, int nameiparent, char *name)
return
0
;
if
(
nameiparent
&&
*
path
==
'\0'
){
// Stop one level early.
if
(
!
haveref
)
idup
(
ip
);
*
retref
=
haveref
;
return
ip
;
}
...
...
@@ -883,23 +887,58 @@ namex(inode *cwd, const char *path, int nameiparent, char *name)
// mtreadavar("inode:%x.%x", ip->dev, ip->inum);
mtwriteavar
(
"inode:%x.%x"
,
ip
->
dev
,
ip
->
inum
);
if
(
!
haveref
)
idup
(
ip
);
*
retref
=
haveref
;
return
ip
;
}
struct
inode
*
inode
*
__namei
(
inode
*
cwd
,
const
char
*
path
,
bool
*
haveref
)
{
// Assumes caller is holding a gc_epoch
char
name
[
DIRSIZ
];
return
__namex
(
cwd
,
path
,
0
,
name
,
haveref
);
}
inode
*
namei
(
inode
*
cwd
,
const
char
*
path
)
{
char
name
[
DIRSIZ
];
struct
inode
*
r
=
namex
(
cwd
,
path
,
0
,
name
);
//cprintf("namei: %s -> %x (%d)\n", path, r, r?r->inum:0);
return
r
;
bool
haveref
;
inode
*
ip
;
retry:
{
scoped_gc_epoch
e
;
ip
=
__namex
(
cwd
,
path
,
0
,
name
,
&
haveref
);
if
(
ip
!=
nullptr
&&
!
haveref
)
if
(
!
ip
->
tryinc
())
goto
retry
;
}
return
ip
;
}
struct
inode
*
nameiparent
(
inode
*
cwd
,
const
char
*
path
,
char
*
name
)
inode
*
__nameiparent
(
inode
*
cwd
,
const
char
*
path
,
char
*
name
,
bool
*
haveref
)
{
return
namex
(
cwd
,
path
,
1
,
name
);
// Assumes caller is holding a gc_epoch
return
__namex
(
cwd
,
path
,
1
,
name
,
haveref
);
}
inode
*
nameiparent
(
inode
*
cwd
,
const
char
*
path
,
char
*
name
)
{
bool
haveref
;
inode
*
ip
;
retry:
{
scoped_gc_epoch
e
;
ip
=
__namex
(
cwd
,
path
,
1
,
name
,
&
haveref
);
if
(
ip
!=
nullptr
&&
!
haveref
)
if
(
!
ip
->
tryinc
())
goto
retry
;
}
return
ip
;
}
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论