X-Git-Url: https://git.llucax.com/z.facultad/75.06/emufs.git/blobdiff_plain/c407055e1cc6ff4c435114091c3a5430486aa659..eb5e623c9e1334da07faa5f4b8b6c3ebf431503f:/emufs/fsc.c?ds=sidebyside diff --git a/emufs/fsc.c b/emufs/fsc.c index 1cf873f..d6ec6a0 100644 --- a/emufs/fsc.c +++ b/emufs/fsc.c @@ -46,7 +46,7 @@ int emufs_fsc_crear(EMUFS* efs) } /* Agrega un registro al archivo de espacios libres. */ -int emufs_fsc_agregar(EMUFS *emu, EMUFS_BLOCK_ID n_Marker, EMUFS_FREE n_FreeSpace) +int emufs_fsc_agregar(EMUFS *emu, EMUFS_BLOCK_ID n_marker, EMUFS_FREE n_freespace) { FILE *f_fsc; EMUFS_FSC reg; @@ -56,8 +56,8 @@ int emufs_fsc_agregar(EMUFS *emu, EMUFS_BLOCK_ID n_Marker, EMUFS_FREE n_FreeSpac strcat(name_f_fsc, EMUFS_FSC_EXT); /* Cargo el registro */ - reg.n_Marker = n_Marker; - reg.n_FreeSpace = n_FreeSpace; + reg.n_marker = n_marker; + reg.n_freespace = n_freespace; /* Lo guardo en el archivo al final "a+"*/ if ( (f_fsc = fopen(name_f_fsc,"a+"))==NULL ) return -1; @@ -67,7 +67,7 @@ int emufs_fsc_agregar(EMUFS *emu, EMUFS_BLOCK_ID n_Marker, EMUFS_FREE n_FreeSpac } /* Objetivo: Actualiza un registro de espacio libre de acorde al FType */ -int emufs_fsc_actualizar(EMUFS *emu, EMUFS_BLOCK_ID n_Marker, EMUFS_FREE n_FreeSpace) +int emufs_fsc_actualizar(EMUFS *emu, EMUFS_BLOCK_ID n_marker, EMUFS_FREE n_freespace) { FILE *f_fsc; EMUFS_FSC reg; @@ -77,11 +77,11 @@ int emufs_fsc_actualizar(EMUFS *emu, EMUFS_BLOCK_ID n_Marker, EMUFS_FREE n_FreeS strcat(name_f_fsc, EMUFS_FSC_EXT); /*busco el bloque o gap que modifique*/ - if ( (f_fsc = fopen(name_f_fsc,"r+")) == NULL) return -1; + if ( (f_fsc = fopen(name_f_fsc,"r+")) == NULL) return -1; while ( !feof(f_fsc) ){ if ( fread(®,sizeof(EMUFS_FSC),1,f_fsc) != 1) continue; - if ( reg.n_Marker == n_Marker ){ - reg.n_FreeSpace = n_FreeSpace; + if ( reg.n_marker == n_marker ){ + reg.n_freespace = n_freespace; fseek(f_fsc,-sizeof(EMUFS_FSC),SEEK_CUR); fwrite(®,sizeof(EMUFS_FSC),1,f_fsc); break; @@ -91,8 +91,8 @@ int emufs_fsc_actualizar(EMUFS *emu, EMUFS_BLOCK_ID n_Marker, EMUFS_FREE n_FreeS return 0; } -/* Me devuelve el ID del bloque u Offset del Gap donde quepa un registro, y guarda en n_FreeSpace el espacio libre actualizado */ -EMUFS_BLOCK_ID emufs_fsc_buscar_lugar(EMUFS *emu, EMUFS_FREE n_RegSize, EMUFS_FREE *n_FreeSpace) +/* Me devuelve el ID del bloque u Offset del Gap donde quepa un registro, y guarda en n_freespace el espacio libre actualizado */ +EMUFS_BLOCK_ID emufs_fsc_buscar_lugar(EMUFS *emu, EMUFS_FREE n_RegSize, EMUFS_FREE *n_freespace) { FILE *f_fsc; EMUFS_FSC reg; @@ -108,22 +108,22 @@ EMUFS_BLOCK_ID emufs_fsc_buscar_lugar(EMUFS *emu, EMUFS_FREE n_RegSize, EMUFS_FR /* en caso de que no se halle un espacio libre apropiado */ while(!feof(f_fsc) && !b_Found){ if (fread(®,sizeof(EMUFS_FSC),1,f_fsc) != 1) continue; - if (reg.n_FreeSpace >= n_RegSize) b_Found = 1; + if (reg.n_freespace >= n_RegSize) b_Found = 1; } /* Si salio por error o por fin de archivo y no encontro space... */ if (!b_Found) { - reg.n_Marker = -1; - *n_FreeSpace = emu->tam_bloque; + reg.n_marker = -1; + *n_freespace = emu->tam_bloque; } - else *n_FreeSpace = reg.n_FreeSpace; + else *n_freespace = reg.n_freespace; fclose(f_fsc); - return reg.n_Marker; + return reg.n_marker; } /* Devuelve el espacio libre de un Bloque o Gap dado */ -EMUFS_FREE emufs_fsc_get_fs(EMUFS *emu, EMUFS_BLOCK_ID n_Marker) +EMUFS_FREE emufs_fsc_get_fs(EMUFS *emu, EMUFS_BLOCK_ID n_marker) { FILE *f_fsc; EMUFS_FSC reg; @@ -136,10 +136,10 @@ EMUFS_FREE emufs_fsc_get_fs(EMUFS *emu, EMUFS_BLOCK_ID n_Marker) if ( (f_fsc = fopen(name_f_fsc,"r"))==NULL ) return -1; while ( !feof(f_fsc) ){ if ( fread(®,sizeof(EMUFS_FSC),1,f_fsc) != 1 ) continue; - if ( reg.n_Marker == n_Marker ) + if ( reg.n_marker == n_marker ) break; } fclose(f_fsc); - return reg.n_FreeSpace; + return reg.n_freespace; }