Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
17e3cf15
提交
17e3cf15
8月 13, 2006
创建
作者:
rtm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix iget() bug that allocated in-use inode[] entries
上级
8abe2bcf
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
19 行增加
和
60 行删除
+19
-60
Notes
Notes
+3
-11
fd.c
fd.c
+2
-0
fs.c
fs.c
+13
-37
init.c
init.c
+0
-3
ioapic.c
ioapic.c
+0
-2
picirq.c
picirq.c
+0
-7
syscall.c
syscall.c
+1
-0
没有找到文件。
Notes
浏览文件 @
17e3cf15
...
...
@@ -357,7 +357,6 @@ OH! recursive interrupts will use up any amount of cpu[].stack!
disk scheduling
mkdir
more than one directory content block
sh arguments
sh redirection
indirect blocks
...
...
@@ -366,17 +365,10 @@ two bugs in unlink: don't just return if nlink > 0,
is there a create/create race for same file name?
resulting in two entries w/ same name in directory?
namei
return just inode
return offset in dir where found, w/ dir locked, for unlink
return dir locked, for mknod
is the offset alone useful? how do I read/write it?
test: one process unlinks a file while another links to it
test: simultaneous create of same file
test: one process opens a file while another deletes it
oy, mkfs wants dir size to be last written entry, but i
want it to be nblocks*512
maybe fix kernel code to handle former
wdir should use writei, to avoid special-case block allocation
also readi
is dir locked? probably
fd.c
浏览文件 @
17e3cf15
...
...
@@ -8,6 +8,8 @@
#include "fd.h"
#include "spinlock.h"
#include "dev.h"
#include "fs.h"
#include "fsvar.h"
struct
spinlock
fd_table_lock
;
struct
devsw
devsw
[
NDEV
];
...
...
fs.c
浏览文件 @
17e3cf15
...
...
@@ -54,7 +54,6 @@ balloc(uint dev)
if
(
b
>=
size
)
panic
(
"balloc: out of blocks
\n
"
);
cprintf
(
"balloc: allocate block %d
\n
"
,
b
);
bp
->
data
[
bi
/
8
]
|=
0x1
<<
(
bi
%
8
);
bwrite
(
bp
,
BBLOCK
(
b
,
ninodes
));
// mark it allocated on disk
brelse
(
bp
);
...
...
@@ -70,7 +69,6 @@ bfree(int dev, uint b)
int
ninodes
;
uchar
m
;
cprintf
(
"bfree: free block %d
\n
"
,
b
);
bp
=
bread
(
dev
,
1
);
sb
=
(
struct
superblock
*
)
bp
->
data
;
ninodes
=
sb
->
ninodes
;
...
...
@@ -93,13 +91,14 @@ bfree(int dev, uint b)
struct
inode
*
iget
(
uint
dev
,
uint
inum
)
{
struct
inode
*
ip
,
*
nip
=
0
;
struct
inode
*
ip
,
*
nip
;
struct
dinode
*
dip
;
struct
buf
*
bp
;
acquire
(
&
inode_table_lock
);
loop:
nip
=
0
;
for
(
ip
=
&
inode
[
0
];
ip
<
&
inode
[
NINODE
];
ip
++
){
if
(
ip
->
count
>
0
&&
ip
->
dev
==
dev
&&
ip
->
inum
==
inum
){
if
(
ip
->
busy
){
...
...
@@ -180,11 +179,9 @@ ialloc(uint dev, short type)
brelse
(
bp
);
}
if
(
inum
>=
ninodes
)
{
if
(
inum
>=
ninodes
)
panic
(
"ialloc: no inodes left
\n
"
);
}
cprintf
(
"ialloc: %d
\n
"
,
inum
);
dip
->
type
=
type
;
bwrite
(
bp
,
IBLOCK
(
inum
));
// mark it allocated on the disk
brelse
(
bp
);
...
...
@@ -195,7 +192,6 @@ ialloc(uint dev, short type)
static
void
ifree
(
struct
inode
*
ip
)
{
cprintf
(
"ifree: %d
\n
"
,
ip
->
inum
);
ip
->
type
=
0
;
iupdate
(
ip
);
}
...
...
@@ -220,7 +216,7 @@ ilock(struct inode *ip)
void
iunlock
(
struct
inode
*
ip
)
{
if
(
ip
->
busy
!=
1
)
if
(
ip
->
busy
!=
1
||
ip
->
count
<
1
)
panic
(
"iunlock"
);
acquire
(
&
inode_table_lock
);
...
...
@@ -271,7 +267,7 @@ iput(struct inode *ip)
if
(
ip
->
count
<
1
||
ip
->
busy
!=
1
)
panic
(
"iput"
);
if
((
ip
->
count
<=
1
)
&&
(
ip
->
nlink
<
=
0
))
if
((
ip
->
count
==
1
)
&&
(
ip
->
nlink
=
=
0
))
iunlink
(
ip
);
acquire
(
&
inode_table_lock
);
...
...
@@ -498,8 +494,6 @@ mknod(char *cp, short type, short major, short minor)
{
struct
inode
*
ip
,
*
dp
;
cprintf
(
"mknod: %s %d %d %d
\n
"
,
cp
,
type
,
major
,
minor
);
if
((
dp
=
namei
(
cp
,
NAMEI_CREATE
,
0
))
==
0
)
return
0
;
...
...
@@ -525,24 +519,17 @@ unlink(char *cp)
{
struct
inode
*
ip
,
*
dp
;
struct
dirent
de
;
uint
off
,
inum
,
cc
;
cprintf
(
"unlink(%s)
\n
"
,
cp
);
uint
off
,
inum
,
dev
;
if
((
dp
=
namei
(
cp
,
NAMEI_DELETE
,
&
off
))
==
0
)
{
cprintf
(
"unlink(%s) it doesn't exist
\n
"
,
cp
);
if
((
dp
=
namei
(
cp
,
NAMEI_DELETE
,
&
off
))
==
0
)
return
-
1
;
}
if
((
cc
=
readi
(
dp
,
(
char
*
)
&
de
,
off
,
sizeof
(
de
)))
!=
sizeof
(
de
)
||
de
.
inum
==
0
){
cprintf
(
"off %d dp->size %d cc %d de.inum %d"
,
off
,
dp
->
size
,
cc
,
de
.
inum
);
dev
=
dp
->
dev
;
if
(
readi
(
dp
,
(
char
*
)
&
de
,
off
,
sizeof
(
de
))
!=
sizeof
(
de
)
||
de
.
inum
==
0
)
panic
(
"unlink no entry"
);
}
inum
=
de
.
inum
;
cprintf
(
"dinum %d off %d de %s/%d
\n
"
,
dp
->
inum
,
off
,
de
.
name
,
de
.
inum
);
memset
(
&
de
,
0
,
sizeof
(
de
));
if
(
writei
(
dp
,
(
char
*
)
&
de
,
off
,
sizeof
(
de
))
!=
sizeof
(
de
))
...
...
@@ -551,9 +538,7 @@ unlink(char *cp)
iupdate
(
dp
);
iput
(
dp
);
ip
=
iget
(
dp
->
dev
,
inum
);
if
(
ip
==
0
)
panic
(
"unlink no inode"
);
ip
=
iget
(
dev
,
inum
);
ip
->
nlink
--
;
...
...
@@ -568,14 +553,9 @@ link(char *name1, char *name2)
{
struct
inode
*
ip
,
*
dp
;
cprintf
(
"link(%s, %s)
\n
"
,
name1
,
name2
);
if
((
ip
=
namei
(
name1
,
NAMEI_LOOKUP
,
0
))
==
0
){
cprintf
(
" failed %s does not exist
\n
"
,
name1
);
if
((
ip
=
namei
(
name1
,
NAMEI_LOOKUP
,
0
))
==
0
)
return
-
1
;
}
if
(
ip
->
type
==
T_DIR
){
cprintf
(
" failed %s is a dir
\n
"
,
name1
);
iput
(
ip
);
return
-
1
;
}
...
...
@@ -583,12 +563,10 @@ link(char *name1, char *name2)
iunlock
(
ip
);
if
((
dp
=
namei
(
name2
,
NAMEI_CREATE
,
0
))
==
0
)
{
cprintf
(
" failed %s exists
\n
"
,
name2
);
idecref
(
ip
);
return
-
1
;
}
if
(
dp
->
dev
!=
ip
->
dev
){
cprintf
(
" cross-device link
\n
"
);
idecref
(
ip
);
iput
(
dp
);
return
-
1
;
...
...
@@ -602,7 +580,5 @@ link(char *name1, char *name2)
iput
(
dp
);
iput
(
ip
);
cprintf
(
" succeeded
\n
"
);
return
0
;
}
init.c
浏览文件 @
17e3cf15
...
...
@@ -17,10 +17,7 @@ main(void)
open
(
"console"
,
1
);
open
(
"console"
,
1
);
puts
(
"init...
\n
"
);
while
(
1
){
puts
(
"running sh...
\n
"
);
pid
=
fork
();
if
(
pid
==
0
){
exec
(
"sh"
,
sh_args
);
...
...
ioapic.c
浏览文件 @
17e3cf15
...
...
@@ -43,7 +43,6 @@ ioapic_init(void)
id
=
ioapic_read
(
io
,
IOAPIC_ID
)
>>
APIC_ID_SHIFT
;
if
(
id
!=
ioapic_id
)
panic
(
"ioapic_init: id isn't equal to ioapic_id
\n
"
);
cprintf
(
"ioapic VER: 0x%x id %d nintr %d
\n
"
,
l
,
id
,
nintr
);
for
(
i
=
0
;
i
<
nintr
;
i
++
)
{
// active-hi and edge-triggered for ISA interrupts
// Assume that pin 0 on the first I/O APIC is an ExtINT pin.
...
...
@@ -78,5 +77,4 @@ ioapic_enable (int irq, int cpunum)
h
&=
~
IOART_DEST
;
h
|=
(
cpunum
<<
APIC_ID_SHIFT
);
ioapic_write
(
io
,
IOAPIC_REDTBL_HI
(
irq
),
h
);
cprintf
(
"cpu%d: intr %d: lo 0x%x hi 0x%x
\n
"
,
cpu
(),
irq
,
l
,
h
);
}
picirq.c
浏览文件 @
17e3cf15
...
...
@@ -22,13 +22,6 @@ irq_setmask_8259A(ushort mask)
outb
(
IO_PIC1
+
1
,
(
char
)
mask
);
outb
(
IO_PIC2
+
1
,
(
char
)(
mask
>>
8
));
cprintf
(
"%d: enabled interrupts:"
,
cpu
());
for
(
i
=
0
;
i
<
16
;
i
++
)
if
(
~
mask
&
(
1
<<
i
))
cprintf
(
" %d"
,
i
);
cprintf
(
"
\n
"
);
}
/* Initialize the 8259A interrupt controllers. */
...
...
syscall.c
浏览文件 @
17e3cf15
...
...
@@ -284,6 +284,7 @@ sys_mknod(void)
return
-
1
;
nip
=
mknod
(
cp
->
mem
+
arg0
,
(
short
)
arg1
,
(
short
)
arg2
,
(
short
)
arg3
);
if
(
nip
)
iput
(
nip
);
return
(
nip
==
0
)
?
-
1
:
0
;
}
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论