X-Git-Url: https://git.llucax.com/z.facultad/75.06/emufs.git/blobdiff_plain/f5f9e412009380bc5aea316c9ff48ea379f17f0c..675bb2f8da067ead4ed2643fa7dc5072de554b57:/emufs/fsc.c?ds=inline diff --git a/emufs/fsc.c b/emufs/fsc.c index 17a7244..a3aad0e 100644 --- a/emufs/fsc.c +++ b/emufs/fsc.c @@ -342,8 +342,8 @@ EMUFS_FREE emufs_fsc_get_total_fs(EMUFS *emu) fclose(f_fsc); return total; } -/* -EMUFS_FREE emufs_fsc_get_max_min_fs(EMUFS *emu, int *min, int *max) + +int emufs_fsc_get_max_min_fs(EMUFS *emu, EMUFS_FREE *min, EMUFS_FREE *max) { FILE *f_fsc; EMUFS_FSC reg; @@ -352,7 +352,7 @@ EMUFS_FREE emufs_fsc_get_max_min_fs(EMUFS *emu, int *min, int *max) strcpy(name_f_fsc,emu->nombre); strcat(name_f_fsc, EMUFS_FSC_EXT); - *min = emu->tam_bloque; + *min = ULONG_MAX; *max = 0; if ( (f_fsc = fopen(name_f_fsc,"r"))==NULL ) return -1; @@ -367,4 +367,26 @@ EMUFS_FREE emufs_fsc_get_max_min_fs(EMUFS *emu, int *min, int *max) fclose(f_fsc); return 0; } -*/ + +EMUFS_FREE emufs_fsc_get_media_fs(EMUFS *emu) +{ + FILE *f_fsc; + EMUFS_FSC reg; + char name_f_fsc[255]; + EMUFS_FREE total_fs = 0; + EMUFS_REG_ID gap_count = 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); + total_fs += reg.freespace; + ++gap_count; + } + + fclose(f_fsc); + return total_fs/gap_count; +}