Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
3d5f21ee
提交
3d5f21ee
8月 24, 2007
创建
作者:
rtm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test concurrent open/unlink of same file (ok)
test files with holes (not ok)
上级
68ae4cc1
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
89 行增加
和
3 行删除
+89
-3
usertests.c
usertests.c
+89
-3
没有找到文件。
usertests.c
浏览文件 @
3d5f21ee
...
...
@@ -139,6 +139,76 @@ writetest1(void)
}
void
writetest2
(
void
)
{
int
fd
,
fd1
,
n
;
printf
(
stdout
,
"files with holes
\n
"
);
fd
=
open
(
"hole"
,
O_CREATE
|
O_RDWR
);
if
(
fd
<
0
){
printf
(
stdout
,
"error: creat hole failed!
\n
"
);
exit
();
}
buf
[
0
]
=
1
;
if
(
write
(
fd
,
buf
,
512
)
!=
512
)
{
printf
(
stdout
,
"error: write hole file failed
\n
"
);
exit
();
}
// now truncate, while fd is still open
fd1
=
open
(
"hole"
,
O_CREATE
|
O_RDWR
);
if
(
fd
<
0
){
printf
(
stdout
,
"error: 2nd creat hole failed!
\n
"
);
exit
();
}
close
(
fd1
);
// now write another block, should be 2nd in file
buf
[
0
]
=
2
;
if
(
write
(
fd
,
buf
,
512
)
!=
512
)
{
printf
(
stdout
,
"error: 2nd write hole file failed
\n
"
);
exit
();
}
close
(
fd
);
fd
=
open
(
"hole"
,
O_RDONLY
);
if
(
fd
<
0
){
printf
(
stdout
,
"error: open hole failed!
\n
"
);
exit
();
}
n
=
read
(
fd
,
buf
,
512
);
if
(
n
!=
512
){
printf
(
stdout
,
"error: 1st hole read failed
\n
"
);
exit
();
}
if
(
buf
[
0
]
!=
0
){
printf
(
stdout
,
"error: 1st hole block didn't have zeros
\n
"
);
exit
();
}
n
=
read
(
fd
,
buf
,
512
);
if
(
n
!=
512
){
printf
(
stdout
,
"error: 2nd hole read failed
\n
"
);
exit
();
}
if
(
buf
[
0
]
!=
1
){
printf
(
stdout
,
"error: 2nd hole block wrong content
\n
"
);
exit
();
}
close
(
fd
);
if
(
unlink
(
"hole"
)
<
0
)
{
printf
(
stdout
,
"unlink hole failed
\n
"
);
exit
();
}
printf
(
stdout
,
"hole files ok
\n
"
);
}
void
createtest
(
void
)
{
int
i
,
fd
;
...
...
@@ -461,7 +531,7 @@ twofiles(void)
printf
(
1
,
"twofiles ok
\n
"
);
}
// two processes create and delete files in same directory
// two processes create and delete
different
files in same directory
void
createdelete
(
void
)
{
...
...
@@ -647,7 +717,7 @@ linktest(void)
printf
(
1
,
"linktest ok
\n
"
);
}
// test concurrent create of the same file
// test concurrent create
and unlink
of the same file
void
concreate
(
void
)
{
...
...
@@ -713,7 +783,22 @@ concreate(void)
for
(
i
=
0
;
i
<
40
;
i
++
){
file
[
1
]
=
'0'
+
i
;
unlink
(
file
);
pid
=
fork
();
if
(
pid
<
0
){
printf
(
1
,
"fork failed
\n
"
);
exit
();
}
if
(((
i
%
3
)
==
0
&&
pid
==
0
)
||
((
i
%
3
)
==
1
&&
pid
!=
0
)){
fd
=
open
(
file
,
0
);
close
(
fd
);
}
else
{
unlink
(
file
);
}
if
(
pid
==
0
)
exit
();
else
wait
();
}
printf
(
1
,
"concreate ok
\n
"
);
...
...
@@ -1095,6 +1180,7 @@ main(int argc, char *argv[])
opentest
();
writetest
();
writetest1
();
writetest2
();
createtest
();
mem
();
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论