Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
0b9edac9
提交
0b9edac9
2月 10, 2012
创建
作者:
Nickolai Zeldovich
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fs.cc
上级
8ffe342f
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
9 行增加
和
7 行删除
+9
-7
fs.cc
fs.cc
+9
-7
没有找到文件。
fs.c
→
fs.c
c
浏览文件 @
0b9edac9
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
// routines. The (higher-level) system call implementations
// routines. The (higher-level) system call implementations
// are in sysfile.c.
// are in sysfile.c.
extern
"C"
{
#include "types.h"
#include "types.h"
#include "stat.h"
#include "stat.h"
#include "mmu.h"
#include "mmu.h"
...
@@ -22,6 +23,7 @@
...
@@ -22,6 +23,7 @@
#include "fs.h"
#include "fs.h"
#include "file.h"
#include "file.h"
#include "cpu.h"
#include "cpu.h"
}
#define min(a, b) ((a) < (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
static
void
itrunc
(
struct
inode
*
);
static
void
itrunc
(
struct
inode
*
);
...
@@ -204,7 +206,7 @@ iupdate(struct inode *ip)
...
@@ -204,7 +206,7 @@ iupdate(struct inode *ip)
static
void
*
static
void
*
evict
(
void
*
vkey
,
void
*
p
,
void
*
arg
)
evict
(
void
*
vkey
,
void
*
p
,
void
*
arg
)
{
{
struct
inode
*
ip
=
p
;
struct
inode
*
ip
=
(
inode
*
)
p
;
if
(
ip
->
ref
||
ip
->
type
==
T_DIR
)
if
(
ip
->
ref
||
ip
->
type
==
T_DIR
)
return
0
;
return
0
;
...
@@ -225,7 +227,7 @@ evict(void *vkey, void *p, void *arg)
...
@@ -225,7 +227,7 @@ evict(void *vkey, void *p, void *arg)
static
void
static
void
ifree
(
void
*
arg
)
ifree
(
void
*
arg
)
{
{
struct
inode
*
ip
=
arg
;
struct
inode
*
ip
=
(
inode
*
)
arg
;
if
(
ip
->
dir
)
{
if
(
ip
->
dir
)
{
ns_remove
(
ip
->
dir
,
KD
(
"."
),
0
);
ns_remove
(
ip
->
dir
,
KD
(
"."
),
0
);
...
@@ -246,7 +248,7 @@ iget(u32 dev, u32 inum)
...
@@ -246,7 +248,7 @@ iget(u32 dev, u32 inum)
retry:
retry:
// Try for cached inode.
// Try for cached inode.
gc_begin_epoch
();
gc_begin_epoch
();
ip
=
ns_lookup
(
ins
,
KII
(
dev
,
inum
));
ip
=
(
inode
*
)
ns_lookup
(
ins
,
KII
(
dev
,
inum
));
if
(
ip
)
{
if
(
ip
)
{
// tricky: first bump ref, then check free flag
// tricky: first bump ref, then check free flag
__sync_fetch_and_add
(
&
ip
->
ref
,
1
);
__sync_fetch_and_add
(
&
ip
->
ref
,
1
);
...
@@ -271,7 +273,7 @@ iget(u32 dev, u32 inum)
...
@@ -271,7 +273,7 @@ iget(u32 dev, u32 inum)
(
void
)
0
;
(
void
)
0
;
u32
cur_free
=
icache_free
[
mycpu
()
->
id
].
x
;
u32
cur_free
=
icache_free
[
mycpu
()
->
id
].
x
;
if
(
cur_free
==
0
)
{
if
(
cur_free
==
0
)
{
struct
inode
*
victim
=
ns_enumerate
(
ins
,
evict
,
0
);
struct
inode
*
victim
=
(
inode
*
)
ns_enumerate
(
ins
,
evict
,
0
);
if
(
!
victim
)
if
(
!
victim
)
panic
(
"iget out of space"
);
panic
(
"iget out of space"
);
// tricky: first flag as free, then check refcnt, then remove from ns
// tricky: first flag as free, then check refcnt, then remove from ns
...
@@ -289,7 +291,7 @@ iget(u32 dev, u32 inum)
...
@@ -289,7 +291,7 @@ iget(u32 dev, u32 inum)
goto
retry_evict
;
goto
retry_evict
;
}
}
ip
=
kmalloc
(
sizeof
(
*
ip
));
ip
=
(
inode
*
)
kmalloc
(
sizeof
(
*
ip
));
ip
->
dev
=
dev
;
ip
->
dev
=
dev
;
ip
->
inum
=
inum
;
ip
->
inum
=
inum
;
ip
->
ref
=
1
;
ip
->
ref
=
1
;
...
@@ -613,8 +615,8 @@ struct flush_state {
...
@@ -613,8 +615,8 @@ struct flush_state {
static
void
*
static
void
*
dir_flush_cb
(
void
*
key
,
void
*
val
,
void
*
arg
)
dir_flush_cb
(
void
*
key
,
void
*
val
,
void
*
arg
)
{
{
struct
flush_state
*
fs
=
arg
;
struct
flush_state
*
fs
=
(
flush_state
*
)
arg
;
char
*
name
=
key
;
char
*
name
=
(
char
*
)
key
;
u32
inum
=
(
u64
)
val
;
u32
inum
=
(
u64
)
val
;
struct
dirent
de
;
struct
dirent
de
;
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论