--- projects/cms/source/ihost/libstatgrab/disk_stat.c 2002/05/19 12:33:53 1.8 +++ projects/cms/source/ihost/libstatgrab/disk_stat.c 2002/05/21 16:16:41 1.10 @@ -116,8 +116,8 @@ char *get_disk_stats(){ } #endif -#ifdef linux - if ((f=fopen("/etc/mtab", "r" ))==NULL){ +#ifdef LINUX + if ((f=setmntent("/etc/mtab", "r" ))==NULL){ errf("Failed to open mounts (%m)"); return NULL; } @@ -154,7 +154,7 @@ char *get_disk_stats(){ sd=sd_ptr; } - if ((fclose(f)) != 0) { + if ((endmntent(f)) != 0) { errf("Failed to close file (%m)"); return NULL; } @@ -199,7 +199,7 @@ char *get_disk_stats(){ sd_ptr=sd; xml_disk_stats=strdup(""); - while(sd_ptr!=NULL){ + for(counter=0;sd_ptr!=NULL;counter++){ xml_disk_stats_ptr=xml_disk_stats; if((xml_disk_stats=strf("%s", xml_disk_stats, counter, sd_ptr->disk->device_name, sd_ptr->disk->mnt_point, sd_ptr->disk->size, sd_ptr->disk->used, sd_ptr->disk->avail, sd_ptr->disk->t_inodes, sd_ptr->disk->f_inodes, counter)) == NULL){ errf("strf failed (%m)"); @@ -207,7 +207,6 @@ char *get_disk_stats(){ } free(xml_disk_stats_ptr); sd_ptr=sd_ptr->next_disk; - counter++; } xml_disk_stats_ptr=xml_disk_stats; xml_disk_stats=strf("%s",xml_disk_stats);