Improved example.

svn path=/trunk/; revision=2758
This commit is contained in:
Benoît Dejean
2008-06-23 22:07:26 +00:00
parent 7f779e078d
commit ce23ce407c

View File

@@ -27,25 +27,31 @@ static void print_fsusage(const char *mountpoint)
} }
int main() int main(int argc, char **argv)
{ {
glibtop_mountlist buf; glibtop_mountlist buf;
glibtop_mountentry *entries;
size_t i;
glibtop_init(); glibtop_init();
printf("%-30s %10s %10s %10s %5s %10s %10s\n", printf("%-30s %10s %10s %10s %5s %10s %10s\n",
"Filesystem", "Size", "Used", "Avail", "Use%", "Read", "Write"); "Filesystem", "Size", "Used", "Avail", "Use%", "Read", "Write");
entries = glibtop_get_mountlist(&buf, TRUE); if (argc > 1) {
while (*++argv)
print_fsusage(*argv);
} else {
glibtop_mountentry *entries;
size_t i;
for(i = 0; i < buf.number; ++i) entries = glibtop_get_mountlist(&buf, TRUE);
{
print_fsusage(entries[i].mountdir);
}
g_free(entries); for(i = 0; i < buf.number; ++i)
{
print_fsusage(entries[i].mountdir);
}
g_free(entries);
}
glibtop_close(); glibtop_close();