Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
432acbaf
提交
432acbaf
8月 22, 2012
创建
作者:
Frans Kaashoek
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
git+ssh://amsterdam.csail.mit.edu/home/am0/6.828/xv6
上级
4ce832dd
9d59eb01
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
28 行增加
和
17 行删除
+28
-17
bio.c
bio.c
+2
-2
defs.h
defs.h
+2
-2
file.c
file.c
+6
-2
log.c
log.c
+1
-0
syscall.c
syscall.c
+9
-9
sysfile.c
sysfile.c
+8
-2
没有找到文件。
bio.c
浏览文件 @
432acbaf
...
...
@@ -79,9 +79,9 @@ bget(uint dev, uint sector)
}
}
// Not cached; recycle some
existing
buffer.
// Not cached; recycle some
non-busy and clean
buffer.
for
(
b
=
bcache
.
head
.
prev
;
b
!=
&
bcache
.
head
;
b
=
b
->
prev
){
if
((
b
->
flags
&
B_BUSY
)
==
0
){
if
((
b
->
flags
&
B_BUSY
)
==
0
&&
(
b
->
flags
&
B_DIRTY
)
==
0
){
b
->
dev
=
dev
;
b
->
sector
=
sector
;
b
->
flags
=
B_BUSY
;
...
...
defs.h
浏览文件 @
432acbaf
...
...
@@ -142,8 +142,8 @@ char* strncpy(char*, const char*, int);
int
argint
(
int
,
int
*
);
int
argptr
(
int
,
char
**
,
int
);
int
argstr
(
int
,
char
**
);
int
fetchint
(
struct
proc
*
,
uint
,
int
*
);
int
fetchstr
(
struct
proc
*
,
uint
,
char
**
);
int
fetchint
(
uint
,
int
*
);
int
fetchstr
(
uint
,
char
**
);
void
syscall
(
void
);
// timer.c
...
...
file.c
浏览文件 @
432acbaf
//
// File descriptors
//
#include "types.h"
#include "defs.h"
#include "param.h"
...
...
@@ -87,7 +91,7 @@ filestat(struct file *f, struct stat *st)
return
-
1
;
}
// Read from file f.
Addr is kernel address.
// Read from file f.
int
fileread
(
struct
file
*
f
,
char
*
addr
,
int
n
)
{
...
...
@@ -108,7 +112,7 @@ fileread(struct file *f, char *addr, int n)
}
//PAGEBREAK!
// Write to file f.
Addr is kernel address.
// Write to file f.
int
filewrite
(
struct
file
*
f
,
char
*
addr
,
int
n
)
{
...
...
log.c
浏览文件 @
432acbaf
...
...
@@ -177,6 +177,7 @@ log_write(struct buf *b)
brelse
(
lbuf
);
if
(
i
==
log
.
lh
.
n
)
log
.
lh
.
n
++
;
b
->
flags
|=
B_DIRTY
;
// XXX prevent eviction
}
//PAGEBREAK!
...
...
syscall.c
浏览文件 @
432acbaf
...
...
@@ -13,28 +13,28 @@
// library system call function. The saved user %esp points
// to a saved program counter, and then the first argument.
// Fetch the int at addr from
process p
.
// Fetch the int at addr from
the current process
.
int
fetchint
(
struct
proc
*
p
,
uint
addr
,
int
*
ip
)
fetchint
(
uint
addr
,
int
*
ip
)
{
if
(
addr
>=
p
->
sz
||
addr
+
4
>
p
->
sz
)
if
(
addr
>=
p
roc
->
sz
||
addr
+
4
>
proc
->
sz
)
return
-
1
;
*
ip
=
*
(
int
*
)(
addr
);
return
0
;
}
// Fetch the nul-terminated string at addr from
process p
.
// Fetch the nul-terminated string at addr from
the current process
.
// Doesn't actually copy the string - just sets *pp to point at it.
// Returns length of string, not including nul.
int
fetchstr
(
struct
proc
*
p
,
uint
addr
,
char
**
pp
)
fetchstr
(
uint
addr
,
char
**
pp
)
{
char
*
s
,
*
ep
;
if
(
addr
>=
p
->
sz
)
if
(
addr
>=
p
roc
->
sz
)
return
-
1
;
*
pp
=
(
char
*
)
addr
;
ep
=
(
char
*
)
p
->
sz
;
ep
=
(
char
*
)
p
roc
->
sz
;
for
(
s
=
*
pp
;
s
<
ep
;
s
++
)
if
(
*
s
==
0
)
return
s
-
*
pp
;
...
...
@@ -45,7 +45,7 @@ fetchstr(struct proc *p, uint addr, char **pp)
int
argint
(
int
n
,
int
*
ip
)
{
return
fetchint
(
proc
,
proc
->
tf
->
esp
+
4
+
4
*
n
,
ip
);
return
fetchint
(
proc
->
tf
->
esp
+
4
+
4
*
n
,
ip
);
}
// Fetch the nth word-sized system call argument as a pointer
...
...
@@ -74,7 +74,7 @@ argstr(int n, char **pp)
int
addr
;
if
(
argint
(
n
,
&
addr
)
<
0
)
return
-
1
;
return
fetchstr
(
proc
,
addr
,
pp
);
return
fetchstr
(
addr
,
pp
);
}
extern
int
sys_chdir
(
void
);
...
...
sysfile.c
浏览文件 @
432acbaf
//
// File-system system calls.
// Mostly argument checking, since we don't trust
// user code, and calls into file.c and fs.c.
//
#include "types.h"
#include "defs.h"
#include "param.h"
...
...
@@ -382,13 +388,13 @@ sys_exec(void)
for
(
i
=
0
;;
i
++
){
if
(
i
>=
NELEM
(
argv
))
return
-
1
;
if
(
fetchint
(
proc
,
uargv
+
4
*
i
,
(
int
*
)
&
uarg
)
<
0
)
if
(
fetchint
(
uargv
+
4
*
i
,
(
int
*
)
&
uarg
)
<
0
)
return
-
1
;
if
(
uarg
==
0
){
argv
[
i
]
=
0
;
break
;
}
if
(
fetchstr
(
proc
,
uarg
,
&
argv
[
i
])
<
0
)
if
(
fetchstr
(
uarg
,
&
argv
[
i
])
<
0
)
return
-
1
;
}
return
exec
(
path
,
argv
);
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论