Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
39f8cc56
提交
39f8cc56
8月 21, 2011
创建
作者:
Frans Kaashoek
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
git+ssh://amsterdam.csail.mit.edu/home/am0/6.828/xv6
上级
3682474f
327cc21f
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
66 行增加
和
18 行删除
+66
-18
fs.c
fs.c
+13
-18
usertests.c
usertests.c
+53
-0
没有找到文件。
fs.c
浏览文件 @
39f8cc56
...
...
@@ -469,30 +469,25 @@ struct inode*
dirlookup
(
struct
inode
*
dp
,
char
*
name
,
uint
*
poff
)
{
uint
off
,
inum
;
struct
buf
*
bp
;
struct
dirent
*
de
;
struct
dirent
de
;
if
(
dp
->
type
!=
T_DIR
)
panic
(
"dirlookup not DIR"
);
for
(
off
=
0
;
off
<
dp
->
size
;
off
+=
BSIZE
){
bp
=
bread
(
dp
->
dev
,
bmap
(
dp
,
off
/
BSIZE
));
for
(
de
=
(
struct
dirent
*
)
bp
->
data
;
de
<
(
struct
dirent
*
)(
bp
->
data
+
BSIZE
);
de
++
){
if
(
de
->
inum
==
0
)
continue
;
if
(
namecmp
(
name
,
de
->
name
)
==
0
){
// entry matches path element
if
(
poff
)
*
poff
=
off
+
(
uchar
*
)
de
-
bp
->
data
;
inum
=
de
->
inum
;
brelse
(
bp
);
return
iget
(
dp
->
dev
,
inum
);
}
for
(
off
=
0
;
off
<
dp
->
size
;
off
+=
sizeof
(
de
)){
if
(
readi
(
dp
,
(
char
*
)
&
de
,
off
,
sizeof
(
de
))
!=
sizeof
(
de
))
panic
(
"dirlink read"
);
if
(
de
.
inum
==
0
)
continue
;
if
(
namecmp
(
name
,
de
.
name
)
==
0
){
// entry matches path element
if
(
poff
)
*
poff
=
off
;
inum
=
de
.
inum
;
return
iget
(
dp
->
dev
,
inum
);
}
brelse
(
bp
);
}
return
0
;
}
...
...
usertests.c
浏览文件 @
39f8cc56
...
...
@@ -1529,6 +1529,59 @@ bigargtest(void)
wait
();
}
// what happens when the file system runs out of blocks?
// answer: balloc panics, so this test is not useful.
void
fsfull
()
{
int
nfiles
;
int
fsblocks
=
0
;
printf
(
1
,
"fsfull test
\n
"
);
for
(
nfiles
=
0
;
;
nfiles
++
){
char
name
[
64
];
name
[
0
]
=
'f'
;
name
[
1
]
=
'0'
+
nfiles
/
1000
;
name
[
2
]
=
'0'
+
(
nfiles
%
1000
)
/
100
;
name
[
3
]
=
'0'
+
(
nfiles
%
100
)
/
10
;
name
[
4
]
=
'0'
+
(
nfiles
%
10
);
name
[
5
]
=
'\0'
;
printf
(
1
,
"writing %s
\n
"
,
name
);
int
fd
=
open
(
name
,
O_CREATE
|
O_RDWR
);
if
(
fd
<
0
){
printf
(
1
,
"open %s failed
\n
"
,
name
);
break
;
}
int
total
=
0
;
while
(
1
){
int
cc
=
write
(
fd
,
buf
,
512
);
if
(
cc
<
512
)
break
;
total
+=
cc
;
fsblocks
++
;
}
printf
(
1
,
"wrote %d bytes
\n
"
,
total
);
close
(
fd
);
if
(
total
==
0
)
break
;
}
while
(
nfiles
>=
0
){
char
name
[
64
];
name
[
0
]
=
'f'
;
name
[
1
]
=
'0'
+
nfiles
/
1000
;
name
[
2
]
=
'0'
+
(
nfiles
%
1000
)
/
100
;
name
[
3
]
=
'0'
+
(
nfiles
%
100
)
/
10
;
name
[
4
]
=
'0'
+
(
nfiles
%
10
);
name
[
5
]
=
'\0'
;
unlink
(
name
);
nfiles
--
;
}
printf
(
1
,
"fsfull test finished
\n
"
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论