Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
cb7ca72d
提交
cb7ca72d
4月 26, 2012
创建
作者:
Silas Boyd-Wickizer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Wrap the xns holding a directory listing in a dirns class.
I'll be changing the dirns implementation soon.
上级
91424b90
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
41 行增加
和
2 行删除
+41
-2
dirns.hh
include/dirns.hh
+35
-0
file.hh
include/file.hh
+3
-1
fs.cc
kernel/fs.cc
+2
-1
sysfile.cc
kernel/sysfile.cc
+1
-0
没有找到文件。
include/dirns.hh
0 → 100644
浏览文件 @
cb7ca72d
#pragma once
u64
namehash
(
const
strbuf
<
DIRSIZ
>&
);
class
dirns
:
public
rcu_freed
{
public
:
dirns
()
:
rcu_freed
(
"dirns"
),
ns_
(
false
)
{}
bool
remove
(
const
strbuf
<
DIRSIZ
>&
name
,
const
u32
*
vp
=
nullptr
)
{
return
ns_
.
remove
(
name
,
vp
);
}
int
insert
(
const
strbuf
<
DIRSIZ
>&
name
,
const
u32
&
inum
)
{
return
ns_
.
insert
(
name
,
inum
);
}
u32
lookup
(
const
strbuf
<
DIRSIZ
>&
name
)
{
return
ns_
.
lookup
(
name
);
}
template
<
class
CB
>
void
enumerate
(
CB
cb
)
{
return
ns_
.
enumerate
(
cb
);
}
virtual
void
do_gc
(
void
)
{
delete
this
;
}
NEW_DELETE_OPS
(
dirns
);
private
:
xns
<
strbuf
<
DIRSIZ
>
,
u32
,
namehash
>
ns_
;
};
include/file.hh
浏览文件 @
cb7ca72d
...
...
@@ -6,6 +6,8 @@
#include "atomic.hh"
#include "ref.hh"
class
dirns
;
u64
namehash
(
const
strbuf
<
DIRSIZ
>&
);
struct
file
:
public
referenced
,
public
rcu_freed
{
...
...
@@ -60,7 +62,7 @@ struct inode : public referenced, public rcu_freed
struct
condvar
cv
;
struct
spinlock
lock
;
char
lockname
[
16
];
std
::
atomic
<
xns
<
strbuf
<
DIRSIZ
>
,
u32
,
namehash
>
*>
dir
;
std
::
atomic
<
dirns
*>
dir
;
short
type
;
// copy of disk inode
short
major
;
...
...
kernel/fs.cc
浏览文件 @
cb7ca72d
...
...
@@ -39,6 +39,7 @@
#include "file.hh"
#include "cpu.hh"
#include "kmtrace.hh"
#include "dirns.hh"
#define min(a, b) ((a) < (b) ? (a) : (b))
static
void
itrunc
(
struct
inode
*
);
...
...
@@ -708,7 +709,7 @@ dir_init(struct inode *dp)
if
(
dp
->
type
!=
T_DIR
)
panic
(
"dir_init not DIR"
);
auto
dir
=
new
xns
<
strbuf
<
DIRSIZ
>
,
u32
,
namehash
>
(
false
);
auto
dir
=
new
dirns
(
);
for
(
u32
off
=
0
;
off
<
dp
->
size
;
off
+=
BSIZE
)
{
struct
buf
*
bp
=
bread
(
dp
->
dev
,
bmap
(
dp
,
off
/
BSIZE
),
0
);
for
(
struct
dirent
*
de
=
(
struct
dirent
*
)
bp
->
data
;
...
...
kernel/sysfile.cc
浏览文件 @
cb7ca72d
...
...
@@ -13,6 +13,7 @@
#include "net.hh"
#include "kmtrace.hh"
#include "sperf.hh"
#include "dirns.hh"
static
bool
getfile
(
int
fd
,
sref
<
file
>
*
f
)
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论