Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
e2a620da
提交
e2a620da
8月 20, 2007
创建
作者:
rsc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
checkpoint - simpler namei interface
上级
ef30c2c7
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
135 行增加
和
121 行删除
+135
-121
defs.h
defs.h
+4
-2
fs.c
fs.c
+86
-84
proc.c
proc.c
+9
-4
sysfile.c
sysfile.c
+36
-31
没有找到文件。
defs.h
浏览文件 @
e2a620da
...
@@ -128,12 +128,14 @@ void itrunc(struct inode*);
...
@@ -128,12 +128,14 @@ void itrunc(struct inode*);
void
idecref
(
struct
inode
*
);
void
idecref
(
struct
inode
*
);
struct
inode
*
iincref
(
struct
inode
*
);
struct
inode
*
iincref
(
struct
inode
*
);
void
iput
(
struct
inode
*
);
void
iput
(
struct
inode
*
);
struct
inode
*
namei
(
char
*
,
int
,
uint
*
,
char
**
,
struct
inode
**
);
struct
inode
*
namei
(
char
*
);
struct
inode
*
nameiparent
(
char
*
,
char
**
,
int
*
);
void
stati
(
struct
inode
*
,
struct
stat
*
);
void
stati
(
struct
inode
*
,
struct
stat
*
);
int
readi
(
struct
inode
*
,
char
*
,
uint
,
uint
);
int
readi
(
struct
inode
*
,
char
*
,
uint
,
uint
);
int
writei
(
struct
inode
*
,
char
*
,
uint
,
uint
);
int
writei
(
struct
inode
*
,
char
*
,
uint
,
uint
);
struct
inode
*
mknod
(
char
*
,
short
,
short
,
short
);
struct
inode
*
mknod
(
char
*
,
short
,
short
,
short
);
struct
inode
*
mknod1
(
struct
inode
*
,
char
*
,
short
,
short
,
short
);
struct
inode
*
dircreat
(
struct
inode
*
,
char
*
,
int
,
short
,
short
,
short
);
int
dirlookup
(
struct
inode
*
,
char
*
,
int
,
uint
*
,
uint
*
);
int
unlink
(
char
*
);
int
unlink
(
char
*
);
void
iupdate
(
struct
inode
*
);
void
iupdate
(
struct
inode
*
);
int
link
(
char
*
,
char
*
);
int
link
(
char
*
,
char
*
);
...
...
fs.c
浏览文件 @
e2a620da
...
@@ -465,7 +465,7 @@ writei(struct inode *ip, char *src, uint off, uint n)
...
@@ -465,7 +465,7 @@ writei(struct inode *ip, char *src, uint off, uint n)
// set *poff to the byte offset of the directory entry
// set *poff to the byte offset of the directory entry
// set *pinum to the inode number
// set *pinum to the inode number
// return 0.
// return 0.
static
int
int
dirlookup
(
struct
inode
*
dp
,
char
*
name
,
int
namelen
,
uint
*
poff
,
uint
*
pinum
)
dirlookup
(
struct
inode
*
dp
,
char
*
name
,
int
namelen
,
uint
*
poff
,
uint
*
pinum
)
{
{
uint
off
;
uint
off
;
...
@@ -485,8 +485,10 @@ dirlookup(struct inode *dp, char *name, int namelen, uint *poff, uint *pinum)
...
@@ -485,8 +485,10 @@ dirlookup(struct inode *dp, char *name, int namelen, uint *poff, uint *pinum)
if
(
memcmp
(
name
,
de
->
name
,
namelen
)
==
0
&&
if
(
memcmp
(
name
,
de
->
name
,
namelen
)
==
0
&&
(
namelen
==
DIRSIZ
||
de
->
name
[
namelen
]
==
0
)){
(
namelen
==
DIRSIZ
||
de
->
name
[
namelen
]
==
0
)){
// entry matches path element
// entry matches path element
*
poff
=
off
+
(
uchar
*
)
de
-
bp
->
data
;
if
(
poff
)
*
pinum
=
de
->
inum
;
*
poff
=
off
+
(
uchar
*
)
de
-
bp
->
data
;
if
(
pinum
)
*
pinum
=
de
->
inum
;
brelse
(
bp
);
brelse
(
bp
);
return
0
;
return
0
;
}
}
...
@@ -499,9 +501,9 @@ dirlookup(struct inode *dp, char *name, int namelen, uint *poff, uint *pinum)
...
@@ -499,9 +501,9 @@ dirlookup(struct inode *dp, char *name, int namelen, uint *poff, uint *pinum)
// Write a new directory entry (name, ino) into the directory dp.
// Write a new directory entry (name, ino) into the directory dp.
// Caller must have locked dp.
// Caller must have locked dp.
void
void
dirwrite
(
struct
inode
*
dp
,
char
*
name
,
uint
ino
)
dirwrite
(
struct
inode
*
dp
,
char
*
name
,
int
namelen
,
uint
ino
)
{
{
int
i
,
off
;
int
off
;
struct
dirent
de
;
struct
dirent
de
;
// Look for an empty dirent.
// Look for an empty dirent.
...
@@ -513,15 +515,37 @@ dirwrite(struct inode *dp, char *name, uint ino)
...
@@ -513,15 +515,37 @@ dirwrite(struct inode *dp, char *name, uint ino)
}
}
de
.
inum
=
ino
;
de
.
inum
=
ino
;
for
(
i
=
0
;
i
<
DIRSIZ
&&
name
[
i
];
i
++
)
if
(
namelen
>
DIRSIZ
)
de
.
name
[
i
]
=
name
[
i
]
;
namelen
=
DIRSIZ
;
for
(;
i
<
DIRSIZ
;
i
++
)
memmove
(
de
.
name
,
name
,
namelen
);
de
.
name
[
i
]
=
'\0'
;
memset
(
de
.
name
+
namelen
,
0
,
DIRSIZ
-
namelen
)
;
if
(
writei
(
dp
,
(
char
*
)
&
de
,
off
,
sizeof
(
de
))
!=
sizeof
(
de
))
if
(
writei
(
dp
,
(
char
*
)
&
de
,
off
,
sizeof
(
de
))
!=
sizeof
(
de
))
panic
(
"dirwrite"
);
panic
(
"dirwrite"
);
}
}
// Create a new inode named name inside dp
// and return its locked inode structure.
// If name already exists, return 0.
struct
inode
*
dircreat
(
struct
inode
*
dp
,
char
*
name
,
int
namelen
,
short
type
,
short
major
,
short
minor
)
{
struct
inode
*
ip
;
ip
=
ialloc
(
dp
->
dev
,
type
);
if
(
ip
==
0
)
return
0
;
ip
->
major
=
major
;
ip
->
minor
=
minor
;
ip
->
size
=
0
;
ip
->
nlink
=
1
;
iupdate
(
ip
);
dirwrite
(
dp
,
name
,
namelen
,
ip
->
inum
);
return
ip
;
}
// Paths
// Paths
// Skip over the next path element in path,
// Skip over the next path element in path,
...
@@ -564,21 +588,13 @@ skipelem(char *path, char **name, int *len)
...
@@ -564,21 +588,13 @@ skipelem(char *path, char **name, int *len)
// NAMEI_DELETE: return locked parent inode, offset of dirent in *ret_off.
// NAMEI_DELETE: return locked parent inode, offset of dirent in *ret_off.
// return 0 if name doesn't exist.
// return 0 if name doesn't exist.
struct
inode
*
struct
inode
*
namei
(
char
*
path
,
int
mode
,
uint
*
ret_off
,
_namei
(
char
*
path
,
int
parent
,
char
**
pname
,
int
*
pnamelen
)
char
**
ret_last
,
struct
inode
**
ret_ip
)
{
{
struct
inode
*
dp
;
struct
inode
*
dp
;
char
*
name
;
char
*
name
;
int
namelen
;
int
namelen
;
uint
off
,
dev
,
inum
;
uint
off
,
dev
,
inum
;
if
(
ret_off
)
*
ret_off
=
0xffffffff
;
if
(
ret_last
)
*
ret_last
=
0
;
if
(
ret_ip
)
*
ret_ip
=
0
;
if
(
*
path
==
'/'
)
if
(
*
path
==
'/'
)
dp
=
igetroot
();
dp
=
igetroot
();
else
{
else
{
...
@@ -593,83 +609,63 @@ namei(char *path, int mode, uint *ret_off,
...
@@ -593,83 +609,63 @@ namei(char *path, int mode, uint *ret_off,
if
(
dp
->
type
!=
T_DIR
)
if
(
dp
->
type
!=
T_DIR
)
goto
fail
;
goto
fail
;
if
(
dirlookup
(
dp
,
name
,
namelen
,
&
off
,
&
inum
)
<
0
){
if
(
parent
&&
*
path
==
'\0'
){
if
(
mode
==
NAMEI_CREATE
&&
*
path
==
'\0'
){
// Stop one level early.
*
ret_last
=
name
;
*
pname
=
name
;
return
dp
;
*
pnamelen
=
namelen
;
}
goto
fail
;
}
if
(
mode
==
NAMEI_DELETE
&&
*
path
==
'\0'
){
// can't unlink . and ..
if
((
namelen
==
1
&&
memcmp
(
name
,
"."
,
1
)
==
0
)
||
(
namelen
==
2
&&
memcmp
(
name
,
".."
,
2
)
==
0
)){
goto
fail
;
}
*
ret_off
=
off
;
return
dp
;
return
dp
;
}
}
if
(
dirlookup
(
dp
,
name
,
namelen
,
&
off
,
&
inum
)
<
0
)
goto
fail
;
dev
=
dp
->
dev
;
dev
=
dp
->
dev
;
iput
(
dp
);
iput
(
dp
);
dp
=
iget
(
dev
,
inum
);
dp
=
iget
(
dev
,
inum
);
if
(
dp
->
type
==
0
||
dp
->
nlink
<
1
)
if
(
dp
->
type
==
0
||
dp
->
nlink
<
1
)
panic
(
"namei"
);
panic
(
"namei"
);
}
}
if
(
parent
)
if
(
mode
==
NAMEI_LOOKUP
)
return
dp
;
if
(
mode
==
NAMEI_CREATE
&&
ret_ip
){
*
ret_ip
=
dp
;
return
0
;
return
0
;
}
return
dp
;
goto
fail
;
fail:
fail:
iput
(
dp
);
iput
(
dp
);
return
0
;
return
0
;
}
}
// Create the path and return its locked inode structure.
// If cp already exists, return 0.
struct
inode
*
struct
inode
*
mknod
(
char
*
path
,
short
type
,
short
major
,
short
minor
)
namei
(
char
*
path
)
{
{
struct
inode
*
ip
,
*
dp
;
return
_namei
(
path
,
0
,
0
,
0
);
char
*
last
;
if
((
dp
=
namei
(
path
,
NAMEI_CREATE
,
0
,
&
last
,
0
))
==
0
)
return
0
;
ip
=
mknod1
(
dp
,
last
,
type
,
major
,
minor
);
iput
(
dp
);
return
ip
;
}
}
// Create a new inode named name inside dp
// and return its locked inode structure.
// If name already exists, return 0.
struct
inode
*
struct
inode
*
mknod1
(
struct
inode
*
dp
,
char
*
name
,
short
type
,
short
major
,
short
minor
)
nameiparent
(
char
*
path
,
char
**
name
,
int
*
namelen
)
{
{
struct
inode
*
ip
;
return
_namei
(
path
,
1
,
name
,
namelen
);
}
ip
=
ialloc
(
dp
->
dev
,
type
);
if
(
ip
==
0
)
return
0
;
ip
->
major
=
major
;
ip
->
minor
=
minor
;
ip
->
size
=
0
;
ip
->
nlink
=
1
;
iupdate
(
ip
);
// write new inode to disk
dirwrite
(
dp
,
name
,
ip
->
inum
);
// Create the path and return its locked inode structure.
// If cp already exists, return 0.
struct
inode
*
mknod
(
char
*
path
,
short
type
,
short
major
,
short
minor
)
{
struct
inode
*
ip
,
*
dp
;
char
*
name
;
int
namelen
;
if
((
dp
=
nameiparent
(
path
,
&
name
,
&
namelen
))
==
0
)
return
0
;
if
(
dirlookup
(
dp
,
name
,
namelen
,
0
,
0
)
>=
0
){
iput
(
dp
);
return
0
;
}
ip
=
dircreat
(
dp
,
name
,
namelen
,
type
,
major
,
minor
);
iput
(
dp
);
return
ip
;
return
ip
;
}
}
...
@@ -680,12 +676,15 @@ unlink(char *path)
...
@@ -680,12 +676,15 @@ unlink(char *path)
struct
inode
*
ip
,
*
dp
;
struct
inode
*
ip
,
*
dp
;
struct
dirent
de
;
struct
dirent
de
;
uint
off
,
inum
,
dev
;
uint
off
,
inum
,
dev
;
char
*
name
;
int
namelen
;
dp
=
namei
(
path
,
NAMEI_DELETE
,
&
off
,
0
,
0
);
if
((
dp
=
nameiparent
(
path
,
&
name
,
&
namelen
))
==
0
)
if
(
dp
==
0
)
return
-
1
;
return
-
1
;
if
(
dirlookup
(
dp
,
name
,
namelen
,
&
off
,
0
)
<
0
){
dev
=
dp
->
dev
;
iput
(
dp
);
return
-
1
;
}
if
(
readi
(
dp
,
(
char
*
)
&
de
,
off
,
sizeof
(
de
))
!=
sizeof
(
de
)
||
de
.
inum
==
0
)
if
(
readi
(
dp
,
(
char
*
)
&
de
,
off
,
sizeof
(
de
))
!=
sizeof
(
de
)
||
de
.
inum
==
0
)
panic
(
"unlink no entry"
);
panic
(
"unlink no entry"
);
...
@@ -702,16 +701,13 @@ unlink(char *path)
...
@@ -702,16 +701,13 @@ unlink(char *path)
if
(
writei
(
dp
,
(
char
*
)
&
de
,
off
,
sizeof
(
de
))
!=
sizeof
(
de
))
if
(
writei
(
dp
,
(
char
*
)
&
de
,
off
,
sizeof
(
de
))
!=
sizeof
(
de
))
panic
(
"unlink dir write"
);
panic
(
"unlink dir write"
);
iupdate
(
dp
)
;
dev
=
dp
->
dev
;
iput
(
dp
);
iput
(
dp
);
ip
=
iget
(
dev
,
inum
);
ip
=
iget
(
dev
,
inum
);
if
(
ip
->
nlink
<
1
)
if
(
ip
->
nlink
<
1
)
panic
(
"unlink nlink < 1"
);
panic
(
"unlink nlink < 1"
);
ip
->
nlink
--
;
ip
->
nlink
--
;
iupdate
(
ip
);
iupdate
(
ip
);
iput
(
ip
);
iput
(
ip
);
...
@@ -720,21 +716,26 @@ unlink(char *path)
...
@@ -720,21 +716,26 @@ unlink(char *path)
// Create the path new as a link to the same inode as old.
// Create the path new as a link to the same inode as old.
int
int
link
(
char
*
name1
,
char
*
name2
)
link
(
char
*
old
,
char
*
new
)
{
{
struct
inode
*
ip
,
*
dp
;
struct
inode
*
ip
,
*
dp
;
char
*
last
;
char
*
name
;
int
namelen
;
if
((
ip
=
namei
(
name1
,
NAMEI_LOOKUP
,
0
,
0
,
0
))
==
0
)
if
((
ip
=
namei
(
old
))
==
0
)
return
-
1
;
return
-
1
;
if
(
ip
->
type
==
T_DIR
){
if
(
ip
->
type
==
T_DIR
){
iput
(
ip
);
iput
(
ip
);
return
-
1
;
return
-
1
;
}
}
iunlock
(
ip
);
iunlock
(
ip
);
if
((
dp
=
namei
(
name2
,
NAMEI_CREATE
,
0
,
&
last
,
0
))
==
0
)
{
if
((
dp
=
nameiparent
(
new
,
&
name
,
&
namelen
))
==
0
){
idecref
(
ip
);
return
-
1
;
}
if
(
dirlookup
(
dp
,
name
,
namelen
,
0
,
0
)
>=
0
){
iput
(
dp
);
idecref
(
ip
);
idecref
(
ip
);
return
-
1
;
return
-
1
;
}
}
...
@@ -744,11 +745,12 @@ link(char *name1, char *name2)
...
@@ -744,11 +745,12 @@ link(char *name1, char *name2)
return
-
1
;
return
-
1
;
}
}
// LOCKING ERROR HERE! TWO LOCKS HELD AT ONCE.
ilock
(
ip
);
ilock
(
ip
);
ip
->
nlink
++
;
ip
->
nlink
++
;
iupdate
(
ip
);
iupdate
(
ip
);
dirwrite
(
dp
,
last
,
ip
->
inum
);
dirwrite
(
dp
,
name
,
namelen
,
ip
->
inum
);
iput
(
dp
);
iput
(
dp
);
iput
(
ip
);
iput
(
ip
);
...
...
proc.c
浏览文件 @
e2a620da
...
@@ -203,7 +203,6 @@ scheduler(void)
...
@@ -203,7 +203,6 @@ scheduler(void)
void
void
sched
(
void
)
sched
(
void
)
{
{
if
(
cp
->
state
==
RUNNING
)
if
(
cp
->
state
==
RUNNING
)
panic
(
"sched running"
);
panic
(
"sched running"
);
if
(
!
holding
(
&
proc_table_lock
))
if
(
!
holding
(
&
proc_table_lock
))
...
@@ -219,7 +218,6 @@ sched(void)
...
@@ -219,7 +218,6 @@ sched(void)
void
void
yield
(
void
)
yield
(
void
)
{
{
acquire
(
&
proc_table_lock
);
acquire
(
&
proc_table_lock
);
cp
->
state
=
RUNNABLE
;
cp
->
state
=
RUNNABLE
;
sched
();
sched
();
...
@@ -422,9 +420,10 @@ procdump(void)
...
@@ -422,9 +420,10 @@ procdump(void)
[
RUNNING
]
"run "
,
[
RUNNING
]
"run "
,
[
ZOMBIE
]
"zombie"
[
ZOMBIE
]
"zombie"
};
};
int
i
;
int
i
,
j
;
struct
proc
*
p
;
struct
proc
*
p
;
char
*
state
;
char
*
state
;
uint
pc
[
10
];
for
(
i
=
0
;
i
<
NPROC
;
i
++
)
{
for
(
i
=
0
;
i
<
NPROC
;
i
++
)
{
p
=
&
proc
[
i
];
p
=
&
proc
[
i
];
...
@@ -434,7 +433,13 @@ procdump(void)
...
@@ -434,7 +433,13 @@ procdump(void)
state
=
states
[
p
->
state
];
state
=
states
[
p
->
state
];
else
else
state
=
"???"
;
state
=
"???"
;
cprintf
(
"%d %s %s
\n
"
,
p
->
pid
,
state
,
p
->
name
);
cprintf
(
"%d %s %s"
,
p
->
pid
,
state
,
p
->
name
);
if
(
p
->
state
==
SLEEPING
)
{
getcallerpcs
((
uint
*
)
p
->
jmpbuf
.
ebp
+
2
,
pc
);
for
(
j
=
0
;
j
<
10
&&
pc
[
j
]
!=
0
;
j
++
)
cprintf
(
" %p"
,
pc
[
j
]);
}
cprintf
(
"
\n
"
);
}
}
}
}
sysfile.c
浏览文件 @
e2a620da
...
@@ -115,34 +115,41 @@ int
...
@@ -115,34 +115,41 @@ int
sys_open
(
void
)
sys_open
(
void
)
{
{
struct
inode
*
ip
,
*
dp
;
struct
inode
*
ip
,
*
dp
;
char
*
path
;
char
*
path
,
*
name
;
int
namelen
;
int
omode
;
int
omode
;
int
fd
;
int
fd
,
dev
;
uint
inum
;
struct
file
*
f
;
struct
file
*
f
;
char
*
last
;
if
(
argstr
(
0
,
&
path
)
<
0
||
argint
(
1
,
&
omode
)
<
0
)
if
(
argstr
(
0
,
&
path
)
<
0
||
argint
(
1
,
&
omode
)
<
0
)
return
-
1
;
return
-
1
;
if
(
omode
&
O_CREATE
){
switch
(
omode
&
O_CREATE
){
dp
=
namei
(
path
,
NAMEI_CREATE
,
0
,
&
last
,
&
ip
);
default:
if
(
dp
){
case
0
:
// regular open
ip
=
mknod1
(
dp
,
last
,
T_FILE
,
0
,
0
);
if
((
ip
=
namei
(
path
))
==
0
)
iput
(
dp
);
if
(
ip
==
0
)
return
-
1
;
}
else
if
(
ip
==
0
){
return
-
1
;
return
-
1
;
}
else
if
(
ip
->
type
==
T_DIR
){
break
;
iput
(
ip
);
case
O_CREATE
:
if
((
dp
=
nameiparent
(
path
,
&
name
,
&
namelen
))
==
0
)
return
-
1
;
return
-
1
;
if
(
dirlookup
(
dp
,
name
,
namelen
,
0
,
&
inum
)
>=
0
){
dev
=
dp
->
dev
;
iput
(
dp
);
ip
=
iget
(
dev
,
inum
);
}
else
{
if
((
ip
=
dircreat
(
dp
,
name
,
namelen
,
T_FILE
,
0
,
0
))
==
0
){
iput
(
dp
);
return
-
1
;
}
iput
(
dp
);
}
}
}
else
{
break
;
ip
=
namei
(
path
,
NAMEI_LOOKUP
,
0
,
0
,
0
);
if
(
ip
==
0
)
return
-
1
;
}
}
if
(
ip
->
type
==
T_DIR
&&
((
omode
&
O_RDWR
)
||
(
omode
&
O_WRONLY
))){
if
(
ip
->
type
==
T_DIR
&&
(
omode
&
(
O_RDWR
|
O_WRONLY
|
O_CREATE
))){
iput
(
ip
);
iput
(
ip
);
return
-
1
;
return
-
1
;
}
}
...
@@ -201,18 +208,22 @@ sys_mkdir(void)
...
@@ -201,18 +208,22 @@ sys_mkdir(void)
{
{
struct
inode
*
nip
;
struct
inode
*
nip
;
struct
inode
*
dp
;
struct
inode
*
dp
;
char
*
path
;
char
*
name
,
*
path
;
struct
dirent
de
;
struct
dirent
de
;
char
*
last
;
int
namelen
;
if
(
argstr
(
0
,
&
path
)
<
0
)
if
(
argstr
(
0
,
&
path
)
<
0
)
return
-
1
;
return
-
1
;
dp
=
namei
(
path
,
NAMEI_CREATE
,
0
,
&
last
,
0
);
dp
=
namei
parent
(
path
,
&
name
,
&
namelen
);
if
(
dp
==
0
)
if
(
dp
==
0
)
return
-
1
;
return
-
1
;
if
(
dirlookup
(
dp
,
name
,
namelen
,
0
,
0
)
>=
0
){
iput
(
dp
);
return
-
1
;
}
nip
=
mknod1
(
dp
,
last
,
T_DIR
,
0
,
0
);
nip
=
dircreat
(
dp
,
name
,
namelen
,
T_DIR
,
0
,
0
);
if
(
nip
==
0
){
if
(
nip
==
0
){
iput
(
dp
);
iput
(
dp
);
return
-
1
;
return
-
1
;
...
@@ -245,22 +256,17 @@ sys_chdir(void)
...
@@ -245,22 +256,17 @@ sys_chdir(void)
if
(
argstr
(
0
,
&
path
)
<
0
)
if
(
argstr
(
0
,
&
path
)
<
0
)
return
-
1
;
return
-
1
;
if
((
ip
=
namei
(
path
,
NAMEI_LOOKUP
,
0
,
0
,
0
))
==
0
)
if
((
ip
=
namei
(
path
))
==
0
)
return
-
1
;
return
-
1
;
if
(
ip
==
cp
->
cwd
)
{
iput
(
ip
);
return
0
;
}
if
(
ip
->
type
!=
T_DIR
)
{
if
(
ip
->
type
!=
T_DIR
)
{
iput
(
ip
);
iput
(
ip
);
return
-
1
;
return
-
1
;
}
}
iunlock
(
ip
);
idecref
(
cp
->
cwd
);
idecref
(
cp
->
cwd
);
cp
->
cwd
=
ip
;
cp
->
cwd
=
ip
;
iunlock
(
cp
->
cwd
);
return
0
;
return
0
;
}
}
...
@@ -324,8 +330,7 @@ sys_exec(void)
...
@@ -324,8 +330,7 @@ sys_exec(void)
if
(
argstr
(
0
,
&
path
)
<
0
||
argint
(
1
,
(
int
*
)
&
argv
)
<
0
)
if
(
argstr
(
0
,
&
path
)
<
0
||
argint
(
1
,
(
int
*
)
&
argv
)
<
0
)
return
-
1
;
return
-
1
;
ip
=
namei
(
path
,
NAMEI_LOOKUP
,
0
,
0
,
0
);
if
((
ip
=
namei
(
path
))
==
0
)
if
(
ip
==
0
)
return
-
1
;
return
-
1
;
if
(
readi
(
ip
,
(
char
*
)
&
elf
,
0
,
sizeof
(
elf
))
<
sizeof
(
elf
))
if
(
readi
(
ip
,
(
char
*
)
&
elf
,
0
,
sizeof
(
elf
))
<
sizeof
(
elf
))
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论