Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
bdb66433
提交
bdb66433
8月 14, 2006
创建
作者:
kaashoek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
set size for directories correctly in wdir and mkfs
mkdir ls shows stat info for each dir entry
上级
d15f0d10
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
36 行增加
和
14 行删除
+36
-14
fs.c
fs.c
+2
-1
ls.c
ls.c
+11
-9
mkfs.c
mkfs.c
+10
-1
syscall.c
syscall.c
+11
-1
ulib.c
ulib.c
+2
-2
没有找到文件。
fs.c
浏览文件 @
bdb66433
...
@@ -355,7 +355,8 @@ writei(struct inode *ip, char *addr, uint off, uint n)
...
@@ -355,7 +355,8 @@ writei(struct inode *ip, char *addr, uint off, uint n)
}
}
if
(
r
>
0
)
{
if
(
r
>
0
)
{
if
(
off
>
ip
->
size
)
{
if
(
off
>
ip
->
size
)
{
ip
->
size
=
off
;
if
(
ip
->
type
==
T_DIR
)
ip
->
size
=
((
off
/
BSIZE
)
+
1
)
*
BSIZE
;
else
ip
->
size
=
off
;
}
}
iupdate
(
ip
);
iupdate
(
ip
);
}
}
...
...
ls.c
浏览文件 @
bdb66433
...
@@ -12,6 +12,7 @@ main(int argc, char *argv[])
...
@@ -12,6 +12,7 @@ main(int argc, char *argv[])
{
{
int
fd
;
int
fd
;
uint
off
;
uint
off
;
uint
sz
;
if
(
argc
>
1
){
if
(
argc
>
1
){
puts
(
"Usage: ls
\n
"
);
puts
(
"Usage: ls
\n
"
);
...
@@ -30,18 +31,19 @@ main(int argc, char *argv[])
...
@@ -30,18 +31,19 @@ main(int argc, char *argv[])
if
(
st
.
st_type
!=
T_DIR
)
{
if
(
st
.
st_type
!=
T_DIR
)
{
printf
(
2
,
"ls: . is not a dir
\n
"
);
printf
(
2
,
"ls: . is not a dir
\n
"
);
}
}
cprintf
(
"size %d
\n
"
,
st
.
st_size
)
;
sz
=
st
.
st_size
;
for
(
off
=
0
;
off
<
s
t
.
st_size
;
off
+=
sizeof
(
struct
dirent
))
{
for
(
off
=
0
;
off
<
s
z
;
off
+=
sizeof
(
struct
dirent
))
{
if
(
read
(
fd
,
&
dirent
,
sizeof
(
struct
dirent
))
!=
sizeof
(
struct
dirent
))
{
if
(
read
(
fd
,
&
dirent
,
sizeof
(
struct
dirent
))
!=
sizeof
(
struct
dirent
))
{
printf
(
2
,
"ls: read error
\n
"
);
printf
(
1
,
"ls: read error
\n
"
);
exit
()
;
break
;
}
}
if
(
dirent
.
inum
!=
0
)
{
if
(
dirent
.
inum
!=
0
)
{
if
(
stat
(
dirent
.
name
,
&
st
)
<
0
)
{
if
(
stat
(
dirent
.
name
,
&
st
)
<
0
)
printf
(
1
,
"stat: failed
\n
"
);
printf
(
2
,
"stat: failed
\n
"
);
break
;
}
printf
(
1
,
"%s t %d
\n
"
,
dirent
.
name
,
st
.
st_type
);
printf
(
1
,
"%s t %d ino %d sz %d
\n
"
,
dirent
.
name
,
st
.
st_type
,
dirent
.
inum
,
st
.
st_size
);
}
}
}
}
close
(
fd
);
close
(
fd
);
...
...
mkfs.c
浏览文件 @
bdb66433
...
@@ -23,6 +23,7 @@ uint freeinode = 1;
...
@@ -23,6 +23,7 @@ uint freeinode = 1;
void
balloc
(
int
);
void
balloc
(
int
);
void
wsect
(
uint
,
void
*
);
void
wsect
(
uint
,
void
*
);
void
winode
(
uint
,
struct
dinode
*
);
void
winode
(
uint
,
struct
dinode
*
);
void
rinode
(
uint
inum
,
struct
dinode
*
ip
);
void
rsect
(
uint
sec
,
void
*
buf
);
void
rsect
(
uint
sec
,
void
*
buf
);
uint
ialloc
(
ushort
type
);
uint
ialloc
(
ushort
type
);
void
iappend
(
uint
inum
,
void
*
p
,
int
n
);
void
iappend
(
uint
inum
,
void
*
p
,
int
n
);
...
@@ -53,9 +54,10 @@ xint(uint x)
...
@@ -53,9 +54,10 @@ xint(uint x)
main
(
int
argc
,
char
*
argv
[])
main
(
int
argc
,
char
*
argv
[])
{
{
int
i
,
cc
,
fd
;
int
i
,
cc
,
fd
;
uint
bn
,
rootino
,
inum
;
uint
bn
,
rootino
,
inum
,
off
;
struct
dirent
de
;
struct
dirent
de
;
char
buf
[
512
];
char
buf
[
512
];
struct
dinode
din
;
if
(
argc
<
2
){
if
(
argc
<
2
){
fprintf
(
stderr
,
"Usage: mkfs fs.img files...
\n
"
);
fprintf
(
stderr
,
"Usage: mkfs fs.img files...
\n
"
);
...
@@ -122,6 +124,13 @@ main(int argc, char *argv[])
...
@@ -122,6 +124,13 @@ main(int argc, char *argv[])
close
(
fd
);
close
(
fd
);
}
}
// fix size of root inode dir
rinode
(
rootino
,
&
din
);
off
=
xint
(
din
.
size
);
off
=
((
off
/
BSIZE
)
+
1
)
*
BSIZE
;
din
.
size
=
xint
(
off
);
winode
(
rootino
,
&
din
);
balloc
(
usedblocks
);
balloc
(
usedblocks
);
exit
(
0
);
exit
(
0
);
...
...
syscall.c
浏览文件 @
bdb66433
...
@@ -294,8 +294,10 @@ sys_mkdir(void)
...
@@ -294,8 +294,10 @@ sys_mkdir(void)
{
{
struct
proc
*
cp
=
curproc
[
cpu
()];
struct
proc
*
cp
=
curproc
[
cpu
()];
struct
inode
*
nip
;
struct
inode
*
nip
;
struct
inode
*
pip
;
uint
arg0
;
uint
arg0
;
int
l
;
int
l
;
struct
dirent
de
;
if
(
fetcharg
(
0
,
&
arg0
)
<
0
)
if
(
fetcharg
(
0
,
&
arg0
)
<
0
)
return
-
1
;
return
-
1
;
...
@@ -308,7 +310,15 @@ sys_mkdir(void)
...
@@ -308,7 +310,15 @@ sys_mkdir(void)
nip
=
mknod
(
cp
->
mem
+
arg0
,
T_DIR
,
0
,
0
);
nip
=
mknod
(
cp
->
mem
+
arg0
,
T_DIR
,
0
,
0
);
// XXX put . and .. in
de
.
name
[
0
]
=
'.'
;
de
.
inum
=
nip
->
inum
;
writei
(
nip
,
(
char
*
)
&
de
,
0
,
sizeof
(
de
));
pip
=
namei
(
"."
,
NAMEI_LOOKUP
,
0
);
de
.
inum
=
pip
->
inum
;
de
.
name
[
1
]
=
'.'
;
iput
(
pip
);
writei
(
nip
,
(
char
*
)
&
de
,
sizeof
(
de
),
sizeof
(
de
));
iput
(
nip
);
iput
(
nip
);
return
(
nip
==
0
)
?
-
1
:
0
;
return
(
nip
==
0
)
?
-
1
:
0
;
...
...
ulib.c
浏览文件 @
bdb66433
...
@@ -61,11 +61,11 @@ gets(char *buf, int max)
...
@@ -61,11 +61,11 @@ gets(char *buf, int max)
int
int
stat
(
char
*
n
,
struct
stat
*
st
)
stat
(
char
*
n
,
struct
stat
*
st
)
{
{
int
fd
=
open
(
n
,
O_RDONLY
)
;
int
fd
;
int
r
;
int
r
;
fd
=
open
(
n
,
O_RDONLY
);
if
(
fd
<
0
)
return
-
1
;
if
(
fd
<
0
)
return
-
1
;
r
=
fstat
(
fd
,
st
);
r
=
fstat
(
fd
,
st
);
close
(
fd
);
close
(
fd
);
return
r
;
return
r
;
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论