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; |
170 |
|
xml_disk_stats=strdup("<disk>"); |
171 |
|
|
172 |
|
while(sd_ptr!=NULL){ |
173 |
+ |
xml_disk_stats_ptr=xml_disk_stats; |
174 |
|
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){ |
175 |
|
errf("strf failed (%m)"); |
176 |
|
return NULL; |
177 |
|
} |
178 |
+ |
free(xml_disk_stats_ptr); |
179 |
|
sd_ptr=sd_ptr->next_disk; |
180 |
|
counter++; |
181 |
|
} |
182 |
|
|
183 |
|
xml_disk_stats=strf("%s</disk>",xml_disk_stats); |
184 |
+ |
|
185 |
+ |
/* Cleaning up */ |
186 |
+ |
sd_ptr=sd; |
187 |
+ |
while(sd_ptr!=NULL){ |
188 |
+ |
sd=sd_ptr->next_disk; |
189 |
+ |
free(sd_ptr->disk->device_name); |
190 |
+ |
free(sd_ptr->disk->mnt_point); |
191 |
+ |
free(sd_ptr->disk); |
192 |
+ |
free(sd_ptr); |
193 |
+ |
sd_ptr=sd; |
194 |
+ |
} |
195 |
|
|
196 |
|
return xml_disk_stats; |
197 |
|
} |