-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
38 lines (36 loc) · 1.05 KB
/
main.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
#include <stdio.h>
#include <string.h>
#include <dirent.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <argp.h>
#include "unistd.h"
#include "fat32_lib.c"
#include "utils.c"
#include "list_mode.c"
#include "shell_mode.c"
char *const SHELL_MODE = "shell";
char *const LIST_MODE = "list";
int main(int argc, char **argv) {
if (argc < 2) {
printf("Please, specify program mode (%s/%s)\n", SHELL_MODE, LIST_MODE);
return 0;
} else {
char *mode = argv[1];
if (!strcmp(SHELL_MODE, mode)) {
if (argc < 3) {
printf("You have to specify target device with FAT32 fs\n");
printf("usage: ./lab1 shell sda1\n");
return 0;
}
printf("Starting program in shell mode...\n");
run_shell_mode(argv[2]);
} else if (!strcmp(LIST_MODE, mode)) {
printf("Starting program in mounts mode...\n");
run_list_mode();
} else {
printf("Unknown mode, terminating program!\n");
}
}
return 0;
}