]> git.llucax.com Git - z.facultad/75.06/emufs.git/commitdiff
locura total, no cambie nada y anda
authorNicolás Dimov <ndimov@gmail.com>
Mon, 5 Apr 2004 21:55:35 +0000 (21:55 +0000)
committerNicolás Dimov <ndimov@gmail.com>
Mon, 5 Apr 2004 21:55:35 +0000 (21:55 +0000)
tipo3/emufs.c
tipo3/param_cte.c
tipo3/param_cte.h

index 49cb4b402d925a6f5e33ff5b89b55538cc841314..68ca04403092bd0b40981451056e95b9189902f3 100644 (file)
@@ -151,7 +151,7 @@ int ver_archivo_FS(EMUFS *emu)
                f_block_free = fopen(name_f_block_free, "r");
                fread(&r, sizeof(BLOCK_REG_T), 1, f_block_free);
                while (!feof(f_block_free)) {
                f_block_free = fopen(name_f_block_free, "r");
                fread(&r, sizeof(BLOCK_REG_T), 1, f_block_free);
                while (!feof(f_block_free)) {
-                       printf("ID %d en bloque %d\n", r.id_reg, r.block);
+                       printf("ID %ld en bloque %d\n", r.id_reg, r.block);
                        fread(&r, sizeof(BLOCK_REG_T), 1, f_block_free);
                }
                fclose(f_block_free);
                        fread(&r, sizeof(BLOCK_REG_T), 1, f_block_free);
                }
                fclose(f_block_free);
