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
327cc21f
Commit
327cc21f
authored
13 years ago
by
Robert Morris
Browse files
Options
Downloads
Patches
Plain Diff
make dirlookup and dirlink more similar
parent
cd3d739e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
fs.c
+13
-18
13 additions, 18 deletions
fs.c
usertests.c
+53
-0
53 additions, 0 deletions
usertests.c
with
66 additions
and
18 deletions
fs.c
+
13
−
18
View file @
327cc21f
...
...
@@ -469,30 +469,25 @@ struct inode*
dirlookup
(
struct
inode
*
dp
,
char
*
name
,
uint
*
poff
)
{
uint
off
,
inum
;
struct
buf
*
bp
;
struct
dirent
*
de
;
struct
dirent
de
;
if
(
dp
->
type
!=
T_DIR
)
panic
(
"dirlookup not DIR"
);
for
(
off
=
0
;
off
<
dp
->
size
;
off
+=
BSIZE
){
bp
=
bread
(
dp
->
dev
,
bmap
(
dp
,
off
/
BSIZE
));
for
(
de
=
(
struct
dirent
*
)
bp
->
data
;
de
<
(
struct
dirent
*
)(
bp
->
data
+
BSIZE
);
de
++
){
if
(
de
->
inum
==
0
)
continue
;
if
(
namecmp
(
name
,
de
->
name
)
==
0
){
// entry matches path element
if
(
poff
)
*
poff
=
off
+
(
uchar
*
)
de
-
bp
->
data
;
inum
=
de
->
inum
;
brelse
(
bp
);
return
iget
(
dp
->
dev
,
inum
);
}
for
(
off
=
0
;
off
<
dp
->
size
;
off
+=
sizeof
(
de
)){
if
(
readi
(
dp
,
(
char
*
)
&
de
,
off
,
sizeof
(
de
))
!=
sizeof
(
de
))
panic
(
"dirlink read"
);
if
(
de
.
inum
==
0
)
continue
;
if
(
namecmp
(
name
,
de
.
name
)
==
0
){
// entry matches path element
if
(
poff
)
*
poff
=
off
;
inum
=
de
.
inum
;
return
iget
(
dp
->
dev
,
inum
);
}
brelse
(
bp
);
}
return
0
;
}
...
...
This diff is collapsed.
Click to expand it.
usertests.c
+
53
−
0
View file @
327cc21f
...
...
@@ -1529,6 +1529,59 @@ bigargtest(void)
wait
();
}
// what happens when the file system runs out of blocks?
// answer: balloc panics, so this test is not useful.
void
fsfull
()
{
int
nfiles
;
int
fsblocks
=
0
;
printf
(
1
,
"fsfull test
\n
"
);
for
(
nfiles
=
0
;
;
nfiles
++
){
char
name
[
64
];
name
[
0
]
=
'f'
;
name
[
1
]
=
'0'
+
nfiles
/
1000
;
name
[
2
]
=
'0'
+
(
nfiles
%
1000
)
/
100
;
name
[
3
]
=
'0'
+
(
nfiles
%
100
)
/
10
;
name
[
4
]
=
'0'
+
(
nfiles
%
10
);
name
[
5
]
=
'\0'
;
printf
(
1
,
"writing %s
\n
"
,
name
);
int
fd
=
open
(
name
,
O_CREATE
|
O_RDWR
);
if
(
fd
<
0
){
printf
(
1
,
"open %s failed
\n
"
,
name
);
break
;
}
int
total
=
0
;
while
(
1
){
int
cc
=
write
(
fd
,
buf
,
512
);
if
(
cc
<
512
)
break
;
total
+=
cc
;
fsblocks
++
;
}
printf
(
1
,
"wrote %d bytes
\n
"
,
total
);
close
(
fd
);
if
(
total
==
0
)
break
;
}
while
(
nfiles
>=
0
){
char
name
[
64
];
name
[
0
]
=
'f'
;
name
[
1
]
=
'0'
+
nfiles
/
1000
;
name
[
2
]
=
'0'
+
(
nfiles
%
1000
)
/
100
;
name
[
3
]
=
'0'
+
(
nfiles
%
100
)
/
10
;
name
[
4
]
=
'0'
+
(
nfiles
%
10
);
name
[
5
]
=
'\0'
;
unlink
(
name
);
nfiles
--
;
}
printf
(
1
,
"fsfull test finished
\n
"
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
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