Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
f7766586
提交
f7766586
3月 07, 2012
创建
作者:
Silas Boyd-Wickizer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
file::pread
上级
0b6ffac6
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
17 行增加
和
10 行删除
+17
-10
file.hh
include/file.hh
+1
-0
file.cc
kernel/file.cc
+15
-0
sysfile.cc
kernel/sysfile.cc
+1
-10
没有找到文件。
include/file.hh
浏览文件 @
f7766586
...
@@ -13,6 +13,7 @@ struct file : public referenced {
...
@@ -13,6 +13,7 @@ struct file : public referenced {
file
*
dup
();
file
*
dup
();
int
stat
(
struct
stat
*
);
int
stat
(
struct
stat
*
);
int
read
(
char
*
addr
,
int
n
);
int
read
(
char
*
addr
,
int
n
);
ssize_t
pread
(
char
*
addr
,
size_t
n
,
off_t
offset
);
int
write
(
char
*
addr
,
int
n
);
int
write
(
char
*
addr
,
int
n
);
enum
{
FD_NONE
,
FD_PIPE
,
FD_INODE
,
FD_SOCKET
}
type
;
enum
{
FD_NONE
,
FD_PIPE
,
FD_INODE
,
FD_SOCKET
}
type
;
...
...
kernel/file.cc
浏览文件 @
f7766586
...
@@ -80,6 +80,21 @@ file::read(char *addr, int n)
...
@@ -80,6 +80,21 @@ file::read(char *addr, int n)
panic
(
"fileread"
);
panic
(
"fileread"
);
}
}
ssize_t
file
::
pread
(
char
*
addr
,
size_t
n
,
off_t
off
)
{
if
(
type
==
file
::
FD_INODE
){
int
r
;
ilock
(
ip
,
0
);
if
(
ip
->
type
==
0
)
panic
(
"file::pread"
);
r
=
readi
(
ip
,
addr
,
off
,
n
);
iunlock
(
ip
);
return
r
;
}
return
-
1
;
}
int
int
file
::
write
(
char
*
addr
,
int
n
)
file
::
write
(
char
*
addr
,
int
n
)
{
{
...
...
kernel/sysfile.cc
浏览文件 @
f7766586
...
@@ -57,7 +57,6 @@ sys_pread(int fd, void *ubuf, size_t count, off_t offset)
...
@@ -57,7 +57,6 @@ sys_pread(int fd, void *ubuf, size_t count, off_t offset)
{
{
sref
<
file
>
f
;
sref
<
file
>
f
;
uptr
i
=
(
uptr
)
ubuf
;
uptr
i
=
(
uptr
)
ubuf
;
int
r
;
if
(
!
getfile
(
fd
,
&
f
))
if
(
!
getfile
(
fd
,
&
f
))
return
-
1
;
return
-
1
;
...
@@ -66,15 +65,7 @@ sys_pread(int fd, void *ubuf, size_t count, off_t offset)
...
@@ -66,15 +65,7 @@ sys_pread(int fd, void *ubuf, size_t count, off_t offset)
if
(
pagefault
(
myproc
()
->
vmap
,
va
,
0
)
<
0
)
if
(
pagefault
(
myproc
()
->
vmap
,
va
,
0
)
<
0
)
return
-
1
;
return
-
1
;
if
(
f
->
type
==
file
::
FD_INODE
){
return
f
->
pread
((
char
*
)
ubuf
,
count
,
offset
);
ilock
(
f
->
ip
,
0
);
if
(
f
->
ip
->
type
==
0
)
panic
(
"fileread"
);
r
=
readi
(
f
->
ip
,
(
char
*
)
ubuf
,
offset
,
count
);
iunlock
(
f
->
ip
);
return
r
;
}
return
-
1
;
}
}
long
long
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论