Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ASA
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ASE-2021
ASA
Commits
42446ce8
Commit
42446ce8
authored
4 years ago
by
Thierno souleymane Bah
Browse files
Options
Downloads
Patches
Plain Diff
feat(init_volume function added)
parent
447d3063
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
tpfs/vol.c
+23
-3
23 additions, 3 deletions
tpfs/vol.c
tpfs/vol.h
+18
-1
18 additions, 1 deletion
tpfs/vol.h
with
41 additions
and
4 deletions
tpfs/vol.c
+
23
−
3
View file @
42446ce8
...
@@ -14,9 +14,9 @@ void load_mbr()
...
@@ -14,9 +14,9 @@ void load_mbr()
/* read_sector(buffer, 0, 0); */
/* read_sector(buffer, 0, 0); */
read_sector_n
(
buffer
,
0
,
0
,
sizeof
(
mbr_t
));
read_sector_n
(
buffer
,
0
,
0
,
sizeof
(
mbr_t
));
memcpy
(
&
mbr
,
buffer
,
sizeof
(
mbr_t
));
memcpy
(
&
mbr
,
buffer
,
sizeof
(
mbr_t
));
if
(
mbr
.
magic
!=
MBR_
MAGIC
)
if
(
mbr
.
magic
!=
MAGIC
)
{
{
mbr
.
magic
=
MBR_
MAGIC
;
mbr
.
magic
=
MAGIC
;
mbr
.
nb_vols
=
0
;
mbr
.
nb_vols
=
0
;
}
}
}
}
...
@@ -159,3 +159,23 @@ void remove_vol(int vol)
...
@@ -159,3 +159,23 @@ void remove_vol(int vol)
mbr
.
vols
[
i
]
=
mbr
.
vols
[
i
+
1
];
mbr
.
vols
[
i
]
=
mbr
.
vols
[
i
+
1
];
mbr
.
nb_vols
--
;
mbr
.
nb_vols
--
;
}
}
void
init_volume
(
unsigned
int
vol
)
{
int
i
;
vsuper_t
super
;
super
.
magic
=
MAGIC
;
super
.
serie
=
vol
;
sprintf
(
super
.
name
,
"volume %i"
,
vol
);
super
.
id
=
vol
;
super
.
first_free
=
1
;
write_bloc
(
vol
,
SUPER_BLOC
,
&
super
);
for
(
int
i
=
1
;
i
<
HDA_SECTORSIZE
;
i
++
)
{
vblockchain_t
blockchain
;
blockchain
.
next
=
(
i
+
1
)
%
HDA_SECTORSIZE
;
write_bloc
(
vol
,
i
,
&
blockchain
);
}
}
This diff is collapsed.
Click to expand it.
tpfs/vol.h
+
18
−
1
View file @
42446ce8
...
@@ -2,9 +2,10 @@
...
@@ -2,9 +2,10 @@
#define VOL_H
#define VOL_H
#define VOLS_MAX 8
#define VOLS_MAX 8
#define
MBR_
MAGIC 0xCAFE
/* Savoir si le mbr a déjà été initialisé ou non */
#define MAGIC 0xCAFE
/* Savoir si le mbr a déjà été initialisé ou non */
#define FMT_DATA 0xCAFEBABE
#define FMT_DATA 0xCAFEBABE
#define FMT_SIZE 0x1
#define FMT_SIZE 0x1
#define SUPER_BLOC 0
typedef
enum
typedef
enum
{
{
...
@@ -30,6 +31,20 @@ typedef struct mbr_s
...
@@ -30,6 +31,20 @@ typedef struct mbr_s
mbr_t
mbr
;
mbr_t
mbr
;
typedef
struct
vsuper_s
{
unsigned
int
magic
;
unsigned
int
serie
;
unsigned
char
*
name
;
unsigned
int
id
;
unsigned
int
first_free
;
}
vsuper_t
;
typedef
struct
vblockchain_s
{
unsigned
int
next
;
}
vblockchain_t
;
void
load_mbr
(
void
);
void
load_mbr
(
void
);
void
save_mbr
(
void
);
void
save_mbr
(
void
);
void
get_sector_cylinder
(
unsigned
int
vol
,
unsigned
int
nbloc
,
unsigned
int
*
sector_cylinder
);
void
get_sector_cylinder
(
unsigned
int
vol
,
unsigned
int
nbloc
,
unsigned
int
*
sector_cylinder
);
...
@@ -42,4 +57,6 @@ void create_vol(unsigned int nb_blocs, unsigned int cylinder, unsigned int secto
...
@@ -42,4 +57,6 @@ void create_vol(unsigned int nb_blocs, unsigned int cylinder, unsigned int secto
void
display_vols
();
void
display_vols
();
void
remove_vol
();
void
remove_vol
();
void
init_volume
(
unsigned
int
vol
);
#endif
#endif
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