-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmi_link.c
More file actions
48 lines (40 loc) · 984 Bytes
/
Copy pathmi_link.c
File metadata and controls
48 lines (40 loc) · 984 Bytes
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
/*
Autores:
- Marc Link Cladera
- Carlos Gálvez Mena
- Jesús Castillo Benito
*/
#include "directorios.h"
int main(int argc, char **argv)
{
if(argc != 4)
{
fprintf(stderr,
RED
"ERROR: invalid syntax. Usage: ./mi_link disco /ruta_fichero_original /ruta_enlace\n"
RESET);
return FALLO;
}
if (bmount(argv[1]) < 0) return FALLO;
if (argv[2][strlen(argv[2]) - 1] == '/')
{
fprintf(stderr,
RED
"ERROR: the original file cannot be a directory\n"
RESET);
return FALLO;
}
if (argv[3][strlen(argv[3]) - 1] == '/')
{
fprintf(stderr,
RED
"ERROR: the link route cannot be a directory route\n"
RESET);
return FALLO;
}
if (mi_link(argv[2], argv[3]) < 0)
{
return FALLO;
}
if (bumount() < 0) return FALLO;
}