// File: /workspace/github_c_makefile_star2_O1/carlitosmarin[P]Sistema-Ficheros-SOII/leer_sf.c
// Function: main
int main (int argc, char **argv) {
	if (argc != 2) {
		printf("Numero de parametros incorrectos");
		return -1;
	}
	//Montamos el disco
	if(bmount(argv[1]) < 0){
		printf("No se ha podido abrir el fichero: %s", argv[1]);
		return -1;
	}

	int tamMB, tamAI;

	struct superbloque sb;
	if(bread(posSB,&sb) < 0) {
		printf("Error en la lectura del superbloque");
		bumount();
		return -1;
	}

	leerSB(); //Mostrar todos los campos del superbloque

	tamMB = sb.posUltimoBloqueMB - sb.posPrimerBloqueMB;
	tamAI = sb.posUltimoBloqueAI - sb.posPrimerBloqueAI;
	printf("Tamanyo MB: %d \nTamanyo AI: %d \n", tamMB, tamAI);

	printf("Tamanyo de la estructura inodo: %lu\n", sizeof(struct inodo));

	unsigned int i = 0,y = 1;

	printf("\nPulsa ENTER para mostrar la lista de inodos no libres."); getchar();
	struct tm *ts;
	char atime[80];
	char mtime[80];
	char ctime[80];
	unsigned int x = 0;
	struct inodo in;

	for(i = 0; i < sb.totInodos && x < (sb.totInodos - sb.cantInodosLibres); i++){ // Muestra todos lo ins
		in = leer_inodo(i);
		if(in.tipo != 'l'){
			x++;
			printf("----> Numero inodo: %d\n",i);
			printf("\tTipo de inodo: %c\n",in.tipo);
			printf("\tPermisos: %d\n",in.permisos);
			printf("\tNumero de links: %d\n",in.cantLinks);
			printf("\tTamanyo en bytes logicos: %d\n",in.tamBytesLogicos);
			printf("\tNumero de bloques que ocupa: %d\n",in.cantBloquesOcupados);
			ts = localtime(&in.atime);
			strftime(atime, sizeof(atime), "%a %Y-%m-%d %H:%M:%S", ts);
			ts = localtime(&in.mtime);
			strftime(mtime, sizeof(mtime), "%a %Y-%m-%d %H:%M:%S", ts);
			ts = localtime(&in.ctime);
			strftime(ctime, sizeof(ctime), "%a %Y-%m-%d %H:%M:%S", ts);
			printf("\tATIME: %s\n\tMTIME: %s\n\tCTIME: %s\n",atime,mtime,ctime);
		}
	}

	printf("\nBLOQUES OCUPADOS (%d bloques ocupados)\n", sb.totBloques-sb.cantBloquesLibres);

	bumount();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x5f8, %rsp            # imm = 0x5F8
cmpl $0x2, %edi
jne 0x405a
movq %rsi, %rbx
movq 0x8(%rsi), %rdi
callq 0x129c
testl %eax, %eax
js 0x406a
leaq 0x178(%rsp), %rsi
xorl %edi, %edi
callq 0x133d
testl %eax, %eax
js 0x407e
xorl %eax, %eax
callq 0x162c
movl 0x17c(%rsp), %esi
movl 0x184(%rsp), %edx
subl 0x178(%rsp), %esi
subl 0x180(%rsp), %edx
leaq 0x16f5(%rip), %rdi      # 0x5594
xorl %eax, %eax
callq 0x1090
leaq 0x1708(%rip), %rdi      # 0x55b5
movl $0x80, %esi
xorl %eax, %eax
callq 0x1090
leaq 0x171a(%rip), %rdi      # 0x55da
xorl %eax, %eax
callq 0x1090
callq 0x1110
movl 0x1a4(%rsp), %eax
testl %eax, %eax
je 0x4033
leaq 0x578(%rsp), %rbx
xorl %r15d, %r15d
xorl %r13d, %r13d
subl 0x19c(%rsp), %eax
cmpl %eax, %r15d
jae 0x4033
movq %rbx, %rdi
movl %r13d, %esi
callq 0x19b1
movl $0x10, %ecx
movq %rsp, %rdi
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
cmpb $0x6c, (%rsp)
je 0x4020
incl %r15d
leaq 0x16ec(%rip), %rdi      # 0x5612
movl %r13d, %esi
xorl %eax, %eax
callq 0x1090
movzbl (%rsp), %esi
leaq 0x16ef(%rip), %rdi      # 0x562a
xorl %eax, %eax
callq 0x1090
movzbl 0x1(%rsp), %esi
leaq 0x16f0(%rip), %rdi      # 0x563e
xorl %eax, %eax
callq 0x1090
movl 0x20(%rsp), %esi
leaq 0x16ed(%rip), %rdi      # 0x564d
xorl %eax, %eax
callq 0x1090
movl 0x24(%rsp), %esi
leaq 0x16f1(%rip), %rdi      # 0x5663
xorl %eax, %eax
callq 0x1090
movl 0x28(%rsp), %esi
leaq 0x16fe(%rip), %rdi      # 0x5682
xorl %eax, %eax
callq 0x1090
leaq 0x8(%rsp), %rdi
callq 0x1030
movl $0x50, %esi
leaq 0x80(%rsp), %rdi
leaq 0x16fb(%rip), %r12      # 0x56a4
movq %r12, %rdx
movq %rax, %rcx
callq 0x1150
leaq 0x10(%rsp), %rdi
callq 0x1030
movl $0x50, %esi
movq %rbx, %rbp
leaq 0x120(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rdx
movq %rax, %rcx
callq 0x1150
leaq 0x18(%rsp), %rdi
callq 0x1030
movl $0x50, %esi
leaq 0xd0(%rsp), %r14
movq %r14, %rdi
movq %r12, %rdx
movq %rax, %rcx
callq 0x1150
leaq 0x16b1(%rip), %rdi      # 0x56b9
leaq 0x80(%rsp), %rsi
movq %rbx, %rdx
movq %rbp, %rbx
movq %r14, %rcx
xorl %eax, %eax
callq 0x1090
incl %r13d
movl 0x1a4(%rsp), %eax
cmpl %eax, %r13d
jb 0x3ee9
movl 0x1a0(%rsp), %esi
subl 0x198(%rsp), %esi
leaq 0x1693(%rip), %rdi      # 0x56db
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x1090
xorl %eax, %eax
callq 0x12da
jmp 0x4098
leaq 0x14c9(%rip), %rdi      # 0x552a
xorl %eax, %eax
callq 0x1090
jmp 0x4093
movq 0x8(%rbx), %rsi
leaq 0x14d6(%rip), %rdi      # 0x554b
xorl %eax, %eax
callq 0x1090
jmp 0x4093
leaq 0x14eb(%rip), %rdi      # 0x5570
xorl %eax, %eax
callq 0x1090
xorl %eax, %eax
callq 0x12da
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0x5f8, %rsp            # imm = 0x5F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq