Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CSEP551
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Krishna Vinnakota
CSEP551
Commits
f3685aa3
Commit
f3685aa3
authored
15 years ago
by
rsc
Browse files
Options
Downloads
Patches
Plain Diff
simplify
parent
7f399cca
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
file.h
+1
-1
1 addition, 1 deletion
file.h
pipe.c
+2
-6
2 additions, 6 deletions
pipe.c
sysfile.c
+13
-22
13 additions, 22 deletions
sysfile.c
with
16 additions
and
29 deletions
file.h
+
1
−
1
View file @
f3685aa3
struct
file
{
enum
{
FD_CLOSED
,
FD_NONE
,
FD_PIPE
,
FD_INODE
}
type
;
enum
{
FD_NONE
,
FD_PIPE
,
FD_INODE
}
type
;
int
ref
;
// reference count
char
readable
;
char
writable
;
...
...
This diff is collapsed.
Click to expand it.
pipe.c
+
2
−
6
View file @
f3685aa3
...
...
@@ -47,14 +47,10 @@ pipealloc(struct file **f0, struct file **f1)
bad:
if
(
p
)
kfree
((
char
*
)
p
,
PAGE
);
if
(
*
f0
){
(
*
f0
)
->
type
=
FD_NONE
;
if
(
*
f0
)
fileclose
(
*
f0
);
}
if
(
*
f1
){
(
*
f1
)
->
type
=
FD_NONE
;
if
(
*
f1
)
fileclose
(
*
f1
);
}
return
-
1
;
}
...
...
This diff is collapsed.
Click to expand it.
sysfile.c
+
13
−
22
View file @
f3685aa3
...
...
@@ -127,17 +127,17 @@ sys_link(void)
iunlock
(
ip
);
if
((
dp
=
nameiparent
(
new
,
name
))
==
0
)
goto
bad
;
goto
bad
;
ilock
(
dp
);
if
(
dp
->
dev
!=
ip
->
dev
||
dirlink
(
dp
,
name
,
ip
->
inum
)
<
0
)
if
(
dp
->
dev
!=
ip
->
dev
||
dirlink
(
dp
,
name
,
ip
->
inum
)
<
0
){
iunlockput
(
dp
);
goto
bad
;
}
iunlockput
(
dp
);
iput
(
ip
);
return
0
;
bad:
if
(
dp
)
iunlockput
(
dp
);
ilock
(
ip
);
ip
->
nlink
--
;
iupdate
(
ip
);
...
...
@@ -212,7 +212,7 @@ sys_unlink(void)
}
static
struct
inode
*
create
(
char
*
path
,
int
canexist
,
short
type
,
short
major
,
short
minor
)
create
(
char
*
path
,
short
type
,
short
major
,
short
minor
)
{
uint
off
;
struct
inode
*
ip
,
*
dp
;
...
...
@@ -222,10 +222,10 @@ create(char *path, int canexist, short type, short major, short minor)
return
0
;
ilock
(
dp
);
if
(
canexist
&&
(
ip
=
dirlookup
(
dp
,
name
,
&
off
))
!=
0
){
if
((
ip
=
dirlookup
(
dp
,
name
,
&
off
))
!=
0
){
iunlockput
(
dp
);
ilock
(
ip
);
if
(
ip
->
type
!=
type
||
ip
->
major
!=
major
||
ip
->
minor
!=
minor
){
if
(
ip
->
type
!=
type
||
type
!=
T_FILE
){
iunlockput
(
ip
);
return
0
;
}
...
...
@@ -250,17 +250,8 @@ create(char *path, int canexist, short type, short major, short minor)
panic
(
"create dots"
);
}
if
(
dirlink
(
dp
,
name
,
ip
->
inum
)
<
0
){
if
(
type
==
T_DIR
){
dp
->
nlink
--
;
iupdate
(
dp
);
}
iunlockput
(
dp
);
ip
->
nlink
=
0
;
iunlockput
(
ip
);
return
0
;
}
if
(
dirlink
(
dp
,
name
,
ip
->
inum
)
<
0
)
panic
(
"create: dirlink"
);
iunlockput
(
dp
);
return
ip
;
...
...
@@ -278,13 +269,13 @@ sys_open(void)
return
-
1
;
if
(
omode
&
O_CREATE
){
if
((
ip
=
create
(
path
,
1
,
T_FILE
,
0
,
0
))
==
0
)
if
((
ip
=
create
(
path
,
T_FILE
,
0
,
0
))
==
0
)
return
-
1
;
}
else
{
if
((
ip
=
namei
(
path
))
==
0
)
return
-
1
;
ilock
(
ip
);
if
(
ip
->
type
==
T_DIR
&&
(
omode
&
(
O_RD
WR
|
O_WR
ONLY
)
))
{
if
(
ip
->
type
==
T_DIR
&&
omode
!=
O_RDONLY
){
iunlockput
(
ip
);
return
-
1
;
}
...
...
@@ -318,7 +309,7 @@ sys_mknod(void)
if
((
len
=
argstr
(
0
,
&
path
))
<
0
||
argint
(
1
,
&
major
)
<
0
||
argint
(
2
,
&
minor
)
<
0
||
(
ip
=
create
(
path
,
0
,
T_DEV
,
major
,
minor
))
==
0
)
(
ip
=
create
(
path
,
T_DEV
,
major
,
minor
))
==
0
)
return
-
1
;
iunlockput
(
ip
);
return
0
;
...
...
@@ -330,7 +321,7 @@ sys_mkdir(void)
char
*
path
;
struct
inode
*
ip
;
if
(
argstr
(
0
,
&
path
)
<
0
||
(
ip
=
create
(
path
,
0
,
T_DIR
,
0
,
0
))
==
0
)
if
(
argstr
(
0
,
&
path
)
<
0
||
(
ip
=
create
(
path
,
T_DIR
,
0
,
0
))
==
0
)
return
-
1
;
iunlockput
(
ip
);
return
0
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment