-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmi_mkfs.c
More file actions
38 lines (34 loc) · 1.1 KB
/
mi_mkfs.c
File metadata and controls
38 lines (34 loc) · 1.1 KB
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
//Antoni Font, Pedro Bustamante, Pavel Ernesto Garcia
#include "directorios.h"
int main(int argc, char **argv)
{
if (argc == 3)
{
int strcVal = strcmp(argv[0], "./mi_mkfs");
if (strcVal == 0)
{
int nbloques = atoi(argv[2]);
int ninodos = nbloques / 4;
// Hacemos el array de 1024 cajas porque cada caja es un byte (char 8 bits)
// y nuestro tamaño de bloque es de 1024 Bytes
unsigned char bloqueVacio[BLOCKSIZE];
// Rellenamos las 1024 bytes a 0
memset(bloqueVacio, 0, BLOCKSIZE);
// Montamos el dispositivo virtual con el nombre especificado
bmount(argv[1]);
// Escribimos todos los bloques
for (int i = 0; i < nbloques; i++)
{
bwrite(i, bloqueVacio);
}
initSB(nbloques, ninodos);
initMB();
initAI();
//Creamos el directorio raíz
reservar_inodo('d', 7);
// Desmontamos el dispositivo virtual
bumount();
}
}
return 0;
}