Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
022104b1
提交
022104b1
6月 23, 2011
创建
作者:
Nickolai Zeldovich
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make ls work
上级
1d1e1ede
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
35 行增加
和
6 行删除
+35
-6
defs.h
defs.h
+1
-0
fs.c
fs.c
+27
-3
sysfile.c
sysfile.c
+7
-3
没有找到文件。
defs.h
浏览文件 @
022104b1
...
@@ -62,6 +62,7 @@ int readi(struct inode*, char*, uint, uint);
...
@@ -62,6 +62,7 @@ int readi(struct inode*, char*, uint, uint);
void
stati
(
struct
inode
*
,
struct
stat
*
);
void
stati
(
struct
inode
*
,
struct
stat
*
);
int
writei
(
struct
inode
*
,
char
*
,
uint
,
uint
);
int
writei
(
struct
inode
*
,
char
*
,
uint
,
uint
);
void
dir_init
(
struct
inode
*
dp
);
void
dir_init
(
struct
inode
*
dp
);
void
dir_flush
(
struct
inode
*
dp
);
// ide.c
// ide.c
void
ideinit
(
void
);
void
ideinit
(
void
);
...
...
fs.c
浏览文件 @
022104b1
...
@@ -587,15 +587,39 @@ dir_init(struct inode *dp)
...
@@ -587,15 +587,39 @@ dir_init(struct inode *dp)
}
}
}
}
struct
flush_state
{
struct
inode
*
dp
;
uint
off
;
};
static
void
*
dir_flush_cb
(
void
*
key
,
void
*
val
,
void
*
arg
)
{
struct
flush_state
*
fs
=
arg
;
char
*
name
=
key
;
uint
inum
=
(
uint
)
val
;
struct
dirent
de
;
strncpy
(
de
.
name
,
name
,
DIRSIZ
);
de
.
inum
=
inum
;
if
(
writei
(
fs
->
dp
,
(
char
*
)
&
de
,
fs
->
off
,
sizeof
(
de
))
!=
sizeof
(
de
))
panic
(
"dir_flush_cb"
);
fs
->
off
+=
sizeof
(
de
);
return
0
;
}
void
void
dir_flush
(
struct
inode
*
dp
)
dir_flush
(
struct
inode
*
dp
)
{
{
// assume already locked
if
(
!
dp
->
dir
)
if
(
!
dp
->
dir
)
return
;
return
;
ilock
(
dp
,
1
);
struct
flush_state
fs
;
fs
.
dp
=
dp
;
iunlock
(
dp
);
fs
.
off
=
0
;
ns_enumerate
(
dp
->
dir
,
dir_flush_cb
,
&
fs
);
}
}
// Look for a directory entry in a directory.
// Look for a directory entry in a directory.
...
...
sysfile.c
浏览文件 @
022104b1
...
@@ -284,9 +284,13 @@ sys_open(void)
...
@@ -284,9 +284,13 @@ sys_open(void)
ilock
(
ip
,
0
);
ilock
(
ip
,
0
);
if
(
ip
->
type
==
0
)
if
(
ip
->
type
==
0
)
panic
(
"open"
);
panic
(
"open"
);
if
(
ip
->
type
==
T_DIR
&&
omode
!=
O_RDONLY
){
if
(
ip
->
type
==
T_DIR
)
{
iunlockput
(
ip
);
if
(
omode
!=
O_RDONLY
){
return
-
1
;
iunlockput
(
ip
);
return
-
1
;
}
dir_flush
(
ip
);
}
}
}
}
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论