1 | /* $Id: mountlist.c,v 1.1.1.2 2004-10-03 04:59:48 ghudson Exp $ */ |
---|
2 | |
---|
3 | /* Copyright (C) 1998-99 Martin Baulig |
---|
4 | This file is part of LibGTop 1.0. |
---|
5 | |
---|
6 | Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. |
---|
7 | |
---|
8 | LibGTop is free software; you can redistribute it and/or modify it |
---|
9 | under the terms of the GNU General Public License as published by |
---|
10 | the Free Software Foundation; either version 2 of the License, |
---|
11 | or (at your option) any later version. |
---|
12 | |
---|
13 | LibGTop is distributed in the hope that it will be useful, but WITHOUT |
---|
14 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
15 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
---|
16 | for more details. |
---|
17 | |
---|
18 | You should have received a copy of the GNU General Public License |
---|
19 | along with LibGTop; see the file COPYING. If not, write to the |
---|
20 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
---|
21 | Boston, MA 02111-1307, USA. |
---|
22 | */ |
---|
23 | |
---|
24 | #include <locale.h> |
---|
25 | #include <libintl.h> |
---|
26 | #include <stdio.h> |
---|
27 | |
---|
28 | #include <glibtop.h> |
---|
29 | #include <glibtop/open.h> |
---|
30 | #include <glibtop/close.h> |
---|
31 | |
---|
32 | #include <glibtop/parameter.h> |
---|
33 | |
---|
34 | #include <glibtop/mountlist.h> |
---|
35 | #include <glibtop/fsusage.h> |
---|
36 | |
---|
37 | #ifndef PROFILE_COUNT |
---|
38 | #define PROFILE_COUNT 1000 |
---|
39 | #endif |
---|
40 | |
---|
41 | int |
---|
42 | main (int argc, char *argv []) |
---|
43 | { |
---|
44 | glibtop_fsusage fsusage; |
---|
45 | glibtop_mountlist mount_list; |
---|
46 | glibtop_mountentry *mount_entries; |
---|
47 | unsigned c, index, method, count, port; |
---|
48 | char buffer [BUFSIZ]; |
---|
49 | |
---|
50 | setlocale (LC_ALL, ""); |
---|
51 | bindtextdomain (GETTEXT_PACKAGE, GTOPLOCALEDIR); |
---|
52 | textdomain (GETTEXT_PACKAGE); |
---|
53 | |
---|
54 | glibtop_init_r (&glibtop_global_server, 0, GLIBTOP_INIT_NO_OPEN); |
---|
55 | |
---|
56 | glibtop_get_parameter (GLIBTOP_PARAM_METHOD, &method, sizeof (method)); |
---|
57 | |
---|
58 | printf ("Method = %d\n", method); |
---|
59 | |
---|
60 | count = glibtop_get_parameter (GLIBTOP_PARAM_COMMAND, buffer, BUFSIZ); |
---|
61 | buffer [count] = 0; |
---|
62 | |
---|
63 | printf ("Command = '%s'\n", buffer); |
---|
64 | |
---|
65 | count = glibtop_get_parameter (GLIBTOP_PARAM_HOST, buffer, BUFSIZ); |
---|
66 | buffer [count] = 0; |
---|
67 | |
---|
68 | glibtop_get_parameter (GLIBTOP_PARAM_PORT, &port, sizeof (port)); |
---|
69 | |
---|
70 | printf ("Host = '%s' - %u\n\n", buffer, port); |
---|
71 | |
---|
72 | printf ("sbrk (0) = %p\n\n", sbrk (0)); |
---|
73 | |
---|
74 | for (c = 0; c < PROFILE_COUNT; c++) { |
---|
75 | mount_entries = glibtop_get_mountlist (&mount_list, 1); |
---|
76 | |
---|
77 | g_free (mount_entries); |
---|
78 | } |
---|
79 | |
---|
80 | printf ("sbrk (0) = %p\n\n", sbrk (0)); |
---|
81 | |
---|
82 | mount_entries = glibtop_get_mountlist (&mount_list, 1); |
---|
83 | |
---|
84 | if (mount_entries == NULL) |
---|
85 | _exit (1); |
---|
86 | |
---|
87 | for (index = 0; index < mount_list.number; index++) |
---|
88 | printf ("Mount_Entry: %-30s %-10s %-20s\n", |
---|
89 | mount_entries [index].mountdir, |
---|
90 | mount_entries [index].type, |
---|
91 | mount_entries [index].devname); |
---|
92 | |
---|
93 | printf ("\n\n%-16s %9s %9s %9s %9s %9s %9s\n", |
---|
94 | "Mount", "Blocks", "Free", "Avail", "Files", "Free", "BlockSz"); |
---|
95 | |
---|
96 | for (index = 0; index < mount_list.number; index++) { |
---|
97 | glibtop_get_fsusage (&fsusage, |
---|
98 | mount_entries [index].mountdir); |
---|
99 | |
---|
100 | printf ("%-16s %9Lu %9Lu %9Lu %9Lu %9Lu %9d\n", |
---|
101 | mount_entries [index].mountdir, |
---|
102 | fsusage.blocks, fsusage.bfree, |
---|
103 | fsusage.bavail, fsusage.files, |
---|
104 | fsusage.ffree, fsusage.block_size); |
---|
105 | } |
---|
106 | |
---|
107 | g_free (mount_entries); |
---|
108 | |
---|
109 | printf ("\nsbrk (0) = %p\n\n", sbrk (0)); |
---|
110 | |
---|
111 | glibtop_close (); |
---|
112 | |
---|
113 | exit (0); |
---|
114 | } |
---|