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
8395f502
Commit
8395f502
authored
4 years ago
by
Thierno souleymane Bah
Browse files
Options
Downloads
Patches
Plain Diff
fix(volume programms reorganized in library)
parent
40b87926
No related branches found
No related tags found
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
tpfs/dvol.c
+1
-25
1 addition, 25 deletions
tpfs/dvol.c
tpfs/mkvol.c
+0
-54
0 additions, 54 deletions
tpfs/mkvol.c
tpfs/rmvol.c
+1
-11
1 addition, 11 deletions
tpfs/rmvol.c
tpfs/vol.c
+87
-0
87 additions, 0 deletions
tpfs/vol.c
tpfs/vol.h
+5
-1
5 additions, 1 deletion
tpfs/vol.h
with
94 additions
and
91 deletions
tpfs/dvol.c
+
1
−
25
View file @
8395f502
...
@@ -4,30 +4,6 @@
...
@@ -4,30 +4,6 @@
#include
"hardware.h"
#include
"hardware.h"
#include
"vol.h"
#include
"vol.h"
void
display_vol
()
{
int
vol
;
char
*
vtype_names
[
3
]
=
{
"BASE"
,
"ANNEXE"
,
"OTHER"
};
vol_t
volume
;
if
(
mbr
.
nb_vols
==
0
)
{
printf
(
"Il n'y aucun volume.
\n
"
);
return
;
}
printf
(
"--------------------------
\n
"
);
for
(
vol
=
0
;
vol
<
mbr
.
nb_vols
;
vol
++
)
{
volume
=
mbr
.
vols
[
vol
];
printf
(
"Volume: %d (%s)
\n
"
,
vol
,
vtype_names
[
volume
.
type
]);
printf
(
"> Sector: %d
\n
"
,
volume
.
sector
);
printf
(
"> Cylinder: %d
\n
"
,
volume
.
cylinder
);
printf
(
"> Nb blocs: %d
\n
"
,
volume
.
nb_blocs
);
printf
(
"--------------------------
\n
"
);
}
}
static
void
static
void
empty_it
()
empty_it
()
{
{
...
@@ -53,7 +29,7 @@ int main(int argc, char const *argv[])
...
@@ -53,7 +29,7 @@ int main(int argc, char const *argv[])
_mask
(
1
);
_mask
(
1
);
load_mbr
();
load_mbr
();
display_vol
();
display_vol
s
();
/* and exit! */
/* and exit! */
exit
(
EXIT_SUCCESS
);
exit
(
EXIT_SUCCESS
);
...
...
This diff is collapsed.
Click to expand it.
tpfs/mkvol.c
+
0
−
54
View file @
8395f502
...
@@ -3,60 +3,6 @@
...
@@ -3,60 +3,6 @@
#include
"hardware.h"
#include
"hardware.h"
#include
"vol.h"
#include
"vol.h"
#include
"drive.h"
void
create_vol
(
unsigned
int
nb_blocs
,
unsigned
int
cylinder
,
unsigned
int
sector
)
{
int
i
,
abs_nbloc
,
remaining_blocs
;
vol_t
*
volume
;
if
(
mbr
.
nb_vols
==
VOLS_MAX
)
{
fprintf
(
stderr
,
"Le nombre de volumes maximal est atteint
\n
"
);
return
;
}
if
(
cylinder
+
sector
==
0
||
cylinder
>=
HDA_MAXCYLINDER
||
sector
>=
HDA_MAXSECTOR
)
{
fprintf
(
stderr
,
"Impossible d'ecrire à cet endroit
\n
"
);
return
;
}
abs_nbloc
=
cylinder
*
HDA_MAXSECTOR
+
sector
;
remaining_blocs
=
HDA_MAXSECTOR
*
HDA_MAXCYLINDER
-
abs_nbloc
;
if
(
abs_nbloc
>
remaining_blocs
)
nb_blocs
=
remaining_blocs
;
for
(
i
=
0
;
i
<
mbr
.
nb_vols
;
i
++
)
{
vol_t
vol
=
mbr
.
vols
[
i
];
int
vol_abs_nbloc
=
vol
.
cylinder
*
HDA_MAXSECTOR
+
vol
.
sector
;
/*
* Les deux commencent sur le même bloc
* Les deux se terminent sur le même bloc
* Si le debut de l'un se trouve entre le debut et la fin de l'autre
*/
printf
(
"%d %d %d %d
\n
"
,
abs_nbloc
,
abs_nbloc
+
nb_blocs
,
vol_abs_nbloc
,
vol_abs_nbloc
+
vol
.
nb_blocs
);
if
(
abs_nbloc
==
vol_abs_nbloc
||
(
abs_nbloc
+
nb_blocs
)
==
(
vol_abs_nbloc
+
vol
.
nb_blocs
)
||
((
abs_nbloc
<
vol_abs_nbloc
)
&&
(
vol_abs_nbloc
<
abs_nbloc
+
nb_blocs
))
||
((
vol_abs_nbloc
<
abs_nbloc
)
&&
(
abs_nbloc
<
vol_abs_nbloc
+
vol
.
nb_blocs
)))
{
fprintf
(
stderr
,
"Le volume %d occupe déjà cet emplacement
\n
"
,
i
);
return
;
}
}
volume
=
mbr
.
vols
+
(
mbr
.
nb_vols
++
);
volume
->
nb_blocs
=
nb_blocs
;
volume
->
cylinder
=
cylinder
;
volume
->
sector
=
sector
;
volume
->
type
=
BASE
;
}
static
void
static
void
empty_it
()
empty_it
()
...
...
This diff is collapsed.
Click to expand it.
tpfs/rmvol.c
+
1
−
11
View file @
8395f502
...
@@ -4,16 +4,6 @@
...
@@ -4,16 +4,6 @@
#include
"hardware.h"
#include
"hardware.h"
#include
"vol.h"
#include
"vol.h"
void
display_vol
()
{
if
(
mbr
.
nb_vols
==
0
)
{
fprintf
(
stderr
,
"Vous ne disposez d'aucun volume
\n
"
);
return
;
}
mbr
.
nb_vols
--
;
}
static
void
static
void
empty_it
()
empty_it
()
{
{
...
@@ -39,7 +29,7 @@ int main(int argc, char const *argv[])
...
@@ -39,7 +29,7 @@ int main(int argc, char const *argv[])
_mask
(
1
);
_mask
(
1
);
load_mbr
();
load_mbr
();
display
_vol
();
remove
_vol
();
save_mbr
();
save_mbr
();
/* and exit! */
/* and exit! */
...
...
This diff is collapsed.
Click to expand it.
tpfs/vol.c
+
87
−
0
View file @
8395f502
...
@@ -91,3 +91,90 @@ void format_vol(unsigned int vol)
...
@@ -91,3 +91,90 @@ void format_vol(unsigned int vol)
format_sector
(
sector_cylinder
[
1
],
sector_cylinder
[
1
],
FMT_SIZE
,
FMT_DATA
);
format_sector
(
sector_cylinder
[
1
],
sector_cylinder
[
1
],
FMT_SIZE
,
FMT_DATA
);
}
}
}
}
void
create_vol
(
unsigned
int
nb_blocs
,
unsigned
int
cylinder
,
unsigned
int
sector
)
{
int
i
,
abs_nbloc
,
remaining_blocs
;
vol_t
*
volume
;
if
(
mbr
.
nb_vols
==
VOLS_MAX
)
{
fprintf
(
stderr
,
"Le nombre de volumes maximal est atteint
\n
"
);
return
;
}
if
(
cylinder
+
sector
==
0
||
cylinder
>=
HDA_MAXCYLINDER
||
sector
>=
HDA_MAXSECTOR
)
{
fprintf
(
stderr
,
"Impossible d'ecrire à cet endroit
\n
"
);
return
;
}
abs_nbloc
=
cylinder
*
HDA_MAXSECTOR
+
sector
;
remaining_blocs
=
HDA_MAXSECTOR
*
HDA_MAXCYLINDER
-
abs_nbloc
;
if
(
abs_nbloc
>
remaining_blocs
)
nb_blocs
=
remaining_blocs
;
for
(
i
=
0
;
i
<
mbr
.
nb_vols
;
i
++
)
{
vol_t
vol
=
mbr
.
vols
[
i
];
int
vol_abs_nbloc
=
vol
.
cylinder
*
HDA_MAXSECTOR
+
vol
.
sector
;
/*
* Les deux commencent sur le même bloc
* Les deux se terminent sur le même bloc
* Si le debut de l'un se trouve entre le debut et la fin de l'autre
*/
printf
(
"%d %d %d %d
\n
"
,
abs_nbloc
,
abs_nbloc
+
nb_blocs
,
vol_abs_nbloc
,
vol_abs_nbloc
+
vol
.
nb_blocs
);
if
(
abs_nbloc
==
vol_abs_nbloc
||
(
abs_nbloc
+
nb_blocs
)
==
(
vol_abs_nbloc
+
vol
.
nb_blocs
)
||
((
abs_nbloc
<
vol_abs_nbloc
)
&&
(
vol_abs_nbloc
<
abs_nbloc
+
nb_blocs
))
||
((
vol_abs_nbloc
<
abs_nbloc
)
&&
(
abs_nbloc
<
vol_abs_nbloc
+
vol
.
nb_blocs
)))
{
fprintf
(
stderr
,
"Le volume %d occupe déjà cet emplacement
\n
"
,
i
);
return
;
}
}
volume
=
mbr
.
vols
+
(
mbr
.
nb_vols
++
);
volume
->
nb_blocs
=
nb_blocs
;
volume
->
cylinder
=
cylinder
;
volume
->
sector
=
sector
;
volume
->
type
=
BASE
;
}
void
display_vols
()
{
int
vol
;
char
*
vtype_names
[
3
]
=
{
"BASE"
,
"ANNEXE"
,
"OTHER"
};
vol_t
volume
;
if
(
mbr
.
nb_vols
==
0
)
{
printf
(
"Il n'y aucun volume.
\n
"
);
return
;
}
printf
(
"--------------------------
\n
"
);
for
(
vol
=
0
;
vol
<
mbr
.
nb_vols
;
vol
++
)
{
volume
=
mbr
.
vols
[
vol
];
printf
(
"Volume: %d (%s)
\n
"
,
vol
,
vtype_names
[
volume
.
type
]);
printf
(
"> Sector: %d
\n
"
,
volume
.
sector
);
printf
(
"> Cylinder: %d
\n
"
,
volume
.
cylinder
);
printf
(
"> Nb blocs: %d
\n
"
,
volume
.
nb_blocs
);
printf
(
"--------------------------
\n
"
);
}
}
void
remove_vol
()
{
if
(
mbr
.
nb_vols
==
0
)
{
fprintf
(
stderr
,
"Vous ne disposez d'aucun volume
\n
"
);
return
;
}
mbr
.
nb_vols
--
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
tpfs/vol.h
+
5
−
1
View file @
8395f502
...
@@ -33,9 +33,13 @@ mbr_t mbr;
...
@@ -33,9 +33,13 @@ mbr_t mbr;
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
);
void
read_bloc
(
unsigned
int
vol
,
unsigned
int
nbloc
,
unsigned
char
*
buffer
);
void
read_bloc
(
unsigned
int
vol
,
unsigned
int
nbloc
,
unsigned
char
*
buffer
);
void
write_bloc
(
unsigned
int
vol
,
unsigned
int
nbloc
,
unsigned
char
*
buffer
);
void
write_bloc
(
unsigned
int
vol
,
unsigned
int
nbloc
,
unsigned
char
*
buffer
);
void
format_vol
(
unsigned
int
vol
);
void
read_sector_n
(
unsigned
char
*
buf
,
int
cylinder
,
int
sector
,
int
size
);
void
create_vol
(
unsigned
int
nb_blocs
,
unsigned
int
cylinder
,
unsigned
int
sector
);
void
display_vols
();
void
remove_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