Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
895af77f
提交
895af77f
4月 10, 2015
创建
作者:
Frans Kaashoek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
check blockno passed to idestart
上级
c24ac5d7
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
9 行增加
和
9 行删除
+9
-9
ide.c
ide.c
+3
-1
mkfs.c
mkfs.c
+5
-8
param.h
param.h
+1
-0
没有找到文件。
ide.c
浏览文件 @
895af77f
...
@@ -48,7 +48,7 @@ void
...
@@ -48,7 +48,7 @@ void
ideinit
(
void
)
ideinit
(
void
)
{
{
int
i
;
int
i
;
initlock
(
&
idelock
,
"ide"
);
initlock
(
&
idelock
,
"ide"
);
picenable
(
IRQ_IDE
);
picenable
(
IRQ_IDE
);
ioapicenable
(
IRQ_IDE
,
ncpu
-
1
);
ioapicenable
(
IRQ_IDE
,
ncpu
-
1
);
...
@@ -73,6 +73,8 @@ idestart(struct buf *b)
...
@@ -73,6 +73,8 @@ idestart(struct buf *b)
{
{
if
(
b
==
0
)
if
(
b
==
0
)
panic
(
"idestart"
);
panic
(
"idestart"
);
if
(
b
->
blockno
>=
FSSIZE
)
panic
(
"incorrect blockno"
);
int
sector_per_block
=
BSIZE
/
SECTOR_SIZE
;
int
sector_per_block
=
BSIZE
/
SECTOR_SIZE
;
int
sector
=
b
->
blockno
*
sector_per_block
;
int
sector
=
b
->
blockno
*
sector_per_block
;
...
...
mkfs.c
浏览文件 @
895af77f
...
@@ -13,13 +13,12 @@
...
@@ -13,13 +13,12 @@
#define static_assert(a, b) do { switch (0) case 0: case (a): ; } while (0)
#define static_assert(a, b) do { switch (0) case 0: case (a): ; } while (0)
#define SIZE 1000
#define NINODES 200
#define NINODES 200
// Disk layout:
// Disk layout:
// [ boot block | sb block | inode blocks | bit map | data blocks | log ]
// [ boot block | sb block | inode blocks | bit map | data blocks | log ]
int
nbitmap
=
SIZE
/
(
BSIZE
*
8
)
+
1
;
int
nbitmap
=
FS
SIZE
/
(
BSIZE
*
8
)
+
1
;
int
ninodeblocks
=
NINODES
/
IPB
+
1
;
int
ninodeblocks
=
NINODES
/
IPB
+
1
;
int
nlog
=
LOGSIZE
;
int
nlog
=
LOGSIZE
;
int
nmeta
;
// Number of meta blocks (inode, bitmap, and 2 extra)
int
nmeta
;
// Number of meta blocks (inode, bitmap, and 2 extra)
...
@@ -90,18 +89,18 @@ main(int argc, char *argv[])
...
@@ -90,18 +89,18 @@ main(int argc, char *argv[])
}
}
nmeta
=
2
+
ninodeblocks
+
nbitmap
;
nmeta
=
2
+
ninodeblocks
+
nbitmap
;
nblocks
=
SIZE
-
nlog
-
nmeta
;
nblocks
=
FS
SIZE
-
nlog
-
nmeta
;
sb
.
size
=
xint
(
SIZE
);
sb
.
size
=
xint
(
FS
SIZE
);
sb
.
nblocks
=
xint
(
nblocks
);
// so whole disk is size sectors
sb
.
nblocks
=
xint
(
nblocks
);
// so whole disk is size sectors
sb
.
ninodes
=
xint
(
NINODES
);
sb
.
ninodes
=
xint
(
NINODES
);
sb
.
nlog
=
xint
(
nlog
);
sb
.
nlog
=
xint
(
nlog
);
printf
(
"nmeta %d (boot, super, inode blocks %u, bitmap blocks %u) blocks %d log %u total %d
\n
"
,
nmeta
,
ninodeblocks
,
nbitmap
,
nblocks
,
nlog
,
SIZE
);
printf
(
"nmeta %d (boot, super, inode blocks %u, bitmap blocks %u) blocks %d log %u total %d
\n
"
,
nmeta
,
ninodeblocks
,
nbitmap
,
nblocks
,
nlog
,
FS
SIZE
);
freeblock
=
nmeta
;
// the first free block that we can allocate
freeblock
=
nmeta
;
// the first free block that we can allocate
for
(
i
=
0
;
i
<
SIZE
;
i
++
)
for
(
i
=
0
;
i
<
FS
SIZE
;
i
++
)
wsect
(
i
,
zeroes
);
wsect
(
i
,
zeroes
);
memset
(
buf
,
0
,
sizeof
(
buf
));
memset
(
buf
,
0
,
sizeof
(
buf
));
...
@@ -164,7 +163,6 @@ main(int argc, char *argv[])
...
@@ -164,7 +163,6 @@ main(int argc, char *argv[])
void
void
wsect
(
uint
sec
,
void
*
buf
)
wsect
(
uint
sec
,
void
*
buf
)
{
{
printf
(
"seek to %d
\n
"
,
sec
*
BSIZE
);
if
(
lseek
(
fsfd
,
sec
*
BSIZE
,
0
)
!=
sec
*
BSIZE
){
if
(
lseek
(
fsfd
,
sec
*
BSIZE
,
0
)
!=
sec
*
BSIZE
){
perror
(
"lseek"
);
perror
(
"lseek"
);
exit
(
1
);
exit
(
1
);
...
@@ -183,7 +181,6 @@ winode(uint inum, struct dinode *ip)
...
@@ -183,7 +181,6 @@ winode(uint inum, struct dinode *ip)
struct
dinode
*
dip
;
struct
dinode
*
dip
;
bn
=
IBLOCK
(
inum
);
bn
=
IBLOCK
(
inum
);
printf
(
"winode %d
\n
"
,
bn
);
rsect
(
bn
,
buf
);
rsect
(
bn
,
buf
);
dip
=
((
struct
dinode
*
)
buf
)
+
(
inum
%
IPB
);
dip
=
((
struct
dinode
*
)
buf
)
+
(
inum
%
IPB
);
*
dip
=
*
ip
;
*
dip
=
*
ip
;
...
...
param.h
浏览文件 @
895af77f
...
@@ -10,4 +10,5 @@
...
@@ -10,4 +10,5 @@
#define MAXOPBLOCKS 10 // max # of blocks any FS op writes
#define MAXOPBLOCKS 10 // max # of blocks any FS op writes
#define LOGSIZE (MAXOPBLOCKS*3) // max data blocks in on-disk log
#define LOGSIZE (MAXOPBLOCKS*3) // max data blocks in on-disk log
#define NBUF (MAXOPBLOCKS*3) // size of disk block cache
#define NBUF (MAXOPBLOCKS*3) // size of disk block cache
#define FSSIZE 1000 // size of file system in blocks
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论