-
Notifications
You must be signed in to change notification settings - Fork 0
/
mi_mkdir.c
49 lines (40 loc) · 965 Bytes
/
mi_mkdir.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
/*
Autores:
- Marc Link Cladera
- Carlos Gálvez Mena
- Jesús Castillo Benito
*/
#include "directorios.h"
int main(int argc, char **args)
{
if (argc < 4)
{
fprintf(
stderr,
RED
"ERROR: invalid syntax. Usage: ./mi_mkdir <disco> <permisos> </ruta/>\n"
RESET
);
return FALLO;
}
if (args[3][strlen(args[3]) - 1] != '/')
{
fprintf(
stderr,
RED
"ERROR: path has to end with '/'. Try to use ./mi_touch instead\n"
RESET
);
return FALLO;
}
int permisos = atoi(args[2]);
if (permisos < 3 || permisos > 7)
{
fprintf(stderr, RED "ERROR: the permissions must be in between 3 and 7\n" RESET);
return FALLO;
}
if (bmount(args[1]) < 0) return FALLO;
mi_creat(args[3], permisos);
if (bumount() < 0) return FALLO;
return EXITO;
}