index a32db33f08172c5c4f17ab561e0c1e4afa813fff..b5787b6b4794075347b33fa6b599eed77c2551a7 100644 (file)
@@ -61,7 +61,7 @@ int existe_registro(EMUFS *emu, int ID)
        strcat(name_f_reg_exist,".ids");
        if ( (f_reg_exist = fopen(name_f_reg_exist,"r")) == NULL) return -1; /*ERROR*/
        while ( !feof(f_reg_exist) ){
        strcat(name_f_reg_exist,".ids");
        if ( (f_reg_exist = fopen(name_f_reg_exist,"r")) == NULL) return -1; /*ERROR*/
        while ( !feof(f_reg_exist) ){
-               fread(&reg,sizeof(reg),1,f_reg_exist);
+               fread(&reg,sizeof(int),1,f_reg_exist);
                if ( reg == ID ){
                        fclose(f_reg_exist);
                        return 0;
                if ( reg == ID ){
                        fclose(f_reg_exist);
                        return 0;
@@ -84,7 +84,7 @@ int buscar_registro(EMUFS *emu, int ID)
        
        if ( (f_block_reg = fopen(name_f_block_reg,"r")) == NULL) return -1; /*ERROR*/
        while ( !feof(f_block_reg) ){
        
        if ( (f_block_reg = fopen(name_f_block_reg,"r")) == NULL) return -1; /*ERROR*/
        while ( !feof(f_block_reg) ){
-               if (fread(&reg,sizeof(reg),1,f_block_reg) != 1) continue;
+               if (fread(&reg,sizeof(BLOCK_REG_T),1,f_block_reg) != 1) continue;
                if ( reg.id_reg == ID ){
                        fclose(f_block_reg);
                        return reg.block;
                if ( reg.id_reg == ID ){
                        fclose(f_block_reg);
                        return reg.block;
@@ -119,14 +119,12 @@ int grabar_registro(EMUFS *emu, void *ptr, unsigned long tam)
 {
        int ID_aux, fs, num_bloque, cant;
        FILE *file;
 {
        int ID_aux, fs, num_bloque, cant;
        FILE *file;
-       FILE *f_id;
        FILE *f_block_reg;
        FILE *f_block_free;
        BLOCK_FREE_T reg;
        BLOCK_REG_T reg_b;
        char name_f[255];
        char name_f_block_reg[255];
        FILE *f_block_reg;
        FILE *f_block_free;
        BLOCK_FREE_T reg;
        BLOCK_REG_T reg_b;
        char name_f[255];
        char name_f_block_reg[255];
-       char name_f_id[255];
        char name_f_free[255];
        char* bloque;
        strcpy(name_f,emu->nombre);
        char name_f_free[255];
        char* bloque;
        strcpy(name_f,emu->nombre);
@@ -134,9 +132,6 @@ int grabar_registro(EMUFS *emu, void *ptr, unsigned long tam)
        
        strcpy(name_f_block_reg,emu->nombre);
        strcat(name_f_block_reg,".idx");
        
        strcpy(name_f_block_reg,emu->nombre);
        strcat(name_f_block_reg,".idx");
-       
-       strcpy(name_f_id,emu->nombre);
-       strcat(name_f_id,".ids");
 
        strcpy(name_f_free,emu->nombre);
        strcat(name_f_free,".fsc");
 
        strcpy(name_f_free,emu->nombre);
        strcat(name_f_free,".fsc");
@@ -174,7 +169,7 @@ int grabar_registro(EMUFS *emu, void *ptr, unsigned long tam)
                reg.free_space = emu->tam_bloque - tam;
                /*lo guardo en el archivo al final  "a+"*/
                if ( (f_block_free = fopen(name_f_free,"a+"))==NULL ) return -1; /*ERROR*/              
                reg.free_space = emu->tam_bloque - tam;
                /*lo guardo en el archivo al final  "a+"*/
                if ( (f_block_free = fopen(name_f_free,"a+"))==NULL ) return -1; /*ERROR*/              
-               fwrite(&reg,sizeof(reg),1,f_block_free);
+               fwrite(&reg,sizeof(BLOCK_FREE_T),1,f_block_free);
                fclose(f_block_free);
        } else {
                /*cargo el bloque en "bloque"*/
                fclose(f_block_free);
        } else {
                /*cargo el bloque en "bloque"*/
@@ -198,27 +193,27 @@ int grabar_registro(EMUFS *emu, void *ptr, unsigned long tam)
                /*busco el bloque que modifique*/
                if ( (f_block_free = fopen(name_f_free,"r+")) == NULL) return -1; /*ERROR*/
                while ( !feof(f_block_free) ){
                /*busco el bloque que modifique*/
                if ( (f_block_free = fopen(name_f_free,"r+")) == NULL) return -1; /*ERROR*/
                while ( !feof(f_block_free) ){
-                       fread(&reg,sizeof(reg),1,f_block_free);
+                       fread(&reg,sizeof(BLOCK_FREE_T),1,f_block_free);
                        if ( reg.block == num_bloque ){
                                reg.free_space -= tam;
                        if ( reg.block == num_bloque ){
                                reg.free_space -= tam;
-                               fseek(f_block_free,-sizeof(reg),SEEK_CUR);
-                               fwrite(&reg,sizeof(reg),1,f_block_free);
+                               fseek(f_block_free,-sizeof(BLOCK_FREE_T),SEEK_CUR);
+                               fwrite(&reg,sizeof(BLOCK_FREE_T),1,f_block_free);
                                break;
                        }
                }
                fclose(f_block_free);
        }
 
                                break;
                        }
                }
                fclose(f_block_free);
        }
 
-       /*actualizo el archivo de id`s*/
-       if ( (f_id = fopen(name_f_id,"a+"))==NULL ) return -1; /*ERROR*/
-       fwrite(&ID_aux,sizeof(ID_aux),1,f_id);
+       /*actualizo el archivo de id`s
+       if ( (f_id = fopen(name_f_id,"a+"))==NULL ) return -1;
+       fwrite(&ID_aux,sizeof(int),1,f_id);
        fclose(f_id);
        fclose(f_id);
-
+       */
        /*actualizo el archivo de bloques y registros*/
        if ( (f_block_reg = fopen(name_f_block_reg,"ab+"))==NULL ) return -1; /*ERROR*/
        reg_b.block = reg.block;
        reg_b.id_reg = ID_aux;
        /*actualizo el archivo de bloques y registros*/
        if ( (f_block_reg = fopen(name_f_block_reg,"ab+"))==NULL ) return -1; /*ERROR*/
        reg_b.block = reg.block;
        reg_b.id_reg = ID_aux;
-       fwrite(&reg_b,sizeof(reg_b),1,f_block_reg); 
+       fwrite(&reg_b,sizeof(BLOCK_REG_T),1,f_block_reg); 
        fclose(f_block_reg);
        
        free(bloque);
        fclose(f_block_reg);
        
        free(bloque);
@@ -263,7 +258,7 @@ int buscar_lugar(EMUFS *emu, unsigned long tam, int *fs)
        reg.block = -1;
        *fs = emu->tam_bloque;
        while( !feof(f_block_free) ){
        reg.block = -1;
        *fs = emu->tam_bloque;
        while( !feof(f_block_free) ){
-               fread(&reg,sizeof(reg),1,f_block_free);
+               fread(&reg,sizeof(BLOCK_FREE_T),1,f_block_free);
                if ( reg.free_space >= tam ) 
                        break;
                else {
                if ( reg.free_space >= tam ) 
                        break;
                else {
@@ -298,8 +293,8 @@ int get_id(EMUFS *emu)
 
        if (ftell(f_reg_exist) > 0){
                /* si el archivo no esta vacio es porque hay un nro disponible*/
 
        if (ftell(f_reg_exist) > 0){
                /* si el archivo no esta vacio es porque hay un nro disponible*/
-               fseek(f_reg_exist, -sizeof(id),SEEK_END);
-               fread(&id,sizeof(id),1,f_reg_exist);
+               fseek(f_reg_exist, -sizeof(int),SEEK_END);
+               fread(&id,sizeof(int),1,f_reg_exist);
                /* FIXME: tengo que truncar el archivo*/
                /* FIXME: tengo que truncar el archivo*/
                /* FIXME: tengo que truncar el archivo*/
                /* FIXME: tengo que truncar el archivo*/
                /* FIXME: tengo que truncar el archivo*/
                /* FIXME: tengo que truncar el archivo*/
@@ -312,7 +307,7 @@ int get_id(EMUFS *emu)
                if ( (f_block_reg = fopen(name_f_block_reg,"r")) == NULL) return -1; /*ERROR*/
                while ( !feof(f_block_reg) ){
                        /* Me aseguro de leer la cantidad de bytes correcta */
                if ( (f_block_reg = fopen(name_f_block_reg,"r")) == NULL) return -1; /*ERROR*/
                while ( !feof(f_block_reg) ){
                        /* Me aseguro de leer la cantidad de bytes correcta */
-                       if (fread(&reg,sizeof(reg),1,f_block_reg) != 1) continue;
+                       if (fread(&reg,sizeof(BLOCK_REG_T),1,f_block_reg) != 1) continue;
                        if ( reg.id_reg >= max ) 
                                max = reg.id_reg;
                }
                        if ( reg.id_reg >= max ) 
                                max = reg.id_reg;
                }
index bb17c0613cb0c04810733fc12346e5a61606b5f2..de2e4236f64b554d51384bbbf41975024cfdbcd5 100644 (file)
@@ -12,7 +12,7 @@ typedef struct block_free_t{
 
 typedef struct block_reg_t{
        int block;
 
 typedef struct block_reg_t{
        int block;
-       int id_reg;
+       long int id_reg;
 }BLOCK_REG_T;
 
 int leer_registro(EMUFS *emu, int ID, void *, unsigned long tam);
 }BLOCK_REG_T;
 
 int leer_registro(EMUFS *emu, int ID, void *, unsigned long tam);