37 |
|
system_disks_t *sd_ptr=sd; |
38 |
|
int counter=0; |
39 |
|
char *xml_disk_stats; |
40 |
+ |
char *xml_disk_stats_ptr; |
41 |
|
#ifdef SOLARIS |
42 |
|
struct mnttab mp; |
43 |
|
struct statvfs df; |
91 |
|
|
92 |
|
} |
93 |
|
|
94 |
+ |
if((fclose(f))!=0){ |
95 |
+ |
errf("Failed to close mnttab"); |
96 |
+ |
return NULL; |
97 |
+ |
} |
98 |
+ |
|
99 |
|
#endif |
100 |
|
#ifdef linux |
101 |
|
if ((f=fopen("/etc/mtab", "r" ))==NULL){ |
175 |
|
xml_disk_stats=strdup("<disk>"); |
176 |
|
|
177 |
|
while(sd_ptr!=NULL){ |
178 |
+ |
xml_disk_stats_ptr=xml_disk_stats; |
179 |
|
if((xml_disk_stats=strf("%s<p%d name=\"%s\" mount=\"%s\" kbytes=\"%ld\" used=\"%ld\" avail=\"%ld\" totalinodes=\"%ld\" freeinodes=\"%ld\"></p%d>", 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){ |
180 |
|
errf("strf failed (%m)"); |
181 |
|
return NULL; |
182 |
|
} |
183 |
+ |
free(xml_disk_stats_ptr); |
184 |
|
sd_ptr=sd_ptr->next_disk; |
185 |
|
counter++; |
186 |
|
} |
187 |
< |
|
187 |
> |
xml_disk_stats_ptr=xml_disk_stats; |
188 |
|
xml_disk_stats=strf("%s</disk>",xml_disk_stats); |
189 |
+ |
free(xml_disk_stats_ptr); |
190 |
+ |
|
191 |
+ |
/* Cleaning up */ |
192 |
+ |
sd_ptr=sd; |
193 |
+ |
while(sd_ptr!=NULL){ |
194 |
+ |
sd=sd_ptr->next_disk; |
195 |
+ |
free(sd_ptr->disk->device_name); |
196 |
+ |
free(sd_ptr->disk->mnt_point); |
197 |
+ |
free(sd_ptr->disk); |
198 |
+ |
free(sd_ptr); |
199 |
+ |
sd_ptr=sd; |
200 |
+ |
} |
201 |
|
|
202 |
|
return xml_disk_stats; |
203 |
|
} |