Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CSEP551
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
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
895af77f
Commit
895af77f
authored
10 years ago
by
Frans Kaashoek
Browse files
Options
Downloads
Patches
Plain Diff
check blockno passed to idestart
parent
c24ac5d7
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
ide.c
+3
-1
3 additions, 1 deletion
ide.c
mkfs.c
+5
-8
5 additions, 8 deletions
mkfs.c
param.h
+1
-0
1 addition, 0 deletions
param.h
with
9 additions
and
9 deletions
ide.c
+
3
−
1
View file @
895af77f
...
...
@@ -48,7 +48,7 @@ void
ideinit
(
void
)
{
int
i
;
initlock
(
&
idelock
,
"ide"
);
picenable
(
IRQ_IDE
);
ioapicenable
(
IRQ_IDE
,
ncpu
-
1
);
...
...
@@ -73,6 +73,8 @@ idestart(struct buf *b)
{
if
(
b
==
0
)
panic
(
"idestart"
);
if
(
b
->
blockno
>=
FSSIZE
)
panic
(
"incorrect blockno"
);
int
sector_per_block
=
BSIZE
/
SECTOR_SIZE
;
int
sector
=
b
->
blockno
*
sector_per_block
;
...
...
This diff is collapsed.
Click to expand it.
mkfs.c
+
5
−
8
View file @
895af77f
...
...
@@ -13,13 +13,12 @@
#define static_assert(a, b) do { switch (0) case 0: case (a): ; } while (0)
#define SIZE 1000
#define NINODES 200
// Disk layout:
// [ boot block | sb block | inode blocks | bit map | data blocks | log ]
int
nbitmap
=
SIZE
/
(
BSIZE
*
8
)
+
1
;
int
nbitmap
=
FS
SIZE
/
(
BSIZE
*
8
)
+
1
;
int
ninodeblocks
=
NINODES
/
IPB
+
1
;
int
nlog
=
LOGSIZE
;
int
nmeta
;
// Number of meta blocks (inode, bitmap, and 2 extra)
...
...
@@ -90,18 +89,18 @@ main(int argc, char *argv[])
}
nmeta
=
2
+
ninodeblocks
+
nbitmap
;
nblocks
=
SIZE
-
nlog
-
nmeta
;
nblocks
=
FS
SIZE
-
nlog
-
nmeta
;
sb
.
size
=
xint
(
SIZE
);
sb
.
size
=
xint
(
FS
SIZE
);
sb
.
nblocks
=
xint
(
nblocks
);
// so whole disk is size sectors
sb
.
ninodes
=
xint
(
NINODES
);
sb
.
nlog
=
xint
(
nlog
);
printf
(
"nmeta %d (boot, super, inode blocks %u, bitmap blocks %u) blocks %d log %u total %d
\n
"
,
nmeta
,
ninodeblocks
,
nbitmap
,
nblocks
,
nlog
,
SIZE
);
printf
(
"nmeta %d (boot, super, inode blocks %u, bitmap blocks %u) blocks %d log %u total %d
\n
"
,
nmeta
,
ninodeblocks
,
nbitmap
,
nblocks
,
nlog
,
FS
SIZE
);
freeblock
=
nmeta
;
// the first free block that we can allocate
for
(
i
=
0
;
i
<
SIZE
;
i
++
)
for
(
i
=
0
;
i
<
FS
SIZE
;
i
++
)
wsect
(
i
,
zeroes
);
memset
(
buf
,
0
,
sizeof
(
buf
));
...
...
@@ -164,7 +163,6 @@ main(int argc, char *argv[])
void
wsect
(
uint
sec
,
void
*
buf
)
{
printf
(
"seek to %d
\n
"
,
sec
*
BSIZE
);
if
(
lseek
(
fsfd
,
sec
*
BSIZE
,
0
)
!=
sec
*
BSIZE
){
perror
(
"lseek"
);
exit
(
1
);
...
...
@@ -183,7 +181,6 @@ winode(uint inum, struct dinode *ip)
struct
dinode
*
dip
;
bn
=
IBLOCK
(
inum
);
printf
(
"winode %d
\n
"
,
bn
);
rsect
(
bn
,
buf
);
dip
=
((
struct
dinode
*
)
buf
)
+
(
inum
%
IPB
);
*
dip
=
*
ip
;
...
...
This diff is collapsed.
Click to expand it.
param.h
+
1
−
0
View file @
895af77f
...
...
@@ -10,4 +10,5 @@
#define MAXOPBLOCKS 10 // max # of blocks any FS op writes
#define LOGSIZE (MAXOPBLOCKS*3) // max data blocks in on-disk log
#define NBUF (MAXOPBLOCKS*3) // size of disk block cache
#define FSSIZE 1000 // size of file system in blocks
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