Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
e69077a7
提交
e69077a7
2月 10, 2012
创建
作者:
Nickolai Zeldovich
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
sysfile.cc
上级
60205a16
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
10 行增加
和
7 行删除
+10
-7
fs.c
fs.c
+1
-1
kernel.h
kernel.h
+3
-3
sysfile.cc
sysfile.cc
+6
-3
没有找到文件。
fs.c
浏览文件 @
e69077a7
...
@@ -658,7 +658,7 @@ dirlookup(struct inode *dp, char *name)
...
@@ -658,7 +658,7 @@ dirlookup(struct inode *dp, char *name)
// Write a new directory entry (name, inum) into the directory dp.
// Write a new directory entry (name, inum) into the directory dp.
int
int
dirlink
(
struct
inode
*
dp
,
char
*
name
,
u32
inum
)
dirlink
(
struct
inode
*
dp
,
c
onst
c
har
*
name
,
u32
inum
)
{
{
dir_init
(
dp
);
dir_init
(
dp
);
...
...
kernel.h
浏览文件 @
e69077a7
...
@@ -112,7 +112,7 @@ void stati(struct inode*, struct stat*);
...
@@ -112,7 +112,7 @@ void stati(struct inode*, struct stat*);
int
writei
(
struct
inode
*
,
char
*
,
u32
,
u32
);
int
writei
(
struct
inode
*
,
char
*
,
u32
,
u32
);
struct
inode
*
idup
(
struct
inode
*
);
struct
inode
*
idup
(
struct
inode
*
);
struct
inode
*
nameiparent
(
char
*
,
char
*
);
struct
inode
*
nameiparent
(
char
*
,
char
*
);
int
dirlink
(
struct
inode
*
,
char
*
,
u32
);
int
dirlink
(
struct
inode
*
,
c
onst
c
har
*
,
u32
);
void
dir_init
(
struct
inode
*
dp
);
void
dir_init
(
struct
inode
*
dp
);
void
dir_flush
(
struct
inode
*
dp
);
void
dir_flush
(
struct
inode
*
dp
);
...
@@ -199,7 +199,7 @@ struct nskey {
...
@@ -199,7 +199,7 @@ struct nskey {
u64
b
;
u64
b
;
}
ii
;
}
ii
;
char
*
s
;
char
*
s
;
char
*
dirname
;
c
onst
c
har
*
dirname
;
struct
{
struct
{
u64
a
;
u64
a
;
u64
b
;
u64
b
;
...
@@ -211,7 +211,7 @@ struct nskey {
...
@@ -211,7 +211,7 @@ struct nskey {
#define KI(v) (struct nskey){type: nskey_int, u: { i: v }}
#define KI(v) (struct nskey){type: nskey_int, u: { i: v }}
#define KII(x,y) (struct nskey){.type=nskey_ii,.u.ii.a=x,.u.ii.b=y}
#define KII(x,y) (struct nskey){.type=nskey_ii,.u.ii.a=x,.u.ii.b=y}
#define KS(v) (struct nskey){.type=nskey_str,.u.s=v}
#define KS(v) (struct nskey){.type=nskey_str,.u.s=v}
#define KD(v) (struct nskey){
.type=nskey_dirname,.u.dirname=v
}
#define KD(v) (struct nskey){
type: nskey_dirname, u: { dirname: v }
}
#define KIIS(x,y,z) (struct nskey){.type=nskey_iis,.u.iis.a=x, \
#define KIIS(x,y,z) (struct nskey){.type=nskey_iis,.u.iis.a=x, \
.u.iis.b=y, \
.u.iis.b=y, \
.u.iis.s=z}
.u.iis.s=z}
...
...
sysfile.c
→
sysfile.c
c
浏览文件 @
e69077a7
extern
"C"
{
#include "types.h"
#include "types.h"
#include "stat.h"
#include "stat.h"
#include "mmu.h"
#include "mmu.h"
...
@@ -10,6 +11,8 @@
...
@@ -10,6 +11,8 @@
#include "file.h"
#include "file.h"
#include "fcntl.h"
#include "fcntl.h"
#include "cpu.h"
#include "cpu.h"
#include "net.h"
}
// Fetch the nth word-sized system call argument as a file descriptor
// Fetch the nth word-sized system call argument as a file descriptor
// and return both the descriptor and the corresponding struct file.
// and return both the descriptor and the corresponding struct file.
...
@@ -310,7 +313,7 @@ sys_open(void)
...
@@ -310,7 +313,7 @@ sys_open(void)
}
}
iunlock
(
ip
);
iunlock
(
ip
);
f
->
type
=
FD_INODE
;
f
->
type
=
file
::
FD_INODE
;
f
->
ip
=
ip
;
f
->
ip
=
ip
;
f
->
off
=
0
;
f
->
off
=
0
;
f
->
readable
=
!
(
omode
&
O_WRONLY
);
f
->
readable
=
!
(
omode
&
O_WRONLY
);
...
@@ -430,7 +433,7 @@ getsocket(int fd, struct file **ret)
...
@@ -430,7 +433,7 @@ getsocket(int fd, struct file **ret)
struct
file
*
f
;
struct
file
*
f
;
if
(
fd
<
0
||
fd
>=
NOFILE
||
(
f
=
myproc
()
->
ofile
[
fd
])
==
0
)
if
(
fd
<
0
||
fd
>=
NOFILE
||
(
f
=
myproc
()
->
ofile
[
fd
])
==
0
)
return
-
1
;
return
-
1
;
if
(
f
->
type
!=
FD_SOCKET
)
if
(
f
->
type
!=
file
::
FD_SOCKET
)
return
-
1
;
return
-
1
;
*
ret
=
f
;
*
ret
=
f
;
...
@@ -453,7 +456,7 @@ allocsocket(struct file **rf, int *rfd)
...
@@ -453,7 +456,7 @@ allocsocket(struct file **rf, int *rfd)
return
fd
;
return
fd
;
}
}
f
->
type
=
FD_SOCKET
;
f
->
type
=
file
::
FD_SOCKET
;
f
->
off
=
0
;
f
->
off
=
0
;
f
->
readable
=
1
;
f
->
readable
=
1
;
f
->
writable
=
1
;
f
->
writable
=
1
;
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论