X-Git-Url: https://git.llucax.com/z.facultad/75.06/emufs.git/blobdiff_plain/5b66d417c3e3e118874abb1861c8237e275bb614..8f3c412038381c67bd166c1bc3de8f808e97d6cb:/emufs/fsc.c?ds=sidebyside diff --git a/emufs/fsc.c b/emufs/fsc.c index ffcad79..cc634c5 100644 --- a/emufs/fsc.c +++ b/emufs/fsc.c @@ -115,7 +115,7 @@ int emufs_fsc_agregar_gap(EMUFS *emu, EMUFS_OFFSET marker, EMUFS_FREE freespace) reg_count += 1; } - /* Si no encontre gaps ni por delante ni por detras */ +/* Si no encontre gaps ni por delante ni por detras */ if ((gap_before.marker == -1) && (gap_after.marker == -1)) { /* Lo guardo ordenado donde deba ir */ gap_new.marker = marker; @@ -457,3 +457,33 @@ EMUFS_FREE emufs_fsc_get_media_fs(EMUFS *emu) if (gap_count > 0) return total_fs/gap_count; else return 0; } + +int emufs_fsc_get_cant_bloques_vacios(EMUFS *emu) +{ + FILE *f_fsc; + EMUFS_FSC reg; + char name_f_fsc[255]; + int cant=0; + + strcpy(name_f_fsc,emu->nombre); + strcat(name_f_fsc, EMUFS_FSC_EXT); + + if ( (f_fsc = fopen(name_f_fsc,"r"))==NULL ) return -1; + while ( !feof(f_fsc) ){ + fread(®, sizeof(EMUFS_FSC), 1, f_fsc); + if ( reg.freespace == emu->tam_bloque ) + cant++; + } + + fclose(f_fsc); + return cant; +} + +int emufs_fsc_truncate(EMUFS* efs, EMUFS_BLOCK_ID blocks) +{ + char name_f_fsc[255]; + + strcpy(name_f_fsc, efs->nombre); + strcat(name_f_fsc, EMUFS_FSC_EXT); + return truncate(name_f_fsc, blocks * sizeof(EMUFS_FSC)); +}