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
ba6cd8a6
Commit
ba6cd8a6
authored
15 years ago
by
rsc
Browse files
Options
Downloads
Patches
Plain Diff
drop NADDRS and INDIRECT; too many names
parent
030a4773
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
fs.c
+6
-6
6 additions, 6 deletions
fs.c
fs.h
+2
-4
2 additions, 4 deletions
fs.h
fsvar.h
+1
-1
1 addition, 1 deletion
fsvar.h
mkfs.c
+4
-4
4 additions, 4 deletions
mkfs.c
with
13 additions
and
15 deletions
fs.c
+
6
−
6
View file @
ba6cd8a6
...
...
@@ -335,10 +335,10 @@ bmap(struct inode *ip, uint bn, int alloc)
if
(
bn
<
NINDIRECT
){
// Load indirect block, allocating if necessary.
if
((
addr
=
ip
->
addrs
[
I
NDIRECT
])
==
0
){
if
((
addr
=
ip
->
addrs
[
NDIRECT
])
==
0
){
if
(
!
alloc
)
return
-
1
;
ip
->
addrs
[
I
NDIRECT
]
=
addr
=
balloc
(
ip
->
dev
);
ip
->
addrs
[
NDIRECT
]
=
addr
=
balloc
(
ip
->
dev
);
}
bp
=
bread
(
ip
->
dev
,
addr
);
a
=
(
uint
*
)
bp
->
data
;
...
...
@@ -375,16 +375,16 @@ itrunc(struct inode *ip)
}
}
if
(
ip
->
addrs
[
I
NDIRECT
]){
bp
=
bread
(
ip
->
dev
,
ip
->
addrs
[
I
NDIRECT
]);
if
(
ip
->
addrs
[
NDIRECT
]){
bp
=
bread
(
ip
->
dev
,
ip
->
addrs
[
NDIRECT
]);
a
=
(
uint
*
)
bp
->
data
;
for
(
j
=
0
;
j
<
NINDIRECT
;
j
++
){
if
(
a
[
j
])
bfree
(
ip
->
dev
,
a
[
j
]);
}
brelse
(
bp
);
bfree
(
ip
->
dev
,
ip
->
addrs
[
I
NDIRECT
]);
ip
->
addrs
[
I
NDIRECT
]
=
0
;
bfree
(
ip
->
dev
,
ip
->
addrs
[
NDIRECT
]);
ip
->
addrs
[
NDIRECT
]
=
0
;
}
ip
->
size
=
0
;
...
...
This diff is collapsed.
Click to expand it.
fs.h
+
2
−
4
View file @
ba6cd8a6
...
...
@@ -15,11 +15,9 @@ struct superblock {
uint
ninodes
;
// Number of inodes.
};
#define NADDRS (NDIRECT+1)
#define NDIRECT 12
#define INDIRECT 12
#define NINDIRECT (BSIZE / sizeof(uint))
#define MAXFILE (NDIRECT
+ NINDIRECT)
#define MAXFILE (NDIRECT + NINDIRECT)
// On-disk inode structure
struct
dinode
{
...
...
@@ -28,7 +26,7 @@ struct dinode {
short
minor
;
// Minor device number (T_DEV only)
short
nlink
;
// Number of links to inode in file system
uint
size
;
// Size of file (bytes)
uint
addrs
[
N
ADDRS
];
// Data block addresses
uint
addrs
[
N
DIRECT
+
1
];
// Data block addresses
};
// Inodes per block.
...
...
This diff is collapsed.
Click to expand it.
fsvar.h
+
1
−
1
View file @
ba6cd8a6
...
...
@@ -11,7 +11,7 @@ struct inode {
short
minor
;
short
nlink
;
uint
size
;
uint
addrs
[
N
ADDRS
];
uint
addrs
[
N
DIRECT
+
1
];
};
#define I_BUSY 0x1
...
...
This diff is collapsed.
Click to expand it.
mkfs.c
+
4
−
4
View file @
ba6cd8a6
...
...
@@ -259,17 +259,17 @@ iappend(uint inum, void *xp, int n)
}
x
=
xint
(
din
.
addrs
[
fbn
]);
}
else
{
if
(
xint
(
din
.
addrs
[
I
NDIRECT
])
==
0
)
{
if
(
xint
(
din
.
addrs
[
NDIRECT
])
==
0
)
{
// printf("allocate indirect block\n");
din
.
addrs
[
I
NDIRECT
]
=
xint
(
freeblock
++
);
din
.
addrs
[
NDIRECT
]
=
xint
(
freeblock
++
);
usedblocks
++
;
}
// printf("read indirect block\n");
rsect
(
xint
(
din
.
addrs
[
I
NDIRECT
]),
(
char
*
)
indirect
);
rsect
(
xint
(
din
.
addrs
[
NDIRECT
]),
(
char
*
)
indirect
);
if
(
indirect
[
fbn
-
NDIRECT
]
==
0
)
{
indirect
[
fbn
-
NDIRECT
]
=
xint
(
freeblock
++
);
usedblocks
++
;
wsect
(
xint
(
din
.
addrs
[
I
NDIRECT
]),
(
char
*
)
indirect
);
wsect
(
xint
(
din
.
addrs
[
NDIRECT
]),
(
char
*
)
indirect
);
}
x
=
xint
(
indirect
[
fbn
-
NDIRECT
]);
}
...
...
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