Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
f18ab5c0
提交
f18ab5c0
8月 20, 2006
创建
作者:
kaashoek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
compiling, but untested dup
上级
16083d44
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
24 行增加
和
12 行删除
+24
-12
defs.h
defs.h
+0
-1
fd.c
fd.c
+0
-6
syscall.c
syscall.c
+24
-5
没有找到文件。
defs.h
浏览文件 @
f18ab5c0
...
@@ -94,7 +94,6 @@ int fd_read(struct fd *fd, char *addr, int n);
...
@@ -94,7 +94,6 @@ int fd_read(struct fd *fd, char *addr, int n);
int
fd_write
(
struct
fd
*
fd
,
char
*
addr
,
int
n
);
int
fd_write
(
struct
fd
*
fd
,
char
*
addr
,
int
n
);
int
fd_stat
(
struct
fd
*
fd
,
struct
stat
*
);
int
fd_stat
(
struct
fd
*
fd
,
struct
stat
*
);
void
fd_incref
(
struct
fd
*
fd
);
void
fd_incref
(
struct
fd
*
fd
);
int
fd_dup
(
struct
fd
*
fd
);
// ide.c
// ide.c
void
ide_init
(
void
);
void
ide_init
(
void
);
...
...
fd.c
浏览文件 @
f18ab5c0
...
@@ -149,9 +149,3 @@ fd_incref(struct fd *fd)
...
@@ -149,9 +149,3 @@ fd_incref(struct fd *fd)
fd
->
ref
++
;
fd
->
ref
++
;
release
(
&
fd_table_lock
);
release
(
&
fd_table_lock
);
}
}
int
fd_dup
(
struct
fd
*
fd
)
{
return
-
1
;
}
syscall.c
浏览文件 @
f18ab5c0
...
@@ -402,17 +402,36 @@ int
...
@@ -402,17 +402,36 @@ int
sys_dup
(
void
)
sys_dup
(
void
)
{
{
struct
proc
*
cp
=
curproc
[
cpu
()];
struct
proc
*
cp
=
curproc
[
cpu
()];
uint
fd
;
uint
fd
,
ufd1
;
int
r
;
struct
fd
*
fd1
;
if
(
fetcharg
(
0
,
&
fd
)
<
0
)
if
(
fetcharg
(
0
,
&
fd
)
<
0
)
return
-
1
;
return
-
1
;
if
(
fd
<
0
||
fd
>=
NOFILE
)
if
(
fd
<
0
||
fd
>=
NOFILE
)
return
-
1
;
return
-
1
;
if
(
cp
->
fds
[
fd
]
==
0
)
if
(
cp
->
fds
[
fd
]
==
0
)
return
-
1
;
return
-
1
;
r
=
fd_dup
(
cp
->
fds
[
fd
]);
if
(
cp
->
fds
[
fd
]
->
type
!=
FD_PIPE
&&
cp
->
fds
[
fd
]
->
type
!=
FD_FILE
)
return
r
;
return
-
1
;
if
((
fd1
=
fd_alloc
())
==
0
)
{
return
-
1
;
}
if
((
ufd1
=
fd_ualloc
())
<
0
)
{
fd_close
(
fd1
);
return
-
1
;
}
fd1
->
type
=
cp
->
fds
[
fd
]
->
type
;
fd1
->
readable
=
cp
->
fds
[
fd
]
->
readable
;
fd1
->
writeable
=
cp
->
fds
[
fd
]
->
writeable
;
if
(
cp
->
fds
[
fd
]
->
type
==
FD_FILE
)
{
fd1
->
ip
=
cp
->
fds
[
fd
]
->
ip
;
iincref
(
fd1
->
ip
);
}
else
if
(
cp
->
fds
[
fd
]
->
type
==
FD_PIPE
)
{
fd1
->
pipe
=
cp
->
fds
[
fd
]
->
pipe
;
}
fd1
->
off
=
cp
->
fds
[
fd
]
->
off
;
return
ufd1
;
}
}
int
int
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论