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
20365348
Commit
20365348
authored
17 years ago
by
rtm
Browse files
Options
Downloads
Patches
Plain Diff
add missing iput() at end of _namei()
parent
b5551379
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
bootmain.c
+1
-1
1 addition, 1 deletion
bootmain.c
fs.c
+6
-4
6 additions, 4 deletions
fs.c
mkfs.c
+2
-2
2 additions, 2 deletions
mkfs.c
param.h
+1
-1
1 addition, 1 deletion
param.h
proc.h
+4
-8
4 additions, 8 deletions
proc.h
runoff
+1
-1
1 addition, 1 deletion
runoff
usertests.c
+95
-0
95 additions, 0 deletions
usertests.c
with
110 additions
and
17 deletions
bootmain.c
+
1
−
1
View file @
20365348
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
// BOOT UP STEPS
// BOOT UP STEPS
// * when the CPU boots it loads the BIOS into memory and executes it
// * when the CPU boots it loads the BIOS into memory and executes it
//
//
// * the BIOS intializes devices, sets
of
the interrupt routines, and
// * the BIOS intializes devices, sets
up
the interrupt routines, and
// reads the first sector of the boot device(e.g., hard-drive)
// reads the first sector of the boot device(e.g., hard-drive)
// into memory and jumps to it.
// into memory and jumps to it.
//
//
...
...
This diff is collapsed.
Click to expand it.
fs.c
+
6
−
4
View file @
20365348
...
@@ -475,6 +475,7 @@ namecmp(const char *s, const char *t)
...
@@ -475,6 +475,7 @@ namecmp(const char *s, const char *t)
// Look for a directory entry in a directory.
// Look for a directory entry in a directory.
// If found, set *poff to byte offset of entry.
// If found, set *poff to byte offset of entry.
// Caller must have already locked dp.
struct
uinode
*
struct
uinode
*
dirlookup
(
struct
inode
*
dp
,
char
*
name
,
uint
*
poff
)
dirlookup
(
struct
inode
*
dp
,
char
*
name
,
uint
*
poff
)
{
{
...
@@ -483,7 +484,7 @@ dirlookup(struct inode *dp, char *name, uint *poff)
...
@@ -483,7 +484,7 @@ dirlookup(struct inode *dp, char *name, uint *poff)
struct
dirent
*
de
;
struct
dirent
*
de
;
if
(
dp
->
type
!=
T_DIR
)
if
(
dp
->
type
!=
T_DIR
)
return
0
;
panic
(
"dirlookup not DIR"
)
;
for
(
off
=
0
;
off
<
dp
->
size
;
off
+=
BSIZE
){
for
(
off
=
0
;
off
<
dp
->
size
;
off
+=
BSIZE
){
bp
=
bread
(
dp
->
dev
,
bmap
(
dp
,
off
/
BSIZE
,
0
));
bp
=
bread
(
dp
->
dev
,
bmap
(
dp
,
off
/
BSIZE
,
0
));
...
@@ -558,7 +559,7 @@ dirlink(struct inode *dp, char *name, uint ino)
...
@@ -558,7 +559,7 @@ dirlink(struct inode *dp, char *name, uint ino)
//
//
// Examples:
// Examples:
// skipelem("a/bb/c", name) = "bb/c", setting name = "a"
// skipelem("a/bb/c", name) = "bb/c", setting name = "a"
// skipelem("///a/bb", name) = "b", setting name="a"
// skipelem("///a/bb", name) = "b
b
", setting name="a"
// skipelem("", name) = skipelem("////", name) = 0
// skipelem("", name) = skipelem("////", name) = 0
//
//
static
char
*
static
char
*
...
@@ -617,14 +618,15 @@ _namei(char *path, int parent, char *name)
...
@@ -617,14 +618,15 @@ _namei(char *path, int parent, char *name)
if
((
ipu
=
dirlookup
(
dp
,
name
,
&
off
))
==
0
){
if
((
ipu
=
dirlookup
(
dp
,
name
,
&
off
))
==
0
){
iput
(
iunlock
(
dp
));
iput
(
iunlock
(
dp
));
iput
(
ipu
);
return
0
;
return
0
;
}
}
iput
(
iunlock
(
dp
));
iput
(
iunlock
(
dp
));
dpu
=
ipu
;
dpu
=
ipu
;
}
}
if
(
parent
)
if
(
parent
){
iput
(
dpu
);
return
0
;
return
0
;
}
return
dpu
;
return
dpu
;
}
}
...
...
This diff is collapsed.
Click to expand it.
mkfs.c
+
2
−
2
View file @
20365348
...
@@ -8,8 +8,8 @@
...
@@ -8,8 +8,8 @@
#include
"param.h"
#include
"param.h"
#include
"fs.h"
#include
"fs.h"
int
nblocks
=
1008
;
int
nblocks
=
995
;
int
ninodes
=
1
00
;
int
ninodes
=
2
00
;
int
size
=
1024
;
int
size
=
1024
;
int
fsfd
;
int
fsfd
;
...
...
This diff is collapsed.
Click to expand it.
param.h
+
1
−
1
View file @
20365348
...
@@ -6,6 +6,6 @@
...
@@ -6,6 +6,6 @@
#define NFILE 100 // open files per system
#define NFILE 100 // open files per system
#define NBUF 10 // size of disk block cache
#define NBUF 10 // size of disk block cache
#define NREQUEST NBUF // outstanding disk requests
#define NREQUEST NBUF // outstanding disk requests
#define NINODE
10
0 // maximum number of active i-nodes
#define NINODE
5
0 // maximum number of active i-nodes
#define NDEV 10 // maximum major device number
#define NDEV 10 // maximum major device number
#define ROOTDEV 1 // device number of file system root disk
#define ROOTDEV 1 // device number of file system root disk
This diff is collapsed.
Click to expand it.
proc.h
+
4
−
8
View file @
20365348
...
@@ -43,19 +43,15 @@ struct proc {
...
@@ -43,19 +43,15 @@ struct proc {
char
name
[
16
];
// Process name (debugging)
char
name
[
16
];
// Process name (debugging)
};
};
// Process memory is laid out contiguously:
// Process memory is laid out contiguously
, low addresses first
:
// text
// text
// original data and bss
// original data and bss
// fixed-size stack
// fixed-size stack
// expandable heap
// expandable heap
// If xv6 was only for uniprocessors, this could be
// Arrange that cp point to the struct proc that this
// struct proc *cp;
// CPU is currently running. Such preprocessor
// Instead we have an array curproc, one per
// subterfuge can be confusing, but saves a lot of typing.
// processor, and #define cp to the right element
// in the array. In general such preprocessor
// subterfuge is to be avoided, but cp is used
// so often that having the shorthand is worth the ugliness.
extern
struct
proc
*
curproc
[
NCPU
];
// Current (running) process per CPU
extern
struct
proc
*
curproc
[
NCPU
];
// Current (running) process per CPU
#define cp (curproc[cpu()]) // Current process on this CPU
#define cp (curproc[cpu()]) // Current process on this CPU
...
...
This diff is collapsed.
Click to expand it.
runoff
+
1
−
1
View file @
20365348
...
@@ -18,7 +18,7 @@ files=`grep -v '^#' runoff.list | awk '{print $1}'`
...
@@ -18,7 +18,7 @@ files=`grep -v '^#' runoff.list | awk '{print $1}'`
n
=
99
n
=
99
for
i
in
$files
for
i
in
$files
do
do
runoff1
-n
$n
$i
>
fmt
/
$i
./
runoff1
-n
$n
$i
>
fmt
/
$i
nn
=
`
tail
-1
fmt
/
$i
|
sed
's/ .*//; s/^0*//'
`
nn
=
`
tail
-1
fmt
/
$i
|
sed
's/ .*//; s/^0*//'
`
if
[
"x
$nn
"
!=
x
]
;
then
if
[
"x
$nn
"
!=
x
]
;
then
n
=
$nn
n
=
$nn
...
...
This diff is collapsed.
Click to expand it.
usertests.c
+
95
−
0
View file @
20365348
...
@@ -1096,6 +1096,99 @@ rmdot(void)
...
@@ -1096,6 +1096,99 @@ rmdot(void)
printf
(
1
,
"rmdot ok
\n
"
);
printf
(
1
,
"rmdot ok
\n
"
);
}
}
void
dirfile
(
void
)
{
int
fd
;
printf
(
1
,
"dir vs file
\n
"
);
fd
=
open
(
"dirfile"
,
O_CREATE
);
if
(
fd
<
0
){
printf
(
1
,
"create dirfile failed
\n
"
);
exit
();
}
close
(
fd
);
if
(
chdir
(
"dirfile"
)
==
0
){
printf
(
1
,
"chdir dirfile succeeded!
\n
"
);
exit
();
}
fd
=
open
(
"dirfile/xx"
,
0
);
if
(
fd
>=
0
){
printf
(
1
,
"create dirfile/xx succeeded!
\n
"
);
exit
();
}
fd
=
open
(
"dirfile/xx"
,
O_CREATE
);
if
(
fd
>=
0
){
printf
(
1
,
"create dirfile/xx succeeded!
\n
"
);
exit
();
}
if
(
mkdir
(
"dirfile/xx"
)
==
0
){
printf
(
1
,
"mkdir dirfile/xx succeeded!
\n
"
);
exit
();
}
if
(
unlink
(
"dirfile/xx"
)
==
0
){
printf
(
1
,
"unlink dirfile/xx succeeded!
\n
"
);
exit
();
}
if
(
link
(
"README"
,
"dirfile/xx"
)
==
0
){
printf
(
1
,
"link to dirfile/xx succeeded!
\n
"
);
exit
();
}
if
(
unlink
(
"dirfile"
)
!=
0
){
printf
(
1
,
"unlink dirfile failed!
\n
"
);
exit
();
}
fd
=
open
(
"."
,
O_RDWR
);
if
(
fd
>=
0
){
printf
(
1
,
"open . for writing succeeded!
\n
"
);
exit
();
}
fd
=
open
(
"."
,
0
);
if
(
write
(
fd
,
"x"
,
1
)
>
0
){
printf
(
1
,
"write . succeeded!
\n
"
);
exit
();
}
close
(
fd
);
printf
(
1
,
"dir vs file OK
\n
"
);
}
// test that iput() is called at the end of _namei()
void
iref
(
void
)
{
int
i
,
fd
;
printf
(
1
,
"empty file name
\n
"
);
// the 50 is NINODE
for
(
i
=
0
;
i
<
50
+
1
;
i
++
){
if
(
mkdir
(
"irefd"
)
!=
0
){
printf
(
1
,
"mkdir irefd failed
\n
"
);
exit
();
}
if
(
chdir
(
"irefd"
)
!=
0
){
printf
(
1
,
"chdir irefd failed
\n
"
);
exit
();
}
mkdir
(
""
);
link
(
"README"
,
""
);
fd
=
open
(
""
,
O_CREATE
);
if
(
fd
>=
0
)
close
(
fd
);
fd
=
open
(
"xx"
,
O_CREATE
);
if
(
fd
>=
0
)
close
(
fd
);
unlink
(
"xx"
);
}
chdir
(
"/"
);
printf
(
1
,
"empty file name OK
\n
"
);
}
int
int
main
(
int
argc
,
char
*
argv
[])
main
(
int
argc
,
char
*
argv
[])
{
{
...
@@ -1128,6 +1221,8 @@ main(int argc, char *argv[])
...
@@ -1128,6 +1221,8 @@ main(int argc, char *argv[])
createdelete
();
createdelete
();
twofiles
();
twofiles
();
sharedfd
();
sharedfd
();
dirfile
();
iref
();
exectest
();
exectest
();
...
...
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