-
Notifications
You must be signed in to change notification settings - Fork 0
/
tfs_format.c
51 lines (41 loc) · 1.14 KB
/
tfs_format.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "tfs.h"
int main(int argc, char *argv[]) {
/********************************************************/
/**
* TEST OF ARGUMENTS
*/
if (argc < 5 || argc > 6 || strcmp(argv[1], "-p") != 0
|| strcmp(argv[3], "-mf") != 0) {
fprintf(stderr, "ERREUR WITH ARGUMENTS\n");
return 1;
}
int nbPartition = 0;
int valreturnSSCRANF = sscanf(argv[2], "%d", &nbPartition);
if (valreturnSSCRANF != 1 || nbPartition < 0) {
//printf("val de partition : %d\n",nbPartition);
fprintf(stderr, "\n-p argument,"
" the number of partition enter : %d is NOT CORRECT \n",
nbPartition);
return 1;
}
int maxFiles = 0;
valreturnSSCRANF = sscanf(argv[4], "%d", &maxFiles);
if (valreturnSSCRANF != 1 || maxFiles < 0) {
fprintf(stderr, "\n-mf argument,"
" the number of maximum files enter : %d is NOT CORRECT \n",
nbPartition);
return 1;
}
char* nameFile;
if (argc != 6) {
nameFile = "disk.tfs";
//printf("name NOT give , we search for disk.tfs\n");
} else {
nameFile = argv[argc - 1];
//printf("name give : %s\n", nameFile);
}
/**
* Call TFS.C format function
*/
return tfs_format(nameFile,nbPartition,maxFiles);
}