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
bdb66433
Commit
bdb66433
authored
18 years ago
by
kaashoek
Browse files
Options
Downloads
Patches
Plain Diff
set size for directories correctly in wdir and mkfs
mkdir ls shows stat info for each dir entry
parent
d15f0d10
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
fs.c
+2
-1
2 additions, 1 deletion
fs.c
ls.c
+11
-9
11 additions, 9 deletions
ls.c
mkfs.c
+10
-1
10 additions, 1 deletion
mkfs.c
syscall.c
+11
-1
11 additions, 1 deletion
syscall.c
ulib.c
+2
-2
2 additions, 2 deletions
ulib.c
with
36 additions
and
14 deletions
fs.c
+
2
−
1
View file @
bdb66433
...
...
@@ -355,7 +355,8 @@ writei(struct inode *ip, char *addr, uint off, uint n)
}
if
(
r
>
0
)
{
if
(
off
>
ip
->
size
)
{
ip
->
size
=
off
;
if
(
ip
->
type
==
T_DIR
)
ip
->
size
=
((
off
/
BSIZE
)
+
1
)
*
BSIZE
;
else
ip
->
size
=
off
;
}
iupdate
(
ip
);
}
...
...
This diff is collapsed.
Click to expand it.
ls.c
+
11
−
9
View file @
bdb66433
...
...
@@ -12,6 +12,7 @@ main(int argc, char *argv[])
{
int
fd
;
uint
off
;
uint
sz
;
if
(
argc
>
1
){
puts
(
"Usage: ls
\n
"
);
...
...
@@ -30,18 +31,19 @@ main(int argc, char *argv[])
if
(
st
.
st_type
!=
T_DIR
)
{
printf
(
2
,
"ls: . is not a dir
\n
"
);
}
cprintf
(
"size %d
\n
"
,
st
.
st_size
)
;
for
(
off
=
0
;
off
<
s
t
.
st_size
;
off
+=
sizeof
(
struct
dirent
))
{
sz
=
st
.
st_size
;
for
(
off
=
0
;
off
<
s
z
;
off
+=
sizeof
(
struct
dirent
))
{
if
(
read
(
fd
,
&
dirent
,
sizeof
(
struct
dirent
))
!=
sizeof
(
struct
dirent
))
{
printf
(
2
,
"ls: read error
\n
"
);
exit
()
;
printf
(
1
,
"ls: read error
\n
"
);
break
;
}
if
(
dirent
.
inum
!=
0
)
{
if
(
stat
(
dirent
.
name
,
&
st
)
<
0
)
printf
(
2
,
"stat: failed
\n
"
);
printf
(
1
,
"%s t %d
\n
"
,
dirent
.
name
,
st
.
st_type
);
if
(
stat
(
dirent
.
name
,
&
st
)
<
0
)
{
printf
(
1
,
"stat: failed
\n
"
);
break
;
}
printf
(
1
,
"%s t %d ino %d sz %d
\n
"
,
dirent
.
name
,
st
.
st_type
,
dirent
.
inum
,
st
.
st_size
);
}
}
close
(
fd
);
...
...
This diff is collapsed.
Click to expand it.
mkfs.c
+
10
−
1
View file @
bdb66433
...
...
@@ -23,6 +23,7 @@ uint freeinode = 1;
void
balloc
(
int
);
void
wsect
(
uint
,
void
*
);
void
winode
(
uint
,
struct
dinode
*
);
void
rinode
(
uint
inum
,
struct
dinode
*
ip
);
void
rsect
(
uint
sec
,
void
*
buf
);
uint
ialloc
(
ushort
type
);
void
iappend
(
uint
inum
,
void
*
p
,
int
n
);
...
...
@@ -53,9 +54,10 @@ xint(uint x)
main
(
int
argc
,
char
*
argv
[])
{
int
i
,
cc
,
fd
;
uint
bn
,
rootino
,
inum
;
uint
bn
,
rootino
,
inum
,
off
;
struct
dirent
de
;
char
buf
[
512
];
struct
dinode
din
;
if
(
argc
<
2
){
fprintf
(
stderr
,
"Usage: mkfs fs.img files...
\n
"
);
...
...
@@ -122,6 +124,13 @@ main(int argc, char *argv[])
close
(
fd
);
}
// fix size of root inode dir
rinode
(
rootino
,
&
din
);
off
=
xint
(
din
.
size
);
off
=
((
off
/
BSIZE
)
+
1
)
*
BSIZE
;
din
.
size
=
xint
(
off
);
winode
(
rootino
,
&
din
);
balloc
(
usedblocks
);
exit
(
0
);
...
...
This diff is collapsed.
Click to expand it.
syscall.c
+
11
−
1
View file @
bdb66433
...
...
@@ -294,8 +294,10 @@ sys_mkdir(void)
{
struct
proc
*
cp
=
curproc
[
cpu
()];
struct
inode
*
nip
;
struct
inode
*
pip
;
uint
arg0
;
int
l
;
struct
dirent
de
;
if
(
fetcharg
(
0
,
&
arg0
)
<
0
)
return
-
1
;
...
...
@@ -308,7 +310,15 @@ sys_mkdir(void)
nip
=
mknod
(
cp
->
mem
+
arg0
,
T_DIR
,
0
,
0
);
// XXX put . and .. in
de
.
name
[
0
]
=
'.'
;
de
.
inum
=
nip
->
inum
;
writei
(
nip
,
(
char
*
)
&
de
,
0
,
sizeof
(
de
));
pip
=
namei
(
"."
,
NAMEI_LOOKUP
,
0
);
de
.
inum
=
pip
->
inum
;
de
.
name
[
1
]
=
'.'
;
iput
(
pip
);
writei
(
nip
,
(
char
*
)
&
de
,
sizeof
(
de
),
sizeof
(
de
));
iput
(
nip
);
return
(
nip
==
0
)
?
-
1
:
0
;
...
...
This diff is collapsed.
Click to expand it.
ulib.c
+
2
−
2
View file @
bdb66433
...
...
@@ -61,11 +61,11 @@ gets(char *buf, int max)
int
stat
(
char
*
n
,
struct
stat
*
st
)
{
int
fd
=
open
(
n
,
O_RDONLY
)
;
int
fd
;
int
r
;
fd
=
open
(
n
,
O_RDONLY
);
if
(
fd
<
0
)
return
-
1
;
r
=
fstat
(
fd
,
st
);
close
(
fd
);
return
r
;
...
...
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