Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
4ddb84ac
提交
4ddb84ac
10月 25, 2011
创建
作者:
Silas Boyd-Wickizer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
memide.c and mkfs.c
上级
f568fbd8
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
45 行增加
和
39 行删除
+45
-39
Makefile
Makefile
+10
-4
mkfs.c
mkfs.c
+35
-35
没有找到文件。
Makefile
浏览文件 @
4ddb84ac
...
...
@@ -5,10 +5,10 @@ OBJS = \
condvar.o
\
console.o
\
fs.o
\
ide.o
\
lapic.o
\
kalloc.o
\
main.o
\
memide.o
\
mp.o
\
ns.o
\
proc.o
\
...
...
@@ -40,9 +40,9 @@ CFLAGS += $(shell $(CC) -fno-stack-protector -E -x c /dev/null >/dev/null 2>&1 &
ASFLAGS
=
-m64
-gdwarf-2
LDFLAGS
+=
-m
elf_x86_64
kernel
:
boot.o $(OBJS) initcode bootother
kernel
:
boot.o $(OBJS) initcode bootother
fs.img
$(LD)
$(LDFLAGS)
-T
kernel.ld
-z
max-page-size
=
4096
-e
start
\
-o
$@
boot.o
$(OBJS)
-b
binary initcode bootother
-o
$@
boot.o
$(OBJS)
-b
binary initcode bootother
fs.img
initcode
:
initcode.S
$(CC)
$(CFLAGS)
-nostdinc
-I
.
-c
initcode.S
...
...
@@ -61,12 +61,18 @@ xv6memfs.img: bootblock kernelmemfs
dd
if
=
bootblock
of
=
xv6memfs.img
conv
=
notrunc
dd
if
=
kernelmemfs
of
=
xv6memfs.img
seek
=
1
conv
=
notrunc
mkfs
:
mkfs.c fs.h
gcc
-m32
-Werror
-Wall
-o
mkfs mkfs.c
fs.img
:
mkfs README $(UPROGS)
./mkfs fs.img README
$(UPROGS)
-include
*.d
.PHONY
:
clean qemu ud0
clean
:
rm
-f
*
.o
*
.d
*
.asm
*
.sym initcode kernel bootother
rm
-f
*
.o
*
.d
*
.asm
*
.sym initcode kernel bootother
mkfs fs.img
QEMUOPTS
=
-smp
$(CPUS)
-m
512
-nographic
qemu
:
kernel
...
...
mkfs.c
浏览文件 @
4ddb84ac
...
...
@@ -17,35 +17,35 @@ int size = 4096;
int
fsfd
;
struct
superblock
sb
;
char
zeroes
[
512
];
u
int
freeblock
;
u
int
usedblocks
;
u
int
bitblocks
;
u
int
freeinode
=
1
;
u
32
freeblock
;
u
32
usedblocks
;
u
32
bitblocks
;
u
32
freeinode
=
1
;
void
balloc
(
int
);
void
wsect
(
u
int
,
void
*
);
void
winode
(
u
int
,
struct
dinode
*
);
void
rinode
(
u
int
inum
,
struct
dinode
*
ip
);
void
rsect
(
u
int
sec
,
void
*
buf
);
u
int
ialloc
(
ushort
type
);
void
iappend
(
u
int
inum
,
void
*
p
,
int
n
);
void
wsect
(
u
32
,
void
*
);
void
winode
(
u
32
,
struct
dinode
*
);
void
rinode
(
u
32
inum
,
struct
dinode
*
ip
);
void
rsect
(
u
32
sec
,
void
*
buf
);
u
32
ialloc
(
u16
type
);
void
iappend
(
u
32
inum
,
void
*
p
,
int
n
);
// convert to intel byte order
u
short
xshort
(
u
short
x
)
u
16
xshort
(
u
16
x
)
{
u
short
y
;
u
char
*
a
=
(
uchar
*
)
&
y
;
u
16
y
;
u
8
*
a
=
(
u8
*
)
&
y
;
a
[
0
]
=
x
;
a
[
1
]
=
x
>>
8
;
return
y
;
}
u
int
xint
(
u
int
x
)
u
32
xint
(
u
32
x
)
{
u
int
y
;
u
char
*
a
=
(
uchar
*
)
&
y
;
u
32
y
;
u
8
*
a
=
(
u8
*
)
&
y
;
a
[
0
]
=
x
;
a
[
1
]
=
x
>>
8
;
a
[
2
]
=
x
>>
16
;
...
...
@@ -57,7 +57,7 @@ int
main
(
int
argc
,
char
*
argv
[])
{
int
i
,
cc
,
fd
;
u
int
rootino
,
inum
,
off
;
u
32
rootino
,
inum
,
off
;
struct
dirent
de
;
char
buf
[
512
];
struct
dinode
din
;
...
...
@@ -150,7 +150,7 @@ main(int argc, char *argv[])
}
void
wsect
(
u
int
sec
,
void
*
buf
)
wsect
(
u
32
sec
,
void
*
buf
)
{
if
(
lseek
(
fsfd
,
sec
*
512L
,
0
)
!=
sec
*
512L
){
perror
(
"lseek"
);
...
...
@@ -162,17 +162,17 @@ wsect(uint sec, void *buf)
}
}
u
int
i2b
(
u
int
inum
)
u
32
i2b
(
u
32
inum
)
{
return
(
inum
/
IPB
)
+
2
;
}
void
winode
(
u
int
inum
,
struct
dinode
*
ip
)
winode
(
u
32
inum
,
struct
dinode
*
ip
)
{
char
buf
[
512
];
u
int
bn
;
u
32
bn
;
struct
dinode
*
dip
;
bn
=
i2b
(
inum
);
...
...
@@ -183,10 +183,10 @@ winode(uint inum, struct dinode *ip)
}
void
rinode
(
u
int
inum
,
struct
dinode
*
ip
)
rinode
(
u
32
inum
,
struct
dinode
*
ip
)
{
char
buf
[
512
];
u
int
bn
;
u
32
bn
;
struct
dinode
*
dip
;
bn
=
i2b
(
inum
);
...
...
@@ -196,7 +196,7 @@ rinode(uint inum, struct dinode *ip)
}
void
rsect
(
u
int
sec
,
void
*
buf
)
rsect
(
u
32
sec
,
void
*
buf
)
{
if
(
lseek
(
fsfd
,
sec
*
512L
,
0
)
!=
sec
*
512L
){
perror
(
"lseek"
);
...
...
@@ -208,10 +208,10 @@ rsect(uint sec, void *buf)
}
}
u
int
ialloc
(
u
short
type
)
u
32
ialloc
(
u
16
type
)
{
u
int
inum
=
freeinode
++
;
u
32
inum
=
freeinode
++
;
struct
dinode
din
;
bzero
(
&
din
,
sizeof
(
din
));
...
...
@@ -226,7 +226,7 @@ ialloc(ushort type)
void
balloc
(
int
used
)
{
u
char
buf
[
512
];
u
8
buf
[
512
];
int
i
;
printf
(
"balloc: first %d blocks have been allocated
\n
"
,
used
);
...
...
@@ -242,14 +242,14 @@ balloc(int used)
#define min(a, b) ((a) < (b) ? (a) : (b))
void
iappend
(
u
int
inum
,
void
*
xp
,
int
n
)
iappend
(
u
32
inum
,
void
*
xp
,
int
n
)
{
char
*
p
=
(
char
*
)
xp
;
u
int
fbn
,
off
,
n1
;
u
32
fbn
,
off
,
n1
;
struct
dinode
din
;
char
buf
[
512
];
u
int
indirect
[
NINDIRECT
];
u
int
x
;
u
32
indirect
[
NINDIRECT
];
u
32
x
;
rinode
(
inum
,
&
din
);
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论