Compare commits
127 Commits
stable_aft
...
top_3_4
Author | SHA1 | Date | |
---|---|---|---|
|
f77eba3d57 | ||
|
f18952a9d8 | ||
|
16cb163bb0 | ||
|
f8bdfa9a43 | ||
|
61f887fc67 | ||
|
9fd8936e93 | ||
|
ef693a93bc | ||
|
aa04293fc3 | ||
|
345a657d2c | ||
|
da7d7ff116 | ||
|
c5263a881e | ||
|
49adb94af0 | ||
|
b991ecaf9a | ||
|
2c8ae09776 | ||
|
8ecb7f296e | ||
|
3477d30dc5 | ||
|
f30dfecaf7 | ||
|
8a666eb5a4 | ||
|
61071132bf | ||
|
b177c3930d | ||
|
eb8d28b694 | ||
|
0b4f757b2b | ||
|
2aa20e2060 | ||
|
7d8ff8f72e | ||
|
576dde394a | ||
|
1d7491be0d | ||
|
15cc0113a9 | ||
|
9532dadc2e | ||
|
94715ef718 | ||
|
44bb75cf6e | ||
|
4d2072ce65 | ||
|
eb36f97c50 | ||
|
a76522a990 | ||
|
71187a5e51 | ||
|
b54a5d2dfd | ||
|
134ec106b3 | ||
|
1b90ed4fcc | ||
|
3fcc477b25 | ||
|
81c75477f4 | ||
|
8b025ff2c2 | ||
|
2de9ea5c7d | ||
|
d9e6288b7a | ||
|
8d78559597 | ||
|
2a281d0a53 | ||
|
28dfff5752 | ||
|
7d0d3db11c | ||
|
63c475d400 | ||
|
d334a77447 | ||
|
1b7d7976b1 | ||
|
d7770a12c6 | ||
|
5fef6560bf | ||
|
75605116d0 | ||
|
35943ea8fc | ||
|
e166f54328 | ||
|
c1cc35ac17 | ||
|
0acb497216 | ||
|
58707dac42 | ||
|
8f14d30d11 | ||
|
bde0d74282 | ||
|
026e93121e | ||
|
f87722233a | ||
|
03c5a235ef | ||
|
215ab9f17b | ||
|
794a8efaed | ||
|
b56c327ccc | ||
|
8f43551d68 | ||
|
23cccaf87f | ||
|
c75b77affc | ||
|
7ffc53f45e | ||
|
6ea7e47194 | ||
|
6130f0a4f9 | ||
|
44dcb69c41 | ||
|
13148c632f | ||
|
6fd3c113ec | ||
|
9661c4becc | ||
|
c60d1d5449 | ||
|
eedc64096c | ||
|
cf8068049f | ||
|
5e3d6bdf18 | ||
|
aff6786e71 | ||
|
2408a0731c | ||
|
a3c345e79e | ||
|
b2950457ce | ||
|
9ce768bc4b | ||
|
c9e7e3a862 | ||
|
33eefd46c7 | ||
|
be91463190 | ||
|
28324c38cc | ||
|
4cb95e1477 | ||
|
691cd81192 | ||
|
9c9ad03d60 | ||
|
c84923132a | ||
|
85f31a1707 | ||
|
92ec7c6d33 | ||
|
0a323e5080 | ||
|
222df2c7d6 | ||
|
f92d7f9ee7 | ||
|
de5cf356c9 | ||
|
d3f9cb80d7 | ||
|
fb61de47a0 | ||
|
0727d0911c | ||
|
fbb3070abe | ||
|
402c96e473 | ||
|
44f28a486b | ||
|
4aeb33b2b9 | ||
|
3728e4c34e | ||
|
e71eb0e75b | ||
|
f233a1673f | ||
|
b96843a960 | ||
|
eb69a5547f | ||
|
7f39d62371 | ||
|
6f179a3141 | ||
|
cad4b8f2f5 | ||
|
beb68e2fc4 | ||
|
b4a16ccd89 | ||
|
15e73d9b7d | ||
|
344bdd330f | ||
|
2546fa37eb | ||
|
080dd0850b | ||
|
b7be9a7141 | ||
|
67798e0d7d | ||
|
6de9ad750b | ||
|
68162783dc | ||
|
95b9d824ea | ||
|
7dd0c2eac3 | ||
|
62dda3b782 | ||
|
4e1e1ccb9f |
@@ -24,3 +24,4 @@ stamp-h
|
||||
sun4
|
||||
sun4sol2
|
||||
support
|
||||
i386-freebsd
|
||||
|
371
ChangeLog
371
ChangeLog
@@ -1,10 +1,288 @@
|
||||
1998-07-14 Martin Baulig <baulig@Stud.Informatik.uni-trier.de>
|
||||
|
||||
* src/daemon/server_config.h.in: Added some comments.
|
||||
|
||||
* src/daemon/server_config.pl: New file. This is a script you can use
|
||||
to create `server_config.h'. It will query you for some configuration
|
||||
options.
|
||||
|
||||
* configure.in (AC_PROG_AWK): Replaced this test with explicit test
|
||||
for `gawk' and `awk' since `mawk' doesn't work.
|
||||
|
||||
1998-07-14 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* src/daemon/gnuserv.c: Doing correct server initialization
|
||||
using `glibtop_set_parameter_l' and `glibtop_init_r'.
|
||||
|
||||
* src/daemon/main.c: Removed call to `glibtop_init_r'.
|
||||
|
||||
* lib/open.c (glibtop_open_l): We now call the open function
|
||||
of the sysdeps directory (glibtop_open_r) for server method
|
||||
`GLIBTOP_METHOD_DIRECT'.
|
||||
|
||||
* sysdeps/{linux, sun4, stub}/open.c: No longer `memset'
|
||||
server to zero.
|
||||
|
||||
* src/daemon/slave.c: New file.
|
||||
|
||||
* src/daemon/*.c: Done some more work on the daemon.
|
||||
|
||||
* sysdeps/common/gnuslib.c: Removed IPC stuff.
|
||||
|
||||
* include/glibtop/gnuserv.h: Removed IPC stuff.
|
||||
|
||||
* include/glibtop/command.h (glibtop_response_unit): Added
|
||||
typedef for `struct _glibtop_response_unit'.
|
||||
|
||||
* lib/Makefile.am: Using `$(top_srcdir)/features.def'
|
||||
instead of `$(top_builddir)/features.def'.
|
||||
|
||||
* sysdeps/guile/Makefile.am: Using `$(top_srcdir)/features.def'
|
||||
instead of `$(top_builddir)/features.def'.
|
||||
|
||||
* sysdeps/guile/names/Makefile.am: Dito.
|
||||
|
||||
* sysdeps/stub/*.c: changed suffix of all functions
|
||||
from '_s' to '_r'; see also ChangeLog entry from Jun 6.
|
||||
|
||||
1998-07-13 Martin Baulig <baulig@merkur.uni-trier.de>
|
||||
|
||||
* src/daemon/server_config.h: Removed from CVS.
|
||||
This is a config file which needs to be edited.
|
||||
|
||||
* src/daemon/server_config.h.in: Added. This is just
|
||||
an example for `server_config.h'.
|
||||
|
||||
1998-07-13 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* glibtop.h: Fixed invocation of `glibtop_close_r'.
|
||||
|
||||
* sysdeps/linux/procstate.c: Added missing `fclose'.
|
||||
|
||||
* include/glibtop/gnuserv.h (UNIX_DOMAIN_SOCKETS): Defining.
|
||||
|
||||
* include/glibtop/open.h (GLIBTOP_METHOD_UNIX): Added.
|
||||
|
||||
* lib/init.c: Added new method `GLIBTOP_METHOD_UNIX'.
|
||||
|
||||
* lib/open.c: Added support for Unix Domain Sockets.
|
||||
|
||||
* lib/close.c: Now closing inet and unix connections.
|
||||
|
||||
* lib/parameter.c (glibtop_set_parameter_l): You can now
|
||||
set the `method' and `features' fields.
|
||||
|
||||
* src/daemon/server_config.h: New file.
|
||||
|
||||
* src/daemon/{gnuserv.c, main.c}: More work on the server.
|
||||
|
||||
1998-07-10 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* src/Makefile.am (SUBDIRS): Removed `proxy'. This directory
|
||||
is considered obsolete and will be removed soon.
|
||||
|
||||
1998-07-06 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* sysdeps/common/mountlist.c: using functions from `xmalloc.c'.
|
||||
|
||||
* sysdeps/common/error.c: all functions now accept NULL as
|
||||
`server' argument.
|
||||
|
||||
* acconfig.h (AFS, MOUNTED_FREAD, MOUNTED_FREAD_FSTYP,
|
||||
MOUNTED_GETFSSTAT, MOUNTED_GETMNT, MOUNTED_GETMNTENT1,
|
||||
MOUNTED_GETMNTENT2, MOUNTED_GETMNTINFO, MOUNTED_LISTMNTENT,
|
||||
MOUNTED_VMOUNT, STAT_STATFS3_OSF1, STAT_READ_FILSYS,
|
||||
STAT_STATFS2_BSIZE, STAT_STATFS2_FSIZE, STAT_STATFS2_FS_DATA,
|
||||
STAT_STATFS4, STAT_STATVFS, STATFS_TRUNCATES_BLOCK_COUNTS):
|
||||
New macros.
|
||||
|
||||
* configure.in: added GNOME_FILEUTILS_CHECKS.
|
||||
|
||||
* sysdeps/common/{fsusage, mountlist}.[ch]:
|
||||
Imported from GNU Fileutils 3.16.
|
||||
|
||||
* sysdeps/common/mountlist.c: using g_malloc, g_realloc and g_strdup.
|
||||
|
||||
1998-07-03 Martin baulig <martin@home-of-linux.org>
|
||||
|
||||
* macros/gnome-libgtop-sysdeps.m4: No longer use
|
||||
`glibtop_machine.h' for Linux.
|
||||
|
||||
* sysdeps/linux/glibtop_machine.h: Removed.
|
||||
|
||||
* sysdeps/guile/guile.awk: Using `scm_append'
|
||||
instead of `gh_append'.
|
||||
|
||||
* sysdeps/guile/names/guile-names.awk: dito.
|
||||
|
||||
* sysdeps/linux/*.c: Using code from stable branch again.
|
||||
|
||||
* include/glibtop/parameter.h: New file.
|
||||
|
||||
* lib/parameter.c: New file.
|
||||
|
||||
* lib/{open, init}.c: Done some more work on server
|
||||
initialization
|
||||
|
||||
1998-06-21 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* perl/*: Added perl interface.
|
||||
|
||||
* sysdeps/linux/cpu.c: Bug fix.
|
||||
|
||||
* include/glibtop/global.h: Only including guile header files
|
||||
within libgtop.
|
||||
|
||||
* configure.in (LIGBTOP_LIBS): Added `-lgtop'.
|
||||
|
||||
* Makefile.am: Creating `perl/Makefile.PL' from `perl/Makefile.PL.in'
|
||||
and `perl/Libgtop.xs' using `perl/perl.awk'.
|
||||
|
||||
1998-06-18 Martin Baulig <baulig@taurus.uni-trier.de>
|
||||
|
||||
* sysdeps/linux/*.c: Reverted some stuff from 06-07-1998
|
||||
since it was too buggy.
|
||||
|
||||
* glibtop.h (_glibtop): New field `server_port'.
|
||||
|
||||
* lib/xmalloc.c (glibtop_strdup_r): New function.
|
||||
|
||||
* lib/gnuclient.c: Removed.
|
||||
|
||||
* lib/{command, write, read}.c: Changed client <-> server
|
||||
interface to make less system calls.
|
||||
|
||||
* src/daemon/main.c: Changed server side of interface.
|
||||
|
||||
* include/glibtop/command.h (struct _glibtop_response): New
|
||||
structure to return data from the server to the client.
|
||||
|
||||
1998-06-14 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* glibtop.h (struct _glibtop): Added `socket' field.
|
||||
|
||||
* include/glibtop/gnuserv.h: New file. Imported from xemacs 20.3.
|
||||
|
||||
* sysdeps/common/gnuslib.c: New file. Imported from xemacs 20.3
|
||||
|
||||
* lib/gnuclient.c: New file. Imported from xemacs 20.3
|
||||
|
||||
* sysdeps/daemon/gnuserv.c: New file. Imported from xemacs 20.3
|
||||
|
||||
* sysdeps/daemon: New directory.
|
||||
|
||||
* configure.in (LIBGTOP_LIBS, LIBGTOP_GUILE_LIBS): Added
|
||||
`$X_LIBS -lXau' when we have xauth.
|
||||
|
||||
* acconfig.h (HAVE_XAUTH): New tag.
|
||||
|
||||
* configure.in: Added check for `HAVE_XAUTH'.
|
||||
|
||||
* sysdeps/common/error.c (glibtop_warn_r): New function -
|
||||
same as `glibtop_error_r', but doesn't call `exit'.
|
||||
(glibtop_error_io_r, glibtop_warn_io_r): New functions,
|
||||
display `strerror (errno)' together with message.
|
||||
|
||||
* include/glibtop/global.h (TIME_WITH_SYS_TIME): including
|
||||
correct headers; (HAVE_UNISTD_H): Added conditional.
|
||||
Added `#include <sys/param.h>' and `#include <sys/stat.h>'.
|
||||
|
||||
* acconfig.h (HAVE_LINUX_TABLE): New tag.
|
||||
|
||||
* lib/lib.awk: New file.
|
||||
Creates `lib.c' depending upon `features.def'.
|
||||
|
||||
* lib/<feature>.c: Removed.
|
||||
|
||||
* sysdeps/guile/guile.awk: New file.
|
||||
Creates `guile.c' depending upon `features.def'.
|
||||
|
||||
* sysdeps/guile/*.c: Removed.
|
||||
|
||||
1998-06-13 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* features.def: List of features for `guile-names.awk'.
|
||||
|
||||
* sysdeps/guile/names/guile-names.awk: New file.
|
||||
Creates `guile-names.c' depending upon `features.def'.
|
||||
|
||||
* sysdeps/guile/names/*.c: Removed.
|
||||
|
||||
* kernel: New directory. Contains some kernel code to
|
||||
implement a new system call table () to fetch information
|
||||
directly from the Linux kernel.
|
||||
|
||||
* sysdeps/kernel: New directory. Uses the table () function
|
||||
from the `kernel' directory to fetch things directly from
|
||||
the Linux kernel.
|
||||
|
||||
* sysdeps/Makefile.am (DIST_SUBDIRS): Added `kernel'.
|
||||
|
||||
* configure.in: Removed `build_CC' again.
|
||||
|
||||
1998-06-12 Martin Baulig <baulig@taurus.uni-trier.de>
|
||||
|
||||
* include/glibtop/sysdeps.h (glibtop_types_sysdeps):
|
||||
Forgot to change declaration on Jun 6.
|
||||
|
||||
* sysdeps/names/sysdeps.c (glibtop_types_sysdeps):
|
||||
Using numeric constants from `types.h' instead of string
|
||||
constants; forgot to change this on Jun 6. Added information
|
||||
about new `features' field of `_glibtop_sysdeps'.
|
||||
|
||||
* sysdeps/guile/names/*.c (glibtop_guile_types_*):
|
||||
Using `gh_ulong2scm' instead of `gh_str02scm'.
|
||||
|
||||
* sysdeps/guile/proclist.c: Replaced call to
|
||||
`gh_append2 ()' with `gh_append ()'.
|
||||
|
||||
* sysdeps/guile/names/*.c: dito.
|
||||
|
||||
1998-06-08 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* support: Added again.
|
||||
|
||||
* Makefile.am (SUBDIRS): Added `support' again.
|
||||
|
||||
* configure.in: First, we check for gnome. If it is not
|
||||
found, we run GNOME_SUPPORT_CHECKS; otherwise use
|
||||
`$GNOME_LIBDIR -lgnomesupport'.
|
||||
|
||||
1998-06-07 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* examples/ChangeLog: New file.
|
||||
|
||||
* macros/gnome-libgtop-sysdeps.m4: Include
|
||||
`glibtop_machine.h' for Linux.
|
||||
|
||||
* sysdeps/linux/glibtop_machine.h: New file.
|
||||
|
||||
* sysdeps/linux/*.c: Performance optimizations. We now use
|
||||
`open' and `read' instead of `fopen' and `fscanf'.
|
||||
|
||||
* *.[ch]: Using single underscore instead of two underscores
|
||||
for function prefixes (regexp: ``s,__([rspl])\b,_$1,g'') to
|
||||
avoid ambiguity with mangled C++ names.
|
||||
|
||||
1998-06-06 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* sysdeps/osf1/glibtop_server.h: New file.
|
||||
|
||||
* sysdeps/osf1/*.c: renamed all functions implementing
|
||||
features that don't need to be suid to '__s'.
|
||||
|
||||
* sysdeps/names/procdata.c: Removed that file.
|
||||
|
||||
* include/glibtop/*.h (glibtop_types_*): Changed declaration.
|
||||
|
||||
* glibtop.h: Added `#include <types.h>'.
|
||||
|
||||
* include/glibtop/types.h: New file - numeric constants
|
||||
for `glibtop_types_<feature>'.
|
||||
|
||||
* sysdeps/names/*.c (glibtop_types_*): Using numeric
|
||||
constants from `types.h' instead of string constants.
|
||||
|
||||
1998-06-05 Martin Baulig <baulig@taurus.uni-trier.de>
|
||||
|
||||
* support: removed that directory.
|
||||
@@ -36,6 +314,99 @@
|
||||
|
||||
* src/server/main.c: #include <locale.h>
|
||||
|
||||
1998-06-02 Martin Baulig <baulig@merkur.uni-trier.de>
|
||||
|
||||
* lib/open.c (glibtop_open): renamed to `glibtop_open__l'.
|
||||
|
||||
* sysdeps/linux/open.c (glibtop_open): renamed to
|
||||
`glibtop_open__r'.
|
||||
|
||||
* include/glibtop/open.h (GLIBTOP_OPEN_NO_OVERRIDE):
|
||||
tells `glibtop_open' to use the default server and not
|
||||
to check the environment variables.
|
||||
|
||||
* include/glibtop/sysdeps.h (_glibtop_sysdeps):
|
||||
renamed 'dummy' member to 'features'.
|
||||
|
||||
* src/proxy/*: new directory - proxy server.
|
||||
|
||||
* include/glibtop/command.h (GLIBTOP_CMND_SYSDEPS):
|
||||
added definition here.
|
||||
|
||||
* src/server/main.c (GLIBTOP_CMND_SYSDEPS): new
|
||||
command to get glibtop_server_features.
|
||||
|
||||
1998-06-01 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* NEWS: added more detailed description of today's and
|
||||
yesterday's changes.
|
||||
|
||||
* include/glibtop/*.h: to use the ChangeLog entry from May 28:
|
||||
'__l' is a function defined in the client part;
|
||||
'__s' is a function defined in the sysdeps part and
|
||||
'__p' is a function that needs special priviledges.
|
||||
'__r' is mapped either on '__p' or on '__s'.
|
||||
the function without suffix is mapped on '__l'.
|
||||
|
||||
* sysdeps/common/sysdeps.c: now using '__r' functions,
|
||||
they are #defined either as the '__p' or the '__s' ones.
|
||||
|
||||
* sysdeps/linux/*.c: changed call of 'glibtop_init__r',
|
||||
it now takes two additional arguments.
|
||||
|
||||
* examples/{first.c, second.c}: now using 'glibtop_init'
|
||||
instead of 'glibtop_init__r'.
|
||||
|
||||
* include/glibtop/sysdeps.h: added 'dummy' member so
|
||||
'GLIBTOP_SYSDEPS_<feature>' now start with 1.
|
||||
|
||||
* include/glibtop/*.h: we now #define 'glibtop_get_<feature>'
|
||||
as 'glibtop_get_<feature>__l' and 'glibtop_get_<feature>__r'
|
||||
either as the '__p' or the '__s' function.
|
||||
|
||||
* lib/*.c: removed #if's - we now decide at runtime
|
||||
whether to use the server or to call the appropriate
|
||||
function for the sysdeps directory.
|
||||
|
||||
1998-05-28 Martin Baulig <baulig@merkur.uni-trier.de>
|
||||
|
||||
* src/server/main.c: we now use the '__p' functions,
|
||||
but only if the appropriate 'GLIBTOP_SUID_<feature>'
|
||||
has a non-zero value.
|
||||
|
||||
* configure.in (@machine_incs@): always use
|
||||
`-I$(top_srcdir)/sysdeps/@sysdeps_dir@'; it's no
|
||||
longer conditional.
|
||||
|
||||
* examples/Makefile.am: removed the '_linux' examples.
|
||||
|
||||
* sysdeps/linux/*.c: renamed all functions implementing
|
||||
features to '__s'.
|
||||
|
||||
* lib/*.c: renamed all functions implementing features
|
||||
to '__l'; we only emit code for those functions if the
|
||||
corresponding 'GLIBTOP_SUID_<feature>' has a positive value.
|
||||
|
||||
* include/glibtop/*.h: added some new function suffixes:
|
||||
'__l' is a function defined in the client part;
|
||||
'__s' is a function defined in the sysdeps part and
|
||||
'__p' is a function that needs special priviledges.
|
||||
'__r' is mapped either on '__l' or on '__s'.
|
||||
|
||||
* sysdeps/linux/glibtop_server.h: New file -
|
||||
defines system dependent constants 'GLIBTOP_SUID_<feature>'
|
||||
being either 'GLIBTOP_SYSDEPS_<feature>'+1 depending upon
|
||||
whether or not this feature requires using the server.
|
||||
|
||||
* lib/sysdeps.c: removed that file; it is no longer
|
||||
needed.
|
||||
|
||||
1998-05-25 Martin Baulig <baulig@merkur.uni-trier.de>
|
||||
|
||||
* src/server/main.c: Fixed `broken pipe' error when server
|
||||
is running SUID; accidentally uses setreuid () instead of
|
||||
setregid ().
|
||||
|
||||
1998-05-24 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* sysdeps/sun4/{open.c, mem.c, glibtop_machine.h}: added
|
||||
|
31
Makefile.am
31
Makefile.am
@@ -4,9 +4,9 @@ if GLIBTOP_EXAMPLES
|
||||
examples_SUBDIRS = examples
|
||||
endif
|
||||
|
||||
built_SUBDIRS = include sysdeps src lib
|
||||
built_SUBDIRS = include sysdeps lib src
|
||||
|
||||
SUBDIRS = po intl macros $(built_SUBDIRS) $(examples_SUBDIRS)
|
||||
SUBDIRS = po intl support macros $(built_SUBDIRS) $(examples_SUBDIRS)
|
||||
|
||||
DIST_SUBDIRS = po intl macros include sysdeps src lib examples
|
||||
|
||||
@@ -22,6 +22,9 @@ release:
|
||||
confexecdir=$(libdir)
|
||||
confexec_DATA = $(top_builddir)/libgtopConf.sh
|
||||
|
||||
noinst_DATA = $(top_builddir)/perl/Makefile.PL \
|
||||
$(top_builddir)/perl/Libgtop.xs
|
||||
|
||||
## to automatically rebuild aclocal.m4 if any of the macros in
|
||||
## `macros/' change
|
||||
@MAINT@include macros/macros.dep
|
||||
@@ -51,3 +54,27 @@ libgtopConf.sh: libgtopConf.sh.in Makefile
|
||||
-e 's,\@libgtop_want_examples\@,$(libgtop_want_examples),g' \
|
||||
< $(srcdir)/libgtopConf.sh.in > libgtopConf.tmp \
|
||||
&& mv libgtopConf.tmp libgtopConf.sh
|
||||
|
||||
perl/Makefile.PL: perl/Makefile.PL.in Makefile
|
||||
## Use sed and then mv to avoid problems if the user interrupts.
|
||||
sed -e 's,\@LIBGTOP_LIBDIR\@,$(libdir),g' \
|
||||
-e 's,\@LIBGTOP_INCLUDEDIR\@,$(includedir),g' \
|
||||
-e 's,\@LIBGTOP_LIBS\@,$(LIBGTOP_LIBS),g' \
|
||||
-e 's,\@LIBGTOP_INCS\@,$(LIBGTOP_INCS),g' \
|
||||
-e 's,\@LIBGTOP_GUILE_LIBS\@,$(LIBGTOP_GUILE_LIBS),g' \
|
||||
-e 's,\@LIBGTOP_GUILE_INCS\@,$(LIBGTOP_GUILE_INCS),g' \
|
||||
-e 's,\@LIBGTOP_BINDIR\@,$(LIBGTOP_BINDIR),g' \
|
||||
-e 's,\@LIBGTOP_SERVER\@,$(LIBGTOP_SERVER),g' \
|
||||
-e 's,\@libgtop_sysdeps_dir\@,$(libgtop_sysdeps_dir),g' \
|
||||
-e 's,\@libgtop_need_server\@,$(libgtop_need_server),g' \
|
||||
-e 's,\@libgtop_use_machine_h\@,$(libgtop_use_machine_h),g' \
|
||||
-e 's,\@libgtop_guile_found\@,$(libgtop_guile_found),g' \
|
||||
-e 's,\@libgtop_want_names\@,$(libgtop_want_names),g' \
|
||||
-e 's,\@libgtop_want_guile_names\@,$(libgtop_want_guile_names),g' \
|
||||
-e 's,\@libgtop_want_examples\@,$(libgtop_want_examples),g' \
|
||||
< $(srcdir)/perl/Makefile.PL.in > perl/Makefile.tmp \
|
||||
&& mv perl/Makefile.tmp perl/Makefile.PL
|
||||
|
||||
perl/Libgtop.xs: perl/perl.awk $(top_builddir)/config.h $(top_srcdir)/features.def
|
||||
$(AWK) -f $(top_srcdir)/perl/perl.awk < $(top_srcdir)/features.def > perl/lgt-t
|
||||
mv perl/lgt-t perl/Libgtop.xs
|
||||
|
111
NEWS
111
NEWS
@@ -1,5 +1,116 @@
|
||||
$Id$
|
||||
|
||||
Jun/01/1998
|
||||
===========
|
||||
|
||||
* We have some new ``suffix rules'':
|
||||
|
||||
'__l' is a function defined in the client part;
|
||||
'__s' is a function defined in the sysdeps part and
|
||||
'__p' is a function that needs special priviledges.
|
||||
'__r' is mapped either on '__p' or on '__s'.
|
||||
the function without suffix is mapped on '__l'.
|
||||
|
||||
* We now decide at runtime whether or not using the server
|
||||
is required for a particular function. All user programs
|
||||
now call the '__l' function defined in '-lgtop' (in the lib
|
||||
subdir). These functions either use 'glibtop_call__l' to
|
||||
call the server or call the '__r' function.
|
||||
|
||||
* A function in the sysdeps directory now has the '__s' suffix
|
||||
if it do not need any priviledges (and thus can be called directly
|
||||
from client code) and the '__p' suffix otherwise (when it has to
|
||||
be called from the server).
|
||||
|
||||
* If you call one of these functions:
|
||||
|
||||
-> use the '__p' suffix to be sure to get the SUID-safe one
|
||||
(used in the server).
|
||||
-> use the '__s' suffix to be sure to get a function that
|
||||
doesn't need any priviledges.
|
||||
-> use the '__r' suffix otherwise (it is mapped either on the
|
||||
'__p' or on the '__s' one).
|
||||
|
||||
Only use the '__p' and '__s' functions in a 'GLIBTOP_SUID_<feature>'
|
||||
conditional, otherwise you'll get undefined symbols !
|
||||
|
||||
* The server is now started from 'glibtop_init__r', but only when
|
||||
it's really needed; for instance on DEC OSF/1 you only need it
|
||||
for the proc* features - if you program only fetches the CPU usage,
|
||||
now server will be started.
|
||||
|
||||
* Sorry, at the moment everything is a little bit unstable, I'm doing
|
||||
heavy changes. I've just some great ideas which still need some work:
|
||||
|
||||
-> I want to have a SUID server that only implements those features
|
||||
that need to be SUID; everything else uses the sysdeps code directly.
|
||||
|
||||
-> If a program only uses stuff that do not need the server, the
|
||||
server will not be started at all.
|
||||
|
||||
-> I'm working on some kind of proxy server that can be used on a remote
|
||||
host; in feature one can then use the MDI stuff from ghex in gtop to
|
||||
have notebook pages displaying processes from different hosts.
|
||||
|
||||
* Well it is as much unstable that it only works under Linux at the moment.
|
||||
|
||||
1998-06-01 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* sysdeps/common/sysdeps.c: now using '__r' functions,
|
||||
they are #defined either as the '__p' or the '__s' ones.
|
||||
|
||||
* sysdeps/linux/*.c: changed call of 'glibtop_init__r',
|
||||
it now takes two additional arguments.
|
||||
|
||||
* examples/{first.c, second.c}: now using 'glibtop_init'
|
||||
instead of 'glibtop_init__r'.
|
||||
|
||||
* include/glibtop/sysdeps.h: added 'dummy' member so
|
||||
'GLIBTOP_SYSDEPS_<feature>' now start with 1.
|
||||
|
||||
* include/glibtop/*.h: we now #define 'glibtop_get_<feature>'
|
||||
as 'glibtop_get_<feature>__l' and 'glibtop_get_<feature>__r'
|
||||
either as the '__p' or the '__s' function.
|
||||
|
||||
* lib/*.c: removed #if's - we now decide at runtime
|
||||
whether to use the server or to call the appropriate
|
||||
function for the sysdeps directory.
|
||||
|
||||
1998-05-28 Martin Baulig <baulig@merkur.uni-trier.de>
|
||||
|
||||
* src/server/main.c: we now use the '__p' functions,
|
||||
but only if the appropriate 'GLIBTOP_SUID_<feature>'
|
||||
has a non-zero value.
|
||||
|
||||
* configure.in (@machine_incs@): always use
|
||||
`-I$(top_srcdir)/sysdeps/@sysdeps_dir@'; it's no
|
||||
longer conditional.
|
||||
|
||||
* examples/Makefile.am: removed the '_linux' examples.
|
||||
|
||||
* sysdeps/linux/*.c: renamed all functions implementing
|
||||
features to '__s'.
|
||||
|
||||
* lib/*.c: renamed all functions implementing features
|
||||
to '__l'; we only emit code for those functions if the
|
||||
corresponding 'GLIBTOP_SUID_<feature>' has a positive value.
|
||||
|
||||
* include/glibtop/*.h: added some new function suffixes:
|
||||
'__l' is a function defined in the client part;
|
||||
'__s' is a function defined in the sysdeps part and
|
||||
'__p' is a function that needs special priviledges.
|
||||
'__r' is mapped either on '__l' or on '__s'.
|
||||
|
||||
* sysdeps/linux/glibtop_server.h: New file -
|
||||
defines system dependent constants 'GLIBTOP_SUID_<feature>'
|
||||
being either 'GLIBTOP_SYSDEPS_<feature>'+1 depending upon
|
||||
whether or not this feature requires using the server.
|
||||
|
||||
* lib/sysdeps.c: removed that file; it is no longer
|
||||
needed.
|
||||
|
||||
|
||||
|
||||
May/21/1998
|
||||
===========
|
||||
|
||||
|
83
acconfig.h
83
acconfig.h
@@ -12,6 +12,85 @@
|
||||
|
||||
/* Do not remove this comments and the empty lines; they are needed */
|
||||
#undef HAVE_PROGRAM_INVOCATION_SHORT_NAME
|
||||
/* Define if you have the Andrew File System. */
|
||||
#undef AFS
|
||||
|
||||
/* Define one of the following to indicate how a program can
|
||||
get a list of mounted filesystems. */
|
||||
|
||||
/* Define if there is no specific function for reading the list of
|
||||
mounted filesystems. fread will be used to read /etc/mnttab. [SVR2] */
|
||||
#undef MOUNTED_FREAD
|
||||
|
||||
/* Define if (like SVR2) there is no specific function for reading the
|
||||
list of mounted filesystems, and your system has these header files:
|
||||
<sys/fstyp.h> and <sys/statfs.h>. [SVR3] */
|
||||
#undef MOUNTED_FREAD_FSTYP
|
||||
|
||||
/* Define if there is a function named getfsstat for reading the list
|
||||
of mounted filesystems. [DEC Alpha running OSF/1] */
|
||||
#undef MOUNTED_GETFSSTAT
|
||||
|
||||
/* Define if there is a function named getmnt for reading the list of
|
||||
mounted filesystems. [Ultrix] */
|
||||
#undef MOUNTED_GETMNT
|
||||
|
||||
/* Define if there is a function named getmntent for reading the list
|
||||
of mounted filesystems, and that function takes a single argument.
|
||||
[4.3BSD, SunOS, HP-UX, Dynix, Irix] */
|
||||
#undef MOUNTED_GETMNTENT1
|
||||
|
||||
/* Define if there is a function named getmntent for reading the list of
|
||||
mounted filesystems, and that function takes two arguments. [SVR4] */
|
||||
#undef MOUNTED_GETMNTENT2
|
||||
|
||||
/* Define if there is a function named getmntinfo for reading the list
|
||||
of mounted filesystems. [4.4BSD] */
|
||||
#undef MOUNTED_GETMNTINFO
|
||||
|
||||
/* Define if there is a function named listmntent that can be used to
|
||||
list all mounted filesystems. [UNICOS] */
|
||||
#undef MOUNTED_LISTMNTENT
|
||||
|
||||
/* Define if there is a function named mntctl that can be used to read
|
||||
the list of mounted filesystems, and there is a system header file
|
||||
that declares `struct vmount.' [AIX] */
|
||||
#undef MOUNTED_VMOUNT
|
||||
|
||||
/* Define one of the following to indicate how a program can obtain
|
||||
filesystems usage information. */
|
||||
|
||||
/* Define if statfs takes 3 args. [DEC Alpha running OSF/1] */
|
||||
#undef STAT_STATFS3_OSF1
|
||||
|
||||
/* Define if there is no specific function for reading filesystems usage
|
||||
information and you have the <sys/filsys.h> header file. [SVR2] */
|
||||
#undef STAT_READ_FILSYS
|
||||
|
||||
/* Define if statfs takes 2 args and struct statfs has a field named f_bsize.
|
||||
[4.3BSD, SunOS 4, HP-UX, AIX PS/2] */
|
||||
#undef STAT_STATFS2_BSIZE
|
||||
|
||||
/* Define if statfs takes 2 args and struct statfs has a field named f_fsize.
|
||||
[4.4BSD, NetBSD] */
|
||||
#undef STAT_STATFS2_FSIZE
|
||||
|
||||
/* Define if statfs takes 2 args and the second argument has
|
||||
type struct fs_data. [Ultrix] */
|
||||
#undef STAT_STATFS2_FS_DATA
|
||||
|
||||
/* Define if statfs takes 4 args. [SVR3, Dynix, Irix, Dolphin] */
|
||||
#undef STAT_STATFS4
|
||||
|
||||
/* Define if there is a function named statvfs. [SVR4] */
|
||||
#undef STAT_STATVFS
|
||||
|
||||
/* Define if the block counts reported by statfs may be truncated to 2GB
|
||||
and the correct values may be stored in the f_spare array.
|
||||
[SunOS 4.1.2, 4.1.3, and 4.1.3_U1 are reported to have this problem.
|
||||
SunOS 4.1.1 seems not to be affected.] */
|
||||
#undef STATFS_TRUNCATES_BLOCK_COUNTS
|
||||
|
||||
|
||||
/* to fix a bug in autoheader on DEC OSF1. */
|
||||
#undef HAVE_PROGRAM_INVOCATION_NAME
|
||||
@@ -33,3 +112,7 @@
|
||||
#undef GLIBTOP_EXAMPLES
|
||||
|
||||
#undef NEED_LIBGTOP
|
||||
|
||||
#undef HAVE_LINUX_TABLE
|
||||
|
||||
#undef HAVE_XAUTH
|
||||
|
100
configure.in
100
configure.in
@@ -4,19 +4,24 @@ dnl
|
||||
|
||||
AC_INIT(copyright.txt)
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
AC_CANONICAL_SYSTEM
|
||||
|
||||
AM_INIT_AUTOMAKE(libgtop, 0.01)
|
||||
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
AM_ACLOCAL_INCLUDE(macros)
|
||||
|
||||
AC_CANONICAL_HOST
|
||||
AC_ISC_POSIX
|
||||
AC_PROG_CC
|
||||
AC_STDC_HEADERS
|
||||
AC_ARG_PROGRAM
|
||||
|
||||
dnl We don't use `AC_PROG_AWK' since it checks for mawk first which
|
||||
dnl does not work for libgtop.
|
||||
AC_CHECK_PROGS(AWK, gawk awk, )
|
||||
test -z "$AWK" && AC_MSG_ERROR([Sorry, you need a working awk interpreter.])
|
||||
|
||||
AC_CHECK_TOOL(CC,gcc)
|
||||
AC_CHECK_TOOL(CXX,g++)
|
||||
AC_CHECK_TOOL(RANLIB,ranlib)
|
||||
AC_CHECK_TOOL(LD,ld)
|
||||
AC_CHECK_TOOL(AS,as)
|
||||
AC_CHECK_TOOL(AR,ar)
|
||||
AC_CHECK_TOOL(NM,nm)
|
||||
@@ -24,8 +29,23 @@ AC_CHECK_TOOL(NM,nm)
|
||||
NM=`which $NM`
|
||||
export CC CXX RANLIB LD AS AR NM
|
||||
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_LN_S
|
||||
AC_PROG_MAKE_SET
|
||||
|
||||
export cross_compiling
|
||||
|
||||
AM_PROG_LIBTOOL
|
||||
|
||||
dnl If you want to use libgtop without gnome, comment the following line out.
|
||||
GNOME_INIT
|
||||
GNOME_INIT_HOOK(gnome_found=yes)
|
||||
|
||||
if test "x$gnome_found" != xyes; then
|
||||
GNOME_SUPPORT_CHECKS
|
||||
else
|
||||
AM_CONDITIONAL(BUILD_GNOME_SUPPORT, false)
|
||||
AM_CONDITIONAL(CROSS_COMPILING, test "x$cross_compiling" = xyes)
|
||||
fi
|
||||
|
||||
AC_LC_SYSDEPS
|
||||
|
||||
@@ -35,7 +55,7 @@ if test x$libgtop_want_guile = xyes ; then
|
||||
if test x$libgtop_want_names = xyes ; then
|
||||
AC_DEFINE(GLIBTOP_GUILE_NAMES)
|
||||
fi
|
||||
guile_examples='third third_static third_linux'
|
||||
guile_examples='third third_static'
|
||||
guile_subdirs='guile'
|
||||
else
|
||||
guile_examples=
|
||||
@@ -49,18 +69,6 @@ fi
|
||||
AC_SUBST(guile_examples)
|
||||
AC_SUBST(guile_subdirs)
|
||||
|
||||
AC_ISC_POSIX
|
||||
AC_PROG_CXX
|
||||
AC_PROG_CC
|
||||
AC_PROG_CPP
|
||||
AC_STDC_HEADERS
|
||||
AC_ARG_PROGRAM
|
||||
AM_PROG_LEX
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_LN_S
|
||||
AC_PROG_MAKE_SET
|
||||
|
||||
export cross_compiling
|
||||
AM_PROG_LIBTOOL
|
||||
|
||||
dnl You need to uncomment the following line if you want to use libgtop without Gnome.
|
||||
@@ -94,9 +102,35 @@ AC_TYPE_SIGNAL
|
||||
AC_FUNC_STRFTIME
|
||||
AC_CHECK_FUNCS(getcwd gettimeofday getwd putenv strdup strtoul uname)
|
||||
|
||||
ALL_LINGUAS=""
|
||||
ALL_LINGUAS="fr"
|
||||
AM_GNU_GETTEXT
|
||||
|
||||
AC_PATH_XTRA
|
||||
|
||||
dnl The construct foo=`echo $w1 $w2 $w3` fails on some systems if $w1 = -e or -n
|
||||
dnl So we use the following instead.
|
||||
dnl XE_SPACE(var, words)
|
||||
define([XE_SPACE],[
|
||||
T=""
|
||||
for W in $2; do if test -z "$T"; then T="$W"; else T="$T $W"; fi; done
|
||||
$1="$T"
|
||||
])dnl
|
||||
|
||||
dnl Autodetect Xauth
|
||||
dnl -lXau is only used by gnuclient, so use a special variable for Xauth X libs
|
||||
test -z "$with_xauth" && test "$window_system" = "none" && with_xauth=no
|
||||
test -z "$with_xauth" && { AC_CHECK_HEADER(X11/Xauth.h, ,with_xauth=no) }
|
||||
test -z "$with_xauth" && { AC_CHECK_LIB(Xau, XauGetAuthByAddr,[:],with_xauth=no, $X_LIBS) }
|
||||
test -z "$with_xauth" && with_xauth=yes
|
||||
if test "$with_xauth" = "yes"; then
|
||||
AC_DEFINE(HAVE_XAUTH)
|
||||
XE_SPACE(libs_xauth, $X_LIBS -lXau)
|
||||
fi
|
||||
AC_SUBST(libs_xauth)
|
||||
|
||||
dnl For diskusage stuff
|
||||
GNOME_FILEUTILS_CHECKS
|
||||
|
||||
CFLAGS="$CFLAGS -D_IN_LIBGTOP"
|
||||
|
||||
AC_SUBST(CFLAGS)
|
||||
@@ -125,7 +159,7 @@ AC_SUBST(LIBSUPPORT)
|
||||
AC_SUBST(SUPPORTINCS)
|
||||
|
||||
dnl These definitions are expanded in make.
|
||||
LIBGTOP_LIBS='-L$(libdir)'
|
||||
LIBGTOP_LIBS='-L$(libdir) -lgtop'
|
||||
LIBGTOP_INCS='-I$(includedir)'
|
||||
LIBGTOP_GUILE_LIBS="$LIBGTOP_LIBS"
|
||||
LIBGTOP_GUILE_INCS="$LIBGTOP_INCS"
|
||||
@@ -157,8 +191,8 @@ fi
|
||||
|
||||
AC_SUBST(libgtop_want_guile_names)
|
||||
|
||||
LIBGTOP_LIBS="$LIBGTOP_LIBS -lgtop_common"
|
||||
LIBGTOP_GUILE_LIBS="$LIBGTOP_GUILE_LIBS -lgtop_common"
|
||||
LIBGTOP_LIBS="$LIBGTOP_LIBS -lgtop_common $libs_xauth"
|
||||
LIBGTOP_GUILE_LIBS="$LIBGTOP_GUILE_LIBS -lgtop_common $libs_xauth"
|
||||
|
||||
if test "x$need_server" = "xyes" ; then
|
||||
LIBGTOP_LIBS="$LIBGTOP_LIBS -lgtop"
|
||||
@@ -174,9 +208,7 @@ if test "x$ac_cv_guile_found" = "xyes" ; then
|
||||
LIBGTOP_GUILE_LIBS="$LIBGTOP_GUILE_LIBS $GUILE_LIBS"
|
||||
fi
|
||||
|
||||
if test "x$libgtop_use_machine_h" = "xyes" ; then
|
||||
machine_incs='-I$(top_srcdir)/sysdeps/@sysdeps_dir@'
|
||||
fi
|
||||
machine_incs='-I$(top_srcdir)/sysdeps/@sysdeps_dir@'
|
||||
|
||||
AC_SUBST(machine_incs)
|
||||
|
||||
@@ -187,6 +219,18 @@ AC_SUBST(LIBGTOP_GUILE_INCS)
|
||||
AC_SUBST(LIBGTOP_BINDIR)
|
||||
AC_SUBST(LIBGTOP_SERVER)
|
||||
|
||||
LIBSUPPORT=
|
||||
SUPPORTINCS=
|
||||
if test "$need_gnome_support" = yes; then
|
||||
if test "x$gnome_found" = xyes ; then
|
||||
LIBSUPPORT="$GNOME_LIBDIR -lgnomesupport"
|
||||
SUPPORTINCS="$GNOME_INCLUDEDIR"
|
||||
else
|
||||
LIBSUPPORT='$(top_builddir)/support/libgnomesupport.la'
|
||||
SUPPORTINCS='-DNEED_GNOMESUPPORT_H -I$(top_builddir)/support -I$(top_srcdir)/support'
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_OUTPUT([
|
||||
Makefile
|
||||
po/Makefile.in
|
||||
@@ -202,8 +246,12 @@ sysdeps/stub/Makefile
|
||||
sysdeps/sun4/Makefile
|
||||
sysdeps/osf1/Makefile
|
||||
sysdeps/linux/Makefile
|
||||
sysdeps/kernel/Makefile
|
||||
src/Makefile
|
||||
src/server/Makefile
|
||||
src/proxy/Makefile
|
||||
src/daemon/Makefile
|
||||
lib/Makefile
|
||||
examples/Makefile
|
||||
support/Makefile
|
||||
macros/Makefile],[sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile])
|
||||
|
11
examples/ChangeLog
Normal file
11
examples/ChangeLog
Normal file
@@ -0,0 +1,11 @@
|
||||
1998-06-12 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* test.scm: New file.
|
||||
|
||||
1998-06-07 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* Makefile.am (CFLAGS): Disable optimize.
|
||||
|
||||
* first.c (PROFILE_COUNT): Number of times each function
|
||||
should be called. Defaults to 1; to profile the code, you
|
||||
can increase this when compiling.
|
@@ -6,46 +6,35 @@ INCLUDES = -I$(top_builddir) -I$(top_srcdir) @machine_incs@ \
|
||||
-I$(top_srcdir)/include -I$(top_srcdir)/intl @GUILE_INCS@ \
|
||||
-DGTOPLOCALEDIR=\"$(datadir)/locale\" -D_GNU_SOURCE
|
||||
|
||||
CFLAGS = -Wall -W @CFLAGS@
|
||||
CFLAGS = -Wall -W @CFLAGS@ -O0
|
||||
|
||||
DEFS = @DEFS@
|
||||
|
||||
bin_PROGRAMS = first first_static first_linux \
|
||||
second second_static second_linux \
|
||||
bin_PROGRAMS = first first_static second second_static \
|
||||
@guile_examples@
|
||||
|
||||
EXTRA_PROGRAMS = third third_static third_linux
|
||||
EXTRA_PROGRAMS = third third_static
|
||||
|
||||
first_SOURCES = first.c
|
||||
first_LDADD = $(top_builddir)/sysdeps/common/libgtop_common.la \
|
||||
$(top_builddir)/lib/libgtop.la \
|
||||
@INTLLIBS@ @LIBSUPPORT@
|
||||
first_LDADD = $(top_builddir)/lib/libgtop.la \
|
||||
$(top_builddir)/sysdeps/common/libgtop_common.la \
|
||||
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \
|
||||
@INTLLIBS@ @LIBSUPPORT@ @libs_xauth@
|
||||
|
||||
first_static_SOURCES = $(first_SOURCES)
|
||||
first_static_LDADD = $(first_LDADD)
|
||||
first_static_LDFLAGS = -static
|
||||
|
||||
first_linux_SOURCES = $(first_SOURCES)
|
||||
first_linux_LDADD = $(top_builddir)/sysdeps/common/libgtop_common.la \
|
||||
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \
|
||||
@INTLLIBS@ @LIBSUPPORT@
|
||||
first_linux_LDFLAGS = -static
|
||||
|
||||
second_SOURCES = second.c
|
||||
second_LDADD = $(top_builddir)/sysdeps/common/libgtop_common.la \
|
||||
$(top_builddir)/lib/libgtop.la \
|
||||
@INTLLIBS@ @LIBSUPPORT@
|
||||
second_LDADD = $(top_builddir)/lib/libgtop.la \
|
||||
$(top_builddir)/sysdeps/common/libgtop_common.la \
|
||||
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \
|
||||
@INTLLIBS@ @LIBSUPPORT@ @libs_xauth@
|
||||
|
||||
second_static_SOURCES = $(second_SOURCES)
|
||||
second_static_LDADD = $(second_LDADD)
|
||||
second_static_LDFLAGS = -static
|
||||
|
||||
second_linux_SOURCES = $(second_SOURCES)
|
||||
second_linux_LDADD = $(top_builddir)/sysdeps/common/libgtop_common.la \
|
||||
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \
|
||||
@INTLLIBS@ @LIBSUPPORT@
|
||||
second_linux_LDFLAGS = -static
|
||||
|
||||
if GLIBTOP_NAMES
|
||||
third_guile_names_LIBS = $(top_builddir)/sysdeps/guile/names/libgtop_guile_names.la
|
||||
third_names_LIBS = $(top_builddir)/sysdeps/names/libgtop_names.la
|
||||
@@ -54,18 +43,11 @@ endif
|
||||
third_SOURCES = third.c
|
||||
third_LDADD = $(top_builddir)/sysdeps/guile/libgtop_guile.la \
|
||||
$(third_guile_names_LIBS) $(third_names_LIBS) \
|
||||
$(top_builddir)/sysdeps/common/libgtop_common.la \
|
||||
$(top_builddir)/lib/libgtop.la \
|
||||
@GUILE_LIBS@ @INTLLIBS@ @LIBSUPPORT@
|
||||
$(top_builddir)/sysdeps/common/libgtop_common.la \
|
||||
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \
|
||||
@GUILE_LIBS@ @INTLLIBS@ @LIBSUPPORT@ @libs_xauth@
|
||||
|
||||
third_static_SOURCES = $(third_SOURCES)
|
||||
third_static_LDADD = $(third_LDADD)
|
||||
third_static_LDFLAGS = -static
|
||||
|
||||
third_linux_SOURCES = $(third_SOURCES)
|
||||
third_linux_LDADD = $(top_builddir)/sysdeps/guile/libgtop_guile.la \
|
||||
$(third_guile_names_LIBS) $(third_names_LIBS) \
|
||||
$(top_builddir)/sysdeps/common/libgtop_common.la \
|
||||
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \
|
||||
@GUILE_LIBS@ @INTLLIBS@ @LIBSUPPORT@
|
||||
third_linux_LDFLAGS = -static
|
||||
|
466
examples/first.c
466
examples/first.c
@@ -26,105 +26,138 @@
|
||||
#include <glibtop/close.h>
|
||||
#include <glibtop/xmalloc.h>
|
||||
|
||||
#include <glibtop/parameter.h>
|
||||
|
||||
#include <glibtop/union.h>
|
||||
#include <glibtop/sysdeps.h>
|
||||
|
||||
#ifndef PROFILE_COUNT
|
||||
#define PROFILE_COUNT 1000
|
||||
#endif
|
||||
|
||||
int
|
||||
main (int argc, char *argv [])
|
||||
{
|
||||
glibtop_union data;
|
||||
glibtop_sysdeps sysdeps;
|
||||
unsigned i, *ptr;
|
||||
unsigned c, method, count, port, i, *ptr;
|
||||
char buffer [BUFSIZ];
|
||||
pid_t pid, ppid;
|
||||
|
||||
count = PROFILE_COUNT;
|
||||
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, GTOPLOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
glibtop_init__r (&glibtop_global_server);
|
||||
glibtop_init_r (&glibtop_global_server, 0, GLIBTOP_INIT_NO_OPEN);
|
||||
|
||||
glibtop_get_cpu (&data.cpu);
|
||||
glibtop_get_parameter (GLIBTOP_PARAM_METHOD, &method, sizeof (method));
|
||||
|
||||
fprintf (stderr, "CPU (0x%08lx): %lu, %lu, %lu, %lu, %lu, %lu\n",
|
||||
data.cpu.flags, data.cpu.total, data.cpu.user, data.cpu.nice,
|
||||
data.cpu.sys, data.cpu.idle, data.cpu.frequency);
|
||||
printf ("Method = %d\n", method);
|
||||
|
||||
glibtop_get_mem (&data.mem);
|
||||
count = glibtop_get_parameter (GLIBTOP_PARAM_COMMAND, buffer, BUFSIZ);
|
||||
buffer [count] = 0;
|
||||
|
||||
fprintf (stderr, "Memory (0x%08lx): %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu\n",
|
||||
data.mem.flags, data.mem.total, data.mem.used, data.mem.free,
|
||||
data.mem.shared, data.mem.buffer, data.mem.cached,
|
||||
data.mem.user, data.mem.locked);
|
||||
printf ("Command = '%s'\n", buffer);
|
||||
|
||||
glibtop_get_swap (&data.swap);
|
||||
count = glibtop_get_parameter (GLIBTOP_PARAM_HOST, buffer, BUFSIZ);
|
||||
buffer [count] = 0;
|
||||
|
||||
fprintf (stderr, "Swap (0x%08lx): %lu, %lu, %lu\n", data.swap.flags,
|
||||
data.swap.total, data.swap.used, data.swap.free);
|
||||
glibtop_get_parameter (GLIBTOP_PARAM_PORT, &port, sizeof (port));
|
||||
|
||||
glibtop_get_uptime (&data.uptime);
|
||||
printf ("Host = '%s' - %u\n\n", buffer, port);
|
||||
|
||||
fprintf (stderr, "Uptime (0x%08lx): %f, %f\n", data.uptime.flags,
|
||||
data.uptime.uptime, data.uptime.idletime);
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_cpu (&data.cpu);
|
||||
|
||||
glibtop_get_loadavg (&data.loadavg);
|
||||
printf ("CPU (0x%08lx): %lu, %lu, %lu, %lu, %lu, %lu\n",
|
||||
data.cpu.flags, data.cpu.total, data.cpu.user, data.cpu.nice,
|
||||
data.cpu.sys, data.cpu.idle, data.cpu.frequency);
|
||||
|
||||
fprintf (stderr, "Loadavg (0x%08lx): %f, %f, %f\n", data.loadavg.flags,
|
||||
data.loadavg.loadavg [0], data.loadavg.loadavg [1],
|
||||
data.loadavg.loadavg [2]);
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_mem (&data.mem);
|
||||
|
||||
glibtop_get_shm_limits (&data.shm_limits);
|
||||
printf ("Memory (0x%08lx): %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu\n",
|
||||
data.mem.flags, data.mem.total, data.mem.used, data.mem.free,
|
||||
data.mem.shared, data.mem.buffer, data.mem.cached,
|
||||
data.mem.user, data.mem.locked);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_swap (&data.swap);
|
||||
|
||||
printf ("Swap (0x%08lx): %lu, %lu, %lu\n", data.swap.flags,
|
||||
data.swap.total, data.swap.used, data.swap.free);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_uptime (&data.uptime);
|
||||
|
||||
printf ("Uptime (0x%08lx): %f, %f\n", data.uptime.flags,
|
||||
data.uptime.uptime, data.uptime.idletime);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_loadavg (&data.loadavg);
|
||||
|
||||
printf ("Loadavg (0x%08lx): %f, %f, %f\n", data.loadavg.flags,
|
||||
data.loadavg.loadavg [0], data.loadavg.loadavg [1],
|
||||
data.loadavg.loadavg [2]);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_shm_limits (&data.shm_limits);
|
||||
|
||||
fprintf (stderr, "Shm Limits (0x%08lx): %ld, %ld, %ld, %ld, %ld\n",
|
||||
data.shm_limits.flags, data.shm_limits.shmmax,
|
||||
data.shm_limits.shmmin, data.shm_limits.shmmni,
|
||||
data.shm_limits.shmseg, data.shm_limits.shmall);
|
||||
printf ("Shm Limits (0x%08lx): %ld, %ld, %ld, %ld, %ld\n",
|
||||
data.shm_limits.flags, data.shm_limits.shmmax,
|
||||
data.shm_limits.shmmin, data.shm_limits.shmmni,
|
||||
data.shm_limits.shmseg, data.shm_limits.shmall);
|
||||
|
||||
glibtop_get_msg_limits (&data.msg_limits);
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_msg_limits (&data.msg_limits);
|
||||
|
||||
fprintf (stderr, "Msg Limits (0x%08lx): %ld, %ld, %ld, %ld, %ld, %ld, %ld\n",
|
||||
data.msg_limits.flags, data.msg_limits.msgpool,
|
||||
data.msg_limits.msgmap, data.msg_limits.msgmax,
|
||||
data.msg_limits.msgmnb, data.msg_limits.msgmni,
|
||||
data.msg_limits.msgssz, data.msg_limits.msgtql);
|
||||
printf ("Msg Limits (0x%08lx): %ld, %ld, %ld, %ld, %ld, %ld, %ld\n",
|
||||
data.msg_limits.flags, data.msg_limits.msgpool,
|
||||
data.msg_limits.msgmap, data.msg_limits.msgmax,
|
||||
data.msg_limits.msgmnb, data.msg_limits.msgmni,
|
||||
data.msg_limits.msgssz, data.msg_limits.msgtql);
|
||||
|
||||
glibtop_get_sem_limits (&data.sem_limits);
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_sem_limits (&data.sem_limits);
|
||||
|
||||
fprintf (stderr, "Sem Limits (0x%08lx): "
|
||||
"%ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld\n",
|
||||
data.sem_limits.flags, data.sem_limits.semmap,
|
||||
data.sem_limits.semmni, data.sem_limits.semmns,
|
||||
data.sem_limits.semmnu, data.sem_limits.semmsl,
|
||||
data.sem_limits.semopm, data.sem_limits.semume,
|
||||
data.sem_limits.semusz, data.sem_limits.semvmx,
|
||||
data.sem_limits.semaem);
|
||||
printf ("Sem Limits (0x%08lx): "
|
||||
"%ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld\n",
|
||||
data.sem_limits.flags, data.sem_limits.semmap,
|
||||
data.sem_limits.semmni, data.sem_limits.semmns,
|
||||
data.sem_limits.semmnu, data.sem_limits.semmsl,
|
||||
data.sem_limits.semopm, data.sem_limits.semume,
|
||||
data.sem_limits.semusz, data.sem_limits.semvmx,
|
||||
data.sem_limits.semaem);
|
||||
|
||||
fprintf (stderr, "\n");
|
||||
printf ("\n");
|
||||
|
||||
glibtop_get_sysdeps (&sysdeps);
|
||||
|
||||
fprintf (stderr, "Sysdeps (0x%08lx): %lu, %lu, %lu, %lu, %lu, "
|
||||
"%lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu\n",
|
||||
sysdeps.flags, sysdeps.cpu, sysdeps.mem, sysdeps.swap,
|
||||
sysdeps.uptime, sysdeps.loadavg, sysdeps.shm_limits,
|
||||
sysdeps.msg_limits, sysdeps.sem_limits,
|
||||
sysdeps.proclist, sysdeps.proc_state,
|
||||
sysdeps.proc_uid, sysdeps.proc_mem,
|
||||
sysdeps.proc_time, sysdeps.proc_signal,
|
||||
sysdeps.proc_kernel, sysdeps.proc_segment);
|
||||
printf ("Sysdeps (0x%08lx): %lu, %lu, %lu, %lu, %lu, "
|
||||
"%lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu\n",
|
||||
sysdeps.flags, sysdeps.cpu, sysdeps.mem, sysdeps.swap,
|
||||
sysdeps.uptime, sysdeps.loadavg, sysdeps.shm_limits,
|
||||
sysdeps.msg_limits, sysdeps.sem_limits,
|
||||
sysdeps.proclist, sysdeps.proc_state,
|
||||
sysdeps.proc_uid, sysdeps.proc_mem,
|
||||
sysdeps.proc_time, sysdeps.proc_signal,
|
||||
sysdeps.proc_kernel, sysdeps.proc_segment);
|
||||
|
||||
fprintf (stderr, "\n");
|
||||
printf ("\n");
|
||||
|
||||
ptr = glibtop_get_proclist (&data.proclist);
|
||||
|
||||
fprintf (stderr, "Proclist (0x%08lx): %ld, %ld, %ld\n",
|
||||
data.proclist.flags, data.proclist.number,
|
||||
data.proclist.size, data.proclist.total);
|
||||
printf ("Proclist (0x%08lx): %ld, %ld, %ld\n",
|
||||
data.proclist.flags, data.proclist.number,
|
||||
data.proclist.size, data.proclist.total);
|
||||
|
||||
if (ptr) {
|
||||
fprintf (stderr, "\nProcess: ");
|
||||
printf ("\nProcess: ");
|
||||
for (i = 0; i < data.proclist.number; i++)
|
||||
fprintf (stderr, "%s%u", i ? ", " : "", ptr [i]);
|
||||
fprintf (stderr, "\n");
|
||||
printf ("%s%u", i ? ", " : "", ptr [i]);
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
glibtop_free (ptr);
|
||||
@@ -132,197 +165,220 @@ main (int argc, char *argv [])
|
||||
pid = getpid ();
|
||||
ppid = getppid ();
|
||||
|
||||
fprintf (stderr, "\n");
|
||||
printf ("\n");
|
||||
|
||||
glibtop_get_proc_state (&data.proc_state, pid);
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_state (&data.proc_state, pid);
|
||||
|
||||
fprintf (stderr, "Proc_State PID %5u (0x%08lx): '%s', %c, %u, %u\n",
|
||||
pid, data.proc_state.flags, data.proc_state.cmd,
|
||||
data.proc_state.state, data.proc_state.uid,
|
||||
data.proc_state.gid);
|
||||
printf ("Proc_State PID %5u (0x%08lx): '%s', %c, %u, %u\n",
|
||||
pid, data.proc_state.flags, data.proc_state.cmd,
|
||||
data.proc_state.state, data.proc_state.uid,
|
||||
data.proc_state.gid);
|
||||
|
||||
glibtop_get_proc_uid (&data.proc_uid, pid);
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_uid (&data.proc_uid, pid);
|
||||
|
||||
fprintf (stderr, "Proc_Uid PID %5u (0x%08lx): "
|
||||
"%d %d %d %d %d %d %d %d %d %d %d %d\n",
|
||||
pid, data.proc_uid.flags, data.proc_uid.uid,
|
||||
data.proc_uid.euid, data.proc_uid.gid,
|
||||
data.proc_uid.egid, data.proc_uid.pid,
|
||||
data.proc_uid.ppid, data.proc_uid.pgrp,
|
||||
data.proc_uid.session, data.proc_uid.tty,
|
||||
data.proc_uid.tpgid, data.proc_uid.priority,
|
||||
data.proc_uid.nice);
|
||||
printf ("Proc_Uid PID %5u (0x%08lx): "
|
||||
"%d %d %d %d %d %d %d %d %d %d %d %d\n",
|
||||
pid, data.proc_uid.flags, data.proc_uid.uid,
|
||||
data.proc_uid.euid, data.proc_uid.gid,
|
||||
data.proc_uid.egid, data.proc_uid.pid,
|
||||
data.proc_uid.ppid, data.proc_uid.pgrp,
|
||||
data.proc_uid.session, data.proc_uid.tty,
|
||||
data.proc_uid.tpgid, data.proc_uid.priority,
|
||||
data.proc_uid.nice);
|
||||
|
||||
glibtop_get_proc_mem (&data.proc_mem, pid);
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_mem (&data.proc_mem, pid);
|
||||
|
||||
fprintf (stderr, "Proc_Mem PID %5u (0x%08lx): "
|
||||
"%ld %ld %ld %ld %ld %ld\n", pid, data.proc_mem.flags,
|
||||
data.proc_mem.size, data.proc_mem.vsize,
|
||||
data.proc_mem.resident, data.proc_mem.share,
|
||||
data.proc_mem.rss, data.proc_mem.rss_rlim);
|
||||
printf ("Proc_Mem PID %5u (0x%08lx): "
|
||||
"%ld %ld %ld %ld %ld %ld\n", pid, data.proc_mem.flags,
|
||||
data.proc_mem.size, data.proc_mem.vsize,
|
||||
data.proc_mem.resident, data.proc_mem.share,
|
||||
data.proc_mem.rss, data.proc_mem.rss_rlim);
|
||||
|
||||
glibtop_get_proc_time (&data.proc_time, pid);
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_time (&data.proc_time, pid);
|
||||
|
||||
fprintf (stderr, "Proc_Time PID %5u (0x%08lx): "
|
||||
"%ld %ld %ld %ld %ld %ld %ld\n", pid, data.proc_time.flags,
|
||||
data.proc_time.start_time, data.proc_time.utime,
|
||||
data.proc_time.stime, data.proc_time.cutime,
|
||||
data.proc_time.cstime, data.proc_time.timeout,
|
||||
data.proc_time.it_real_value);
|
||||
printf ("Proc_Time PID %5u (0x%08lx): "
|
||||
"%ld %ld %ld %ld %ld %ld %ld\n", pid, data.proc_time.flags,
|
||||
data.proc_time.start_time, data.proc_time.utime,
|
||||
data.proc_time.stime, data.proc_time.cutime,
|
||||
data.proc_time.cstime, data.proc_time.timeout,
|
||||
data.proc_time.it_real_value);
|
||||
|
||||
glibtop_get_proc_signal (&data.proc_signal, pid);
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_signal (&data.proc_signal, pid);
|
||||
|
||||
fprintf (stderr, "Proc_Signal PID %5u (0x%08lx): "
|
||||
"%d %d %d %d\n", pid, data.proc_signal.flags,
|
||||
data.proc_signal.signal, data.proc_signal.blocked,
|
||||
data.proc_signal.sigignore, data.proc_signal.sigcatch);
|
||||
printf ("Proc_Signal PID %5u (0x%08lx): "
|
||||
"%d %d %d %d\n", pid, data.proc_signal.flags,
|
||||
data.proc_signal.signal, data.proc_signal.blocked,
|
||||
data.proc_signal.sigignore, data.proc_signal.sigcatch);
|
||||
|
||||
glibtop_get_proc_kernel (&data.proc_kernel, pid);
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_kernel (&data.proc_kernel, pid);
|
||||
|
||||
fprintf (stderr, "Proc_Kernel PID %5u (0x%08lx): "
|
||||
"%lu %lu %lu %lu %lu %lu %lu %lu\n", pid,
|
||||
data.proc_kernel.flags, data.proc_kernel.k_flags,
|
||||
data.proc_kernel.min_flt, data.proc_kernel.maj_flt,
|
||||
data.proc_kernel.cmin_flt, data.proc_kernel.cmaj_flt,
|
||||
data.proc_kernel.kstk_esp, data.proc_kernel.kstk_eip,
|
||||
data.proc_kernel.wchan);
|
||||
printf ("Proc_Kernel PID %5u (0x%08lx): "
|
||||
"%lu %lu %lu %lu %lu %lu %lu %lu\n", pid,
|
||||
data.proc_kernel.flags, data.proc_kernel.k_flags,
|
||||
data.proc_kernel.min_flt, data.proc_kernel.maj_flt,
|
||||
data.proc_kernel.cmin_flt, data.proc_kernel.cmaj_flt,
|
||||
data.proc_kernel.kstk_esp, data.proc_kernel.kstk_eip,
|
||||
data.proc_kernel.wchan);
|
||||
|
||||
glibtop_get_proc_segment (&data.proc_segment, pid);
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_segment (&data.proc_segment, pid);
|
||||
|
||||
fprintf (stderr, "Proc_Segment PID %5u (0x%08lx): "
|
||||
"%ld %ld %ld %ld %lu %lu %lu\n", pid, data.proc_segment.flags,
|
||||
data.proc_segment.trs, data.proc_segment.lrs,
|
||||
data.proc_segment.drs, data.proc_segment.dt,
|
||||
data.proc_segment.start_code, data.proc_segment.end_code,
|
||||
data.proc_segment.start_stack);
|
||||
printf ("Proc_Segment PID %5u (0x%08lx): "
|
||||
"%ld %ld %ld %ld %lu %lu %lu\n", pid, data.proc_segment.flags,
|
||||
data.proc_segment.trs, data.proc_segment.lrs,
|
||||
data.proc_segment.drs, data.proc_segment.dt,
|
||||
data.proc_segment.start_code, data.proc_segment.end_code,
|
||||
data.proc_segment.start_stack);
|
||||
|
||||
fprintf (stderr, "\n");
|
||||
printf ("\n");
|
||||
|
||||
glibtop_get_proc_state (&data.proc_state, ppid);
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_state (&data.proc_state, ppid);
|
||||
|
||||
fprintf (stderr, "Proc_State PPID %5u (0x%08lx): '%s', %c, %u, %u\n",
|
||||
ppid, data.proc_state.flags, data.proc_state.cmd,
|
||||
data.proc_state.state, data.proc_state.uid,
|
||||
data.proc_state.gid);
|
||||
printf ("Proc_State PPID %5u (0x%08lx): '%s', %c, %u, %u\n",
|
||||
ppid, data.proc_state.flags, data.proc_state.cmd,
|
||||
data.proc_state.state, data.proc_state.uid,
|
||||
data.proc_state.gid);
|
||||
|
||||
glibtop_get_proc_uid (&data.proc_uid, ppid);
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_uid (&data.proc_uid, ppid);
|
||||
|
||||
fprintf (stderr, "Proc_Uid PPID %5u (0x%08lx): "
|
||||
"%d %d %d %d %d %d %d %d %d %d %d %d\n",
|
||||
ppid, data.proc_uid.flags, data.proc_uid.uid,
|
||||
data.proc_uid.euid, data.proc_uid.gid,
|
||||
data.proc_uid.egid, data.proc_uid.pid,
|
||||
data.proc_uid.ppid, data.proc_uid.pgrp,
|
||||
data.proc_uid.session, data.proc_uid.tty,
|
||||
data.proc_uid.tpgid, data.proc_uid.priority,
|
||||
data.proc_uid.nice);
|
||||
printf ("Proc_Uid PPID %5u (0x%08lx): "
|
||||
"%d %d %d %d %d %d %d %d %d %d %d %d\n",
|
||||
ppid, data.proc_uid.flags, data.proc_uid.uid,
|
||||
data.proc_uid.euid, data.proc_uid.gid,
|
||||
data.proc_uid.egid, data.proc_uid.pid,
|
||||
data.proc_uid.ppid, data.proc_uid.pgrp,
|
||||
data.proc_uid.session, data.proc_uid.tty,
|
||||
data.proc_uid.tpgid, data.proc_uid.priority,
|
||||
data.proc_uid.nice);
|
||||
|
||||
glibtop_get_proc_mem (&data.proc_mem, ppid);
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_mem (&data.proc_mem, ppid);
|
||||
|
||||
fprintf (stderr, "Proc_Mem PPID %5u (0x%08lx): "
|
||||
"%ld %ld %ld %ld %ld %ld\n", ppid, data.proc_mem.flags,
|
||||
data.proc_mem.size, data.proc_mem.vsize,
|
||||
data.proc_mem.resident, data.proc_mem.share,
|
||||
data.proc_mem.rss, data.proc_mem.rss_rlim);
|
||||
printf ("Proc_Mem PPID %5u (0x%08lx): "
|
||||
"%ld %ld %ld %ld %ld %ld\n", ppid, data.proc_mem.flags,
|
||||
data.proc_mem.size, data.proc_mem.vsize,
|
||||
data.proc_mem.resident, data.proc_mem.share,
|
||||
data.proc_mem.rss, data.proc_mem.rss_rlim);
|
||||
|
||||
glibtop_get_proc_time (&data.proc_time, ppid);
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_time (&data.proc_time, ppid);
|
||||
|
||||
fprintf (stderr, "Proc_Time PPID %5u (0x%08lx): "
|
||||
"%ld %ld %ld %ld %ld %ld %ld\n", ppid, data.proc_time.flags,
|
||||
data.proc_time.start_time, data.proc_time.utime,
|
||||
data.proc_time.stime, data.proc_time.cutime,
|
||||
data.proc_time.cstime, data.proc_time.timeout,
|
||||
data.proc_time.it_real_value);
|
||||
printf ("Proc_Time PPID %5u (0x%08lx): "
|
||||
"%ld %ld %ld %ld %ld %ld %ld\n", ppid, data.proc_time.flags,
|
||||
data.proc_time.start_time, data.proc_time.utime,
|
||||
data.proc_time.stime, data.proc_time.cutime,
|
||||
data.proc_time.cstime, data.proc_time.timeout,
|
||||
data.proc_time.it_real_value);
|
||||
|
||||
glibtop_get_proc_signal (&data.proc_signal, ppid);
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_signal (&data.proc_signal, ppid);
|
||||
|
||||
fprintf (stderr, "Proc_Signal PPID %5u (0x%08lx): "
|
||||
"%d %d %d %d\n", ppid, data.proc_signal.flags,
|
||||
data.proc_signal.signal, data.proc_signal.blocked,
|
||||
data.proc_signal.sigignore, data.proc_signal.sigcatch);
|
||||
printf ("Proc_Signal PPID %5u (0x%08lx): "
|
||||
"%d %d %d %d\n", ppid, data.proc_signal.flags,
|
||||
data.proc_signal.signal, data.proc_signal.blocked,
|
||||
data.proc_signal.sigignore, data.proc_signal.sigcatch);
|
||||
|
||||
glibtop_get_proc_kernel (&data.proc_kernel, ppid);
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_kernel (&data.proc_kernel, ppid);
|
||||
|
||||
fprintf (stderr, "Proc_Kernel PPID %5u (0x%08lx): "
|
||||
"%lu %lu %lu %lu %lu %lu %lu %lu\n", ppid,
|
||||
data.proc_kernel.flags, data.proc_kernel.k_flags,
|
||||
data.proc_kernel.min_flt, data.proc_kernel.maj_flt,
|
||||
data.proc_kernel.cmin_flt, data.proc_kernel.cmaj_flt,
|
||||
data.proc_kernel.kstk_esp, data.proc_kernel.kstk_eip,
|
||||
data.proc_kernel.wchan);
|
||||
printf ("Proc_Kernel PPID %5u (0x%08lx): "
|
||||
"%lu %lu %lu %lu %lu %lu %lu %lu\n", ppid,
|
||||
data.proc_kernel.flags, data.proc_kernel.k_flags,
|
||||
data.proc_kernel.min_flt, data.proc_kernel.maj_flt,
|
||||
data.proc_kernel.cmin_flt, data.proc_kernel.cmaj_flt,
|
||||
data.proc_kernel.kstk_esp, data.proc_kernel.kstk_eip,
|
||||
data.proc_kernel.wchan);
|
||||
|
||||
glibtop_get_proc_segment (&data.proc_segment, ppid);
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_segment (&data.proc_segment, ppid);
|
||||
|
||||
fprintf (stderr, "Proc_Segment PPID %5u (0x%08lx): "
|
||||
"%ld %ld %ld %ld %lu %lu %lu\n", ppid, data.proc_segment.flags,
|
||||
data.proc_segment.trs, data.proc_segment.lrs,
|
||||
data.proc_segment.drs, data.proc_segment.dt,
|
||||
data.proc_segment.start_code, data.proc_segment.end_code,
|
||||
data.proc_segment.start_stack);
|
||||
printf ("Proc_Segment PPID %5u (0x%08lx): "
|
||||
"%ld %ld %ld %ld %lu %lu %lu\n", ppid, data.proc_segment.flags,
|
||||
data.proc_segment.trs, data.proc_segment.lrs,
|
||||
data.proc_segment.drs, data.proc_segment.dt,
|
||||
data.proc_segment.start_code, data.proc_segment.end_code,
|
||||
data.proc_segment.start_stack);
|
||||
|
||||
fprintf (stderr, "\n");
|
||||
printf ("\n");
|
||||
|
||||
glibtop_get_proc_state (&data.proc_state, 1);
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_state (&data.proc_state, 1);
|
||||
|
||||
fprintf (stderr, "Proc_State INIT %5u (0x%08lx): '%s', %c, %u, %u\n",
|
||||
1, data.proc_state.flags, data.proc_state.cmd,
|
||||
data.proc_state.state, data.proc_state.uid,
|
||||
data.proc_state.gid);
|
||||
printf ("Proc_State INIT %5u (0x%08lx): '%s', %c, %u, %u\n",
|
||||
1, data.proc_state.flags, data.proc_state.cmd,
|
||||
data.proc_state.state, data.proc_state.uid,
|
||||
data.proc_state.gid);
|
||||
|
||||
glibtop_get_proc_uid (&data.proc_uid, 1);
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_uid (&data.proc_uid, 1);
|
||||
|
||||
fprintf (stderr, "Proc_Uid INIT %5u (0x%08lx): "
|
||||
"%d %d %d %d %d %d %d %d %d %d %d %d\n",
|
||||
1, data.proc_uid.flags, data.proc_uid.uid,
|
||||
data.proc_uid.euid, data.proc_uid.gid,
|
||||
data.proc_uid.egid, data.proc_uid.pid,
|
||||
data.proc_uid.ppid, data.proc_uid.pgrp,
|
||||
data.proc_uid.session, data.proc_uid.tty,
|
||||
data.proc_uid.tpgid, data.proc_uid.priority,
|
||||
data.proc_uid.nice);
|
||||
printf ("Proc_Uid INIT %5u (0x%08lx): "
|
||||
"%d %d %d %d %d %d %d %d %d %d %d %d\n",
|
||||
1, data.proc_uid.flags, data.proc_uid.uid,
|
||||
data.proc_uid.euid, data.proc_uid.gid,
|
||||
data.proc_uid.egid, data.proc_uid.pid,
|
||||
data.proc_uid.ppid, data.proc_uid.pgrp,
|
||||
data.proc_uid.session, data.proc_uid.tty,
|
||||
data.proc_uid.tpgid, data.proc_uid.priority,
|
||||
data.proc_uid.nice);
|
||||
|
||||
glibtop_get_proc_mem (&data.proc_mem, 1);
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_mem (&data.proc_mem, 1);
|
||||
|
||||
fprintf (stderr, "Proc_Mem INIT %5u (0x%08lx): "
|
||||
"%ld %ld %ld %ld %ld %ld\n", 1, data.proc_mem.flags,
|
||||
data.proc_mem.size, data.proc_mem.vsize,
|
||||
data.proc_mem.resident, data.proc_mem.share,
|
||||
data.proc_mem.rss, data.proc_mem.rss_rlim);
|
||||
printf ("Proc_Mem INIT %5u (0x%08lx): "
|
||||
"%ld %ld %ld %ld %ld %ld\n", 1, data.proc_mem.flags,
|
||||
data.proc_mem.size, data.proc_mem.vsize,
|
||||
data.proc_mem.resident, data.proc_mem.share,
|
||||
data.proc_mem.rss, data.proc_mem.rss_rlim);
|
||||
|
||||
glibtop_get_proc_time (&data.proc_time, 1);
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_time (&data.proc_time, 1);
|
||||
|
||||
fprintf (stderr, "Proc_Time INIT %5u (0x%08lx): "
|
||||
"%ld %ld %ld %ld %ld %ld %ld\n", 1, data.proc_time.flags,
|
||||
data.proc_time.start_time, data.proc_time.utime,
|
||||
data.proc_time.stime, data.proc_time.cutime,
|
||||
data.proc_time.cstime, data.proc_time.timeout,
|
||||
data.proc_time.it_real_value);
|
||||
printf ("Proc_Time INIT %5u (0x%08lx): "
|
||||
"%ld %ld %ld %ld %ld %ld %ld\n", 1, data.proc_time.flags,
|
||||
data.proc_time.start_time, data.proc_time.utime,
|
||||
data.proc_time.stime, data.proc_time.cutime,
|
||||
data.proc_time.cstime, data.proc_time.timeout,
|
||||
data.proc_time.it_real_value);
|
||||
|
||||
glibtop_get_proc_signal (&data.proc_signal, 1);
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_signal (&data.proc_signal, 1);
|
||||
|
||||
fprintf (stderr, "Proc_Signal INIT %5u (0x%08lx): "
|
||||
"%d %d %d %d\n", 1, data.proc_signal.flags,
|
||||
data.proc_signal.signal, data.proc_signal.blocked,
|
||||
data.proc_signal.sigignore, data.proc_signal.sigcatch);
|
||||
printf ("Proc_Signal INIT %5u (0x%08lx): "
|
||||
"%d %d %d %d\n", 1, data.proc_signal.flags,
|
||||
data.proc_signal.signal, data.proc_signal.blocked,
|
||||
data.proc_signal.sigignore, data.proc_signal.sigcatch);
|
||||
|
||||
glibtop_get_proc_kernel (&data.proc_kernel, 1);
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_kernel (&data.proc_kernel, 1);
|
||||
|
||||
fprintf (stderr, "Proc_Kernel INIT %5u (0x%08lx): "
|
||||
"%lu %lu %lu %lu %lu %lu %lu %lu\n", 1,
|
||||
data.proc_kernel.flags, data.proc_kernel.k_flags,
|
||||
data.proc_kernel.min_flt, data.proc_kernel.maj_flt,
|
||||
data.proc_kernel.cmin_flt, data.proc_kernel.cmaj_flt,
|
||||
data.proc_kernel.kstk_esp, data.proc_kernel.kstk_eip,
|
||||
data.proc_kernel.wchan);
|
||||
printf ("Proc_Kernel INIT %5u (0x%08lx): "
|
||||
"%lu %lu %lu %lu %lu %lu %lu %lu\n", 1,
|
||||
data.proc_kernel.flags, data.proc_kernel.k_flags,
|
||||
data.proc_kernel.min_flt, data.proc_kernel.maj_flt,
|
||||
data.proc_kernel.cmin_flt, data.proc_kernel.cmaj_flt,
|
||||
data.proc_kernel.kstk_esp, data.proc_kernel.kstk_eip,
|
||||
data.proc_kernel.wchan);
|
||||
|
||||
glibtop_get_proc_segment (&data.proc_segment, 1);
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_segment (&data.proc_segment, 1);
|
||||
|
||||
fprintf (stderr, "Proc_Segment INIT %5u (0x%08lx): "
|
||||
"%ld %ld %ld %ld %lu %lu %lu\n", 1, data.proc_segment.flags,
|
||||
data.proc_segment.trs, data.proc_segment.lrs,
|
||||
data.proc_segment.drs, data.proc_segment.dt,
|
||||
data.proc_segment.start_code, data.proc_segment.end_code,
|
||||
data.proc_segment.start_stack);
|
||||
printf ("Proc_Segment INIT %5u (0x%08lx): "
|
||||
"%ld %ld %ld %ld %lu %lu %lu\n", 1, data.proc_segment.flags,
|
||||
data.proc_segment.trs, data.proc_segment.lrs,
|
||||
data.proc_segment.drs, data.proc_segment.dt,
|
||||
data.proc_segment.start_code, data.proc_segment.end_code,
|
||||
data.proc_segment.start_stack);
|
||||
|
||||
glibtop_close ();
|
||||
|
||||
exit (0);
|
||||
}
|
||||
|
@@ -41,7 +41,7 @@ main (int argc, char *argv [])
|
||||
bindtextdomain (PACKAGE, GTOPLOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
glibtop_init__r (&glibtop_global_server);
|
||||
glibtop_init ();
|
||||
|
||||
glibtop_get_sysdeps (&sysdeps);
|
||||
|
||||
|
80
examples/test.scm
Normal file
80
examples/test.scm
Normal file
@@ -0,0 +1,80 @@
|
||||
(display (glibtop-names-sysdeps)) (newline)
|
||||
(display (glibtop-labels-sysdeps)) (newline)
|
||||
(display (glibtop-descriptions-sysdeps)) (newline)
|
||||
(display (glibtop-types-sysdeps)) (newline)
|
||||
|
||||
(newline)
|
||||
|
||||
(display (glibtop-names-cpu)) (newline)
|
||||
(display (glibtop-names-mem)) (newline)
|
||||
(display (glibtop-names-swap)) (newline)
|
||||
(display (glibtop-names-uptime)) (newline)
|
||||
(display (glibtop-names-loadavg)) (newline)
|
||||
(display (glibtop-names-shm_limits)) (newline)
|
||||
(display (glibtop-names-msg_limits)) (newline)
|
||||
(display (glibtop-names-sem_limits)) (newline)
|
||||
(display (glibtop-names-proclist)) (newline)
|
||||
(display (glibtop-names-proc_state)) (newline)
|
||||
(display (glibtop-names-proc_uid)) (newline)
|
||||
(display (glibtop-names-proc_mem)) (newline)
|
||||
(display (glibtop-names-proc_time)) (newline)
|
||||
(display (glibtop-names-proc_signal)) (newline)
|
||||
(display (glibtop-names-proc_kernel)) (newline)
|
||||
(display (glibtop-names-proc_segment)) (newline)
|
||||
|
||||
(newline)
|
||||
|
||||
(display (glibtop-labels-cpu)) (newline)
|
||||
(display (glibtop-labels-mem)) (newline)
|
||||
(display (glibtop-labels-swap)) (newline)
|
||||
(display (glibtop-labels-uptime)) (newline)
|
||||
(display (glibtop-labels-loadavg)) (newline)
|
||||
(display (glibtop-labels-shm_limits)) (newline)
|
||||
(display (glibtop-labels-msg_limits)) (newline)
|
||||
(display (glibtop-labels-sem_limits)) (newline)
|
||||
(display (glibtop-labels-proclist)) (newline)
|
||||
(display (glibtop-labels-proc_state)) (newline)
|
||||
(display (glibtop-labels-proc_uid)) (newline)
|
||||
(display (glibtop-labels-proc_mem)) (newline)
|
||||
(display (glibtop-labels-proc_time)) (newline)
|
||||
(display (glibtop-labels-proc_signal)) (newline)
|
||||
(display (glibtop-labels-proc_kernel)) (newline)
|
||||
(display (glibtop-labels-proc_segment)) (newline)
|
||||
|
||||
(newline)
|
||||
|
||||
(display (glibtop-descriptions-cpu)) (newline)
|
||||
(display (glibtop-descriptions-mem)) (newline)
|
||||
(display (glibtop-descriptions-swap)) (newline)
|
||||
(display (glibtop-descriptions-uptime)) (newline)
|
||||
(display (glibtop-descriptions-loadavg)) (newline)
|
||||
(display (glibtop-descriptions-shm_limits)) (newline)
|
||||
(display (glibtop-descriptions-msg_limits)) (newline)
|
||||
(display (glibtop-descriptions-sem_limits)) (newline)
|
||||
(display (glibtop-descriptions-proclist)) (newline)
|
||||
(display (glibtop-descriptions-proc_state)) (newline)
|
||||
(display (glibtop-descriptions-proc_uid)) (newline)
|
||||
(display (glibtop-descriptions-proc_mem)) (newline)
|
||||
(display (glibtop-descriptions-proc_time)) (newline)
|
||||
(display (glibtop-descriptions-proc_signal)) (newline)
|
||||
(display (glibtop-descriptions-proc_kernel)) (newline)
|
||||
(display (glibtop-descriptions-proc_segment)) (newline)
|
||||
|
||||
(newline)
|
||||
|
||||
(display (glibtop-types-cpu)) (newline)
|
||||
(display (glibtop-types-mem)) (newline)
|
||||
(display (glibtop-types-swap)) (newline)
|
||||
(display (glibtop-types-uptime)) (newline)
|
||||
(display (glibtop-types-loadavg)) (newline)
|
||||
(display (glibtop-types-shm_limits)) (newline)
|
||||
(display (glibtop-types-msg_limits)) (newline)
|
||||
(display (glibtop-types-sem_limits)) (newline)
|
||||
(display (glibtop-types-proclist)) (newline)
|
||||
(display (glibtop-types-proc_state)) (newline)
|
||||
(display (glibtop-types-proc_uid)) (newline)
|
||||
(display (glibtop-types-proc_mem)) (newline)
|
||||
(display (glibtop-types-proc_time)) (newline)
|
||||
(display (glibtop-types-proc_signal)) (newline)
|
||||
(display (glibtop-types-proc_kernel)) (newline)
|
||||
(display (glibtop-types-proc_segment)) (newline)
|
16
features.def
Normal file
16
features.def
Normal file
@@ -0,0 +1,16 @@
|
||||
cpu ulong(total,user,nice,sys,idle,frequency)
|
||||
mem ulong(total,used,free,shared,buffer,cached,user,locked)
|
||||
swap ulong(total,used,free)
|
||||
uptime double(uptime,idletime)
|
||||
loadavg double(loadavg[0],loadavg[1],loadavg[2])
|
||||
shm_limits ulong(shmmax,shmmin,shmmni,shmseg,shmall)
|
||||
msg_limits ulong(msgpool,msgmap,msgmax,msgmnb,msgmni,msgssz,msgtql)
|
||||
sem_limits ulong(semmap,semmni,semmns,semmnu,semmsl,semopm,semume,semusz,semvmx,semaem)
|
||||
proclist ulong(number,size,total)
|
||||
proc_state str(cmd):char(state):ulong(uid,gid)
|
||||
proc_uid long(uid,euid,gid,egid,pid,ppid,pgrp,session,tty,tpgid,priority,nice)
|
||||
proc_mem long(size,vsize,resident,share,rss,rss_rlim)
|
||||
proc_time long(start_time,utime,stime,cutime,cstime,timeout,it_real_value)
|
||||
proc_signal long(signal,blocked,sigignore,sigcatch)
|
||||
proc_kernel ulong(k_flags,min_flt,maj_flt,cmin_flt,cmaj_flt,kstk_esp,kstk_eip,wchan)
|
||||
proc_segment long(trs,lrs,drs,dt):ulong(start_code,end_code,start_stack)
|
21
glibtop.h
21
glibtop.h
@@ -24,6 +24,9 @@
|
||||
|
||||
#include <glibtop/global.h>
|
||||
|
||||
#include <glibtop_server.h>
|
||||
#include <glibtop/types.h>
|
||||
|
||||
#ifdef HAVE_GLIBTOP_MACHINE_H
|
||||
#include <glibtop_machine.h>
|
||||
#endif
|
||||
@@ -32,22 +35,34 @@ typedef struct _glibtop glibtop;
|
||||
|
||||
struct _glibtop
|
||||
{
|
||||
int fd; /* Server file descriptor */
|
||||
unsigned flags;
|
||||
unsigned method; /* Server Method */
|
||||
#ifdef HAVE_GLIBTOP_MACHINE_H
|
||||
glibtop_machine machine; /* Machine dependent data */
|
||||
#endif
|
||||
int input [2]; /* Pipe client <- server */
|
||||
int output [2]; /* Pipe client -> server */
|
||||
int socket; /* Accepted connection of a socket */
|
||||
unsigned long os_version_code; /* Version code of the operating system */
|
||||
const char *name; /* Program name for error messages */
|
||||
const char *server_command; /* Command used to invoke server */
|
||||
const char *server_host; /* Host the server should run on */
|
||||
const char *server_user; /* Name of the user on the target host */
|
||||
const char *server_rsh; /* Command used to connect to the target host */
|
||||
unsigned long features; /* Server is required for this features */
|
||||
unsigned long server_port; /* Port on which daemon is listening */
|
||||
pid_t pid; /* PID of the server */
|
||||
};
|
||||
|
||||
extern glibtop *glibtop_global_server;
|
||||
|
||||
#define glibtop_init() glibtop_init__r(&glibtop_global_server);
|
||||
extern const unsigned long glibtop_server_features;
|
||||
|
||||
extern glibtop *glibtop_init__r __P((glibtop **));
|
||||
#define glibtop_init() glibtop_init_r(&glibtop_global_server, 0, 0);
|
||||
|
||||
#define glibtop_close() glibtop_close_r(glibtop_global_server);
|
||||
|
||||
extern glibtop *glibtop_init_r __P((glibtop **, const unsigned long, const unsigned));
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
|
||||
|
@@ -5,4 +5,5 @@ glibtop_HEADERS = close.h loadavg.h prockernel.h procstate.h \
|
||||
proctime.h shm_limits.h version.h cpu.h msg_limits.h \
|
||||
procmem.h procuid.h swap.h write.h error.h open.h \
|
||||
procsegment.h read.h sysdeps.h xmalloc.h global.h \
|
||||
output.h procsignal.h read_data.h union.h
|
||||
output.h procsignal.h read_data.h union.h types.h \
|
||||
parameter.h
|
||||
|
@@ -26,7 +26,7 @@
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
extern void glibtop_close __P((glibtop *));
|
||||
extern void glibtop_close_r __P((glibtop *));
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
@@ -29,6 +29,7 @@ __BEGIN_DECLS
|
||||
|
||||
#define GLIBTOP_CMND_QUIT 0
|
||||
#define GLIBTOP_CMND_SYSDEPS 1
|
||||
|
||||
#define GLIBTOP_CMND_CPU 2
|
||||
#define GLIBTOP_CMND_MEM 3
|
||||
#define GLIBTOP_CMND_SWAP 4
|
||||
@@ -49,18 +50,38 @@ __BEGIN_DECLS
|
||||
|
||||
#define GLIBTOP_MAX_CMND 18
|
||||
|
||||
typedef struct _glibtop_command glibtop_command;
|
||||
#define _GLIBTOP_PARAM_SIZE 16
|
||||
|
||||
typedef struct _glibtop_command glibtop_command;
|
||||
|
||||
typedef struct _glibtop_response glibtop_response;
|
||||
typedef union _glibtop_response_union glibtop_response_union;
|
||||
|
||||
struct _glibtop_command
|
||||
{
|
||||
glibtop server;
|
||||
unsigned command;
|
||||
size_t size;
|
||||
glibtop server;
|
||||
unsigned command;
|
||||
size_t size, data_size;
|
||||
char parameter [_GLIBTOP_PARAM_SIZE];
|
||||
};
|
||||
|
||||
#define glibtop_call(p1, p2, p3, p4) glibtop_call__r(glibtop_global_server, p1, p2, p3, p4)
|
||||
union _glibtop_response_union
|
||||
{
|
||||
glibtop_union data;
|
||||
glibtop_sysdeps sysdeps;
|
||||
};
|
||||
|
||||
extern void *glibtop_call__r __P((glibtop *, unsigned, size_t, void *, size_t, void *));
|
||||
struct _glibtop_response
|
||||
{
|
||||
off_t offset;
|
||||
size_t size, data_size;
|
||||
glibtop_response_union u;
|
||||
};
|
||||
|
||||
#define glibtop_call(p1, p2, p3, p4) glibtop_call_r(glibtop_global_server, p1, p2, p3, p4)
|
||||
|
||||
extern void *glibtop_call_l __P((glibtop *, unsigned, size_t, void *, size_t, void *));
|
||||
extern void *glibtop_call_s __P((glibtop *, unsigned, size_t, void *, size_t, void *));
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
@@ -49,9 +49,21 @@ struct _glibtop_cpu
|
||||
frequency; /* GLIBTOP_CPU_FREQUENCY */
|
||||
};
|
||||
|
||||
#define glibtop_get_cpu(cpu) glibtop_get_cpu__r(glibtop_global_server, cpu)
|
||||
#define glibtop_get_cpu(cpu) glibtop_get_cpu_l(glibtop_global_server, cpu)
|
||||
|
||||
extern void glibtop_get_cpu__r __P((glibtop *, glibtop_cpu *));
|
||||
#if GLIBTOP_SUID_CPU
|
||||
#define glibtop_get_cpu_r glibtop_get_cpu_p
|
||||
#else
|
||||
#define glibtop_get_cpu_r glibtop_get_cpu_s
|
||||
#endif
|
||||
|
||||
extern void glibtop_get_cpu_l __P((glibtop *, glibtop_cpu *));
|
||||
|
||||
#if GLIBTOP_SUID_CPU
|
||||
extern void glibtop_get_cpu_p __P((glibtop *, glibtop_cpu *));
|
||||
#else
|
||||
extern void glibtop_get_cpu_s __P((glibtop *, glibtop_cpu *));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
|
||||
@@ -77,7 +89,7 @@ extern SCM glibtop_guile_descriptions_cpu __P((void));
|
||||
/* You need to link with -lgtop_names to get this stuff here. */
|
||||
|
||||
extern const char *glibtop_names_cpu [];
|
||||
extern const char *glibtop_types_cpu [];
|
||||
extern const unsigned glibtop_types_cpu [];
|
||||
extern const char *glibtop_labels_cpu [];
|
||||
extern const char *glibtop_descriptions_cpu [];
|
||||
|
||||
|
@@ -26,9 +26,17 @@
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define glibtop_error(p1, args...) glibtop_error__r(glibtop_global_server , p1 , ## args)
|
||||
#define glibtop_error(p1, args...) glibtop_error_r(glibtop_global_server , p1 , ## args)
|
||||
#define glibtop_warn(p1, args...) glibtop_warn_r(glibtop_global_server , p1 , ## args)
|
||||
|
||||
extern void glibtop_error__r __P((glibtop *, char *, ...));
|
||||
#define glibtop_error_io(p1, args...) glibtop_error_io_r(glibtop_global_server , p1 , ## args)
|
||||
#define glibtop_warn_io(p1, args...) glibtop_warn_io_r(glibtop_global_server , p1 , ## args)
|
||||
|
||||
extern void glibtop_error_r __P((glibtop *, char *, ...));
|
||||
extern void glibtop_warn_r __P((glibtop *, char *, ...));
|
||||
|
||||
extern void glibtop_error_io_r __P((glibtop *, char *, ...));
|
||||
extern void glibtop_warn_io_r __P((glibtop *, char *, ...));
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
@@ -51,6 +51,22 @@
|
||||
# define __P(protos) ()
|
||||
#endif
|
||||
|
||||
#if TIME_WITH_SYS_TIME
|
||||
# include <sys/time.h>
|
||||
# include <time.h>
|
||||
#else
|
||||
# if HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
# else
|
||||
# include <time.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef WITHOUT_GUILE
|
||||
#undef HAVE_GUILE
|
||||
#undef GLIBTOP_GUILE_NAMES
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
#include <guile/gh.h>
|
||||
#endif
|
||||
@@ -67,7 +83,10 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MEMORY_H
|
||||
#include <memory.h>
|
||||
@@ -75,7 +94,9 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
|
||||
|
158
include/glibtop/gnuserv.h
Normal file
158
include/glibtop/gnuserv.h
Normal file
@@ -0,0 +1,158 @@
|
||||
/* -*-C-*-
|
||||
|
||||
Header file for the GNU Emacs server and client C code.
|
||||
|
||||
This file is part of GNU Emacs.
|
||||
|
||||
Copying is permitted under those conditions described by the GNU
|
||||
General Public License.
|
||||
|
||||
Copyright (C) 1989 Free Software Foundation, Inc.
|
||||
|
||||
Author: Andy Norman (ange@hplb.hpl.hp.com), based on
|
||||
'etc/server.c' and 'etc/emacsclient.c' from the 18.52 GNU
|
||||
Emacs distribution.
|
||||
|
||||
Please mail bugs and suggestions to the author at the above address.
|
||||
*/
|
||||
|
||||
/* HISTORY
|
||||
* 11-Nov-1990 bristor@simba
|
||||
* Added EOT stuff.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file incorporates new features added by Bob Weiner <weiner@mot.com>,
|
||||
* Darrell Kindred <dkindred@cmu.edu> and Arup Mukherjee <arup@cmu.edu>.
|
||||
* Please see the note at the end of the README file for details.
|
||||
*
|
||||
* (If gnuserv came bundled with your emacs, the README file is probably
|
||||
* ../etc/gnuserv.README relative to the directory containing this file)
|
||||
*/
|
||||
|
||||
#if 0
|
||||
static char header_rcsid [] = "!Header: gnuserv.h,v 2.4 95/02/16 11:58:11 arup alpha !";
|
||||
#endif
|
||||
|
||||
#define NO_SHORTNAMES
|
||||
|
||||
#define PATCHLEVEL 2
|
||||
|
||||
#define NO_SHORTNAMES
|
||||
/* gnuserv should not be compiled using SOCKS */
|
||||
#define DO_NOT_SOCKSIFY
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#undef read
|
||||
#undef write
|
||||
#undef open
|
||||
#undef close
|
||||
#undef signal
|
||||
|
||||
/* Define the communication method between server and clients:
|
||||
* You can have either or both kinds of sockets, but you can't mix
|
||||
* sockets with sysv ipc
|
||||
*/
|
||||
|
||||
#define INTERNET_DOMAIN_SOCKETS
|
||||
#define UNIX_DOMAIN_SOCKETS
|
||||
|
||||
/*
|
||||
* Define additional authentication protocols to be used. These methods will
|
||||
* be tried before falling back to the default gnuserv protocol (based on
|
||||
* the GNU_SECURE environment variable). Currently, only MIT-MAGIC-COOKIE-1
|
||||
* is also supported.
|
||||
*
|
||||
* Comment out the next line(s) if you don't want to enable the
|
||||
* appropriate authentication protocol.
|
||||
*/
|
||||
|
||||
#if defined (HAVE_XAUTH)
|
||||
#define AUTH_MAGIC_COOKIE
|
||||
#endif /* HAVE_XAUTH */
|
||||
|
||||
/*
|
||||
* stuff related to supporting MIT-MAGIC-COOKIE-1
|
||||
*/
|
||||
|
||||
#define MCOOKIE_SCREEN "42980" /* screen # to use as the gnuserv cookie */
|
||||
#define MCOOKIE_NAME "MAGIC-1" /* authentication protocol name */
|
||||
#define MCOOKIE_X_NAME "MIT-MAGIC-COOKIE-1" /* as needed by X */
|
||||
|
||||
|
||||
#define DEFAUTH_NAME "GNU-SECURE" /* name of default auth protocol */
|
||||
#define AUTH_TIMEOUT 15 /* # seconds to wait for auth data */
|
||||
#define AUTH_NAMESZ 15 /* max allows auth protocol name size */
|
||||
|
||||
|
||||
/*
|
||||
* Pick a default communication scheme, if none was specified.
|
||||
*/
|
||||
|
||||
#if !defined(UNIX_DOMAIN_SOCKETS) && !defined(INTERNET_DOMAIN_SOCKETS)
|
||||
|
||||
/* BSD systems use Unix Domain sockets by default */
|
||||
|
||||
#ifdef BSD
|
||||
#define UNIX_DOMAIN_SOCKETS
|
||||
#endif
|
||||
|
||||
#endif /* No communication method pre-defined */
|
||||
|
||||
/*
|
||||
* If you are using SYSV_IPC, you might want to make the buffer size bigger
|
||||
* since it limits the size of requests and responses. Don't make it bigger
|
||||
* than your system's max message size though (usually a couple of k) or else
|
||||
* msgsend will start failing. For sockets, using the system BUFSIZ is usually
|
||||
* what you want.
|
||||
*/
|
||||
|
||||
#if defined(INTERNET_DOMAIN_SOCKETS) || defined(UNIX_DOMAIN_SOCKETS)
|
||||
#include <sys/socket.h>
|
||||
#endif /* INTERNET_DOMAIN_SOCKETS || UNIX_DOMAIN_SOCKETS */
|
||||
|
||||
#ifdef INTERNET_DOMAIN_SOCKETS
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#define TABLE_SIZE 101 /* The number of entries in the hash table */
|
||||
#define HASH(host) host /* Rather simplistic hash function */
|
||||
#define DEFAULT_PORT 21490 /* default port number to use is
|
||||
* DEFAULT_PORT + uid */
|
||||
#endif /* INTERNET_DOMAIN_SOCKETS */
|
||||
|
||||
#ifdef UNIX_DOMAIN_SOCKETS
|
||||
#include <sys/un.h>
|
||||
#define HIDE_UNIX_SOCKET /* put the unix socket in a protected dir */
|
||||
#endif /* UNIX_DOMAIN_SOCKETS */
|
||||
|
||||
#define HOSTNAMSZ 255 /* max size of a hostname */
|
||||
#define REPLYSIZ 300 /* max size of reply from server to client */
|
||||
#undef FALSE
|
||||
#define FALSE 0
|
||||
#undef TRUE
|
||||
#define TRUE 1
|
||||
|
||||
/* The casts shut Sun's compiler up and are safe in the context these
|
||||
are actually used. */
|
||||
#define max2(x,y) (((int) (x) > (int) (y)) ? (x) : (y))
|
||||
#define min2(x,y) (((int) (x) < (int) (y)) ? (x) : (y))
|
||||
|
||||
#ifndef _NFILE /* rough guess at maximum number of open files */
|
||||
#define _NFILE 20
|
||||
#endif
|
||||
|
||||
#define EOT_STR "\004"
|
||||
#define EOT_CHR '\004'
|
||||
|
||||
/* connection types */
|
||||
#define CONN_UNIX 0
|
||||
#define CONN_INTERNET 1
|
||||
#define CONN_IPC 2
|
||||
|
||||
/* function declarations */
|
||||
extern int glibtop_make_connection __P((const char *, int, int *));
|
||||
|
||||
#ifdef INTERNET_DOMAIN_SOCKETS
|
||||
extern long glibtop_internet_addr __P((const char *));
|
||||
#endif
|
@@ -39,9 +39,21 @@ struct _glibtop_loadavg
|
||||
double loadavg [3]; /* GLIBTOP_LOADAVG_LOADAVG */
|
||||
};
|
||||
|
||||
#define glibtop_get_loadavg(loadavg) glibtop_get_loadavg__r(glibtop_global_server, loadavg)
|
||||
#define glibtop_get_loadavg(loadavg) glibtop_get_loadavg_l(glibtop_global_server, loadavg)
|
||||
|
||||
extern void glibtop_get_loadavg__r __P((glibtop *, glibtop_loadavg *));
|
||||
#if GLIBTOP_SUID_LOADAVG
|
||||
#define glibtop_get_loadavg_r glibtop_get_loadavg_p
|
||||
#else
|
||||
#define glibtop_get_loadavg_r glibtop_get_loadavg_s
|
||||
#endif
|
||||
|
||||
extern void glibtop_get_loadavg_l __P((glibtop *, glibtop_loadavg *));
|
||||
|
||||
#if GLIBTOP_SUID_LOADAVG
|
||||
extern void glibtop_get_loadavg_p __P((glibtop *, glibtop_loadavg *));
|
||||
#else
|
||||
extern void glibtop_get_loadavg_s __P((glibtop *, glibtop_loadavg *));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
|
||||
@@ -67,7 +79,7 @@ extern SCM glibtop_guile_descriptions_loadavg __P((void));
|
||||
/* You need to link with -lgtop_names to get this stuff here. */
|
||||
|
||||
extern const char *glibtop_names_loadavg [];
|
||||
extern const char *glibtop_types_loadavg [];
|
||||
extern const unsigned glibtop_types_loadavg [];
|
||||
extern const char *glibtop_labels_loadavg [];
|
||||
extern const char *glibtop_descriptions_loadavg [];
|
||||
|
||||
|
@@ -53,9 +53,21 @@ struct _glibtop_mem
|
||||
locked; /* GLIBTOP_MEM_LOCKED */
|
||||
};
|
||||
|
||||
#define glibtop_get_mem(mem) glibtop_get_mem__r(glibtop_global_server, mem)
|
||||
#define glibtop_get_mem(mem) glibtop_get_mem_l(glibtop_global_server, mem)
|
||||
|
||||
extern void glibtop_get_mem__r __P((glibtop *, glibtop_mem *));
|
||||
#if GLIBTOP_SUID_MEM
|
||||
#define glibtop_get_mem_r glibtop_get_mem_p
|
||||
#else
|
||||
#define glibtop_get_mem_r glibtop_get_mem_s
|
||||
#endif
|
||||
|
||||
extern void glibtop_get_mem_l __P((glibtop *, glibtop_mem *));
|
||||
|
||||
#if GLIBTOP_SUID_MEM
|
||||
extern void glibtop_get_mem_p __P((glibtop *, glibtop_mem *));
|
||||
#else
|
||||
extern void glibtop_get_mem_s __P((glibtop *, glibtop_mem *));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
|
||||
@@ -81,7 +93,7 @@ extern SCM glibtop_guile_descriptions_mem __P((void));
|
||||
/* You need to link with -lgtop_names to get this stuff here. */
|
||||
|
||||
extern const char *glibtop_names_mem [];
|
||||
extern const char *glibtop_types_mem [];
|
||||
extern const unsigned glibtop_types_mem [];
|
||||
extern const char *glibtop_labels_mem [];
|
||||
extern const char *glibtop_descriptions_mem [];
|
||||
|
||||
|
@@ -51,9 +51,21 @@ struct _glibtop_msg_limits
|
||||
msgtql; /* GLIBTOP_IPC_MSGTQL */
|
||||
};
|
||||
|
||||
#define glibtop_get_msg_limits(msg) glibtop_get_msg_limits__r(glibtop_global_server, msg)
|
||||
#define glibtop_get_msg_limits(msg) glibtop_get_msg_limits_l(glibtop_global_server, msg)
|
||||
|
||||
extern void glibtop_get_msg_limits__r __P((glibtop *, glibtop_msg_limits *));
|
||||
#if GLIBTOP_SUID_MSG_LIMITS
|
||||
#define glibtop_get_msg_limits_r glibtop_get_msg_limits_p
|
||||
#else
|
||||
#define glibtop_get_msg_limits_r glibtop_get_msg_limits_s
|
||||
#endif
|
||||
|
||||
extern void glibtop_get_msg_limits_l __P((glibtop *, glibtop_msg_limits *));
|
||||
|
||||
#if GLIBTOP_SUID_MSG_LIMITS
|
||||
extern void glibtop_get_msg_limits_p __P((glibtop *, glibtop_msg_limits *));
|
||||
#else
|
||||
extern void glibtop_get_msg_limits_s __P((glibtop *, glibtop_msg_limits *));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
|
||||
@@ -79,7 +91,7 @@ extern SCM glibtop_guile_descriptions_msg_limits __P((void));
|
||||
/* You need to link with -lgtop_names to get this stuff here. */
|
||||
|
||||
extern const char *glibtop_names_msg_limits [];
|
||||
extern const char *glibtop_types_msg_limits [];
|
||||
extern const unsigned glibtop_types_msg_limits [];
|
||||
extern const char *glibtop_labels_msg_limits [];
|
||||
extern const char *glibtop_descriptions_msg_limits [];
|
||||
|
||||
|
@@ -26,7 +26,23 @@
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
extern void glibtop_open __P((glibtop *, const char *));
|
||||
#define _GLIBTOP_INIT_STATE_INIT 0x10000
|
||||
#define _GLIBTOP_INIT_STATE_OPEN 0x20000
|
||||
#define _GLIBTOP_INIT_STATE_SERVER 0x40000
|
||||
|
||||
#define GLIBTOP_INIT_NO_OPEN 1
|
||||
#define GLIBTOP_INIT_NO_INIT 2
|
||||
|
||||
#define GLIBTOP_OPEN_NO_OVERRIDE 1
|
||||
|
||||
#define GLIBTOP_METHOD_DIRECT 1
|
||||
#define GLIBTOP_METHOD_PIPE 2
|
||||
#define GLIBTOP_METHOD_INET 3
|
||||
#define GLIBTOP_METHOD_UNIX 4
|
||||
|
||||
extern void glibtop_open_l __P((glibtop *, const char *, const unsigned long, const unsigned));
|
||||
|
||||
extern void glibtop_open_r __P((glibtop *, const char *, const unsigned long, const unsigned));
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
@@ -1,5 +1,3 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the Gnome Top Library.
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
@@ -19,37 +17,26 @@
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef __GLIBTOP_PARAMETER_H__
|
||||
#define __GLIBTOP_PARAMETER_H__
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/xmalloc.h>
|
||||
#include <glibtop/proclist.h>
|
||||
#include <glibtop/open.h>
|
||||
|
||||
#include <guile/gh.h>
|
||||
__BEGIN_DECLS
|
||||
|
||||
SCM
|
||||
glibtop_guile_get_proclist (void)
|
||||
{
|
||||
glibtop_proclist proclist;
|
||||
unsigned *ptr;
|
||||
unsigned i;
|
||||
SCM list;
|
||||
#define GLIBTOP_PARAM_METHOD 1
|
||||
#define GLIBTOP_PARAM_FEATURES 2
|
||||
#define GLIBTOP_PARAM_COMMAND 3
|
||||
#define GLIBTOP_PARAM_HOST 4
|
||||
#define GLIBTOP_PARAM_PORT 5
|
||||
|
||||
ptr = glibtop_get_proclist (&proclist);
|
||||
#define glibtop_get_parameter(p1,p2,p3) glibtop_get_parameter_l(glibtop_global_server,p1,p2,p3)
|
||||
#define glibtop_set_parameter(p1,p2,p3) glibtop_set_parameter_l(glibtop_global_server,p1,p2,p3)
|
||||
|
||||
list = gh_list (gh_ulong2scm (proclist.flags),
|
||||
gh_ulong2scm (proclist.number),
|
||||
gh_ulong2scm (proclist.size),
|
||||
gh_ulong2scm (proclist.total),
|
||||
SCM_UNDEFINED);
|
||||
extern size_t glibtop_get_parameter_l __P((glibtop *, const unsigned, void *, size_t));
|
||||
extern void glibtop_set_parameter_l __P((glibtop *, const unsigned, const void *, size_t));
|
||||
|
||||
if (ptr) {
|
||||
for (i = 0; i < proclist.number; i++)
|
||||
list = gh_append
|
||||
(gh_list (list,
|
||||
gh_list (gh_ulong2scm ((unsigned long) ptr [i])),
|
||||
SCM_UNDEFINED));
|
||||
}
|
||||
__END_DECLS
|
||||
|
||||
glibtop_free (ptr);
|
||||
|
||||
return list;
|
||||
}
|
||||
#endif
|
@@ -60,9 +60,21 @@ struct _glibtop_proc_kernel
|
||||
* proc is sleeping in */
|
||||
};
|
||||
|
||||
#define glibtop_get_proc_kernel(p1, p2) glibtop_get_proc_kernel__r(glibtop_global_server, p1, p2)
|
||||
#define glibtop_get_proc_kernel(p1, p2) glibtop_get_proc_kernel_l(glibtop_global_server, p1, p2)
|
||||
|
||||
extern void glibtop_get_proc_kernel__r __P((glibtop *, glibtop_proc_kernel *, pid_t));
|
||||
#if GLIBTOP_SUID_PROC_KERNEL
|
||||
#define glibtop_get_proc_kernel_r glibtop_get_proc_kernel_p
|
||||
#else
|
||||
#define glibtop_get_proc_kernel_r glibtop_get_proc_kernel_s
|
||||
#endif
|
||||
|
||||
extern void glibtop_get_proc_kernel_l __P((glibtop *, glibtop_proc_kernel *, pid_t));
|
||||
|
||||
#if GLIBTOP_SUID_PROC_KERNEL
|
||||
extern void glibtop_get_proc_kernel_p __P((glibtop *, glibtop_proc_kernel *, pid_t));
|
||||
#else
|
||||
extern void glibtop_get_proc_kernel_s __P((glibtop *, glibtop_proc_kernel *, pid_t));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
|
||||
@@ -87,8 +99,8 @@ extern SCM glibtop_guile_descriptions_proc_kernel __P((void));
|
||||
|
||||
/* You need to link with -lgtop_names to get this stuff here. */
|
||||
|
||||
extern const char *glibtop_types_proc_kernel [];
|
||||
extern const char *glibtop_names_proc_kernel [];
|
||||
extern const unsigned glibtop_types_proc_kernel [];
|
||||
extern const char *glibtop_labels_proc_kernel [];
|
||||
extern const char *glibtop_descriptions_proc_kernel [];
|
||||
|
||||
|
@@ -43,9 +43,21 @@ struct _glibtop_proclist
|
||||
size; /* GLIBTOP_PROCLIST_SIZE */
|
||||
};
|
||||
|
||||
#define glibtop_get_proclist(proclist) glibtop_get_proclist__r(glibtop_global_server, proclist)
|
||||
#define glibtop_get_proclist(proclist) glibtop_get_proclist_l(glibtop_global_server, proclist)
|
||||
|
||||
extern unsigned *glibtop_get_proclist__r __P((glibtop *, glibtop_proclist *));
|
||||
#if GLIBTOP_SUID_PROCLIST
|
||||
#define glibtop_get_proclist_r glibtop_get_proclist_p
|
||||
#else
|
||||
#define glibtop_get_proclist_r glibtop_get_proclist_s
|
||||
#endif
|
||||
|
||||
extern unsigned *glibtop_get_proclist_l __P((glibtop *, glibtop_proclist *));
|
||||
|
||||
#if GLIBTOP_SUID_PROCLIST
|
||||
extern unsigned *glibtop_get_proclist_p __P((glibtop *, glibtop_proclist *));
|
||||
#else
|
||||
extern unsigned *glibtop_get_proclist_s __P((glibtop *, glibtop_proclist *));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
|
||||
@@ -71,7 +83,7 @@ extern SCM glibtop_guile_descriptions_proclist __P((void));
|
||||
/* You need to link with -lgtop_names to get this stuff here. */
|
||||
|
||||
extern const char *glibtop_names_proclist [];
|
||||
extern const char *glibtop_types_proclist [];
|
||||
extern const unsigned glibtop_types_proclist [];
|
||||
extern const char *glibtop_labels_proclist [];
|
||||
extern const char *glibtop_descriptions_proclist [];
|
||||
|
||||
|
@@ -53,9 +53,21 @@ struct _glibtop_proc_mem
|
||||
* of the process; usually 2,147,483,647 */
|
||||
};
|
||||
|
||||
#define glibtop_get_proc_mem(p1, p2) glibtop_get_proc_mem__r(glibtop_global_server, p1, p2)
|
||||
#define glibtop_get_proc_mem(p1, p2) glibtop_get_proc_mem_l(glibtop_global_server, p1, p2)
|
||||
|
||||
extern void glibtop_get_proc_mem__r __P((glibtop *, glibtop_proc_mem *, pid_t));
|
||||
#if GLIBTOP_SUID_PROC_MEM
|
||||
#define glibtop_get_proc_mem_r glibtop_get_proc_mem_p
|
||||
#else
|
||||
#define glibtop_get_proc_mem_r glibtop_get_proc_mem_s
|
||||
#endif
|
||||
|
||||
extern void glibtop_get_proc_mem_l __P((glibtop *, glibtop_proc_mem *, pid_t));
|
||||
|
||||
#if GLIBTOP_SUID_PROC_MEM
|
||||
extern void glibtop_get_proc_mem_p __P((glibtop *, glibtop_proc_mem *, pid_t));
|
||||
#else
|
||||
extern void glibtop_get_proc_mem_s __P((glibtop *, glibtop_proc_mem *, pid_t));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
|
||||
@@ -81,7 +93,7 @@ extern SCM glibtop_guile_descriptions_proc_mem __P((void));
|
||||
/* You need to link with -lgtop_names to get this stuff here. */
|
||||
|
||||
extern const char *glibtop_names_proc_mem [];
|
||||
extern const char *glibtop_types_proc_mem [];
|
||||
extern const unsigned glibtop_types_proc_mem [];
|
||||
extern const char *glibtop_labels_proc_mem [];
|
||||
extern const char *glibtop_descriptions_proc_mem [];
|
||||
|
||||
|
@@ -54,9 +54,21 @@ struct _glibtop_proc_segment
|
||||
start_stack; /* address of the bottom of stack segment */
|
||||
};
|
||||
|
||||
#define glibtop_get_proc_segment(p1, p2) glibtop_get_proc_segment__r(glibtop_global_server, p1, p2)
|
||||
#define glibtop_get_proc_segment(p1, p2) glibtop_get_proc_segment_l(glibtop_global_server, p1, p2)
|
||||
|
||||
extern void glibtop_get_proc_segment__r __P((glibtop *, glibtop_proc_segment *, pid_t));
|
||||
#if GLIBTOP_SUID_PROC_SEGMENT
|
||||
#define glibtop_get_proc_segment_r glibtop_get_proc_segment_p
|
||||
#else
|
||||
#define glibtop_get_proc_segment_r glibtop_get_proc_segment_s
|
||||
#endif
|
||||
|
||||
extern void glibtop_get_proc_segment_l __P((glibtop *, glibtop_proc_segment *, pid_t));
|
||||
|
||||
#if GLIBTOP_SUID_PROC_SEGMENT
|
||||
extern void glibtop_get_proc_segment_p __P((glibtop *, glibtop_proc_segment *, pid_t));
|
||||
#else
|
||||
extern void glibtop_get_proc_segment_s __P((glibtop *, glibtop_proc_segment *, pid_t));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
|
||||
@@ -81,8 +93,8 @@ extern SCM glibtop_guile_descriptions_proc_segment __P((void));
|
||||
|
||||
/* You need to link with -lgtop_names to get this stuff here. */
|
||||
|
||||
extern const char *glibtop_types_proc_segment [];
|
||||
extern const char *glibtop_names_proc_segment [];
|
||||
extern const unsigned glibtop_types_proc_segment [];
|
||||
extern const char *glibtop_labels_proc_segment [];
|
||||
extern const char *glibtop_descriptions_proc_segment [];
|
||||
|
||||
|
@@ -47,9 +47,21 @@ struct _glibtop_proc_signal
|
||||
sigcatch; /* mask of caught signals */
|
||||
};
|
||||
|
||||
#define glibtop_get_proc_signal(p1, p2) glibtop_get_proc_signal__r(glibtop_global_server, p1, p2)
|
||||
#define glibtop_get_proc_signal(p1, p2) glibtop_get_proc_signal_l(glibtop_global_server, p1, p2)
|
||||
|
||||
extern void glibtop_get_proc_signal__r __P((glibtop *, glibtop_proc_signal *, pid_t));
|
||||
#if GLIBTOP_SUID_PROC_SIGNAL
|
||||
#define glibtop_get_proc_signal_r glibtop_get_proc_signal_p
|
||||
#else
|
||||
#define glibtop_get_proc_signal_r glibtop_get_proc_signal_s
|
||||
#endif
|
||||
|
||||
extern void glibtop_get_proc_signal_l __P((glibtop *, glibtop_proc_signal *, pid_t));
|
||||
|
||||
#if GLIBTOP_SUID_PROC_SIGNAL
|
||||
extern void glibtop_get_proc_signal_p __P((glibtop *, glibtop_proc_signal *, pid_t));
|
||||
#else
|
||||
extern void glibtop_get_proc_signal_s __P((glibtop *, glibtop_proc_signal *, pid_t));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
|
||||
@@ -75,7 +87,7 @@ extern SCM glibtop_guile_descriptions_proc_signal __P((void));
|
||||
/* You need to link with -lgtop_names to get this stuff here. */
|
||||
|
||||
extern const char *glibtop_names_proc_signal [];
|
||||
extern const char *glibtop_types_proc_signal [];
|
||||
extern const unsigned glibtop_types_proc_signal [];
|
||||
extern const char *glibtop_labels_proc_signal [];
|
||||
extern const char *glibtop_descriptions_proc_signal [];
|
||||
|
||||
|
@@ -54,9 +54,21 @@ struct _glibtop_proc_state
|
||||
gid; /* GID of process */
|
||||
};
|
||||
|
||||
#define glibtop_get_proc_state(p1, p2) glibtop_get_proc_state__r(glibtop_global_server, p1, p2)
|
||||
#define glibtop_get_proc_state(p1, p2) glibtop_get_proc_state_l(glibtop_global_server, p1, p2)
|
||||
|
||||
extern void glibtop_get_proc_state__r __P((glibtop *, glibtop_proc_state *, pid_t));
|
||||
#if GLIBTOP_SUID_PROC_STATE
|
||||
#define glibtop_get_proc_state_r glibtop_get_proc_state_p
|
||||
#else
|
||||
#define glibtop_get_proc_state_r glibtop_get_proc_state_s
|
||||
#endif
|
||||
|
||||
extern void glibtop_get_proc_state_l __P((glibtop *, glibtop_proc_state *, pid_t));
|
||||
|
||||
#if GLIBTOP_SUID_PROC_STATE
|
||||
extern void glibtop_get_proc_state_p __P((glibtop *, glibtop_proc_state *, pid_t));
|
||||
#else
|
||||
extern void glibtop_get_proc_state_s __P((glibtop *, glibtop_proc_state *, pid_t));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
|
||||
@@ -82,7 +94,7 @@ extern SCM glibtop_guile_descriptions_proc_state __P((void));
|
||||
/* You need to link with -lgtop_names to get this stuff here. */
|
||||
|
||||
extern const char *glibtop_names_proc_state [];
|
||||
extern const char *glibtop_types_proc_state [];
|
||||
extern const unsigned glibtop_types_proc_state [];
|
||||
extern const char *glibtop_labels_proc_state [];
|
||||
extern const char *glibtop_descriptions_proc_state [];
|
||||
|
||||
|
@@ -59,9 +59,21 @@ struct _glibtop_proc_time
|
||||
* due to an interval timer. */
|
||||
};
|
||||
|
||||
#define glibtop_get_proc_time(p1, p2) glibtop_get_proc_time__r(glibtop_global_server, p1, p2)
|
||||
#define glibtop_get_proc_time(p1, p2) glibtop_get_proc_time_l(glibtop_global_server, p1, p2)
|
||||
|
||||
extern void glibtop_get_proc_time__r __P((glibtop *, glibtop_proc_time *, pid_t));
|
||||
#if GLIBTOP_SUID_PROC_TIME
|
||||
#define glibtop_get_proc_time_r glibtop_get_proc_time_p
|
||||
#else
|
||||
#define glibtop_get_proc_time_r glibtop_get_proc_time_s
|
||||
#endif
|
||||
|
||||
extern void glibtop_get_proc_time_l __P((glibtop *, glibtop_proc_time *, pid_t));
|
||||
|
||||
#if GLIBTOP_SUID_PROC_TIME
|
||||
extern void glibtop_get_proc_time_p __P((glibtop *, glibtop_proc_time *, pid_t));
|
||||
#else
|
||||
extern void glibtop_get_proc_time_s __P((glibtop *, glibtop_proc_time *, pid_t));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
|
||||
@@ -87,7 +99,7 @@ extern SCM glibtop_guile_descriptions_proc_time __P((void));
|
||||
/* You need to link with -lgtop_names to get this stuff here. */
|
||||
|
||||
extern const char *glibtop_names_proc_time [];
|
||||
extern const char *glibtop_types_proc_time [];
|
||||
extern const unsigned glibtop_types_proc_time [];
|
||||
extern const char *glibtop_labels_proc_time [];
|
||||
extern const char *glibtop_descriptions_proc_time [];
|
||||
|
||||
|
@@ -63,9 +63,21 @@ struct _glibtop_proc_uid
|
||||
nice; /* standard unix nice level of process */
|
||||
};
|
||||
|
||||
#define glibtop_get_proc_uid(p1, p2) glibtop_get_proc_uid__r(glibtop_global_server, p1, p2)
|
||||
#define glibtop_get_proc_uid(p1, p2) glibtop_get_proc_uid_l(glibtop_global_server, p1, p2)
|
||||
|
||||
extern void glibtop_get_proc_uid__r __P((glibtop *, glibtop_proc_uid *, pid_t));
|
||||
#if GLIBTOP_SUID_PROC_UID
|
||||
#define glibtop_get_proc_uid_r glibtop_get_proc_uid_p
|
||||
#else
|
||||
#define glibtop_get_proc_uid_r glibtop_get_proc_uid_s
|
||||
#endif
|
||||
|
||||
extern void glibtop_get_proc_uid_l __P((glibtop *, glibtop_proc_uid *, pid_t));
|
||||
|
||||
#if GLIBTOP_SUID_PROC_UID
|
||||
extern void glibtop_get_proc_uid_p __P((glibtop *, glibtop_proc_uid *, pid_t));
|
||||
#else
|
||||
extern void glibtop_get_proc_uid_s __P((glibtop *, glibtop_proc_uid *, pid_t));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
|
||||
@@ -91,7 +103,7 @@ extern SCM glibtop_guile_descriptions_proc_uid __P((void));
|
||||
/* You need to link with -lgtop_names to get this stuff here. */
|
||||
|
||||
extern const char *glibtop_names_proc_uid [];
|
||||
extern const char *glibtop_types_proc_uid [];
|
||||
extern const unsigned glibtop_types_proc_uid [];
|
||||
extern const char *glibtop_labels_proc_uid [];
|
||||
extern const char *glibtop_descriptions_proc_uid [];
|
||||
|
||||
|
@@ -29,7 +29,8 @@ __BEGIN_DECLS
|
||||
|
||||
#define glibtop_read(p1, p2) glibtop_read(glibtop_global_server, p1, p2)
|
||||
|
||||
extern void glibtop_read__r __P((glibtop *, size_t, void *));
|
||||
extern void glibtop_read_l __P((glibtop *, size_t, void *));
|
||||
extern void glibtop_read_s __P((glibtop *, size_t, void *));
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
@@ -27,9 +27,10 @@
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define glibtop_read_data() glibtop_read_data__r(glibtop_global_server)
|
||||
#define glibtop_read_data() glibtop_read_data_r(glibtop_global_server)
|
||||
|
||||
extern void *glibtop_read_data__r __P((glibtop *));
|
||||
extern void *glibtop_read_data_l __P((glibtop *));
|
||||
extern void *glibtop_read_data_s __P((glibtop *));
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
@@ -57,9 +57,21 @@ struct _glibtop_sem_limits
|
||||
semaem; /* GLIBTOP_IPC_SEMAEM */
|
||||
};
|
||||
|
||||
#define glibtop_get_sem_limits(sem) glibtop_get_sem_limits__r(glibtop_global_server, sem)
|
||||
#define glibtop_get_sem_limits(sem) glibtop_get_sem_limits_l(glibtop_global_server, sem)
|
||||
|
||||
extern void glibtop_get_sem_limits__r __P((glibtop *, glibtop_sem_limits *));
|
||||
#if GLIBTOP_SUID_SEM_LIMITS
|
||||
#define glibtop_get_sem_limits_r glibtop_get_sem_limits_p
|
||||
#else
|
||||
#define glibtop_get_sem_limits_r glibtop_get_sem_limits_s
|
||||
#endif
|
||||
|
||||
extern void glibtop_get_sem_limits_l __P((glibtop *, glibtop_sem_limits *));
|
||||
|
||||
#if GLIBTOP_SUID_SEM_LIMITS
|
||||
extern void glibtop_get_sem_limits_p __P((glibtop *, glibtop_sem_limits *));
|
||||
#else
|
||||
extern void glibtop_get_sem_limits_s __P((glibtop *, glibtop_sem_limits *));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
|
||||
@@ -85,7 +97,7 @@ extern SCM glibtop_guile_descriptions_sem_limits __P((void));
|
||||
/* You need to link with -lgtop_names to get this stuff here. */
|
||||
|
||||
extern const char *glibtop_names_sem_limits [];
|
||||
extern const char *glibtop_types_sem_limits [];
|
||||
extern const unsigned glibtop_types_sem_limits [];
|
||||
extern const char *glibtop_labels_sem_limits [];
|
||||
extern const char *glibtop_descriptions_sem_limits [];
|
||||
|
||||
|
@@ -47,9 +47,21 @@ struct _glibtop_shm_limits
|
||||
shmall; /* GLIBTOP_IPC_SHMALL */
|
||||
};
|
||||
|
||||
#define glibtop_get_shm_limits(shm) glibtop_get_shm_limits__r(glibtop_global_server, shm)
|
||||
#define glibtop_get_shm_limits(shm) glibtop_get_shm_limits_l(glibtop_global_server, shm)
|
||||
|
||||
extern void glibtop_get_shm_limits__r __P((glibtop *, glibtop_shm_limits *));
|
||||
#if GLIBTOP_SUID_SHM_LIMITS
|
||||
#define glibtop_get_shm_limits_r glibtop_get_shm_limits_p
|
||||
#else
|
||||
#define glibtop_get_shm_limits_r glibtop_get_shm_limits_s
|
||||
#endif
|
||||
|
||||
extern void glibtop_get_shm_limits_l __P((glibtop *, glibtop_shm_limits *));
|
||||
|
||||
#if GLIBTOP_SUID_SHM_LIMITS
|
||||
extern void glibtop_get_shm_limits_p __P((glibtop *, glibtop_shm_limits *));
|
||||
#else
|
||||
extern void glibtop_get_shm_limits_s __P((glibtop *, glibtop_shm_limits *));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
|
||||
@@ -75,7 +87,7 @@ extern SCM glibtop_guile_descriptions_shm_limits __P((void));
|
||||
/* You need to link with -lgtop_names to get this stuff here. */
|
||||
|
||||
extern const char *glibtop_names_shm_limits [];
|
||||
extern const char *glibtop_types_shm_limits [];
|
||||
extern const unsigned glibtop_types_shm_limits [];
|
||||
extern const char *glibtop_labels_shm_limits [];
|
||||
extern const char *glibtop_descriptions_shm_limits [];
|
||||
|
||||
|
@@ -43,9 +43,21 @@ struct _glibtop_swap
|
||||
free; /* GLIBTOP_SWAP_FREE */
|
||||
};
|
||||
|
||||
#define glibtop_get_swap(swap) glibtop_get_swap__r(glibtop_global_server, swap)
|
||||
#define glibtop_get_swap(swap) glibtop_get_swap_l(glibtop_global_server, swap)
|
||||
|
||||
extern void glibtop_get_swap__r __P((glibtop *, glibtop_swap *));
|
||||
#if GLIBTOP_SUID_SWAP
|
||||
#define glibtop_get_swap_r glibtop_get_swap_p
|
||||
#else
|
||||
#define glibtop_get_swap_r glibtop_get_swap_s
|
||||
#endif
|
||||
|
||||
extern void glibtop_get_swap_l __P((glibtop *, glibtop_swap *));
|
||||
|
||||
#if GLIBTOP_SUID_SWAP
|
||||
extern void glibtop_get_swap_p __P((glibtop *, glibtop_swap *));
|
||||
#else
|
||||
extern void glibtop_get_swap_s __P((glibtop *, glibtop_swap *));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
|
||||
@@ -71,7 +83,7 @@ extern SCM glibtop_guile_descriptions_swap __P((void));
|
||||
/* You need to link with -lgtop_names to get this stuff here. */
|
||||
|
||||
extern const char *glibtop_names_swap [];
|
||||
extern const char *glibtop_types_swap [];
|
||||
extern const unsigned glibtop_types_swap [];
|
||||
extern const char *glibtop_labels_swap [];
|
||||
extern const char *glibtop_descriptions_swap [];
|
||||
|
||||
|
@@ -27,30 +27,34 @@
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define GLIBTOP_SYSDEPS_CPU 0
|
||||
#define GLIBTOP_SYSDEPS_MEM 1
|
||||
#define GLIBTOP_SYSDEPS_SWAP 2
|
||||
#define GLIBTOP_SYSDEPS_UPTIME 3
|
||||
#define GLIBTOP_SYSDEPS_LOADAVG 4
|
||||
#define GLIBTOP_SYSDEPS_SHM_LIMITS 5
|
||||
#define GLIBTOP_SYSDEPS_MSG_LIMITS 6
|
||||
#define GLIBTOP_SYSDEPS_SEM_LIMITS 7
|
||||
#define GLIBTOP_SYSDEPS_PROCLIST 8
|
||||
#define GLIBTOP_SYSDEPS_PROC_STATE 9
|
||||
#define GLIBTOP_SYSDEPS_PROC_UID 10
|
||||
#define GLIBTOP_SYSDEPS_PROC_MEM 11
|
||||
#define GLIBTOP_SYSDEPS_PROC_TIME 12
|
||||
#define GLIBTOP_SYSDEPS_PROC_SIGNAL 13
|
||||
#define GLIBTOP_SYSDEPS_PROC_KERNEL 14
|
||||
#define GLIBTOP_SYSDEPS_PROC_SEGMENT 15
|
||||
#define GLIBTOP_SYSDEPS_FEATURES 0
|
||||
#define GLIBTOP_SYSDEPS_CPU 1
|
||||
#define GLIBTOP_SYSDEPS_MEM 2
|
||||
#define GLIBTOP_SYSDEPS_SWAP 3
|
||||
#define GLIBTOP_SYSDEPS_UPTIME 4
|
||||
#define GLIBTOP_SYSDEPS_LOADAVG 5
|
||||
#define GLIBTOP_SYSDEPS_SHM_LIMITS 6
|
||||
#define GLIBTOP_SYSDEPS_MSG_LIMITS 7
|
||||
#define GLIBTOP_SYSDEPS_SEM_LIMITS 8
|
||||
#define GLIBTOP_SYSDEPS_PROCLIST 9
|
||||
#define GLIBTOP_SYSDEPS_PROC_STATE 10
|
||||
#define GLIBTOP_SYSDEPS_PROC_UID 11
|
||||
#define GLIBTOP_SYSDEPS_PROC_MEM 12
|
||||
#define GLIBTOP_SYSDEPS_PROC_TIME 13
|
||||
#define GLIBTOP_SYSDEPS_PROC_SIGNAL 14
|
||||
#define GLIBTOP_SYSDEPS_PROC_KERNEL 15
|
||||
#define GLIBTOP_SYSDEPS_PROC_SEGMENT 16
|
||||
|
||||
#define GLIBTOP_MAX_SYSDEPS 16
|
||||
#define GLIBTOP_MAX_SYSDEPS 17
|
||||
|
||||
#define GLIBTOP_SYSDEPS_ALL ((1 << GLIBTOP_MAX_SYSDEPS) - 1)
|
||||
|
||||
typedef struct _glibtop_sysdeps glibtop_sysdeps;
|
||||
|
||||
struct _glibtop_sysdeps
|
||||
{
|
||||
unsigned long flags,
|
||||
features, /* server features */
|
||||
cpu, /* glibtop_cpu */
|
||||
mem, /* glibtop_mem */
|
||||
swap, /* glibtop_swap */
|
||||
@@ -69,9 +73,9 @@ struct _glibtop_sysdeps
|
||||
proc_segment; /* glibtop_proc_segment */
|
||||
};
|
||||
|
||||
#define glibtop_get_sysdeps(sysdeps) glibtop_get_sysdeps__r(glibtop_global_server,sysdeps)
|
||||
#define glibtop_get_sysdeps(sysdeps) glibtop_get_sysdeps_r(glibtop_global_server,sysdeps)
|
||||
|
||||
extern void glibtop_get_sysdeps__r __P((glibtop *, glibtop_sysdeps *));
|
||||
extern void glibtop_get_sysdeps_r __P((glibtop *, glibtop_sysdeps *));
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
|
||||
@@ -97,7 +101,7 @@ extern SCM glibtop_guile_descriptions_sysdeps __P((void));
|
||||
/* You need to link with -lgtop_names to get this stuff here. */
|
||||
|
||||
extern const char *glibtop_names_sysdeps [];
|
||||
extern const char *glibtop_types_sysdeps [];
|
||||
extern const unsigned glibtop_types_sysdeps [];
|
||||
extern const char *glibtop_labels_sysdeps [];
|
||||
extern const char *glibtop_descriptions_sysdeps [];
|
||||
|
||||
|
@@ -19,15 +19,18 @@
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop/loadavg.h>
|
||||
#include <glibtop/command.h>
|
||||
#ifndef __GLIBTOP_TYPES_H__
|
||||
#define __GLIBTOP_TYPES_H__
|
||||
|
||||
/* Provides load averange. */
|
||||
__BEGIN_DECLS
|
||||
|
||||
void
|
||||
glibtop_get_loadavg__r (glibtop *server, glibtop_loadavg *buf)
|
||||
{
|
||||
glibtop_init__r (&server);
|
||||
glibtop_call__r (server, GLIBTOP_CMND_LOADAVG, 0, NULL, sizeof (glibtop_loadavg), buf);
|
||||
}
|
||||
#define GLIBTOP_TYPE_LONG 1
|
||||
#define GLIBTOP_TYPE_ULONG 2
|
||||
#define GLIBTOP_TYPE_DOUBLE 3
|
||||
#define GLIBTOP_TYPE_INT 4
|
||||
#define GLIBTOP_TYPE_CHAR 5
|
||||
#define GLIBTOP_TYPE_STRING 6
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
@@ -41,9 +41,21 @@ struct _glibtop_uptime
|
||||
idletime; /* GLIBTOP_UPTIME_IDLETIME */
|
||||
};
|
||||
|
||||
#define glibtop_get_uptime(uptime) glibtop_get_uptime__r(glibtop_global_server, uptime)
|
||||
#define glibtop_get_uptime(uptime) glibtop_get_uptime_l(glibtop_global_server, uptime)
|
||||
|
||||
extern void glibtop_get_uptime__r __P((glibtop *, glibtop_uptime *));
|
||||
#if GLIBTOP_SUID_UPTIME
|
||||
#define glibtop_get_uptime_r glibtop_get_uptime_p
|
||||
#else
|
||||
#define glibtop_get_uptime_r glibtop_get_uptime_s
|
||||
#endif
|
||||
|
||||
extern void glibtop_get_uptime_l __P((glibtop *, glibtop_uptime *));
|
||||
|
||||
#if GLIBTOP_SUID_UPTIME
|
||||
extern void glibtop_get_uptime_p __P((glibtop *, glibtop_uptime *));
|
||||
#else
|
||||
extern void glibtop_get_uptime_s __P((glibtop *, glibtop_uptime *));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
|
||||
@@ -69,7 +81,7 @@ extern SCM glibtop_guile_descriptions_uptime __P((void));
|
||||
/* You need to link with -lgtop_names to get this stuff here. */
|
||||
|
||||
extern const char *glibtop_names_uptime [];
|
||||
extern const char *glibtop_types_uptime [];
|
||||
extern const unsigned glibtop_types_uptime [];
|
||||
extern const char *glibtop_labels_uptime [];
|
||||
extern const char *glibtop_descriptions_uptime [];
|
||||
|
||||
|
@@ -29,7 +29,8 @@ __BEGIN_DECLS
|
||||
|
||||
#define glibtop_write(p1, p2) glibtop_write(glibtop_global_server, p1, p2)
|
||||
|
||||
extern void glibtop_write__r __P((glibtop *, size_t, void *));
|
||||
extern void glibtop_write_l __P((glibtop *, size_t, void *));
|
||||
extern void glibtop_write_s __P((glibtop *, size_t, void *));
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
@@ -27,15 +27,17 @@
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define glibtop_malloc(p1) glibtop_malloc__r(glibtop_global_server, p1)
|
||||
#define glibtop_calloc(p1, p2) glibtop_calloc__r(glibtop_global_server, p1, p2)
|
||||
#define glibtop_realloc(p1, p2) glibtop_realloc__r(glibtop_global_server, p1, p2)
|
||||
#define glibtop_free(p1) glibtop_free__r(glibtop_global_server, p1)
|
||||
#define glibtop_malloc(p1) glibtop_malloc_r(glibtop_global_server, p1)
|
||||
#define glibtop_calloc(p1, p2) glibtop_calloc_r(glibtop_global_server, p1, p2)
|
||||
#define glibtop_realloc(p1, p2) glibtop_realloc_r(glibtop_global_server, p1, p2)
|
||||
#define glibtop_strdup(p2) glibtop_strdup_r(glibtop_global_server, p1)
|
||||
#define glibtop_free(p1) glibtop_free_r(glibtop_global_server, p1)
|
||||
|
||||
extern void *glibtop_malloc__r __P((glibtop *, size_t));
|
||||
extern void *glibtop_calloc__r __P((glibtop *, size_t, size_t));
|
||||
extern void *glibtop_realloc__r __P((glibtop *, void *, size_t));
|
||||
extern void glibtop_free__r __P((glibtop *, void *));
|
||||
extern void *glibtop_malloc_r __P((glibtop *, size_t));
|
||||
extern void *glibtop_calloc_r __P((glibtop *, size_t, size_t));
|
||||
extern void *glibtop_realloc_r __P((glibtop *, void *, size_t));
|
||||
extern char *glibtop_strdup_r __P((glibtop *, const char *));
|
||||
extern void glibtop_free_r __P((glibtop *, void *));
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
6
kernel/ChangeLog
Normal file
6
kernel/ChangeLog
Normal file
@@ -0,0 +1,6 @@
|
||||
1998-06-14 Martin Baulig <baulig@taurus.uni-trier.de>
|
||||
|
||||
* README: Added README.
|
||||
|
||||
* kernel.patch: Patch for the Linux kernel to add the
|
||||
new system call.
|
13
kernel/Makefile
Normal file
13
kernel/Makefile
Normal file
@@ -0,0 +1,13 @@
|
||||
#
|
||||
# Makefile for the linux system information tables.
|
||||
#
|
||||
# Note! Dependencies are done automagically by 'make dep', which also
|
||||
# removes any old dependencies. DON'T put your own dependencies here
|
||||
# unless it's something special (ie not a .c file).
|
||||
#
|
||||
# Note 2! The CFLAGS definition is now in the main makefile...
|
||||
|
||||
O_TARGET := table.o
|
||||
O_OBJS := main.o
|
||||
|
||||
include $(TOPDIR)/Rules.make
|
21
kernel/README
Normal file
21
kernel/README
Normal file
@@ -0,0 +1,21 @@
|
||||
This is a new system call `table ()' for the Linux table. It is faster
|
||||
than reading from /proc and can be used to fetch all information required
|
||||
for libgtop until whe have some other function (extended sysctl, ...) in
|
||||
standard kernels.
|
||||
|
||||
I didn't want to change sysctl or some other function myself cause this may
|
||||
cause other applications relying upon those function to fail. This is
|
||||
something for the ``real'' kernel gurus ...
|
||||
|
||||
To use this new system call for libgtop, do the following:
|
||||
|
||||
* Copy this directory to /usr/src/linux/table
|
||||
* Make /usr/src/linux/include/linux/table.h symlink to /usr/src/linux/table/table.h
|
||||
* Apply the patch `kernel.patch' to the kernel, compile, install and reboot
|
||||
* Recompile libgtop (remove `config.cache' and run the `autogen.sh' again).
|
||||
|
||||
If you want to change and/or add something - feel free to do so !
|
||||
|
||||
Have fun,
|
||||
|
||||
Martin
|
49
kernel/kernel.patch
Normal file
49
kernel/kernel.patch
Normal file
@@ -0,0 +1,49 @@
|
||||
diff -ur linux-2.0.32/Makefile linux-hacked/Makefile
|
||||
--- linux-2.0.32/Makefile Fri Nov 7 19:51:05 1997
|
||||
+++ linux-hacked/Makefile Thu Jun 11 20:41:12 1998
|
||||
@@ -87,7 +87,7 @@
|
||||
# standard CFLAGS
|
||||
#
|
||||
|
||||
-CFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -fno-strength-reduce
|
||||
+CFLAGS = -Wall -Wstrict-prototypes -g -O2 -fomit-frame-pointer -fno-strength-reduce
|
||||
|
||||
ifdef CONFIG_CPP
|
||||
CFLAGS := $(CFLAGS) -x c++
|
||||
@@ -113,12 +113,12 @@
|
||||
# Include the make variables (CC, etc...)
|
||||
#
|
||||
|
||||
-ARCHIVES =kernel/kernel.o mm/mm.o fs/fs.o ipc/ipc.o net/network.a
|
||||
+ARCHIVES =kernel/kernel.o mm/mm.o fs/fs.o ipc/ipc.o net/network.a table/table.o
|
||||
FILESYSTEMS =fs/filesystems.a
|
||||
DRIVERS =drivers/block/block.a \
|
||||
drivers/char/char.a
|
||||
LIBS =$(TOPDIR)/lib/lib.a
|
||||
-SUBDIRS =kernel drivers mm fs net ipc lib
|
||||
+SUBDIRS =kernel drivers mm fs net ipc lib table
|
||||
|
||||
ifeq ($(CONFIG_ISDN),y)
|
||||
DRIVERS := $(DRIVERS) drivers/isdn/isdn.a
|
||||
diff -ur linux-2.0.32/arch/i386/kernel/entry.S linux-hacked/arch/i386/kernel/entry.S
|
||||
--- linux-2.0.32/arch/i386/kernel/entry.S Tue Sep 16 23:42:45 1997
|
||||
+++ linux-hacked/arch/i386/kernel/entry.S Thu Jun 11 21:37:20 1998
|
||||
@@ -699,4 +699,6 @@
|
||||
.long SYMBOL_NAME(sys_mremap)
|
||||
.long 0,0
|
||||
.long SYMBOL_NAME(sys_vm86)
|
||||
- .space (NR_syscalls-166)*4
|
||||
+ .long 0
|
||||
+ .long SYMBOL_NAME(sys_table)
|
||||
+ .space (NR_syscalls-168)*4
|
||||
diff -ur linux-2.0.32/include/asm-i386/unistd.h linux-hacked/include/asm-i386/unistd.h
|
||||
--- linux-2.0.32/include/asm-i386/unistd.h Fri Mar 22 07:34:02 1996
|
||||
+++ linux-hacked/include/asm-i386/unistd.h Thu Jun 11 21:37:03 1998
|
||||
@@ -169,6 +169,7 @@
|
||||
#define __NR_sched_rr_get_interval 161
|
||||
#define __NR_nanosleep 162
|
||||
#define __NR_mremap 163
|
||||
+#define __NR_table 168
|
||||
|
||||
/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
|
||||
#define _syscall0(type,name) \
|
423
kernel/main.c
Normal file
423
kernel/main.c
Normal file
@@ -0,0 +1,423 @@
|
||||
/*
|
||||
* linux/table/table_impl.c
|
||||
* Copyright (C) 1998 Martin Baulig
|
||||
*/
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/kernel_stat.h>
|
||||
#include <linux/tty.h>
|
||||
#include <linux/user.h>
|
||||
#include <linux/a.out.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/mman.h>
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/ioport.h>
|
||||
#include <linux/config.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/pagemap.h>
|
||||
#include <linux/swap.h>
|
||||
|
||||
#include <asm/segment.h>
|
||||
#include <asm/pgtable.h>
|
||||
#include <asm/io.h>
|
||||
|
||||
#include <linux/table.h>
|
||||
|
||||
#include "version.h"
|
||||
|
||||
#if defined(__i386__)
|
||||
# define KSTK_EIP(tsk) (((unsigned long *)tsk->kernel_stack_page)[1019])
|
||||
# define KSTK_ESP(tsk) (((unsigned long *)tsk->kernel_stack_page)[1022])
|
||||
#elif defined(__alpha__)
|
||||
/*
|
||||
* See arch/alpha/kernel/ptrace.c for details.
|
||||
*/
|
||||
# define PT_REG(reg) (PAGE_SIZE - sizeof(struct pt_regs) \
|
||||
+ (long)&((struct pt_regs *)0)->reg)
|
||||
# define KSTK_EIP(tsk) (*(unsigned long *)(tsk->kernel_stack_page + PT_REG(pc)))
|
||||
# define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->tss.usp)
|
||||
#elif defined(__sparc__)
|
||||
# define PT_REG(reg) (PAGE_SIZE - sizeof(struct pt_regs) \
|
||||
+ (long)&((struct pt_regs *)0)->reg)
|
||||
# define KSTK_EIP(tsk) (*(unsigned long *)(tsk->kernel_stack_page + PT_REG(pc)))
|
||||
# define KSTK_ESP(tsk) (*(unsigned long *)(tsk->kernel_stack_page + PT_REG(u_regs[UREG_FP])))
|
||||
#endif
|
||||
|
||||
static struct task_struct *
|
||||
get_task (pid_t pid)
|
||||
{
|
||||
struct task_struct ** p;
|
||||
|
||||
p = task;
|
||||
while (++p < task+NR_TASKS) {
|
||||
if (*p && (*p)->pid == pid)
|
||||
return *p;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline void statm_pte_range(pmd_t * pmd, unsigned long address, unsigned long size,
|
||||
int * pages, int * shared, int * dirty, int * total)
|
||||
{
|
||||
pte_t * pte;
|
||||
unsigned long end;
|
||||
|
||||
if (pmd_none(*pmd))
|
||||
return;
|
||||
if (pmd_bad(*pmd)) {
|
||||
printk("statm_pte_range: bad pmd (%08lx)\n", pmd_val(*pmd));
|
||||
pmd_clear(pmd);
|
||||
return;
|
||||
}
|
||||
pte = pte_offset(pmd, address);
|
||||
address &= ~PMD_MASK;
|
||||
end = address + size;
|
||||
if (end > PMD_SIZE)
|
||||
end = PMD_SIZE;
|
||||
do {
|
||||
pte_t page = *pte;
|
||||
|
||||
address += PAGE_SIZE;
|
||||
pte++;
|
||||
if (pte_none(page))
|
||||
continue;
|
||||
++*total;
|
||||
if (!pte_present(page))
|
||||
continue;
|
||||
++*pages;
|
||||
if (pte_dirty(page))
|
||||
++*dirty;
|
||||
if (pte_page(page) >= high_memory)
|
||||
continue;
|
||||
if (mem_map[MAP_NR(pte_page(page))].count > 1)
|
||||
++*shared;
|
||||
} while (address < end);
|
||||
}
|
||||
|
||||
static inline void statm_pmd_range(pgd_t * pgd, unsigned long address, unsigned long size,
|
||||
int * pages, int * shared, int * dirty, int * total)
|
||||
{
|
||||
pmd_t * pmd;
|
||||
unsigned long end;
|
||||
|
||||
if (pgd_none(*pgd))
|
||||
return;
|
||||
if (pgd_bad(*pgd)) {
|
||||
printk("statm_pmd_range: bad pgd (%08lx)\n", pgd_val(*pgd));
|
||||
pgd_clear(pgd);
|
||||
return;
|
||||
}
|
||||
pmd = pmd_offset(pgd, address);
|
||||
address &= ~PGDIR_MASK;
|
||||
end = address + size;
|
||||
if (end > PGDIR_SIZE)
|
||||
end = PGDIR_SIZE;
|
||||
do {
|
||||
statm_pte_range(pmd, address, end - address, pages, shared, dirty, total);
|
||||
address = (address + PMD_SIZE) & PMD_MASK;
|
||||
pmd++;
|
||||
} while (address < end);
|
||||
}
|
||||
|
||||
static void statm_pgd_range(pgd_t * pgd, unsigned long address, unsigned long end,
|
||||
int * pages, int * shared, int * dirty, int * total)
|
||||
{
|
||||
while (address < end) {
|
||||
statm_pmd_range(pgd, address, end - address, pages, shared, dirty, total);
|
||||
address = (address + PGDIR_SIZE) & PGDIR_MASK;
|
||||
pgd++;
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
get_wchan (struct task_struct *p)
|
||||
{
|
||||
if (!p || p == current || p->state == TASK_RUNNING)
|
||||
return 0;
|
||||
#if defined(__i386__)
|
||||
{
|
||||
unsigned long ebp, eip;
|
||||
unsigned long stack_page;
|
||||
int count = 0;
|
||||
|
||||
stack_page = p->kernel_stack_page;
|
||||
if (!stack_page)
|
||||
return 0;
|
||||
ebp = p->tss.ebp;
|
||||
do {
|
||||
if (ebp < stack_page || ebp >= 4092+stack_page)
|
||||
return 0;
|
||||
eip = *(unsigned long *) (ebp+4);
|
||||
if (eip < (unsigned long) interruptible_sleep_on
|
||||
|| eip >= (unsigned long) add_timer)
|
||||
return eip;
|
||||
ebp = *(unsigned long *) ebp;
|
||||
} while (count++ < 16);
|
||||
}
|
||||
#elif defined(__alpha__)
|
||||
/*
|
||||
* This one depends on the frame size of schedule(). Do a
|
||||
* "disass schedule" in gdb to find the frame size. Also, the
|
||||
* code assumes that sleep_on() follows immediately after
|
||||
* interruptible_sleep_on() and that add_timer() follows
|
||||
* immediately after interruptible_sleep(). Ugly, isn't it?
|
||||
* Maybe adding a wchan field to task_struct would be better,
|
||||
* after all...
|
||||
*/
|
||||
{
|
||||
unsigned long schedule_frame;
|
||||
unsigned long pc;
|
||||
|
||||
pc = thread_saved_pc(&p->tss);
|
||||
if (pc >= (unsigned long) interruptible_sleep_on && pc < (unsigned long) add_timer) {
|
||||
schedule_frame = ((unsigned long *)p->tss.ksp)[6];
|
||||
return ((unsigned long *)schedule_frame)[12];
|
||||
}
|
||||
return pc;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
asmlinkage int
|
||||
sys_table (int type, union table *buf, const void *param)
|
||||
{
|
||||
union table tbl;
|
||||
struct sysinfo i;
|
||||
struct task_struct *tsk = NULL;
|
||||
pid_t pid;
|
||||
int err;
|
||||
|
||||
if (type == TABLE_VERSION)
|
||||
return _TABLE_VERSION;
|
||||
|
||||
if (!buf)
|
||||
return -EFAULT;
|
||||
|
||||
memset (&tbl, 0, sizeof (union table));
|
||||
|
||||
/* For TABLE_PROC_*, read pid and get task_struct */
|
||||
|
||||
switch (type) {
|
||||
case TABLE_PROC_UID:
|
||||
case TABLE_PROC_MEM:
|
||||
case TABLE_PROC_SEGMENT:
|
||||
case TABLE_PROC_TIME:
|
||||
case TABLE_PROC_STATE:
|
||||
case TABLE_PROC_SIGNAL:
|
||||
case TABLE_PROC_KERNEL:
|
||||
err = verify_area (VERIFY_READ, param, sizeof (pid_t));
|
||||
if (err)
|
||||
return err;
|
||||
memcpy_fromfs (&pid, param, sizeof (pid_t));
|
||||
|
||||
tsk = get_task (pid);
|
||||
if (tsk == NULL)
|
||||
return -ESRCH;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Main function dispatcher */
|
||||
|
||||
switch (type) {
|
||||
case TABLE_CPU:
|
||||
tbl.cpu.total = jiffies;
|
||||
tbl.cpu.user = kstat.cpu_user;
|
||||
tbl.cpu.nice = kstat.cpu_nice;
|
||||
tbl.cpu.sys = kstat.cpu_system;
|
||||
tbl.cpu.idle = tbl.cpu.total - (tbl.cpu.user + tbl.cpu.nice + tbl.cpu.sys);
|
||||
tbl.cpu.frequency = HZ;
|
||||
break;
|
||||
case TABLE_MEM:
|
||||
si_meminfo (&i);
|
||||
tbl.mem.total = i.totalram;
|
||||
tbl.mem.used = i.totalram - i.freeram;
|
||||
tbl.mem.free = i.freeram;
|
||||
tbl.mem.shared = i.sharedram;
|
||||
tbl.mem.buffer = i.bufferram;
|
||||
tbl.mem.cached = page_cache_size << PAGE_SHIFT;
|
||||
break;
|
||||
case TABLE_SWAP:
|
||||
si_swapinfo (&i);
|
||||
tbl.swap.total = i.totalswap;
|
||||
tbl.swap.used = i.totalswap - i.freeswap;
|
||||
tbl.swap.free = i.freeswap;
|
||||
break;
|
||||
case TABLE_LOADAVG:
|
||||
tbl.loadavg.loadavg [0] = (double) avenrun [0] / (1 << FSHIFT);
|
||||
tbl.loadavg.loadavg [1] = (double) avenrun [1] / (1 << FSHIFT);
|
||||
tbl.loadavg.loadavg [2] = (double) avenrun [2] / (1 << FSHIFT);
|
||||
tbl.loadavg.nr_running = nr_running;
|
||||
tbl.loadavg.nr_tasks = nr_tasks;
|
||||
tbl.loadavg.last_pid = last_pid;
|
||||
break;
|
||||
case TABLE_UPTIME:
|
||||
tbl.uptime.uptime = jiffies;
|
||||
tbl.uptime.idle = task[0]->utime + task[0]->stime;
|
||||
break;
|
||||
case TABLE_PROC_STATE:
|
||||
tbl.proc_state.state = tsk->state;
|
||||
tbl.proc_state.flags = tsk->flags;
|
||||
memcpy (tbl.proc_state.comm, tsk->comm, sizeof (tbl.proc_state.comm));
|
||||
break;
|
||||
case TABLE_PROC_UID:
|
||||
tbl.proc_uid.uid = tsk->uid;
|
||||
tbl.proc_uid.euid = tsk->euid;
|
||||
tbl.proc_uid.suid = tsk->suid;
|
||||
tbl.proc_uid.fsuid = tsk->fsuid;
|
||||
|
||||
tbl.proc_uid.gid = tsk->gid;
|
||||
tbl.proc_uid.egid = tsk->egid;
|
||||
tbl.proc_uid.sgid = tsk->sgid;
|
||||
tbl.proc_uid.fsgid = tsk->fsgid;
|
||||
|
||||
tbl.proc_uid.pid = tsk->pid;
|
||||
tbl.proc_uid.pgrp = tsk->pgrp;
|
||||
tbl.proc_uid.ppid = tsk->p_pptr->pid;
|
||||
|
||||
tbl.proc_uid.session = tsk->session;
|
||||
tbl.proc_uid.tty = tsk->tty ? kdev_t_to_nr (tsk->tty->device) : 0;
|
||||
tbl.proc_uid.tpgid = tsk->tty ? tsk->tty->pgrp : -1;
|
||||
|
||||
tbl.proc_uid.priority = tsk->priority;
|
||||
tbl.proc_uid.counter = tsk->counter;
|
||||
tbl.proc_uid.def_priority = DEF_PRIORITY;
|
||||
break;
|
||||
case TABLE_PROC_SIGNAL:
|
||||
tbl.proc_signal.signal = tsk->signal;
|
||||
tbl.proc_signal.blocked = tsk->blocked;
|
||||
|
||||
if (tsk->sig) {
|
||||
struct sigaction * action = tsk->sig->action;
|
||||
unsigned long sig_ign = 0, sig_caught = 0;
|
||||
unsigned long bit = 1;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 32; i++) {
|
||||
switch((unsigned long) action->sa_handler) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
sig_ign |= bit;
|
||||
break;
|
||||
default:
|
||||
sig_caught |= bit;
|
||||
}
|
||||
bit <<= 1;
|
||||
action++;
|
||||
}
|
||||
|
||||
tbl.proc_signal.ignored = sig_ign;
|
||||
tbl.proc_signal.caught = sig_caught;
|
||||
} else {
|
||||
tbl.proc_signal.ignored = 0;
|
||||
tbl.proc_signal.caught = 0;
|
||||
}
|
||||
break;
|
||||
case TABLE_PROC_MEM:
|
||||
if (tsk->mm && tsk->mm != &init_mm) {
|
||||
tbl.proc_mem.context = tsk->mm->context;
|
||||
tbl.proc_mem.start_code = tsk->mm->start_code;
|
||||
tbl.proc_mem.end_code = tsk->mm->end_code;
|
||||
tbl.proc_mem.start_data = tsk->mm-> start_data;
|
||||
tbl.proc_mem.end_data = tsk->mm->end_data;
|
||||
tbl.proc_mem.start_brk = tsk->mm->start_brk;
|
||||
tbl.proc_mem.brk = tsk->mm->brk;
|
||||
tbl.proc_mem.start_stack = tsk->mm->start_stack;
|
||||
tbl.proc_mem.start_mmap = tsk->mm->start_mmap;
|
||||
tbl.proc_mem.arg_start = tsk->mm->arg_start;
|
||||
tbl.proc_mem.arg_end = tsk->mm->arg_end;
|
||||
tbl.proc_mem.env_start = tsk->mm->env_start;
|
||||
tbl.proc_mem.env_end = tsk->mm->env_end;
|
||||
tbl.proc_mem.rss = tsk->mm->rss;
|
||||
tbl.proc_mem.total_vm = tsk->mm->total_vm;
|
||||
tbl.proc_mem.locked_vm = tsk->mm->locked_vm;
|
||||
}
|
||||
tbl.proc_mem.rlim = tsk->rlim ? tsk->rlim[RLIMIT_RSS].rlim_cur : 0;
|
||||
break;
|
||||
case TABLE_PROC_SEGMENT:
|
||||
if (tsk->mm && tsk->mm != &init_mm) {
|
||||
unsigned long vsize = 0;
|
||||
int size = 0, resident = 0, share = 0;
|
||||
int trs = 0, lrs = 0, drs = 0, dt = 0;
|
||||
struct vm_area_struct * vma = tsk->mm->mmap;
|
||||
|
||||
while (vma) {
|
||||
pgd_t *pgd = pgd_offset(tsk->mm, vma->vm_start);
|
||||
int pages = 0, shared = 0, dirty = 0, total = 0;
|
||||
|
||||
vsize += vma->vm_end - vma->vm_start;
|
||||
|
||||
statm_pgd_range (pgd, vma->vm_start, vma->vm_end,
|
||||
&pages, &shared, &dirty, &total);
|
||||
resident += pages;
|
||||
share += shared;
|
||||
dt += dirty;
|
||||
size += total;
|
||||
if (vma->vm_flags & VM_EXECUTABLE)
|
||||
trs += pages; /* text */
|
||||
else if (vma->vm_flags & VM_GROWSDOWN)
|
||||
drs += pages; /* stack */
|
||||
else if (vma->vm_end > 0x60000000)
|
||||
lrs += pages; /* library */
|
||||
else
|
||||
drs += pages;
|
||||
vma = vma->vm_next;
|
||||
}
|
||||
|
||||
tbl.proc_segment.vsize = vsize;
|
||||
tbl.proc_segment.size = size;
|
||||
tbl.proc_segment.resident = resident;
|
||||
tbl.proc_segment.shared = share;
|
||||
tbl.proc_segment.trs = trs;
|
||||
tbl.proc_segment.lrs = lrs;
|
||||
tbl.proc_segment.dt = dt;
|
||||
}
|
||||
break;
|
||||
case TABLE_PROC_TIME:
|
||||
tbl.proc_time.utime = tsk->utime;
|
||||
tbl.proc_time.stime = tsk->stime;
|
||||
tbl.proc_time.cutime = tsk->cutime;
|
||||
tbl.proc_time.cstime = tsk->cstime;
|
||||
|
||||
tbl.proc_time.start_time = tsk->start_time;
|
||||
tbl.proc_time.timeout = tsk->timeout;
|
||||
tbl.proc_time.policy = tsk->policy;
|
||||
tbl.proc_time.rt_priority = tsk->rt_priority;
|
||||
|
||||
tbl.proc_time.it_real_value = tsk->it_real_value;
|
||||
tbl.proc_time.it_prof_value = tsk->it_prof_value;
|
||||
tbl.proc_time.it_virt_value = tsk->it_virt_value;
|
||||
tbl.proc_time.it_real_incr = tsk->it_real_incr;
|
||||
tbl.proc_time.it_prof_incr = tsk->it_prof_incr;
|
||||
tbl.proc_time.it_virt_incr = tsk->it_virt_incr;
|
||||
break;
|
||||
case TABLE_PROC_KERNEL:
|
||||
tbl.proc_kernel.min_flt = tsk->min_flt;
|
||||
tbl.proc_kernel.cmin_flt = tsk->cmin_flt;
|
||||
tbl.proc_kernel.maj_flt = tsk->maj_flt;
|
||||
tbl.proc_kernel.cmaj_flt = tsk->cmaj_flt;
|
||||
|
||||
tbl.proc_kernel.kesp = tsk->kernel_stack_page ? KSTK_EIP(tsk) : 0;
|
||||
tbl.proc_kernel.keip = tsk->kernel_stack_page ? KSTK_ESP(tsk) : 0;
|
||||
|
||||
tbl.proc_kernel.nswap = tsk->nswap;
|
||||
tbl.proc_kernel.cnswap = tsk->cnswap;
|
||||
|
||||
tbl.proc_kernel.wchan = get_wchan (tsk);
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
err = verify_area (VERIFY_WRITE, buf, sizeof (struct table));
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
memcpy_tofs (buf, &tbl, sizeof (union table));
|
||||
return 0;
|
||||
}
|
154
kernel/table.h
Normal file
154
kernel/table.h
Normal file
@@ -0,0 +1,154 @@
|
||||
#ifndef _LINUX_TABLE_H
|
||||
#define _LINUX_TABLE_H
|
||||
|
||||
#ifdef _KERNEL
|
||||
#include <linux/types.h>
|
||||
#endif
|
||||
|
||||
#define TABLE_VERSION 0
|
||||
#define TABLE_CPU 1
|
||||
#define TABLE_MEM 2
|
||||
#define TABLE_SWAP 3
|
||||
#define TABLE_LOADAVG 4
|
||||
#define TABLE_UPTIME 5
|
||||
#define TABLE_PROC_UID 6
|
||||
#define TABLE_PROC_MEM 7
|
||||
#define TABLE_PROC_SEGMENT 8
|
||||
#define TABLE_PROC_TIME 9
|
||||
#define TABLE_PROC_STATE 10
|
||||
#define TABLE_PROC_SIGNAL 11
|
||||
#define TABLE_PROC_KERNEL 12
|
||||
|
||||
/* CPU Usage (in jiffies = 1/100th seconds) */
|
||||
|
||||
struct table_cpu
|
||||
{
|
||||
unsigned long total; /* Total CPU Time */
|
||||
unsigned long user; /* CPU Time in User Mode */
|
||||
unsigned long nice; /* CPU Time in User Mode (nice) */
|
||||
unsigned long sys; /* CPU Time in System Mode */
|
||||
unsigned long idle; /* CPU Time in the Idle Task */
|
||||
unsigned long frequency; /* Tick frequency */
|
||||
};
|
||||
|
||||
/* Memory Usage (in bytes) */
|
||||
|
||||
struct table_mem
|
||||
{
|
||||
unsigned long total; /* Total physical memory */
|
||||
unsigned long used; /* Used memory size */
|
||||
unsigned long free; /* Free memory size */
|
||||
unsigned long shared; /* Shared memory size */
|
||||
unsigned long buffer; /* Size of buffers */
|
||||
unsigned long cached; /* Size of cached memory */
|
||||
};
|
||||
|
||||
/* Swap Space (in bytes) */
|
||||
|
||||
struct table_swap
|
||||
{
|
||||
unsigned long total; /* Total swap space */
|
||||
unsigned long used; /* Used swap space */
|
||||
unsigned long free; /* Free swap space */
|
||||
};
|
||||
|
||||
/* Load average */
|
||||
|
||||
struct table_loadavg
|
||||
{
|
||||
double loadavg [3];
|
||||
unsigned nr_running;
|
||||
unsigned nr_tasks;
|
||||
unsigned last_pid;
|
||||
};
|
||||
|
||||
/* Uptime */
|
||||
|
||||
struct table_uptime
|
||||
{
|
||||
unsigned long uptime;
|
||||
unsigned long idle;
|
||||
};
|
||||
|
||||
/* Information about processes. */
|
||||
|
||||
struct table_proc_state
|
||||
{
|
||||
long state;
|
||||
unsigned long flags;
|
||||
char comm[16];
|
||||
};
|
||||
|
||||
struct table_proc_uid
|
||||
{
|
||||
int uid, euid, suid, fsuid;
|
||||
int gid, egid, sgid, fsgid;
|
||||
int pid, pgrp, ppid;
|
||||
int session;
|
||||
unsigned int tty;
|
||||
int tpgid;
|
||||
long priority;
|
||||
long counter;
|
||||
long def_priority;
|
||||
};
|
||||
|
||||
struct table_proc_mem
|
||||
{
|
||||
unsigned long context;
|
||||
unsigned long start_code, end_code, start_data, end_data;
|
||||
unsigned long start_brk, brk, start_stack, start_mmap;
|
||||
unsigned long arg_start, arg_end, env_start, env_end;
|
||||
unsigned long rss, rlim, total_vm, locked_vm;
|
||||
};
|
||||
|
||||
struct table_proc_segment
|
||||
{
|
||||
unsigned long vsize;
|
||||
int size, resident, shared;
|
||||
int trs, lrs, drs, dt;
|
||||
};
|
||||
|
||||
struct table_proc_time
|
||||
{
|
||||
long utime, stime, cutime, cstime, start_time;
|
||||
unsigned long timeout, policy, rt_priority;
|
||||
unsigned long it_real_value, it_prof_value, it_virt_value;
|
||||
unsigned long it_real_incr, it_prof_incr, it_virt_incr;
|
||||
};
|
||||
|
||||
struct table_proc_signal
|
||||
{
|
||||
unsigned long signal;
|
||||
unsigned long blocked; /* bitmap of masked signals */
|
||||
unsigned long ignored; /* mask of ignored signals */
|
||||
unsigned long caught; /* mask of caught signals */
|
||||
};
|
||||
|
||||
struct table_proc_kernel
|
||||
{
|
||||
unsigned long keip, kesp, wchan;
|
||||
unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt;
|
||||
unsigned long nswap, cnswap;
|
||||
};
|
||||
|
||||
/* Union */
|
||||
|
||||
union table
|
||||
{
|
||||
struct table_cpu cpu;
|
||||
struct table_mem mem;
|
||||
struct table_swap swap;
|
||||
struct table_loadavg loadavg;
|
||||
struct table_uptime uptime;
|
||||
struct table_proc_uid proc_uid;
|
||||
struct table_proc_mem proc_mem;
|
||||
struct table_proc_segment proc_segment;
|
||||
struct table_proc_time proc_time;
|
||||
struct table_proc_state proc_state;
|
||||
struct table_proc_signal proc_signal;
|
||||
struct table_proc_kernel proc_kernel;
|
||||
};
|
||||
|
||||
#endif /* _LINUX_IPC_H */
|
||||
|
||||
|
85
kernel/test.c
Normal file
85
kernel/test.c
Normal file
@@ -0,0 +1,85 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <linux/unistd.h>
|
||||
#include <linux/table.h>
|
||||
|
||||
#include <syscall.h>
|
||||
|
||||
static inline _syscall3 (int, table, int, type, union table *, tbl, const void *, param);
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
union table tbl;
|
||||
unsigned count;
|
||||
int ret;
|
||||
|
||||
ret = table (TABLE_VERSION, NULL, NULL);
|
||||
|
||||
if (ret == -1) {
|
||||
fprintf (stderr, "table(%u): %s\n", TABLE_VERSION, sys_errlist [errno]);
|
||||
exit (-errno);
|
||||
}
|
||||
|
||||
fprintf (stderr, "Table (%u) = %u\n", TABLE_VERSION, ret);
|
||||
|
||||
for (count = 0; count < 5; count++) {
|
||||
ret = table (TABLE_CPU, &tbl, NULL);
|
||||
|
||||
if (ret == -1) {
|
||||
fprintf (stderr, "table(%u): %s\n", TABLE_CPU, sys_errlist [errno]);
|
||||
exit (-errno);
|
||||
}
|
||||
|
||||
fprintf (stderr, "Table (%u) = %lu, %lu, %lu, %lu, %lu, %lu\n",
|
||||
TABLE_CPU, tbl.cpu.total, tbl.cpu.user, tbl.cpu.nice,
|
||||
tbl.cpu.sys, tbl.cpu.idle, tbl.cpu.frequency);
|
||||
}
|
||||
|
||||
ret = table (TABLE_MEM, &tbl, NULL);
|
||||
|
||||
if (ret == -1) {
|
||||
fprintf (stderr, "table(%u): %s\n", TABLE_MEM, sys_errlist [errno]);
|
||||
exit (-errno);
|
||||
}
|
||||
|
||||
fprintf (stderr, "Table (%u) = %lu, %lu, %lu, %lu, %lu, %lu\n",
|
||||
TABLE_MEM, tbl.mem.total, tbl.mem.used, tbl.mem.free,
|
||||
tbl.mem.shared, tbl.mem.buffer, tbl.mem.cached);
|
||||
|
||||
ret = table (TABLE_SWAP, &tbl, NULL);
|
||||
|
||||
if (ret == -1) {
|
||||
fprintf (stderr, "table(%u): %s\n", TABLE_SWAP, sys_errlist [errno]);
|
||||
exit (-errno);
|
||||
}
|
||||
|
||||
fprintf (stderr, "Table (%u) = %lu, %lu, %lu\n",
|
||||
TABLE_SWAP, tbl.swap.total, tbl.swap.used, tbl.swap.free);
|
||||
|
||||
ret = table (TABLE_LOADAVG, &tbl, NULL);
|
||||
|
||||
if (ret == -1) {
|
||||
fprintf (stderr, "table(%u): %s\n", TABLE_LOADAVG, sys_errlist [errno]);
|
||||
exit (-errno);
|
||||
}
|
||||
|
||||
fprintf (stderr, "Table (%u) = (%lu, %lu, %lu) - %u, %u, %u\n",
|
||||
TABLE_LOADAVG, tbl.loadavg.loadavg [0], tbl.loadavg.loadavg [1],
|
||||
tbl.loadavg.loadavg [2], tbl.loadavg.nr_running,
|
||||
tbl.loadavg.nr_tasks, tbl.loadavg.last_pid);
|
||||
|
||||
ret = table (TABLE_UPTIME, &tbl, NULL);
|
||||
|
||||
if (ret == -1) {
|
||||
fprintf (stderr, "table(%u): %s\n", TABLE_UPTIME, sys_errlist [errno]);
|
||||
exit (-errno);
|
||||
}
|
||||
|
||||
fprintf (stderr, "Table (%u) = %lu, %lu\n",
|
||||
TABLE_UPTIME, tbl.uptime.uptime, tbl.uptime.idle);
|
||||
|
||||
exit (0);
|
||||
}
|
1
kernel/version.h
Normal file
1
kernel/version.h
Normal file
@@ -0,0 +1 @@
|
||||
#define _TABLE_VERSION 1
|
@@ -32,3 +32,4 @@ sysinfo.lo
|
||||
uptime.lo
|
||||
write.lo
|
||||
xmalloc.lo
|
||||
lib.c
|
||||
|
@@ -8,10 +8,16 @@ CFLAGS = -Wall -W @CFLAGS@ -DGTOP_SERVER=\""@LIBGTOP_SERVER@"\"
|
||||
|
||||
lib_LTLIBRARIES = libgtop.la
|
||||
|
||||
libgtop_la_SOURCES = init.c open.c close.c read.c read_data.c \
|
||||
write.c command.c cpu.c mem.c swap.c uptime.c \
|
||||
loadavg.c shm_limits.c msg_limits.c \
|
||||
sem_limits.c proclist.c procstate.c procuid.c \
|
||||
proctime.c procmem.c procsignal.c prockernel.c \
|
||||
procsegment.c
|
||||
libgtop_la_SOURCES = init.c open.c close.c command.c read.c read_data.c \
|
||||
write.c lib.c parameter.c
|
||||
|
||||
BUILT_SOURCES = lib.c
|
||||
|
||||
lib.c: lib.awk $(top_builddir)/config.h $(top_srcdir)/features.def
|
||||
$(AWK) -f $(srcdir)/lib.awk < $(top_srcdir)/features.def > lib-t
|
||||
mv lib-t lib.c
|
||||
|
||||
EXTRA_DIST = lib.awk
|
||||
|
||||
CLEANFILES = lib.c
|
||||
|
||||
|
26
lib/close.c
26
lib/close.c
@@ -19,14 +19,30 @@
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/open.h>
|
||||
#include <glibtop/close.h>
|
||||
#include <glibtop/command.h>
|
||||
|
||||
/* Closes pipe to gtop server. */
|
||||
/* Closes server. */
|
||||
|
||||
void
|
||||
glibtop_close (glibtop *server)
|
||||
glibtop_close_r (glibtop *server)
|
||||
{
|
||||
kill (server->pid, SIGKILL);
|
||||
close (server->input [0]);
|
||||
close (server->output [1]);
|
||||
switch (server->method) {
|
||||
case GLIBTOP_METHOD_UNIX:
|
||||
case GLIBTOP_METHOD_INET:
|
||||
glibtop_call_l (server, GLIBTOP_CMND_QUIT,
|
||||
0, NULL, 0, NULL);
|
||||
|
||||
if (close (server->socket))
|
||||
glibtop_warn_io ("close");
|
||||
|
||||
break;
|
||||
case GLIBTOP_METHOD_PIPE:
|
||||
kill (server->pid, SIGKILL);
|
||||
close (server->input [0]);
|
||||
close (server->output [1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@@ -27,28 +27,51 @@
|
||||
#include <glibtop/xmalloc.h>
|
||||
|
||||
void *
|
||||
glibtop_call__r (glibtop *server, unsigned command, size_t send_size, void *send_buf,
|
||||
size_t recv_size, void *recv_buf)
|
||||
glibtop_call_l (glibtop *server, unsigned command, size_t send_size,
|
||||
void *send_buf, size_t recv_size, void *recv_buf)
|
||||
{
|
||||
glibtop_command *cmnd;
|
||||
void *ptr;
|
||||
glibtop_command cmnd;
|
||||
glibtop_response response;
|
||||
|
||||
glibtop_init__r (&server);
|
||||
glibtop_init_r (&server, 0, 0);
|
||||
|
||||
cmnd = glibtop_calloc__r (server, 1, sizeof (glibtop_command));
|
||||
memset (&cmnd, 0, sizeof (glibtop_command));
|
||||
|
||||
memcpy (&cmnd.server, server, sizeof (glibtop));
|
||||
|
||||
memcpy (&cmnd->server, server, sizeof (glibtop));
|
||||
cmnd.command = command;
|
||||
|
||||
/* If send_size is less than _GLIBTOP_PARAM_SIZE (normally 16 Bytes), we
|
||||
* send it together with command, so we only need one system call instead
|
||||
* of two. */
|
||||
|
||||
if (send_size <= _GLIBTOP_PARAM_SIZE) {
|
||||
memcpy (cmnd.parameter, send_buf, send_size);
|
||||
cmnd.size = send_size;
|
||||
} else {
|
||||
cmnd.data_size = send_size;
|
||||
}
|
||||
|
||||
cmnd->command = command;
|
||||
cmnd->size = send_size;
|
||||
|
||||
glibtop_write__r (server, sizeof (glibtop_command), cmnd);
|
||||
glibtop_write__r (server, send_size, send_buf);
|
||||
glibtop_read__r (server, recv_size, recv_buf);
|
||||
|
||||
ptr = glibtop_read_data__r (server);
|
||||
|
||||
glibtop_free__r (server, cmnd);
|
||||
|
||||
return ptr;
|
||||
glibtop_write_l (server, sizeof (glibtop_command), &cmnd);
|
||||
|
||||
glibtop_read_l (server, sizeof (glibtop_response), &response);
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "RESPONSE: %lu - %d\n",
|
||||
response.offset, response.data_size);
|
||||
#endif
|
||||
|
||||
if (recv_buf)
|
||||
memcpy (recv_buf, ((char *) &response) + response.offset,
|
||||
recv_size);
|
||||
|
||||
if (response.data_size) {
|
||||
void *ptr = glibtop_malloc_r (server, response.data_size);
|
||||
|
||||
glibtop_read_l (server, response.data_size, ptr);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
168
lib/init.c
168
lib/init.c
@@ -20,21 +20,169 @@
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/open.h>
|
||||
#include <glibtop/xmalloc.h>
|
||||
#include <glibtop/parameter.h>
|
||||
|
||||
static glibtop _glibtop_global_server;
|
||||
glibtop *glibtop_global_server = NULL;
|
||||
#ifndef DEFAULT_PORT
|
||||
#define DEFAULT_PORT 42800
|
||||
#endif
|
||||
|
||||
static glibtop _glibtop_global_server;
|
||||
glibtop *glibtop_global_server = &_glibtop_global_server;
|
||||
|
||||
|
||||
void
|
||||
_init_server (glibtop *server, const unsigned features)
|
||||
{
|
||||
char *command, *temp;
|
||||
|
||||
/* Try to get server command, but don't override if already
|
||||
* set via glibtop_set_parameter () */
|
||||
|
||||
if (server->server_command == NULL) {
|
||||
const char *temp = getenv ("LIBGTOP_SERVER") ?
|
||||
getenv ("LIBGTOP_SERVER") : GTOP_SERVER;
|
||||
|
||||
server->server_command = glibtop_strdup_r (server, temp);
|
||||
}
|
||||
|
||||
if (server->server_rsh == NULL) {
|
||||
const char *temp = getenv ("LIBGTOP_RSH") ?
|
||||
getenv ("LIBGTOP_RSH") : "/usr/bin/ssh";
|
||||
|
||||
server->server_rsh = glibtop_strdup_r (server, temp);
|
||||
}
|
||||
|
||||
/* Try to get server method, but don't override if already
|
||||
* set via glibtop_set_parameter () */
|
||||
|
||||
if (server->method) return;
|
||||
|
||||
/* If server->command doesn't start with a colon, then it is
|
||||
* the full pathname of the server executable. */
|
||||
|
||||
if (server->server_command [0] != ':') {
|
||||
if (features & glibtop_server_features) {
|
||||
/* We really need the server. */
|
||||
server->method = GLIBTOP_METHOD_PIPE;
|
||||
} else {
|
||||
/* Fine. No server is needed, so we call the
|
||||
* sysdeps functions directly. */
|
||||
server->method = GLIBTOP_METHOD_DIRECT;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* If the first character of 'server_command' is a colon,
|
||||
* the first field is the method to connect to the server. */
|
||||
|
||||
/* Everything up to the next colon is the method. */
|
||||
|
||||
command = glibtop_strdup_r (server, server->server_command+1);
|
||||
temp = strstr (command, ":");
|
||||
if (temp) *temp = 0;
|
||||
|
||||
/* Dispatch method. */
|
||||
|
||||
if (!strcmp (command, "direct")) {
|
||||
/* Use sysdeps dir instead of connecting to server
|
||||
* even if using the server would be required on
|
||||
* the current system. */
|
||||
server->method = GLIBTOP_METHOD_DIRECT;
|
||||
|
||||
} else if (!strcmp (command, "inet")) {
|
||||
|
||||
server->method = GLIBTOP_METHOD_INET;
|
||||
|
||||
/* Connect to internet server. */
|
||||
|
||||
if (temp == NULL) {
|
||||
/* If no value was set, we use 'localhost'. */
|
||||
if (server->server_host == NULL)
|
||||
server->server_host = glibtop_strdup_r
|
||||
(server, "localhost");
|
||||
} else {
|
||||
char *temp2 = strstr (temp+1, ":");
|
||||
if (temp2) *temp2 = 0;
|
||||
|
||||
/* Override default. */
|
||||
if (server->server_host)
|
||||
glibtop_free_r (server, (char *) server->server_host);
|
||||
|
||||
server->server_host = glibtop_strdup_r
|
||||
(server, temp+1);
|
||||
|
||||
temp = temp2;
|
||||
}
|
||||
|
||||
if (temp == NULL) {
|
||||
/* If no value was set, we use DEFAULT_PORT. */
|
||||
if (server->server_port == 0)
|
||||
server->server_port = DEFAULT_PORT;
|
||||
} else {
|
||||
char *temp2 = strstr (temp+1, ":");
|
||||
if (temp2) *temp2 = 0;
|
||||
|
||||
if (sscanf (temp+1, "%ld", &server->server_port) != 1)
|
||||
server->server_port = DEFAULT_PORT;
|
||||
|
||||
temp = temp2 ? temp2 + 1 : temp2;
|
||||
}
|
||||
|
||||
} else if (!strcmp (command, "unix")) {
|
||||
|
||||
/* Connect to unix domain socket. */
|
||||
server->method = GLIBTOP_METHOD_UNIX;
|
||||
|
||||
} else {
|
||||
|
||||
glibtop_error_r (server, "Unknown server method '%s'",
|
||||
server->server_command+1);
|
||||
|
||||
}
|
||||
|
||||
glibtop_free_r (server, command);
|
||||
}
|
||||
|
||||
glibtop *
|
||||
glibtop_init__r (glibtop **server)
|
||||
glibtop_init_r (glibtop **server_ptr, const unsigned long features,
|
||||
const unsigned flags)
|
||||
{
|
||||
if (*server != NULL)
|
||||
return *server;
|
||||
glibtop *server;
|
||||
|
||||
if (glibtop_global_server == NULL) {
|
||||
glibtop_global_server = &_glibtop_global_server;
|
||||
glibtop_open (glibtop_global_server, "glibtop");
|
||||
if (server_ptr == NULL)
|
||||
return NULL;
|
||||
|
||||
if (*server_ptr == NULL)
|
||||
*server_ptr = glibtop_global_server;
|
||||
|
||||
server = *server_ptr;
|
||||
|
||||
/* Should we do the initialization? */
|
||||
|
||||
if (flags & GLIBTOP_INIT_NO_INIT)
|
||||
return server;
|
||||
|
||||
/* Do the initialization, but only if not already initialized. */
|
||||
|
||||
if ((server->flags & _GLIBTOP_INIT_STATE_INIT) == 0) {
|
||||
_init_server (server, features);
|
||||
|
||||
server->flags |= _GLIBTOP_INIT_STATE_INIT;
|
||||
}
|
||||
|
||||
/* Should we open the server? */
|
||||
|
||||
if (flags & GLIBTOP_INIT_NO_OPEN)
|
||||
return server;
|
||||
|
||||
/* Open server, but only if not already opened. */
|
||||
|
||||
return *server = glibtop_global_server;
|
||||
if ((server->flags & _GLIBTOP_INIT_STATE_OPEN) == 0)
|
||||
glibtop_open_l (glibtop_global_server, "glibtop",
|
||||
features, flags);
|
||||
|
||||
return server;
|
||||
}
|
||||
|
55
lib/lib.awk
Normal file
55
lib/lib.awk
Normal file
@@ -0,0 +1,55 @@
|
||||
BEGIN {
|
||||
print "/* lib.c */";
|
||||
print "/* This is a generated file. Please modify `lib.awk' */";
|
||||
print "";
|
||||
|
||||
print "#include <glibtop.h>";
|
||||
print "#include <glibtop/open.h>";
|
||||
print "#include <glibtop/sysdeps.h>";
|
||||
print "#include <glibtop/command.h>";
|
||||
|
||||
print "";
|
||||
|
||||
}
|
||||
|
||||
function output(feature) {
|
||||
if (feature ~ /^proclist$/) {
|
||||
print "unsigned *";
|
||||
prefix = "return ";
|
||||
} else {
|
||||
prefix = "";
|
||||
print "void";
|
||||
}
|
||||
if (feature ~ /^proc_/) {
|
||||
param = ", pid_t pid";
|
||||
} else {
|
||||
param = "";
|
||||
}
|
||||
|
||||
print "glibtop_get_"feature"_l (glibtop *server, glibtop_"feature" *buf"param")";
|
||||
print "{";
|
||||
print "\tglibtop_init_r (&server, GLIBTOP_SYSDEPS_"toupper(feature)", 0);";
|
||||
print "";
|
||||
print "\tif ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&";
|
||||
print "\t (server->features & GLIBTOP_SYSDEPS_"toupper(feature)"))";
|
||||
print "\t{";
|
||||
|
||||
if (feature ~ /^proc_/) {
|
||||
print "\t\t"prefix"glibtop_call_l (server, GLIBTOP_CMND_"toupper(feature)", sizeof (pid_t),";
|
||||
print "\t\t\t\t&pid, sizeof (glibtop_"feature"), buf);";
|
||||
print "\t} else {";
|
||||
print "\t\t"prefix"glibtop_get_"feature"_r (server, buf, pid);";
|
||||
} else {
|
||||
print "\t\t"prefix"glibtop_call_l (server, GLIBTOP_CMND_"toupper(feature)", 0, NULL,";
|
||||
print "\t\t\t sizeof (glibtop_"feature"), buf);";
|
||||
print "\t} else {";
|
||||
print "\t\t"prefix"glibtop_get_"feature"_r (server, buf);";
|
||||
}
|
||||
print "\t}";
|
||||
print "}";
|
||||
print "";
|
||||
}
|
||||
|
||||
/^(\w+)/ { output($1) }
|
||||
|
||||
|
79
lib/open.c
79
lib/open.c
@@ -19,42 +19,75 @@
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/open.h>
|
||||
#include <glibtop/sysdeps.h>
|
||||
#include <glibtop/command.h>
|
||||
#include <glibtop/xmalloc.h>
|
||||
|
||||
#include <glibtop/gnuserv.h>
|
||||
|
||||
/* Opens pipe to gtop server. Returns 0 on success and -1 on error. */
|
||||
|
||||
void
|
||||
glibtop_open (glibtop *server, const char *program_name)
|
||||
glibtop_open_l (glibtop *server, const char *program_name,
|
||||
const unsigned long features, const unsigned flags)
|
||||
{
|
||||
char version [BUFSIZ], buffer [BUFSIZ];
|
||||
|
||||
memset (server, 0, sizeof (glibtop));
|
||||
int connect_type;
|
||||
|
||||
server->name = program_name;
|
||||
|
||||
if (pipe (server->input) || pipe (server->output))
|
||||
glibtop_error__r (server, _("cannot make a pipe: %s\n"), strerror (errno));
|
||||
/* It is important to set _GLIBTOP_INIT_STATE_OPEN here when we
|
||||
* do recursive calls to glibtop_init_r (). */
|
||||
|
||||
server->pid = fork ();
|
||||
server->flags |= _GLIBTOP_INIT_STATE_OPEN;
|
||||
|
||||
if (server->pid < 0) {
|
||||
glibtop_error__r (server, _("%s: fork failed: %s\n"), strerror (errno));
|
||||
} else if (server->pid == 0) {
|
||||
close (0); close (1); /* close (2); */
|
||||
close (server->input [0]); close (server->output [1]);
|
||||
dup2 (server->input [1], 1); /* dup2 (server->input [1], 2); */
|
||||
dup2 (server->output [0], 0);
|
||||
execl (GTOP_SERVER, NULL);
|
||||
_exit (2);
|
||||
switch (server->method) {
|
||||
case GLIBTOP_METHOD_DIRECT:
|
||||
fprintf (stderr, "Calling sysdeps open function.\n");
|
||||
|
||||
glibtop_open_r (server, program_name, features, flags);
|
||||
|
||||
break;
|
||||
case GLIBTOP_METHOD_INET:
|
||||
fprintf (stderr, "Connecting to '%s' port %ld.\n",
|
||||
server->server_host, server->server_port);
|
||||
|
||||
connect_type = glibtop_make_connection
|
||||
(server->server_host, server->server_port,
|
||||
&server->socket);
|
||||
|
||||
fprintf (stderr, "Connect Type is %d.\n", connect_type);
|
||||
|
||||
server->flags |= _GLIBTOP_INIT_STATE_SERVER;
|
||||
|
||||
server->features = -1;
|
||||
break;
|
||||
case GLIBTOP_METHOD_UNIX:
|
||||
fprintf (stderr, "Connecting to Unix Domain Socket.\n");
|
||||
|
||||
connect_type = glibtop_make_connection
|
||||
("unix", 0, &server->socket);
|
||||
|
||||
fprintf (stderr, "Connect Type is %d.\n", connect_type);
|
||||
|
||||
server->flags |= _GLIBTOP_INIT_STATE_SERVER;
|
||||
|
||||
server->features = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
close (server->input [1]);
|
||||
close (server->output [0]);
|
||||
/* If the server has been started, ask it for its features. */
|
||||
|
||||
sprintf (version, "%s server %s ready.\n", PACKAGE, VERSION);
|
||||
if (server->flags & _GLIBTOP_INIT_STATE_SERVER) {
|
||||
glibtop_sysdeps sysdeps;
|
||||
|
||||
glibtop_call_l (server, GLIBTOP_CMND_SYSDEPS, 0, NULL,
|
||||
sizeof (glibtop_sysdeps), &sysdeps);
|
||||
|
||||
server->features = sysdeps.features;
|
||||
|
||||
glibtop_read__r (server, strlen (version), buffer);
|
||||
|
||||
if (memcmp (version, buffer, strlen (version)))
|
||||
glibtop_error__r (server, _("server version is not %s"), VERSION);
|
||||
fprintf (stderr, "Server features are %lu.\n",
|
||||
server->features);
|
||||
}
|
||||
}
|
||||
|
80
lib/parameter.c
Normal file
80
lib/parameter.c
Normal file
@@ -0,0 +1,80 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the Gnome Top Library.
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
The Gnome Top Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The Gnome Top Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/parameter.h>
|
||||
|
||||
#define _write_data(ptr,size) \
|
||||
if ((data_ptr == NULL) || (data_size < size)) return -size; \
|
||||
if (ptr == NULL) { strcpy (data_ptr, ""); return 1; } \
|
||||
memcpy (data_ptr, ptr, size); \
|
||||
return size;
|
||||
|
||||
#define _check_data(size) \
|
||||
if ((data_ptr == NULL) || (data_size != size)) { \
|
||||
glibtop_error_r (server, "glibtop_set_parameter (%d): " \
|
||||
"Expected %lu bytes but got %lu.", \
|
||||
parameter, size, data_size); \
|
||||
return; \
|
||||
}
|
||||
|
||||
#define _strlen(ptr) (ptr ? strlen (ptr) : 0)
|
||||
|
||||
size_t
|
||||
glibtop_get_parameter_l (glibtop *server, const unsigned parameter,
|
||||
void *data_ptr, size_t data_size)
|
||||
{
|
||||
switch (parameter) {
|
||||
case GLIBTOP_PARAM_METHOD:
|
||||
_write_data (&server->method,
|
||||
sizeof (server->method));
|
||||
case GLIBTOP_PARAM_FEATURES:
|
||||
_write_data (&server->features,
|
||||
sizeof (server->features));
|
||||
case GLIBTOP_PARAM_COMMAND:
|
||||
_write_data (server->server_command,
|
||||
_strlen(server->server_command));
|
||||
case GLIBTOP_PARAM_HOST:
|
||||
_write_data (server->server_host,
|
||||
_strlen(server->server_host));
|
||||
case GLIBTOP_PARAM_PORT:
|
||||
_write_data (&server->server_port,
|
||||
sizeof (server->server_port));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
glibtop_set_parameter_l (glibtop *server, const unsigned parameter,
|
||||
const void *data_ptr, size_t data_size)
|
||||
{
|
||||
switch (parameter) {
|
||||
case GLIBTOP_PARAM_METHOD:
|
||||
_check_data (sizeof (server->method));
|
||||
memcpy (&server->method, data_ptr, data_size);
|
||||
break;
|
||||
case GLIBTOP_PARAM_FEATURES:
|
||||
_check_data (sizeof (server->features));
|
||||
memcpy (&server->features, data_ptr, data_size);
|
||||
break;
|
||||
}
|
||||
}
|
@@ -1,35 +0,0 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the Gnome Top Library.
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
The Gnome Top Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The Gnome Top Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/prockernel.h>
|
||||
#include <glibtop/command.h>
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
void
|
||||
glibtop_get_proc_kernel__r (glibtop *server, glibtop_proc_kernel *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
glibtop_init__r (&server);
|
||||
glibtop_call__r (server, GLIBTOP_CMND_PROC_KERNEL, sizeof (pid_t),
|
||||
&pid, sizeof (glibtop_proc_kernel), buf);
|
||||
}
|
@@ -1,32 +0,0 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the Gnome Top Library.
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
The Gnome Top Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The Gnome Top Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <glibtop/proclist.h>
|
||||
#include <glibtop/command.h>
|
||||
|
||||
/* Fetch list of currently running processes. */
|
||||
|
||||
unsigned *
|
||||
glibtop_get_proclist__r (glibtop *server, glibtop_proclist *buf)
|
||||
{
|
||||
glibtop_init__r (&server);
|
||||
return glibtop_call__r (server, GLIBTOP_CMND_PROCLIST, 0, NULL, sizeof (glibtop_proclist), buf);
|
||||
}
|
@@ -1,35 +0,0 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the Gnome Top Library.
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
The Gnome Top Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The Gnome Top Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/procsegment.h>
|
||||
#include <glibtop/command.h>
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
void
|
||||
glibtop_get_proc_segment__r (glibtop *server, glibtop_proc_segment *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
glibtop_init__r (&server);
|
||||
glibtop_call__r (server, GLIBTOP_CMND_PROC_SEGMENT, sizeof (pid_t),
|
||||
&pid, sizeof (glibtop_proc_segment), buf);
|
||||
}
|
55
lib/read.c
55
lib/read.c
@@ -23,19 +23,48 @@
|
||||
|
||||
/* Reads some data from server. */
|
||||
|
||||
void
|
||||
glibtop_read__r (glibtop *server, size_t size, void *buf)
|
||||
static void
|
||||
do_read (int s, void *ptr, size_t total_size)
|
||||
{
|
||||
size_t ssize;
|
||||
int nread;
|
||||
size_t already_read = 0, remaining = total_size;
|
||||
|
||||
while (already_read < total_size) {
|
||||
nread = recv (s, ptr, remaining, 0);
|
||||
|
||||
glibtop_init__r (&server);
|
||||
|
||||
if (read (server->input [0], &ssize, sizeof (size_t)) < 0)
|
||||
glibtop_error__r (server, _("read size: %s"), strerror (errno));
|
||||
|
||||
if (size != ssize)
|
||||
glibtop_error__r (server, _("got %d bytes but requested %d"), ssize, size);
|
||||
|
||||
if (read (server->input [0], buf, size) < 0)
|
||||
glibtop_error__r (server, _("read %d bytes: %s"), size, strerror (errno));
|
||||
if (nread == 0) {
|
||||
close (s);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (nread <= 0) {
|
||||
glibtop_error_io ("recv");
|
||||
return;
|
||||
}
|
||||
|
||||
already_read += nread;
|
||||
remaining -= nread;
|
||||
(char *) ptr += nread;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
glibtop_read_l (glibtop *server, size_t size, void *buf)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
glibtop_init_r (&server, 0, 0);
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "LIBRARY: really reading %d bytes.\n", size);
|
||||
#endif
|
||||
|
||||
if (server->socket) {
|
||||
do_read (server->socket, buf, size);
|
||||
} else {
|
||||
ret = read (server->input [0], buf, size);
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
glibtop_error_io_r (server, _("read %d bytes"), size);
|
||||
}
|
||||
|
@@ -25,24 +25,43 @@
|
||||
/* Reads some data from server. */
|
||||
|
||||
void *
|
||||
glibtop_read_data__r (glibtop *server)
|
||||
glibtop_read_data_l (glibtop *server)
|
||||
{
|
||||
size_t size;
|
||||
void *ptr;
|
||||
int ret;
|
||||
|
||||
glibtop_init__r (&server);
|
||||
glibtop_init_r (&server, 0, 0);
|
||||
|
||||
if (read (server->input [0], &size, sizeof (size_t)) < 0)
|
||||
glibtop_error__r (server, _("read data size: %s"), strerror (errno));
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "LIBRARY: reading %d data bytes.\n", sizeof (size_t));
|
||||
#endif
|
||||
|
||||
if (server->socket) {
|
||||
ret = recv (server->socket, &size, sizeof (size_t), 0);
|
||||
} else {
|
||||
ret = read (server->input [0], &size, sizeof (size_t));
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
glibtop_error_io_r (server, _("read data size"));
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "LIBRARY: really reading %d data bytes (ret = %d).\n", size, ret);
|
||||
#endif
|
||||
|
||||
if (!size) return NULL;
|
||||
|
||||
fprintf (stderr, "Server has %d bytes of data.\n", size);
|
||||
ptr = glibtop_malloc_r (server, size);
|
||||
|
||||
ptr = glibtop_malloc__r (server, size);
|
||||
|
||||
if (read (server->input [0], ptr, size) < 0)
|
||||
glibtop_error__r (server, _("read data %d bytes: %s"), size, strerror (errno));
|
||||
if (server->socket) {
|
||||
ret = recv (server->socket, ptr, size, 0);
|
||||
} else {
|
||||
ret = read (server->input [0], ptr, size);
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
glibtop_error_io_r (server, _("read data %d bytes"));
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
25
lib/write.c
25
lib/write.c
@@ -24,15 +24,24 @@
|
||||
/* Writes some data to server. */
|
||||
|
||||
void
|
||||
glibtop_write__r (glibtop *server, size_t size, void *buf)
|
||||
glibtop_write_l (glibtop *server, size_t size, void *buf)
|
||||
{
|
||||
glibtop_init__r (&server);
|
||||
int ret;
|
||||
|
||||
if (write (server->output [1], &size, sizeof (size_t)) < 0)
|
||||
glibtop_error__r (server, _("write size: %s"), strerror (errno));
|
||||
glibtop_init_r (&server, 0, 0);
|
||||
|
||||
if (!size) return;
|
||||
|
||||
if (write (server->output [1], buf, size) < 0)
|
||||
glibtop_error__r (server, _("write %d bytes: %s"), size, strerror (errno));
|
||||
if (size == 0) return;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "LIBRARY: really writing %d bytes.\n", size);
|
||||
#endif
|
||||
|
||||
if (server->socket) {
|
||||
ret = send (server->socket, buf, size, 0);
|
||||
} else {
|
||||
ret = write (server->output [1], buf, size);
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
glibtop_error_io_r (server, _("write %d bytes"), size);
|
||||
}
|
||||
|
70
libgtop.spec
70
libgtop.spec
@@ -3,39 +3,32 @@
|
||||
%define rel SNAP
|
||||
%define prefix /usr
|
||||
|
||||
Summary: GNOME Top Library
|
||||
Summary: libgtop library
|
||||
Name: libgtop
|
||||
Version: %ver
|
||||
Release: %rel
|
||||
Copyright: LGPL
|
||||
Group: X11/gnome
|
||||
Group: X11/Libraries
|
||||
Source: ftp://ftp.gnome.org/pub/libgtop-%{ver}.tar.gz
|
||||
BuildRoot: /tmp/libgtop-root
|
||||
Obsoletes: gnome
|
||||
Packager: Marc Ewing <marc@redhat.com>
|
||||
URL: http://www.gnome.org/
|
||||
Packager: Michael Fulbright <msf@redhat.com>
|
||||
URL: http://www.gnome.org
|
||||
Prereq: /sbin/install-info
|
||||
Docdir: %{prefix}/doc
|
||||
|
||||
%description
|
||||
Library that fetches information about the running system such as cpu
|
||||
and memory usage, active processes etc. On Linux systems, these information
|
||||
are taken directly from the /proc filesystem. For other systems such as
|
||||
Solaris, where such programs need to be suid root (or only setgid kmem/mem
|
||||
on some systems), it provides a suid/setgid server that fetches those
|
||||
information and a client-side library that talks to this server.
|
||||
|
||||
Main idea was to have the same interface for all operating systems,
|
||||
thus all system dependent details are hidden in the implementation
|
||||
of that server.
|
||||
A library that fetches
|
||||
information about the running system such as cpu and memory usage,
|
||||
active processes etc. On Linux systems, these information are taken
|
||||
directly from the /proc filesystem.
|
||||
|
||||
%package devel
|
||||
Summary: Libraries, includes, etc to use libgtop in GNOME applications
|
||||
Group: X11/gnome
|
||||
Requires: libgtop
|
||||
Obsoletes: gnome
|
||||
|
||||
%description devel
|
||||
Libraries, include files, etc you need to use libgtop in GNOME applications.
|
||||
%changelog
|
||||
|
||||
* Tue Jun 2 1998 Michael Fulbright <msf@redhat.com>
|
||||
|
||||
- first version of the RPM
|
||||
|
||||
%prep
|
||||
%setup
|
||||
@@ -43,9 +36,9 @@ Libraries, include files, etc you need to use libgtop in GNOME applications.
|
||||
%build
|
||||
# Needed for snapshot releases.
|
||||
if [ ! -f configure ]; then
|
||||
CFLAGS="$RPM_OPT_FLAGS" ./autogen.sh --prefix=%prefix
|
||||
CFLAGS="$RPM_OPT_FLAGS" ./autogen.sh --prefix=%prefix --disable-libgtop-examples
|
||||
else
|
||||
CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%prefix
|
||||
CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%prefix --disable-libgtop-examples
|
||||
fi
|
||||
|
||||
if [ "$SMP" != "" ]; then
|
||||
@@ -60,30 +53,29 @@ rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
make prefix=$RPM_BUILD_ROOT%{prefix} install
|
||||
|
||||
#
|
||||
# msf - remove these as they are really supposed to come from gnome-libs
|
||||
#
|
||||
rm -f $RPM_BUILD_ROOT/%{prefix}/lib/libgnomesupport.a
|
||||
rm -f $RPM_BUILD_ROOT/%{prefix}/lib/libgnomesupport.la
|
||||
rm -f $RPM_BUILD_ROOT/%{prefix}/lib/libgnomesupport.so.0
|
||||
rm -f $RPM_BUILD_ROOT/%{prefix}/lib/libgnomesupport.so.0.0.0
|
||||
|
||||
rm -fr $RPM_BUILD_ROOT/%{prefix}/include/libgtop
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
#rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%post
|
||||
if ! grep %{prefix}/lib /etc/ld.so.conf > /dev/null ; then
|
||||
echo "%{prefix}/lib" >> /etc/ld.so.conf
|
||||
fi
|
||||
|
||||
/sbin/ldconfig
|
||||
%post -p /sbin/ldconfig
|
||||
|
||||
%postun -p /sbin/ldconfig
|
||||
|
||||
%files
|
||||
%defattr(-, root, root)
|
||||
|
||||
%doc AUTHORS COPYING ChangeLog NEWS README
|
||||
%{prefix}/lib/lib*.so.*
|
||||
%doc ANNOUNCE AUTHORS ChangeLog NEWS README README.LATEST copyright.txt doc
|
||||
%{prefix}/bin/*
|
||||
|
||||
%files devel
|
||||
%defattr(-, root, root)
|
||||
|
||||
%{prefix}/lib/lib*.so
|
||||
%{prefix}/lib/lib*.so.*
|
||||
%{prefix}/lib/libgtopConf.sh
|
||||
%{prefix}/lib/*a
|
||||
%{prefix}/lib/*.sh
|
||||
%{prefix}/lib/libgtop
|
||||
%{prefix}/include/*
|
||||
|
1
perl/.cvsignore
Normal file
1
perl/.cvsignore
Normal file
@@ -0,0 +1 @@
|
||||
Libgtop.xs Makefile blib pm_to_blib Libgtop.c Libgtop.bs Makefile.PL
|
5
perl/Changes
Normal file
5
perl/Changes
Normal file
@@ -0,0 +1,5 @@
|
||||
Revision history for Perl extension Libgtop.
|
||||
|
||||
0.01 Sun Jun 21 21:00:59 1998
|
||||
- original version; created by h2xs 1.18
|
||||
|
26
perl/Libgtop.pm
Normal file
26
perl/Libgtop.pm
Normal file
@@ -0,0 +1,26 @@
|
||||
package Libgtop;
|
||||
|
||||
use strict;
|
||||
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
|
||||
|
||||
require Exporter;
|
||||
require DynaLoader;
|
||||
require AutoLoader;
|
||||
|
||||
@ISA = qw(Exporter DynaLoader);
|
||||
# Items to export into callers namespace by default. Note: do not export
|
||||
# names by default without a very good reason. Use EXPORT_OK instead.
|
||||
# Do not simply export all your public functions/methods/constants.
|
||||
@EXPORT = qw(
|
||||
|
||||
);
|
||||
$VERSION = '0.01';
|
||||
|
||||
bootstrap Libgtop $VERSION;
|
||||
|
||||
# Preloaded methods go here.
|
||||
|
||||
# Autoload methods go after __END__, and are processed by the autosplit program.
|
||||
|
||||
1;
|
||||
__END__
|
8
perl/MANIFEST
Normal file
8
perl/MANIFEST
Normal file
@@ -0,0 +1,8 @@
|
||||
.cvsignore
|
||||
Changes
|
||||
Libgtop.pm
|
||||
MANIFEST
|
||||
Makefile.PL.in
|
||||
new.pl
|
||||
perl.awk
|
||||
test.pl
|
10
perl/Makefile.PL.in
Normal file
10
perl/Makefile.PL.in
Normal file
@@ -0,0 +1,10 @@
|
||||
# -*-cperl-*-
|
||||
use ExtUtils::MakeMaker;
|
||||
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
|
||||
# the contents of the Makefile that is written.
|
||||
WriteMakefile('NAME' => 'Libgtop',
|
||||
'VERSION_FROM' => 'Libgtop.pm',
|
||||
'LIBS' => ['@LIBGTOP_GUILE_LIBS@'],
|
||||
'DEFINE' => '',
|
||||
'INC' => '@LIBGTOP_GUILE_INCS@',
|
||||
);
|
13
perl/new.pl
Executable file
13
perl/new.pl
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
require 5.004;
|
||||
|
||||
use blib;
|
||||
use strict;
|
||||
use Libgtop;
|
||||
|
||||
print "CPU Usage: ".join (':', Libgtop::cpu)."\n";
|
||||
print "Memory Usage: ".join (':', Libgtop::mem)."\n";
|
||||
print "Swap Usage: ".join (':', Libgtop::swap)."\n";
|
||||
|
||||
|
86
perl/perl.awk
Normal file
86
perl/perl.awk
Normal file
@@ -0,0 +1,86 @@
|
||||
BEGIN {
|
||||
print "/* Libgtop.xs */";
|
||||
print "/* This is a generated file. Please modify `perl.awk' */";
|
||||
print "";
|
||||
|
||||
print "#ifdef __cplusplus";
|
||||
print "extern \"C\" {";
|
||||
print "#endif";
|
||||
print "#include \"EXTERN.h\"";
|
||||
print "#include \"perl.h\"";
|
||||
print "#include \"XSUB.h\"";
|
||||
print "#ifdef __cplusplus";
|
||||
print "}";
|
||||
print "#endif";
|
||||
print "";
|
||||
print "#undef PACKAGE";
|
||||
print "";
|
||||
print "#include <glibtop.h>";
|
||||
print "#include <glibtop/union.h>";
|
||||
print "";
|
||||
print "MODULE = Libgtop\t\tPACKAGE = Libgtop";
|
||||
print "";
|
||||
|
||||
convert["long"] = "newSViv";
|
||||
convert["ulong"] = "newSViv";
|
||||
convert["double"] = "newSVnv";
|
||||
}
|
||||
|
||||
/^(\w+)/ {
|
||||
feature = $1;
|
||||
|
||||
print "void";
|
||||
if (feature ~ /^proc_/) {
|
||||
print feature"(pid)";
|
||||
print "\tunsigned\tpid;";
|
||||
} else {
|
||||
print feature"()";
|
||||
}
|
||||
|
||||
print "PREINIT:";
|
||||
print "\tglibtop_"feature" "feature";";
|
||||
|
||||
if (feature ~ /^proclist/) {
|
||||
print "\tunsigned i, *ptr;";
|
||||
print "PPCODE:";
|
||||
print "\tptr = glibtop_get_proclist (&proclist);";
|
||||
print "";
|
||||
print "\tif (ptr) {";
|
||||
print "\t\tfor (i = 0; i < proclist.number; i++)";
|
||||
print "\t\t\tXPUSHs (sv_2mortal (newSViv (ptr [i])));";
|
||||
print "\t}";
|
||||
print "";
|
||||
print "\tglibtop_free (ptr);";
|
||||
} else {
|
||||
print "PPCODE:";
|
||||
if (feature ~ /^proc_/) {
|
||||
print "\tglibtop_get_"feature" (&"feature", pid);";
|
||||
} else {
|
||||
print "\tglibtop_get_"feature" (&"feature");";
|
||||
}
|
||||
print "";
|
||||
|
||||
nr_elements = split ($2, elements, /:/);
|
||||
for (element = 1; element <= nr_elements; element++) {
|
||||
list = elements[element];
|
||||
type = elements[element];
|
||||
sub(/\(.*/, "", type);
|
||||
sub(/^\w+\(/, "", list); sub(/\)$/, "", list);
|
||||
count = split (list, fields, /,/);
|
||||
for (field = 1; field <= count; field++) {
|
||||
if (type ~ /^str$/) {
|
||||
print "\tXPUSHs (sv_2mortal (newSVpv ("$1"."fields[field]", 0)));";
|
||||
} else {
|
||||
if (type ~ /^char$/) {
|
||||
print "\tXPUSHs (sv_2mortal (newSVpv (&"$1"."fields[field]", 1)));";
|
||||
} else {
|
||||
print "\tXPUSHs (sv_2mortal ("convert[type]" ("$1"."fields[field]")));";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print "";
|
||||
}
|
||||
|
20
perl/test.pl
Normal file
20
perl/test.pl
Normal file
@@ -0,0 +1,20 @@
|
||||
# Before `make install' is performed this script should be runnable with
|
||||
# `make test'. After `make install' it should work as `perl test.pl'
|
||||
|
||||
######################### We start with some black magic to print on failure.
|
||||
|
||||
# Change 1..1 below to 1..last_test_to_print .
|
||||
# (It may become useful if the test is moved to ./t subdirectory.)
|
||||
|
||||
BEGIN { $| = 1; print "1..1\n"; }
|
||||
END {print "not ok 1\n" unless $loaded;}
|
||||
use Libgtop;
|
||||
$loaded = 1;
|
||||
print "ok 1\n";
|
||||
|
||||
######################### End of black magic.
|
||||
|
||||
# Insert your test code below (better if it prints "ok 13"
|
||||
# (correspondingly "not ok 13") depending on the success of chunk 13
|
||||
# of the test code):
|
||||
|
@@ -2,4 +2,5 @@ Makefile
|
||||
Makefile.in
|
||||
POTFILES
|
||||
cat-id-tbl.c
|
||||
fr.gmo
|
||||
libgtop.pot
|
||||
|
@@ -1,3 +1,7 @@
|
||||
Sun, 31 May 1998 22:38:59 +0200 Vincent Renardias <vincent@waw.com>
|
||||
|
||||
* fr.po: new file - ChangeLog isn't empty anymore _(;
|
||||
|
||||
1998-05-21 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* ChangeLog: new file - currently empty
|
||||
|
@@ -1,17 +1,8 @@
|
||||
lib/close.c
|
||||
lib/command.c
|
||||
lib/cpu.c
|
||||
lib/mem.c
|
||||
lib/open.c
|
||||
lib/read.c
|
||||
lib/swap.c
|
||||
lib/write.c
|
||||
lib/uptime.c
|
||||
lib/loadavg.c
|
||||
lib/shm_limits.c
|
||||
lib/msg_limits.c
|
||||
lib/sem_limits.c
|
||||
lib/proclist.c
|
||||
lib/read_data.c
|
||||
acconfig.h
|
||||
glibtop.h
|
||||
|
402
po/fr.po
Normal file
402
po/fr.po
Normal file
@@ -0,0 +1,402 @@
|
||||
# libgtop fr.po
|
||||
# Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
# Vincent Renardias <vincent@waw.com>, 1998.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: libgtop VERSION\n"
|
||||
"POT-Creation-Date: 1998-06-20 15:28+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: Vincent Renardias <vincent@waw.com>\n"
|
||||
"Language-Team: Vincent Renardias <vincent@waw.com>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=iso-8859-1\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: lib/open.c:36
|
||||
#, c-format
|
||||
msgid "cannot make a pipe: %s\n"
|
||||
msgstr "impossible de cr<63><72>r un tube: %s\n"
|
||||
|
||||
#: lib/open.c:41
|
||||
#, c-format
|
||||
msgid "%s: fork failed: %s\n"
|
||||
msgstr "%s: duplication <20>chou<6F>e: %s\n"
|
||||
|
||||
#: lib/open.c:59
|
||||
#, c-format
|
||||
msgid "server version is not %s"
|
||||
msgstr "la version du serveur n'est pas %s"
|
||||
|
||||
#: lib/read.c:34
|
||||
#, c-format
|
||||
msgid "read size: %s"
|
||||
msgstr "taille lue: %s"
|
||||
|
||||
#: lib/read.c:37
|
||||
#, c-format
|
||||
msgid "got %d bytes but requested %d"
|
||||
msgstr "obtenu %d octets, mais %d <20>taient demand<6E>s"
|
||||
|
||||
#: lib/read.c:40
|
||||
#, c-format
|
||||
msgid "read %d bytes: %s"
|
||||
msgstr "lecture de %d octets: %s"
|
||||
|
||||
#: lib/write.c:32
|
||||
#, c-format
|
||||
msgid "write size: %s"
|
||||
msgstr "taille <20>crite: %s"
|
||||
|
||||
#: lib/write.c:37
|
||||
#, c-format
|
||||
msgid "write %d bytes: %s"
|
||||
msgstr "<22>crit %d octets: %s"
|
||||
|
||||
#: lib/read_data.c:36
|
||||
#, c-format
|
||||
msgid "read data size: %s"
|
||||
msgstr "taille de la lecture: %s"
|
||||
|
||||
#: lib/read_data.c:46
|
||||
#, c-format
|
||||
msgid "read data %d bytes: %s"
|
||||
msgstr "lecture de %d octets de donn<6E>es: %s"
|
||||
|
||||
#: sysdeps/common/xmalloc.c:32
|
||||
#, c-format
|
||||
msgid "malloc %d bytes: %s"
|
||||
msgstr "malloc de %d octets: %s"
|
||||
|
||||
#: sysdeps/common/xmalloc.c:44
|
||||
#, c-format
|
||||
msgid "calloc %d block (%d bytes each): %s"
|
||||
msgstr "calloc de %d blocks (%d octets chacuns): %s"
|
||||
|
||||
#: sysdeps/common/xmalloc.c:56
|
||||
#, c-format
|
||||
msgid "realloc %d bytes: %s"
|
||||
msgstr "realloc de %d octets: %s"
|
||||
|
||||
#: sysdeps/names/sysdeps.c:42 sysdeps/names/sysdeps.c:62
|
||||
msgid "CPU Usage"
|
||||
msgstr "Utilisation CPU"
|
||||
|
||||
#: sysdeps/names/sysdeps.c:43 sysdeps/names/sysdeps.c:63
|
||||
msgid "Memory Usage"
|
||||
msgstr "Utilisation M<>moire"
|
||||
|
||||
#: sysdeps/names/sysdeps.c:44 sysdeps/names/sysdeps.c:64
|
||||
msgid "Swap Usage"
|
||||
msgstr "Utilisation du Swap"
|
||||
|
||||
#: sysdeps/names/sysdeps.c:45 sysdeps/names/sysdeps.c:65
|
||||
msgid "System Uptime"
|
||||
msgstr "Uptime du syst<73>me"
|
||||
|
||||
#: sysdeps/names/sysdeps.c:46 sysdeps/names/sysdeps.c:66
|
||||
msgid "Load Averange"
|
||||
msgstr "Charge moyenne"
|
||||
|
||||
#: sysdeps/names/sysdeps.c:47 sysdeps/names/sysdeps.c:67
|
||||
msgid "Shared Memory Limits"
|
||||
msgstr "Limites de la m<>moire partag<61>e"
|
||||
|
||||
#: sysdeps/names/sysdeps.c:48 sysdeps/names/sysdeps.c:68
|
||||
msgid "Message Queue Limits"
|
||||
msgstr "Limites de la queue de messages"
|
||||
|
||||
#: sysdeps/names/sysdeps.c:49 sysdeps/names/sysdeps.c:69
|
||||
msgid "Semaphore Set Limits"
|
||||
msgstr "Limites de l'ensemble de s<>maphores"
|
||||
|
||||
#: sysdeps/names/sysdeps.c:50 sysdeps/names/sysdeps.c:70
|
||||
msgid "List of running Processes"
|
||||
msgstr "Liste des taches en cours d'<27>x<EFBFBD>cution"
|
||||
|
||||
#: sysdeps/names/sysdeps.c:51 sysdeps/names/sysdeps.c:71
|
||||
msgid "Process Status information"
|
||||
msgstr "Information sur l'<27>tat du processus"
|
||||
|
||||
#: sysdeps/names/sysdeps.c:52 sysdeps/names/sysdeps.c:72
|
||||
msgid "Process UID and TTY information"
|
||||
msgstr "Information UID et TTY du processus"
|
||||
|
||||
#: sysdeps/names/sysdeps.c:53 sysdeps/names/sysdeps.c:73
|
||||
msgid "Process Memory information"
|
||||
msgstr "Information M<>moire du Processus"
|
||||
|
||||
#: sysdeps/names/sysdeps.c:54 sysdeps/names/sysdeps.c:74
|
||||
msgid "Process Time information"
|
||||
msgstr "Information Temporelle sur le processus"
|
||||
|
||||
#: sysdeps/names/sysdeps.c:55 sysdeps/names/sysdeps.c:75
|
||||
msgid "Process Signal information"
|
||||
msgstr "Information sur les signaux du processus"
|
||||
|
||||
#: sysdeps/names/sysdeps.c:56 sysdeps/names/sysdeps.c:76
|
||||
msgid "Process Kernel Data information"
|
||||
msgstr "Information sur les donn<6E>es noyau du processus"
|
||||
|
||||
#: sysdeps/names/sysdeps.c:57 sysdeps/names/sysdeps.c:77
|
||||
msgid "Process Segment information"
|
||||
msgstr "Information sur la segmentation du processus"
|
||||
|
||||
#: sysdeps/names/cpu.c:37
|
||||
msgid "Total CPU Time"
|
||||
msgstr "Temps CPU Total"
|
||||
|
||||
#: sysdeps/names/cpu.c:38
|
||||
msgid "CPU Time in User Mode"
|
||||
msgstr "Temps CPU en mode utilisateur"
|
||||
|
||||
#: sysdeps/names/cpu.c:39
|
||||
msgid "CPU Time in User Mode (nice)"
|
||||
msgstr "Temps CPU en mode utilisateur (nice)"
|
||||
|
||||
#: sysdeps/names/cpu.c:40
|
||||
msgid "CPU Time in System Mode"
|
||||
msgstr "Temps CPU en mode syst<73>me"
|
||||
|
||||
#: sysdeps/names/cpu.c:41
|
||||
msgid "CPU Time in the Idle Task"
|
||||
msgstr "Temps CPU pour la tache inactive"
|
||||
|
||||
#: sysdeps/names/cpu.c:42
|
||||
msgid "Tick Frequency"
|
||||
msgstr "Fr<46>quence des ticks"
|
||||
|
||||
#: sysdeps/names/cpu.c:47
|
||||
msgid "The number of jiffies (1/100ths of a second) since system boot"
|
||||
msgstr "Nombre de jiffies (1/100e de seconde) depuis le boot du syst<73>me"
|
||||
|
||||
#: sysdeps/names/cpu.c:49
|
||||
msgid ""
|
||||
"The number of jiffies (1/100ths of a second) that the system spent in user "
|
||||
"mode"
|
||||
msgstr "Le nombre de jiffies (1/100<30>me de seconde) que le systme a pass<73> en mode utilisateur"
|
||||
|
||||
#: sysdeps/names/cpu.c:51
|
||||
msgid ""
|
||||
"The number of jiffies (1/100ths of a second) that the system spent in user "
|
||||
"mode with low priority (nice)"
|
||||
msgstr "Le nombre de jiffies (1/100<30>me de seconde) que le syst<73>me a pass<73> en mode utilisateur en priorit<69> basse (nice)"
|
||||
|
||||
#: sysdeps/names/cpu.c:53
|
||||
msgid ""
|
||||
"The number of jiffies (1/100ths of a second) that the system spent in system "
|
||||
"mode"
|
||||
msgstr "Le nombre de jiffies (1/100<30>me de seconde) que le syst<73>me a pass<73> en mode syst<73>me"
|
||||
|
||||
#: sysdeps/names/cpu.c:55
|
||||
msgid ""
|
||||
"The number of jiffies (1/100ths of a second) that the system spend in the "
|
||||
"idle task"
|
||||
msgstr "Le nombre de jiffies (1/100<30>me de seconde) que le systme a pass<73> dans le processus inactif (idle task)"
|
||||
|
||||
#: sysdeps/names/cpu.c:57
|
||||
msgid ""
|
||||
"All of the above values are in jiffies (1/100ths of a second) unless "
|
||||
"otherwise stated in this field (i.e. 'frequency != 100')"
|
||||
msgstr "Toutes les valeurs ci-dessus sont exprim<69>es en jiffies (1/100<30>me de seconde) sauf pr<70>cision contraire (i.e.: fr<66>quence != 100)"
|
||||
|
||||
#: sysdeps/names/loadavg.c:36
|
||||
msgid "Load Average"
|
||||
msgstr "Charge Moyenne"
|
||||
|
||||
#: sysdeps/names/loadavg.c:41
|
||||
msgid "Number of jobs running simultaneously averaged over 1, 5 and 15 minutes"
|
||||
msgstr "Nombre de processus tournant simultannement en moyenne sur 1, 5 et 15 minutes"
|
||||
|
||||
#: sysdeps/names/mem.c:39
|
||||
msgid "Total Memory"
|
||||
msgstr "M<>moire Totale"
|
||||
|
||||
#: sysdeps/names/mem.c:40
|
||||
msgid "Used Memory"
|
||||
msgstr "M<>moire Utilis<69>e"
|
||||
|
||||
#: sysdeps/names/mem.c:41
|
||||
msgid "Free Memory"
|
||||
msgstr "M<>moire Libre"
|
||||
|
||||
#: sysdeps/names/mem.c:42
|
||||
msgid "Shared Memory"
|
||||
msgstr "M<>moire Partag<61>e"
|
||||
|
||||
#: sysdeps/names/mem.c:43
|
||||
msgid "Buffers"
|
||||
msgstr "Tampons"
|
||||
|
||||
#: sysdeps/names/mem.c:44
|
||||
msgid "Cached"
|
||||
msgstr "Dans le cache"
|
||||
|
||||
#: sysdeps/names/mem.c:45
|
||||
msgid "User"
|
||||
msgstr "Utilisateur"
|
||||
|
||||
#: sysdeps/names/mem.c:46
|
||||
msgid "Locked"
|
||||
msgstr "V<>rouill<6C>"
|
||||
|
||||
#: sysdeps/names/mem.c:51
|
||||
msgid "Total physical memory in kB"
|
||||
msgstr "M<>moire physique totalle en Ko"
|
||||
|
||||
#: sysdeps/names/mem.c:52
|
||||
msgid "Used memory size in kB"
|
||||
msgstr "M<>moire utilis<69>e en Ko"
|
||||
|
||||
#: sysdeps/names/mem.c:53
|
||||
msgid "Free memory size in kB"
|
||||
msgstr "M<>moire libre en Ko"
|
||||
|
||||
#: sysdeps/names/mem.c:54
|
||||
msgid "Shared memory size in kB"
|
||||
msgstr "M<>moire partag<61>e en Ko"
|
||||
|
||||
#: sysdeps/names/mem.c:55
|
||||
msgid "Size of buffers kB"
|
||||
msgstr "Taille des tampons en Ko"
|
||||
|
||||
#: sysdeps/names/mem.c:56
|
||||
msgid "Size of cached memory in kB"
|
||||
msgstr "Taille de la m<>moire dans le cache en Ko"
|
||||
|
||||
#: sysdeps/names/mem.c:57
|
||||
msgid "Memory used from user processes in kB"
|
||||
msgstr "M<>moire utilis<69>e par les processus utilisateurs en Ko"
|
||||
|
||||
#: sysdeps/names/mem.c:58
|
||||
msgid "Memory in locked pages in kB"
|
||||
msgstr "M<>moire dans les pages v<>rouill<6C>es en Ko"
|
||||
|
||||
#: sysdeps/names/swap.c:36 sysdeps/names/swap.c:43
|
||||
msgid "Total Swap Space"
|
||||
msgstr "Taille totalle de la zone d'<27>change"
|
||||
|
||||
#: sysdeps/names/swap.c:37 sysdeps/names/swap.c:44
|
||||
msgid "Used Swap Space"
|
||||
msgstr "Taille utilis<69>e de la zone d'<27>change"
|
||||
|
||||
#: sysdeps/names/swap.c:38 sysdeps/names/swap.c:45
|
||||
msgid "Free Swap Space"
|
||||
msgstr "Espace libre de la zone d'<27>change"
|
||||
|
||||
#: sysdeps/names/uptime.c:36
|
||||
msgid "Uptime"
|
||||
msgstr "Uptime"
|
||||
|
||||
#: sysdeps/names/uptime.c:37
|
||||
msgid "Idletime"
|
||||
msgstr "Idletime"
|
||||
|
||||
#: sysdeps/names/uptime.c:42
|
||||
msgid "Time in seconds since system boot"
|
||||
msgstr "Temps en secondes depuis le d<>marrage du syst<73>me"
|
||||
|
||||
#: sysdeps/names/uptime.c:43
|
||||
msgid "Time in seconds the system spent in the idle task since system boot"
|
||||
msgstr "Temps en secondes pass<73> dans le processus inactif depuis le d<>marrage du syst<73>me"
|
||||
|
||||
#: sysdeps/names/shm_limits.c:37 sysdeps/names/shm_limits.c:46
|
||||
msgid "Max segment size"
|
||||
msgstr "Taille maximum des segments"
|
||||
|
||||
#: sysdeps/names/shm_limits.c:38 sysdeps/names/shm_limits.c:47
|
||||
msgid "Min segment size"
|
||||
msgstr "Taille minimum des segments"
|
||||
|
||||
#: sysdeps/names/shm_limits.c:39 sysdeps/names/shm_limits.c:48
|
||||
msgid "Max number of segments"
|
||||
msgstr "Nombre maximum des segments"
|
||||
|
||||
#: sysdeps/names/shm_limits.c:40 sysdeps/names/shm_limits.c:49
|
||||
msgid "Max shared segments per process"
|
||||
msgstr "Nombre maximum de segments partag<61>s par processus"
|
||||
|
||||
#: sysdeps/names/shm_limits.c:41 sysdeps/names/shm_limits.c:50
|
||||
msgid "Max total shared memory"
|
||||
msgstr "Taille totalle de la m<>moire partag<61>e"
|
||||
|
||||
#: sysdeps/names/msg_limits.c:37 sysdeps/names/msg_limits.c:48
|
||||
msgid "Size in kilobytes of message pool"
|
||||
msgstr "Taille en kilo-octets du pool de messages"
|
||||
|
||||
#: sysdeps/names/msg_limits.c:38 sysdeps/names/msg_limits.c:49
|
||||
msgid "Number of entries in message map"
|
||||
msgstr ""
|
||||
|
||||
#: sysdeps/names/msg_limits.c:39 sysdeps/names/msg_limits.c:50
|
||||
msgid "Max size of message"
|
||||
msgstr "Taille maximum des messages"
|
||||
|
||||
#: sysdeps/names/msg_limits.c:40 sysdeps/names/msg_limits.c:51
|
||||
msgid "Default max size of queue"
|
||||
msgstr "Taille maximum par d<>faut de la queue"
|
||||
|
||||
#: sysdeps/names/msg_limits.c:41 sysdeps/names/msg_limits.c:52
|
||||
msgid "Max queues system wide"
|
||||
msgstr "Nombre maximum de queues dans le syst<73>me"
|
||||
|
||||
#: sysdeps/names/msg_limits.c:42 sysdeps/names/msg_limits.c:53
|
||||
msgid "Message segment size"
|
||||
msgstr "Taille des segments de messages"
|
||||
|
||||
#: sysdeps/names/msg_limits.c:43 sysdeps/names/msg_limits.c:54
|
||||
msgid "Number of system message headers"
|
||||
msgstr "Nombre d'entetes de messages syst<73>me"
|
||||
|
||||
#: sysdeps/names/sem_limits.c:39 sysdeps/names/sem_limits.c:53
|
||||
msgid "Number of entries in semaphore map"
|
||||
msgstr ""
|
||||
|
||||
#: sysdeps/names/sem_limits.c:40 sysdeps/names/sem_limits.c:54
|
||||
msgid "Max number of arrays"
|
||||
msgstr "Nombre maximum de tables"
|
||||
|
||||
#: sysdeps/names/sem_limits.c:41 sysdeps/names/sem_limits.c:55
|
||||
msgid "Max semaphores system wide"
|
||||
msgstr "Nombre maximum de s<>maphores dans le syst<73>me"
|
||||
|
||||
#: sysdeps/names/sem_limits.c:42 sysdeps/names/sem_limits.c:56
|
||||
msgid "Number of undo structures system wide"
|
||||
msgstr "Nombre de structures 'undo' dans le syst<73>me"
|
||||
|
||||
#: sysdeps/names/sem_limits.c:43 sysdeps/names/sem_limits.c:57
|
||||
msgid "Max semaphores per array"
|
||||
msgstr "Nombre maximum de s<>maphores par table"
|
||||
|
||||
#: sysdeps/names/sem_limits.c:44 sysdeps/names/sem_limits.c:58
|
||||
msgid "Max ops per semop call"
|
||||
msgstr ""
|
||||
|
||||
#: sysdeps/names/sem_limits.c:45 sysdeps/names/sem_limits.c:59
|
||||
msgid "Max number of undo entries per process"
|
||||
msgstr ""
|
||||
|
||||
#: sysdeps/names/sem_limits.c:46 sysdeps/names/sem_limits.c:60
|
||||
msgid "sizeof struct sem_undo"
|
||||
msgstr "sizeof struct sem_undo"
|
||||
|
||||
#: sysdeps/names/sem_limits.c:47 sysdeps/names/sem_limits.c:61
|
||||
msgid "Semaphore max value"
|
||||
msgstr "Valeur maximum d'un s<>maphore"
|
||||
|
||||
#: sysdeps/names/sem_limits.c:48 sysdeps/names/sem_limits.c:62
|
||||
msgid "Adjust on exit max value"
|
||||
msgstr ""
|
||||
|
||||
#: sysdeps/names/proclist.c:36 sysdeps/names/proclist.c:43
|
||||
msgid "Number of list elements"
|
||||
msgstr ""
|
||||
|
||||
#: sysdeps/names/proclist.c:37 sysdeps/names/proclist.c:44
|
||||
msgid "Total size of list"
|
||||
msgstr "Taille totalle de la liste"
|
||||
|
||||
#: sysdeps/names/proclist.c:38 sysdeps/names/proclist.c:45
|
||||
msgid "Size of a single list element"
|
||||
msgstr ""
|
@@ -1 +1 @@
|
||||
SUBDIRS = server
|
||||
SUBDIRS = server daemon
|
||||
|
4
src/daemon/.cvsignore
Normal file
4
src/daemon/.cvsignore
Normal file
@@ -0,0 +1,4 @@
|
||||
Makefile.in
|
||||
Makefile
|
||||
gnuserv
|
||||
server_config.h
|
25
src/daemon/Makefile.am
Normal file
25
src/daemon/Makefile.am
Normal file
@@ -0,0 +1,25 @@
|
||||
LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@
|
||||
|
||||
INCLUDES = -I$(top_builddir) -I$(top_srcdir) @machine_incs@ \
|
||||
-I$(top_srcdir)/include -I$(top_srcdir)/intl @GUILE_INCS@ \
|
||||
-DGTOPLOCALEDIR=\"$(datadir)/locale\" -D_GNU_SOURCE
|
||||
|
||||
CFLAGS = -Wall -W @CFLAGS@ -DGTOP_SERVER=\""@LIBGTOP_SERVER@"\" -DDEBUG -DREAL_DEBUG
|
||||
|
||||
bin_PROGRAMS = gnuserv
|
||||
|
||||
EXTRA_PROGRAMS = gtop_daemon
|
||||
|
||||
gnuserv_SOURCES = gnuserv.c main.c slave.c
|
||||
gnuserv_LDADD = $(top_builddir)/lib/libgtop.la \
|
||||
$(top_builddir)/sysdeps/common/libgtop_common.la \
|
||||
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \
|
||||
@INTLLIBS@ @LIBSUPPORT@ @X_LIBS@ -lXau
|
||||
gnuserv_LDFLAGS = -static
|
||||
|
||||
gtop_daemon_SOURCES = main.c inet.c loop.c output.c version.c
|
||||
gtop_daemon_LDADD = $(top_builddir)/lib/libgtop.la \
|
||||
$(top_builddir)/sysdeps/common/libgtop_common.la \
|
||||
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \
|
||||
@INTLLIBS@ @LIBSUPPORT@
|
||||
gtop_daemon_LDFLAGS = -static
|
665
src/daemon/gnuserv.c
Normal file
665
src/daemon/gnuserv.c
Normal file
@@ -0,0 +1,665 @@
|
||||
/* -*-C-*-
|
||||
* Server code for handling requests from clients and forwarding them
|
||||
* on to the GNU Emacs process.
|
||||
*
|
||||
* This file is part of GNU Emacs.
|
||||
*
|
||||
* Copying is permitted under those conditions described by the GNU
|
||||
* General Public License.
|
||||
*
|
||||
* Copyright (C) 1989 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Andy Norman (ange@hplb.hpl.hp.com), based on 'etc/server.c'
|
||||
* from the 18.52 GNU Emacs distribution.
|
||||
*
|
||||
* Please mail bugs and suggestions to the author at the above address.
|
||||
*/
|
||||
|
||||
/* HISTORY
|
||||
* 11-Nov-1990 bristor@simba
|
||||
* Added EOT stuff.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file incorporates new features added by Bob Weiner <weiner@mot.com>,
|
||||
* Darrell Kindred <dkindred@cmu.edu> and Arup Mukherjee <arup@cmu.edu>.
|
||||
* Please see the note at the end of the README file for details.
|
||||
*
|
||||
* (If gnuserv came bundled with your emacs, the README file is probably
|
||||
* ../etc/gnuserv.README relative to the directory containing this file)
|
||||
*/
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/open.h>
|
||||
#include <glibtop/close.h>
|
||||
#include <glibtop/command.h>
|
||||
#include <glibtop/xmalloc.h>
|
||||
|
||||
#include <glibtop/parameter.h>
|
||||
|
||||
#include "server_config.h"
|
||||
|
||||
#include <glibtop/gnuserv.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#ifdef AIX
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
extern void handle_parent_connection __P ((int));
|
||||
extern void handle_child_connection __P ((int));
|
||||
extern void handle_ipc_connection __P ((int));
|
||||
|
||||
#if !defined(UNIX_DOMAIN_SOCKETS) && !defined(INTERNET_DOMAIN_SOCKETS)
|
||||
#error "Unix Domain sockets or Internet Domain sockets are required"
|
||||
#endif
|
||||
|
||||
#ifdef INTERNET_DOMAIN_SOCKETS
|
||||
|
||||
#ifdef AUTH_MAGIC_COOKIE
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xauth.h>
|
||||
|
||||
static Xauth *server_xauth = NULL;
|
||||
|
||||
#endif /* INTERNET_DOMAIN_SOCKETS */
|
||||
|
||||
/*
|
||||
* timed_read - Read with timeout.
|
||||
*/
|
||||
|
||||
static int
|
||||
timed_read (int fd, char *buf, int max, int timeout, int one_line)
|
||||
{
|
||||
fd_set rmask;
|
||||
struct timeval tv; /* = {timeout, 0}; */
|
||||
char c = 0;
|
||||
int nbytes = 0;
|
||||
int r;
|
||||
|
||||
tv.tv_sec = timeout;
|
||||
tv.tv_usec = 0;
|
||||
|
||||
FD_ZERO (&rmask);
|
||||
FD_SET (fd, &rmask);
|
||||
|
||||
do {
|
||||
r = select (fd + 1, &rmask, NULL, NULL, &tv);
|
||||
|
||||
if (r > 0) {
|
||||
if (read (fd, &c, 1) == 1) {
|
||||
*buf++ = c;
|
||||
++nbytes;
|
||||
} else {
|
||||
glibtop_warn_io ("read error on socket");
|
||||
return -1;
|
||||
}
|
||||
} else if (r == 0) {
|
||||
glibtop_warn ("read timed out");
|
||||
return -1;
|
||||
} else {
|
||||
glibtop_warn_io ("error in select");
|
||||
return -1;
|
||||
}
|
||||
} while ((nbytes < max) && !(one_line && (c == '\n')));
|
||||
|
||||
--buf;
|
||||
if (one_line && *buf == '\n') {
|
||||
*buf = 0;
|
||||
}
|
||||
return nbytes;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* permitted -- return whether a given host is allowed to connect to the server.
|
||||
*/
|
||||
|
||||
static int
|
||||
permitted (u_long host_addr, int fd)
|
||||
{
|
||||
int i;
|
||||
|
||||
char auth_protocol[128];
|
||||
char buf[1024];
|
||||
int auth_data_len;
|
||||
|
||||
if (fd > 0) {
|
||||
/* we are checking permission on a real connection */
|
||||
|
||||
/* Read auth protocol name */
|
||||
|
||||
if (timed_read (fd, auth_protocol, AUTH_NAMESZ, AUTH_TIMEOUT, 1) <= 0)
|
||||
return FALSE;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "Client sent authenticatin protocol '%s'\n",
|
||||
auth_protocol);
|
||||
#endif
|
||||
|
||||
if (strcmp (auth_protocol, DEFAUTH_NAME) &&
|
||||
strcmp (auth_protocol, MCOOKIE_NAME)) {
|
||||
glibtop_warn ("Invalid authentication protocol "
|
||||
"'%s' from client", auth_protocol);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!strcmp (auth_protocol, MCOOKIE_NAME)) {
|
||||
/*
|
||||
* doing magic cookie auth
|
||||
*/
|
||||
|
||||
if (timed_read (fd, buf, 10, AUTH_TIMEOUT, 1) <= 0)
|
||||
return FALSE;
|
||||
|
||||
auth_data_len = atoi (buf);
|
||||
|
||||
if (timed_read (fd, buf, auth_data_len, AUTH_TIMEOUT, 0) != auth_data_len)
|
||||
return FALSE;
|
||||
|
||||
#ifdef AUTH_MAGIC_COOKIE
|
||||
if (server_xauth && server_xauth->data &&
|
||||
!memcmp (buf, server_xauth->data, auth_data_len)) {
|
||||
return TRUE;
|
||||
}
|
||||
#else
|
||||
glibtop_warn ("Client tried Xauth, but server is "
|
||||
"not compiled with Xauth");
|
||||
#endif
|
||||
|
||||
/*
|
||||
* auth failed, but allow this to fall through to the
|
||||
* GNU_SECURE protocol....
|
||||
*/
|
||||
|
||||
glibtop_warn ("Xauth authentication failed, "
|
||||
"trying GNU_SECURE auth...");
|
||||
|
||||
}
|
||||
|
||||
/* Other auth protocols go here, and should execute only if
|
||||
* the * auth_protocol name matches. */
|
||||
}
|
||||
|
||||
/* Now, try the old GNU_SECURE stuff... */
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "Doing GNU_SECURE auth ...\n");
|
||||
#endif
|
||||
|
||||
/* Now check the chain for that hash key */
|
||||
for (i = 0; i < HOST_TABLE_ENTRIES; i++) {
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "Trying %lx - %lx\n",
|
||||
host_addr, permitted_hosts [i]);
|
||||
#endif
|
||||
if (host_addr == permitted_hosts [i])
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* setup_table -- initialise the table of hosts allowed to contact the server,
|
||||
* by reading from the file specified by the GNU_SECURE
|
||||
* environment variable
|
||||
* Put in the local machine, and, if a security file is specifed,
|
||||
* add each host that is named in the file.
|
||||
* Return the number of hosts added.
|
||||
*/
|
||||
|
||||
static int
|
||||
setup_table (void)
|
||||
{
|
||||
char hostname [HOSTNAMSZ];
|
||||
u_int host_addr;
|
||||
int i, hosts = 0;
|
||||
|
||||
/* Make sure every entry is null */
|
||||
for (i = 0; i < HOST_TABLE_ENTRIES; i++)
|
||||
permitted_hosts [i] = 0;
|
||||
|
||||
gethostname (hostname, HOSTNAMSZ);
|
||||
|
||||
if (((long) host_addr = glibtop_internet_addr (hostname)) == -1)
|
||||
glibtop_error ("Can't resolve '%s'", hostname);
|
||||
|
||||
#ifdef AUTH_MAGIC_COOKIE
|
||||
|
||||
server_xauth = XauGetAuthByAddr
|
||||
(FamilyInternet,
|
||||
sizeof (host_addr), (char *) &host_addr,
|
||||
strlen (MCOOKIE_SCREEN), MCOOKIE_SCREEN,
|
||||
strlen (MCOOKIE_X_NAME), MCOOKIE_X_NAME);
|
||||
hosts++;
|
||||
|
||||
#endif /* AUTH_MAGIC_COOKIE */
|
||||
|
||||
/* Resolv host names from permitted_host_names []. */
|
||||
|
||||
for (i = 0; i < HOST_TABLE_ENTRIES; i++) {
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "Resolving %s ...\n",
|
||||
permitted_host_names [i]);
|
||||
#endif
|
||||
permitted_hosts [i] =
|
||||
glibtop_internet_addr (permitted_host_names [i]);
|
||||
if ((long) permitted_hosts [i] == -1)
|
||||
glibtop_error ("Can't resolve '%s'",
|
||||
permitted_host_names [i]);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
for (i = 0; i < HOST_TABLE_ENTRIES; i++)
|
||||
fprintf (stderr, "Host %s - %lx\n",
|
||||
permitted_host_names [i],
|
||||
permitted_hosts [i]);
|
||||
#endif
|
||||
|
||||
hosts += HOST_TABLE_ENTRIES;
|
||||
|
||||
return hosts;
|
||||
} /* setup_table */
|
||||
|
||||
/*
|
||||
* internet_init -- initialize server, returning an internet socket that can
|
||||
* be listened on.
|
||||
*/
|
||||
|
||||
static int
|
||||
internet_init (void)
|
||||
{
|
||||
int ls; /* socket descriptor */
|
||||
struct sockaddr_in server; /* for local socket address */
|
||||
|
||||
if (setup_table () == 0)
|
||||
return -1;
|
||||
|
||||
/* clear out address structure */
|
||||
memset ((char *) &server, 0, sizeof (struct sockaddr_in));
|
||||
|
||||
/* Set up address structure for the listen socket. */
|
||||
server.sin_family = AF_INET;
|
||||
server.sin_addr.s_addr = INADDR_ANY;
|
||||
|
||||
/* We use a fixed port given in the config file. */
|
||||
server.sin_port = htons (SERVER_PORT);
|
||||
|
||||
fprintf (stderr, "Using port %u.\n", server.sin_port);
|
||||
|
||||
/* Create the listen socket. */
|
||||
if ((ls = socket (AF_INET, SOCK_STREAM, 0)) == -1)
|
||||
glibtop_error_io ("unable to create socket");
|
||||
|
||||
/* Bind the listen address to the socket. */
|
||||
if (bind (ls, (struct sockaddr *) &server, sizeof (struct sockaddr_in)) == -1)
|
||||
glibtop_error_io ("bind");
|
||||
|
||||
/* Initiate the listen on the socket so remote users * can connect. */
|
||||
if (listen (ls, 20) == -1)
|
||||
glibtop_error_io ("listen");
|
||||
|
||||
return (ls);
|
||||
} /* internet_init */
|
||||
|
||||
|
||||
/*
|
||||
* handle_internet_request -- accept a request from a client and send the
|
||||
* information to stdout (the gnu process).
|
||||
*/
|
||||
|
||||
static void
|
||||
handle_internet_request (int ls)
|
||||
{
|
||||
int s;
|
||||
size_t addrlen = sizeof (struct sockaddr_in);
|
||||
struct sockaddr_in peer; /* for peer socket address */
|
||||
pid_t pid;
|
||||
|
||||
memset ((char *) &peer, 0, sizeof (struct sockaddr_in));
|
||||
|
||||
if ((s = accept (ls, (struct sockaddr *) &peer, (void *) &addrlen)) == -1)
|
||||
glibtop_error_io ("accept");
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "Connection was made from %s.\n", inet_ntoa (peer.sin_addr));
|
||||
#endif
|
||||
|
||||
/* Check that access is allowed - if not return crud to the client */
|
||||
if (!permitted (peer.sin_addr.s_addr, s)) {
|
||||
close (s);
|
||||
glibtop_warn ("Refused connection from %s.", inet_ntoa (peer.sin_addr));
|
||||
return;
|
||||
} /* if */
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "Accepted connection from %s (%u) on socket %d.\n",
|
||||
inet_ntoa (peer.sin_addr), ntohs (peer.sin_port), s);
|
||||
#endif
|
||||
|
||||
pid = fork ();
|
||||
|
||||
if (pid == -1)
|
||||
glibtop_error_io ("fork failed");
|
||||
|
||||
if (pid)
|
||||
return;
|
||||
|
||||
handle_parent_connection (s);
|
||||
|
||||
close (s);
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "Closed connection to %s (%d).\n",
|
||||
inet_ntoa (peer.sin_addr), ntohs (peer.sin_port));
|
||||
#endif
|
||||
|
||||
_exit (0);
|
||||
} /* handle_internet_request */
|
||||
#endif /* INTERNET_DOMAIN_SOCKETS */
|
||||
|
||||
|
||||
#ifdef UNIX_DOMAIN_SOCKETS
|
||||
/*
|
||||
* unix_init -- initialize server, returning an unix-domain socket that can
|
||||
* be listened on.
|
||||
*/
|
||||
static int
|
||||
unix_init (void)
|
||||
{
|
||||
int ls; /* socket descriptor */
|
||||
struct sockaddr_un server; /* unix socket address */
|
||||
int bindlen;
|
||||
|
||||
if ((ls = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
|
||||
glibtop_error_io ("unable to create socket");
|
||||
|
||||
/* Set up address structure for the listen socket. */
|
||||
|
||||
#ifdef HIDE_UNIX_SOCKET
|
||||
sprintf (server.sun_path, "/tmp/lgtddir%d", (int) geteuid ());
|
||||
if (mkdir (server.sun_path, 0700) < 0) {
|
||||
/* assume it already exists, and try to set perms */
|
||||
if (chmod (server.sun_path, 0700) < 0)
|
||||
glibtop_error_io ("Can't set permissions on %s",
|
||||
server.sun_path);
|
||||
}
|
||||
strcat (server.sun_path, "/lgtd");
|
||||
unlink (server.sun_path); /* remove old file if it exists */
|
||||
#else /* HIDE_UNIX_SOCKET */
|
||||
sprintf (server.sun_path, "/tmp/lgtd%d", (int) geteuid ());
|
||||
unlink (server.sun_path); /* remove old file if it exists */
|
||||
#endif /* HIDE_UNIX_SOCKET */
|
||||
|
||||
server.sun_family = AF_UNIX;
|
||||
#ifdef HAVE_SOCKADDR_SUN_LEN
|
||||
/* See W. R. Stevens "Advanced Programming in the Unix Environment"
|
||||
* p. 502 */
|
||||
bindlen = (sizeof (server.sun_len) + sizeof (server.sun_family)
|
||||
+ strlen (server.sun_path) + 1);
|
||||
server.sun_len = bindlen;
|
||||
#else
|
||||
bindlen = strlen (server.sun_path) + sizeof (server.sun_family);
|
||||
#endif
|
||||
|
||||
if (bind (ls, (struct sockaddr *) &server, bindlen) < 0)
|
||||
glibtop_error_io ("bind");
|
||||
|
||||
chmod (server.sun_path, 0700); /* only this user can send commands */
|
||||
|
||||
if (listen (ls, 20) < 0)
|
||||
glibtop_error_io ("listen");
|
||||
|
||||
/* #### there are also better ways of dealing with this when sigvec()
|
||||
* is present. */
|
||||
#if defined (HAVE_SIGPROCMASK)
|
||||
{
|
||||
sigset_t _mask;
|
||||
|
||||
sigemptyset (&_mask);
|
||||
sigaddset (&_mask, SIGPIPE);
|
||||
sigprocmask (SIG_BLOCK, &_mask, NULL);
|
||||
}
|
||||
#else
|
||||
signal (SIGPIPE, SIG_IGN); /* in case user kills client */
|
||||
#endif
|
||||
|
||||
return (ls);
|
||||
} /* unix_init */
|
||||
|
||||
|
||||
/*
|
||||
* handle_unix_request -- accept a request from a client and send the information
|
||||
* to stdout (the gnu process).
|
||||
*/
|
||||
static void
|
||||
handle_unix_request (int ls)
|
||||
{
|
||||
int s;
|
||||
size_t len = sizeof (struct sockaddr_un);
|
||||
struct sockaddr_un server; /* for unix socket address */
|
||||
pid_t pid;
|
||||
|
||||
server.sun_family = AF_UNIX;
|
||||
|
||||
if ((s = accept (ls, (struct sockaddr *) &server, (void *) &len)) < 0)
|
||||
glibtop_error_io ("accept");
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "Accepted connection on socket %d.\n", s);
|
||||
#endif
|
||||
|
||||
pid = fork ();
|
||||
|
||||
if (pid == -1)
|
||||
glibtop_error_io ("fork failed");
|
||||
|
||||
if (pid)
|
||||
return;
|
||||
|
||||
handle_child_connection (s);
|
||||
|
||||
close (s);
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "Closed connection on socket %d.\n", s);
|
||||
#endif
|
||||
|
||||
glibtop_close_r (glibtop_global_server);
|
||||
|
||||
exit (0);
|
||||
} /* handle_unix_request */
|
||||
|
||||
#endif /* UNIX_DOMAIN_SOCKETS */
|
||||
|
||||
void
|
||||
handle_signal (int sig)
|
||||
{
|
||||
fprintf (stderr, "Catched signal %d.\n", sig);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv [])
|
||||
{
|
||||
glibtop *server = glibtop_global_server;
|
||||
|
||||
int ils = -1; /* internet domain listen socket */
|
||||
int uls = -1; /* unix domain listen socket */
|
||||
pid_t pid;
|
||||
|
||||
glibtop_init_r (&glibtop_global_server, 0, GLIBTOP_INIT_NO_INIT);
|
||||
|
||||
/* Fork a child.
|
||||
*
|
||||
* The parent will listen for incoming internet connections
|
||||
* and the child will listen for connections from the local
|
||||
* host using unix domain name sockets.
|
||||
*/
|
||||
|
||||
signal (SIGCHLD, handle_signal);
|
||||
|
||||
pid = fork ();
|
||||
|
||||
if (pid == -1)
|
||||
glibtop_error_io ("fork failed");
|
||||
else if (pid == 0) {
|
||||
/* We are the child. */
|
||||
|
||||
const unsigned method = GLIBTOP_METHOD_DIRECT;
|
||||
|
||||
/* Temporarily drop our priviledges. */
|
||||
|
||||
fprintf (stderr, "Child ID: (%d, %d) - (%d, %d)\n",
|
||||
getuid (), geteuid (), getgid (), getegid ());
|
||||
|
||||
if (setreuid (geteuid (), getuid ()))
|
||||
glibtop_error_io ("setreuid (euid <-> uid)");
|
||||
|
||||
if (setregid (getegid (), getgid ()))
|
||||
glibtop_error_io ("setregid (egid <-> gid)");
|
||||
|
||||
fprintf (stderr, "Child ID: (%d, %d) - (%d, %d)\n",
|
||||
getuid (), geteuid (), getgid (), getegid ());
|
||||
|
||||
#ifdef UNIX_DOMAIN_SOCKETS
|
||||
/* get a unix domain socket to listen on. */
|
||||
uls = unix_init ();
|
||||
#endif
|
||||
|
||||
glibtop_set_parameter_l (server, GLIBTOP_PARAM_METHOD,
|
||||
&method, sizeof (method));
|
||||
|
||||
glibtop_set_parameter_l (server, GLIBTOP_PARAM_FEATURES,
|
||||
&glibtop_server_features,
|
||||
sizeof (glibtop_server_features));
|
||||
|
||||
glibtop_init_r (&server, 0, 0);
|
||||
|
||||
} else {
|
||||
/* We are the parent. */
|
||||
|
||||
const unsigned method = GLIBTOP_METHOD_UNIX;
|
||||
|
||||
const unsigned long features = GLIBTOP_SYSDEPS_ALL;
|
||||
|
||||
/* If we are root, completely switch to SERVER_UID and
|
||||
* SERVER_GID. Otherwise we completely drop any priviledges.
|
||||
*/
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "Parent ID: (%d, %d) - (%d, %d)\n",
|
||||
getuid (), geteuid (), getgid (), getegid ());
|
||||
#endif
|
||||
|
||||
if (setreuid (geteuid (), getuid ()))
|
||||
glibtop_error_io ("setreuid (euid <-> uid)");
|
||||
|
||||
if (setregid (getegid (), getgid ()))
|
||||
glibtop_error_io ("setregid (egid <-> gid)");
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "Parent ID: (%d, %d) - (%d, %d)\n",
|
||||
getuid (), geteuid (), getgid (), getegid ());
|
||||
#endif
|
||||
|
||||
if ((geteuid () == 0) || (getuid () == 0)) {
|
||||
if (setreuid (0, 0))
|
||||
glibtop_error_io ("setreuid (root)");
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "Parent ID: (%d, %d) - (%d, %d)\n",
|
||||
getuid (), geteuid (), getgid (), getegid ());
|
||||
#endif
|
||||
|
||||
if (geteuid () == 0) {
|
||||
if (setregid (SERVER_GID, SERVER_GID))
|
||||
glibtop_error_io ("setregid (SERVER_GID)");
|
||||
if (setreuid (SERVER_UID, SERVER_UID))
|
||||
glibtop_error_io ("setreuid (SERVER_UID)");
|
||||
} else {
|
||||
if (setreuid (geteuid (), geteuid ()))
|
||||
glibtop_error_io ("setreuid (euid)");
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "Parent ID: (%d, %d) - (%d, %d)\n",
|
||||
getuid (), geteuid (), getgid (), getegid ());
|
||||
#endif
|
||||
|
||||
#ifdef INTERNET_DOMAIN_SOCKETS
|
||||
/* get a internet domain socket to listen on. */
|
||||
ils = internet_init ();
|
||||
#endif
|
||||
|
||||
glibtop_set_parameter_l (server, GLIBTOP_PARAM_METHOD,
|
||||
&method, sizeof (method));
|
||||
|
||||
glibtop_set_parameter_l (server, GLIBTOP_PARAM_FEATURES,
|
||||
&features, sizeof (features));
|
||||
|
||||
glibtop_init_r (&server, 0, 0);
|
||||
|
||||
}
|
||||
|
||||
while (1) {
|
||||
fd_set rmask;
|
||||
int ret;
|
||||
|
||||
while ((ret = wait3 (NULL, WNOHANG, NULL)) != 0) {
|
||||
if ((ret == -1) && (errno == ECHILD))
|
||||
break;
|
||||
|
||||
if ((ret == -1) && ((errno == EAGAIN)))
|
||||
continue;
|
||||
if (ret > 0)
|
||||
fprintf (stderr, "Child %d exited.\n", ret);
|
||||
else
|
||||
glibtop_warn_io ("wait3: %d", ret);
|
||||
}
|
||||
|
||||
FD_ZERO (&rmask);
|
||||
|
||||
/* Only the child accepts connections from standard
|
||||
* input made by its parent. */
|
||||
|
||||
if (pid == 0)
|
||||
FD_SET (fileno (stdin), &rmask);
|
||||
|
||||
if (uls >= 0)
|
||||
FD_SET (uls, &rmask);
|
||||
if (ils >= 0)
|
||||
FD_SET (ils, &rmask);
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "Server ready and waiting for connections.\n");
|
||||
#endif
|
||||
|
||||
if (select (max2 (fileno (stdin), max2 (uls, ils)) + 1, &rmask,
|
||||
(fd_set *) NULL, (fd_set *) NULL,
|
||||
(struct timeval *) NULL) < 0) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
glibtop_error_io ("select");
|
||||
}
|
||||
|
||||
#ifdef UNIX_DOMAIN_SOCKETS
|
||||
if (uls > 0 && FD_ISSET (uls, &rmask))
|
||||
handle_unix_request (uls);
|
||||
#endif
|
||||
|
||||
#ifdef INTERNET_DOMAIN_SOCKETS
|
||||
if (ils > 0 && FD_ISSET (ils, &rmask))
|
||||
handle_internet_request (ils);
|
||||
#endif
|
||||
|
||||
if (FD_ISSET (fileno (stdin), &rmask))
|
||||
handle_child_connection (fileno (stdin));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
311
src/daemon/main.c
Normal file
311
src/daemon/main.c
Normal file
@@ -0,0 +1,311 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the Gnome Top Library.
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
The Gnome Top Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The Gnome Top Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <glibtop/gnuserv.h>
|
||||
|
||||
#include <glibtop/open.h>
|
||||
#include <glibtop/union.h>
|
||||
#include <glibtop/xmalloc.h>
|
||||
#include <glibtop/version.h>
|
||||
#include <glibtop/command.h>
|
||||
#include <glibtop/parameter.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <locale.h>
|
||||
|
||||
#undef REAL_DEBUG
|
||||
#define PARENT_DEBUG
|
||||
|
||||
#define MSG_BUFSZ sizeof (struct _glibtop_ipc_message)
|
||||
#define MSG_MSGSZ (MSG_BUFSZ - sizeof (long))
|
||||
|
||||
#if defined(HAVE_GETDTABLESIZE)
|
||||
#define GET_MAX_FDS() getdtablesize()
|
||||
#else
|
||||
/* Fallthrough case - please add other #elif cases above
|
||||
for different OS's as necessary */
|
||||
#define GET_MAX_FDS() 256
|
||||
#endif
|
||||
|
||||
extern void handle_slave_command __P((glibtop_command *, glibtop_response *, const void *));
|
||||
|
||||
#define _offset_union(p) ((char *) &resp->u.p - (char *) resp)
|
||||
#define _offset_data(p) _offset_union (data.p)
|
||||
|
||||
static void do_output __P((int, glibtop_response *, off_t, size_t, const void *));
|
||||
static int do_read __P((int, void *, size_t));
|
||||
|
||||
static void
|
||||
do_output (int s, glibtop_response *resp, off_t offset,
|
||||
size_t data_size, const void *data)
|
||||
{
|
||||
#ifdef REAL_DEBUG
|
||||
fprintf (stderr, "Really writing %d bytes at offset %lu.\n",
|
||||
sizeof (glibtop_response), offset);
|
||||
#endif
|
||||
|
||||
resp->offset = offset;
|
||||
resp->data_size = data_size;
|
||||
|
||||
if (send (s, resp, sizeof (glibtop_response), 0) < 0)
|
||||
glibtop_warn_io ("send");
|
||||
|
||||
if (resp->data_size) {
|
||||
#ifdef REAL_DEBUG
|
||||
fprintf (stderr, "Writing %d bytes of data.\n", resp->data_size);
|
||||
#endif
|
||||
|
||||
if (send (s, data, resp->data_size, 0) , 0)
|
||||
glibtop_warn_io ("send");
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
do_read (int s, void *ptr, size_t total_size)
|
||||
{
|
||||
int nread;
|
||||
size_t already_read = 0, remaining = total_size;
|
||||
|
||||
while (already_read < total_size) {
|
||||
if (s)
|
||||
nread = recv (s, ptr, remaining, 0);
|
||||
else
|
||||
nread = read (0, ptr, remaining);
|
||||
|
||||
if ((already_read == 0) && (nread == 0)) {
|
||||
glibtop_warn ("pid %d received eof.", getpid ());
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (nread <= 0) {
|
||||
glibtop_warn_io ("recv");
|
||||
return 0;
|
||||
}
|
||||
|
||||
already_read += nread;
|
||||
remaining -= nread;
|
||||
(char *) ptr += nread;
|
||||
|
||||
#ifdef REAL_DEBUG
|
||||
fprintf (stderr, "READ (%d): %d - %d - %d\n",
|
||||
nread, already_read, remaining, total_size);
|
||||
#endif
|
||||
}
|
||||
|
||||
return already_read;
|
||||
}
|
||||
|
||||
void
|
||||
handle_parent_connection (int s)
|
||||
{
|
||||
glibtop *server = glibtop_global_server;
|
||||
glibtop_response _resp, *resp = &_resp;
|
||||
glibtop_command _cmnd, *cmnd = &_cmnd;
|
||||
char parameter [BUFSIZ];
|
||||
pid_t pid;
|
||||
void *ptr;
|
||||
|
||||
fprintf (stderr, "Parent features = %lu\n", glibtop_server_features);
|
||||
|
||||
while (do_read (s, &cmnd, sizeof (glibtop_command))) {
|
||||
#ifdef PARENT_DEBUG
|
||||
fprintf (stderr, "Parent (%d) received command %d from client.\n",
|
||||
getpid (), cmnd->command);
|
||||
#endif
|
||||
|
||||
if (cmnd->data_size >= BUFSIZ) {
|
||||
glibtop_warn ("Client sent %d bytes, but buffer is %d", cmnd->size, BUFSIZ);
|
||||
return;
|
||||
}
|
||||
|
||||
memset (parameter, 0, sizeof (parameter));
|
||||
|
||||
if (cmnd->data_size) {
|
||||
#ifdef PARENT_DEBUG
|
||||
fprintf (stderr, "Client has %d bytes of data.\n", cmnd->data_size);
|
||||
#endif
|
||||
|
||||
do_read (s, parameter, cmnd->data_size);
|
||||
|
||||
} else if (cmnd->size) {
|
||||
memcpy (parameter, cmnd->parameter, cmnd->size);
|
||||
}
|
||||
|
||||
switch (cmnd->command) {
|
||||
case GLIBTOP_CMND_QUIT:
|
||||
do_output (s, resp, 0, 0, NULL);
|
||||
|
||||
fprintf (stderr, "Sending QUIT command (%d).\n",
|
||||
server->socket);
|
||||
|
||||
glibtop_call_l (server, GLIBTOP_CMND_QUIT,
|
||||
0, NULL, 0, NULL);
|
||||
|
||||
fprintf (stderr, "Done sending QUIT command (%d).\n",
|
||||
server->socket);
|
||||
|
||||
close (server->socket);
|
||||
return;
|
||||
case GLIBTOP_CMND_SYSDEPS:
|
||||
resp->u.sysdeps.features = GLIBTOP_SYSDEPS_ALL;
|
||||
do_output (s, resp, _offset_union (sysdeps), 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_CPU:
|
||||
glibtop_get_cpu_l (server, &resp->u.data.cpu);
|
||||
do_output (s, resp, _offset_data (cpu), 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_MEM:
|
||||
glibtop_get_mem_l (server, &resp->u.data.mem);
|
||||
do_output (s, resp, _offset_data (mem), 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_SWAP:
|
||||
glibtop_get_swap_l (server, &resp->u.data.swap);
|
||||
do_output (s, resp, _offset_data (swap), 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_UPTIME:
|
||||
glibtop_get_uptime_l (server, &resp->u.data.uptime);
|
||||
do_output (s, resp, _offset_data (uptime), 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_LOADAVG:
|
||||
glibtop_get_loadavg_l (server, &resp->u.data.loadavg);
|
||||
do_output (s, resp, _offset_data (loadavg), 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_SHM_LIMITS:
|
||||
glibtop_get_shm_limits_l (server, &resp->u.data.shm_limits);
|
||||
do_output (s, resp, _offset_data (shm_limits), 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_MSG_LIMITS:
|
||||
glibtop_get_msg_limits_l (server, &resp->u.data.msg_limits);
|
||||
do_output (s, resp, _offset_data (msg_limits), 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_SEM_LIMITS:
|
||||
glibtop_get_sem_limits_l (server, &resp->u.data.sem_limits);
|
||||
do_output (s, resp, _offset_data (sem_limits), 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROCLIST:
|
||||
ptr = glibtop_get_proclist_l (server, &resp->u.data.proclist);
|
||||
do_output (s, resp, _offset_data (proclist),
|
||||
resp->u.data.proclist.total, ptr);
|
||||
glibtop_free_r (server, ptr);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROC_STATE:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_state_l
|
||||
(server, &resp->u.data.proc_state, pid);
|
||||
do_output (s, resp, _offset_data (proc_state), 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROC_UID:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_uid_l
|
||||
(server, &resp->u.data.proc_uid, pid);
|
||||
do_output (s, resp, _offset_data (proc_uid), 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROC_MEM:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_mem_l
|
||||
(server, &resp->u.data.proc_mem, pid);
|
||||
do_output (s, resp, _offset_data (proc_mem), 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROC_TIME:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_time_l
|
||||
(server, &resp->u.data.proc_time, pid);
|
||||
do_output (s, resp, _offset_data (proc_time), 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROC_SIGNAL:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_signal_l
|
||||
(server, &resp->u.data.proc_signal, pid);
|
||||
do_output (s, resp, _offset_data (proc_signal), 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROC_KERNEL:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_kernel_l
|
||||
(server, &resp->u.data.proc_kernel, pid);
|
||||
do_output (s, resp, _offset_data (proc_kernel), 0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROC_SEGMENT:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_segment_l
|
||||
(server, &resp->u.data.proc_segment, pid);
|
||||
do_output (s, resp, _offset_data (proc_segment), 0, NULL);
|
||||
break;
|
||||
default:
|
||||
glibtop_warn ("Parent received unknown command %u",
|
||||
cmnd->command);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
handle_child_connection (int s)
|
||||
{
|
||||
glibtop *server = glibtop_global_server;
|
||||
glibtop_response _resp, *resp = &_resp;
|
||||
glibtop_command _cmnd, *cmnd = &_cmnd;
|
||||
char parameter [BUFSIZ];
|
||||
void *ptr;
|
||||
|
||||
while (do_read (s, cmnd, sizeof (glibtop_command))) {
|
||||
#ifdef CHILD_DEBUG
|
||||
fprintf (stderr, "Child (%d - %d) received command "
|
||||
"%d from client.\n", getpid (), s, cmnd->command);
|
||||
#endif
|
||||
|
||||
if (cmnd->data_size >= BUFSIZ) {
|
||||
glibtop_warn ("Client sent %d bytes, but buffer is %d", cmnd->size, BUFSIZ);
|
||||
return;
|
||||
}
|
||||
|
||||
memset (parameter, 0, sizeof (parameter));
|
||||
|
||||
if (cmnd->data_size) {
|
||||
#ifdef CHILD_DEBUG
|
||||
fprintf (stderr, "Client has %d bytes of data.\n", cmnd->data_size);
|
||||
#endif
|
||||
|
||||
do_read (s, parameter, cmnd->data_size);
|
||||
|
||||
} else if (cmnd->size) {
|
||||
memcpy (parameter, cmnd->parameter, cmnd->size);
|
||||
}
|
||||
|
||||
switch (cmnd->command) {
|
||||
case GLIBTOP_CMND_QUIT:
|
||||
do_output (s, resp, 0, 0, NULL);
|
||||
return;
|
||||
#if GLIBTOP_SUID_PROCLIST
|
||||
case GLIBTOP_CMND_PROCLIST:
|
||||
ptr = glibtop_get_proclist_p
|
||||
(server, &resp->u.data.proclist);
|
||||
do_output (s, resp, _offset_data (proclist),
|
||||
resp->u.data.proclist.total, ptr);
|
||||
glibtop_free_r (server, ptr);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
handle_slave_command (cmnd, resp, parameter);
|
||||
do_output (s, resp, resp->offset, 0, NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
40
src/daemon/server_config.h.in
Normal file
40
src/daemon/server_config.h.in
Normal file
@@ -0,0 +1,40 @@
|
||||
/* This is a sample config file.
|
||||
*
|
||||
* Copy this file to 'server_config.h' and edit it to fix your needs !
|
||||
*
|
||||
* You can also use the 'server_config.pl' script to create 'server_config.h'.
|
||||
*
|
||||
/
|
||||
|
||||
#define SERVER_PORT 42800 /* Port the server should listen on. */
|
||||
|
||||
/* NOTE: On RedHat 5.1 nobody is UID 99 and GID 99.
|
||||
*
|
||||
* The 'server_config.pl' script will use the real UID and GID of 'nobody'
|
||||
* on your system as default.
|
||||
*
|
||||
* NOTE: This only works if the server is started as root or SUID to root.
|
||||
*/
|
||||
|
||||
#define SERVER_UID 99 /* User ID the server should run as. */
|
||||
#define SERVER_GID 99 /* Group ID the server should run as. */
|
||||
|
||||
#define HOST_TABLE_ENTRIES 1 /* Number of entries in the host table. */
|
||||
|
||||
/* List of hosts that should be authorized to connect to the server.
|
||||
*
|
||||
* SECURITY WARNING:
|
||||
* Enabling access for a particular hosts means the ALL USERS on this host will
|
||||
* be allowed to connect to the server !
|
||||
*
|
||||
* If you want security, let this table empty and use the 'xauth' method instead.
|
||||
* Look at the manpage of gnuserv (1) as shipped with GNU Emacs for more details
|
||||
* about security. The server uses the same security mechanisms like gnuserv from
|
||||
* XEmacs 20.3.
|
||||
*/
|
||||
|
||||
const char *permitted_host_names [HOST_TABLE_ENTRIES] =
|
||||
{ "localhost" };
|
||||
|
||||
unsigned long permitted_hosts [HOST_TABLE_ENTRIES];
|
||||
|
111
src/daemon/server_config.pl
Executable file
111
src/daemon/server_config.pl
Executable file
@@ -0,0 +1,111 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
require 5.004;
|
||||
use strict;
|
||||
|
||||
print "Enter port the server should listen on [42800]: ";
|
||||
|
||||
my $port = <stdin>; chop $port;
|
||||
$port = 42800 unless $port =~ /^\d+$/;
|
||||
|
||||
print "\nUser name or UID to run as [nobody]: ";
|
||||
|
||||
my $user = <stdin>; chop $user; $user = 'nobody' if $user eq '';
|
||||
|
||||
my ($login, $pass, $uid, $gid);
|
||||
|
||||
unless ($user =~ /^\d+$/) {
|
||||
($login, $pass, $uid, $gid) = getpwnam ($user) or
|
||||
die "User '$user' not in passwd file.";
|
||||
}
|
||||
|
||||
my $g_default = (defined $gid) ? $gid : 'nogroup';
|
||||
|
||||
print "Group name or GID to run as [$g_default]: ";
|
||||
|
||||
my $group = <stdin>; chop $group; $group = $g_default if $group eq '';
|
||||
|
||||
unless ($group =~ /^\d+$/) {
|
||||
$gid = getgrnam ($group) or
|
||||
die "Group '$group' not in group file.";
|
||||
}
|
||||
|
||||
print "\nEnter list of hosts which should be authorized to";
|
||||
print "\nconnect to the server (terminate with a blank line):\n\n";
|
||||
|
||||
print "SECURITY WARNING:\n";
|
||||
print " Enabling access for a particular hosts means the ALL USERS on this host will\n";
|
||||
print " be allowed to connect to the server !\n\n";
|
||||
|
||||
print " If you want security, let this table empty and use the 'xauth' method instead.\n";
|
||||
print " Look at the manpage of gnuserv (1) as shipped with GNU Emacs for more details\n";
|
||||
print " about security. The server uses the same security mechanisms like gnuserv from\n";
|
||||
print " XEmacs 20.3\n\n";
|
||||
|
||||
my @hosts = ();
|
||||
my @host_addrs = ();
|
||||
my @host_names = ();
|
||||
|
||||
while (1) {
|
||||
print "Host: ";
|
||||
|
||||
my $host = <stdin>; chop $host;
|
||||
last if $host eq '';
|
||||
|
||||
my ($name,$aliases,$addrtype,$length,@addrs) = gethostbyname ($host) or
|
||||
die "gethostbyname (): Can't resolve '$host'";
|
||||
|
||||
my ($a,$b,$c,$d) = unpack('C4',$addrs[0]);
|
||||
|
||||
push @hosts, sprintf ("0x%02X%02X%02X%02X", $d, $c, $b, $a);
|
||||
push @host_addrs, sprintf ("%d.%d.%d.%d", $a, $b, $c, $d);
|
||||
push @host_names, $name;
|
||||
};
|
||||
|
||||
print "\n";
|
||||
print "This is your config:\n";
|
||||
print "====================\n\n";
|
||||
|
||||
printf qq[%-30s: %d\n\n], 'Port', $port;
|
||||
printf qq[%-30s: %d\n], 'UID', $uid;
|
||||
printf qq[%-30s: %d\n\n], 'GID', $gid;
|
||||
|
||||
foreach (0..$#hosts) {
|
||||
printf qq[%-30s (%s - %s)\n], $host_names[$_], $hosts[$_], $host_addrs [$_];
|
||||
}
|
||||
|
||||
print "\n";
|
||||
|
||||
print "Accept? (yes/no) ";
|
||||
|
||||
my $accept = <stdin>; chop $accept;
|
||||
|
||||
exit unless $accept eq 'yes';
|
||||
|
||||
print "\n";
|
||||
|
||||
open CONFIG, "> server_config.h" or
|
||||
die "open (server_config.h): $!";
|
||||
select CONFIG;
|
||||
|
||||
printf qq[\#define SERVER_PORT\t\t%d\n\n], $port;
|
||||
|
||||
printf qq[\#define SERVER_UID\t\t%d\n], $uid;
|
||||
printf qq[\#define SERVER_GID\t\t%d\n\n], $gid;
|
||||
|
||||
printf qq[\#define HOST_TABLE_ENTRIES\t%d\n\n], $#hosts + 1;
|
||||
|
||||
foreach (@host_names) {
|
||||
$_ = qq["$_"];
|
||||
}
|
||||
|
||||
printf qq[const char *permitted_host_names [HOST_TABLE_ENTRIES] = \n];
|
||||
printf qq[{ %s };\n\n], join (', ', @host_names);
|
||||
|
||||
printf qq[unsigned long permitted_hosts [HOST_TABLE_ENTRIES];\n];
|
||||
|
||||
close CONFIG;
|
||||
|
||||
select STDOUT;
|
||||
|
||||
print "Your config has successfully been written to 'server_config.h'.\n";
|
155
src/daemon/slave.c
Normal file
155
src/daemon/slave.c
Normal file
@@ -0,0 +1,155 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the Gnome Top Library.
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
The Gnome Top Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The Gnome Top Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/gnuserv.h>
|
||||
|
||||
#include <glibtop/open.h>
|
||||
#include <glibtop/union.h>
|
||||
|
||||
#include <glibtop/command.h>
|
||||
#include <glibtop/parameter.h>
|
||||
|
||||
#define _offset_union(p) ((char *) &resp->u.p - (char *) resp)
|
||||
#define _offset_data(p) _offset_union (data.p)
|
||||
|
||||
void
|
||||
handle_slave_command (glibtop_command *cmnd, glibtop_response *resp,
|
||||
const void *parameter)
|
||||
{
|
||||
glibtop *server = glibtop_global_server;
|
||||
pid_t pid;
|
||||
|
||||
switch (cmnd->command) {
|
||||
case GLIBTOP_CMND_SYSDEPS:
|
||||
resp->u.sysdeps.features = glibtop_server_features;
|
||||
resp->offset = _offset_union (sysdeps);
|
||||
break;
|
||||
#if GLIBTOP_SUID_CPU
|
||||
case GLIBTOP_CMND_CPU:
|
||||
glibtop_get_cpu_p (server, &resp->u.data.cpu);
|
||||
resp->offset = _offset_data (cpu);
|
||||
break;
|
||||
#endif
|
||||
#if GLIBTOP_SUID_MEM
|
||||
case GLIBTOP_CMND_MEM:
|
||||
glibtop_get_mem_p (server, &resp->u.data.mem);
|
||||
resp->offset = _offset_data (mem);
|
||||
break;
|
||||
#endif
|
||||
#if GLIBTOP_SUID_SWAP
|
||||
case GLIBTOP_CMND_SWAP:
|
||||
glibtop_get_swap_p (server, &resp->u.data.swap);
|
||||
resp->offset = _offset_data (swap);
|
||||
break;
|
||||
#endif
|
||||
#if GLIBTOP_SUID_UPTIME
|
||||
case GLIBTOP_CMND_UPTIME:
|
||||
glibtop_get_uptime_p (server, &resp->u.data.uptime);
|
||||
resp->offset = _offset_data (uptime);
|
||||
break;
|
||||
#endif
|
||||
#if GLIBTOP_SUID_LOADAVG
|
||||
case GLIBTOP_CMND_LOADAVG:
|
||||
glibtop_get_loadavg_p (server, &resp->u.data.loadavg);
|
||||
resp->offset = _offset_data (loadavg);
|
||||
break;
|
||||
#endif
|
||||
#if GLIBTOP_SUID_SHM_LIMITS
|
||||
case GLIBTOP_CMND_SHM_LIMITS:
|
||||
glibtop_get_shm_limits_p (server, &resp->u.data.shm_limits);
|
||||
resp->offset = _offset_data (shm_limits);
|
||||
break;
|
||||
#endif
|
||||
#if GLIBTOP_SUID_MSG_LIMITS
|
||||
case GLIBTOP_CMND_MSG_LIMITS:
|
||||
glibtop_get_msg_limits_p (server, &resp->u.data.msg_limits);
|
||||
resp->offset = _offset_data (msg_limits);
|
||||
break;
|
||||
#endif
|
||||
#if GLIBTOP_SUID_SEM_LIMITS
|
||||
case GLIBTOP_CMND_SEM_LIMITS:
|
||||
glibtop_get_sem_limits_p (server, &resp->u.data.sem_limits);
|
||||
resp->offset = _offset_data (sem_limits);
|
||||
break;
|
||||
#endif
|
||||
#if GLIBTOP_SUID_PROC_STATE
|
||||
case GLIBTOP_CMND_PROC_STATE:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_state_p
|
||||
(server, &resp->u.data.proc_state, pid);
|
||||
resp->offset = _offset_data (proc_state);
|
||||
break;
|
||||
#endif
|
||||
#if GLIBTOP_SUID_PROC_UID
|
||||
case GLIBTOP_CMND_PROC_UID:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_uid_p
|
||||
(server, &resp->u.data.proc_uid, pid);
|
||||
resp->offset = _offset_data (proc_uid);
|
||||
break;
|
||||
#endif
|
||||
#if GLIBTOP_SUID_PROC_MEM
|
||||
case GLIBTOP_CMND_PROC_MEM:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_mem_p
|
||||
(server, &resp->u.data.proc_mem, pid);
|
||||
resp->offset = _offset_data (proc_mem);
|
||||
break;
|
||||
#endif
|
||||
#if GLIBTOP_SUID_PROC_TIME
|
||||
case GLIBTOP_CMND_PROC_TIME:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_time_p
|
||||
(server, &resp->u.data.proc_time, pid);
|
||||
resp->offset = _offset_data (proc_time);
|
||||
break;
|
||||
#endif
|
||||
#if GLIBTOP_SUID_PROC_SIGNAL
|
||||
case GLIBTOP_CMND_PROC_SIGNAL:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_signal_p
|
||||
(server, &resp->u.data.proc_signal, pid);
|
||||
resp->offset = _offset_data (proc_signal);
|
||||
break;
|
||||
#endif
|
||||
#if GLIBTOP_SUID_PROC_KERNEL
|
||||
case GLIBTOP_CMND_PROC_KERNEL:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_kernel_p
|
||||
(server, &resp->u.data.proc_kernel, pid);
|
||||
resp->offset = _offset_data (proc_kernel);
|
||||
break;
|
||||
#endif
|
||||
#if GLIBTOP_SUID_PROC_SEGMENT
|
||||
case GLIBTOP_CMND_PROC_SEGMENT:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_segment_p
|
||||
(server, &resp->u.data.proc_segment, pid);
|
||||
resp->offset = _offset_data (proc_segment);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
glibtop_error ("Child received unknown command %u",
|
||||
cmnd->command);
|
||||
break;
|
||||
}
|
||||
}
|
5
src/proxy/.cvsignore
Normal file
5
src/proxy/.cvsignore
Normal file
@@ -0,0 +1,5 @@
|
||||
.deps
|
||||
.libs
|
||||
Makefile
|
||||
Makefile.in
|
||||
gtop_proxy
|
16
src/proxy/Makefile.am
Normal file
16
src/proxy/Makefile.am
Normal file
@@ -0,0 +1,16 @@
|
||||
LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@
|
||||
|
||||
INCLUDES = -I$(top_builddir) -I$(top_srcdir) @machine_incs@ \
|
||||
-I$(top_srcdir)/include -I$(top_srcdir)/intl @GUILE_INCS@ \
|
||||
-DGTOPLOCALEDIR=\"$(datadir)/locale\" -D_GNU_SOURCE
|
||||
|
||||
CFLAGS = -Wall -W @CFLAGS@ -DGTOP_SERVER=\""@LIBGTOP_SERVER@"\"
|
||||
|
||||
bin_PROGRAMS = gtop_proxy
|
||||
|
||||
gtop_proxy_SOURCES = main.c output.c version.c
|
||||
gtop_proxy_LDADD = $(top_builddir)/lib/libgtop.la \
|
||||
$(top_builddir)/sysdeps/common/libgtop_common.la \
|
||||
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \
|
||||
@INTLLIBS@ @LIBSUPPORT@ @libs_xauth@
|
||||
gtop_proxy_LDFLAGS = -static
|
234
src/proxy/main.c
Normal file
234
src/proxy/main.c
Normal file
@@ -0,0 +1,234 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the Gnome Top Library.
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
The Gnome Top Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The Gnome Top Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <glibtop/command.h>
|
||||
#include <glibtop/version.h>
|
||||
#include <glibtop/xmalloc.h>
|
||||
#include <glibtop/union.h>
|
||||
#include <glibtop/open.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <locale.h>
|
||||
|
||||
#if defined(HAVE_GETDTABLESIZE)
|
||||
#define GET_MAX_FDS() getdtablesize()
|
||||
#else
|
||||
/* Fallthrough case - please add other #elif cases above
|
||||
for different OS's as necessary */
|
||||
#define GET_MAX_FDS() 256
|
||||
#endif
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
pid_t pid;
|
||||
int fd, max_fd, nread;
|
||||
size_t size, dsize;
|
||||
char parameter [BUFSIZ];
|
||||
glibtop_union data;
|
||||
glibtop_command cmnd;
|
||||
glibtop_sysdeps sysdeps;
|
||||
glibtop server;
|
||||
void *ptr;
|
||||
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, GTOPLOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
glibtop_version ();
|
||||
|
||||
glibtop_open_l (&server, argv [0], 0, GLIBTOP_OPEN_NO_OVERRIDE);
|
||||
|
||||
/* close all file descriptors except ones used by the pipes (0 and 1). */
|
||||
max_fd = GET_MAX_FDS();
|
||||
for(fd = 3 /* The first fd after the pipes */; fd < max_fd; fd++)
|
||||
close(fd);
|
||||
|
||||
while(1) {
|
||||
/* block on read from client */
|
||||
/* fprintf (stderr, "waiting for input ...\n"); */
|
||||
nread = read (0, &size, sizeof (size_t));
|
||||
|
||||
/* will return 0 if parent exits. */
|
||||
|
||||
if (nread == 0)
|
||||
_exit(0);
|
||||
|
||||
if (nread != sizeof (size_t))
|
||||
_exit(1);
|
||||
|
||||
if (size != sizeof (glibtop_command))
|
||||
_exit(2);
|
||||
|
||||
nread = read (0, &cmnd, size);
|
||||
|
||||
/* will return 0 if parent exits. */
|
||||
|
||||
if (nread == 0)
|
||||
_exit(0);
|
||||
|
||||
if (nread < 0)
|
||||
_exit(1);
|
||||
|
||||
nread = read (0, &dsize, sizeof (size_t));
|
||||
|
||||
/* will return 0 if parent exits. */
|
||||
|
||||
if (nread == 0)
|
||||
_exit(0);
|
||||
|
||||
if (nread < 0)
|
||||
_exit(1);
|
||||
|
||||
if (dsize >= BUFSIZ)
|
||||
_exit(3);
|
||||
|
||||
memset (parameter, 0, sizeof (parameter));
|
||||
|
||||
if (dsize) {
|
||||
nread = read (0, parameter, dsize);
|
||||
|
||||
/* will return 0 if parent exits. */
|
||||
|
||||
if (nread == 0)
|
||||
_exit(0);
|
||||
|
||||
if (nread < 0)
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
switch (cmnd.command) {
|
||||
case GLIBTOP_CMND_SYSDEPS:
|
||||
sysdeps.features = GLIBTOP_SYSDEPS_ALL;
|
||||
glibtop_output (sizeof (glibtop_sysdeps), &sysdeps);
|
||||
glibtop_output (0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_CPU:
|
||||
glibtop_get_cpu_l (&server, &data.cpu);
|
||||
glibtop_output (sizeof (glibtop_cpu), &data.cpu);
|
||||
glibtop_output (0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_MEM:
|
||||
glibtop_get_mem_l (&server, &data.mem);
|
||||
glibtop_output (sizeof (glibtop_mem), &data.mem);
|
||||
glibtop_output (0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_SWAP:
|
||||
glibtop_get_swap_l (&server, &data.swap);
|
||||
glibtop_output (sizeof (glibtop_swap), &data.swap);
|
||||
glibtop_output (0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_UPTIME:
|
||||
glibtop_get_uptime_l (&server, &data.uptime);
|
||||
glibtop_output (sizeof (glibtop_uptime), &data.uptime);
|
||||
glibtop_output (0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_LOADAVG:
|
||||
glibtop_get_loadavg_l (&server, &data.loadavg);
|
||||
glibtop_output (sizeof (glibtop_loadavg), &data.loadavg);
|
||||
glibtop_output (0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_SHM_LIMITS:
|
||||
glibtop_get_shm_limits_l (&server, &data.shm_limits);
|
||||
glibtop_output (sizeof (glibtop_shm_limits),
|
||||
&data.shm_limits);
|
||||
glibtop_output (0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_MSG_LIMITS:
|
||||
glibtop_get_msg_limits_l (&server, &data.msg_limits);
|
||||
glibtop_output (sizeof (glibtop_msg_limits),
|
||||
&data.msg_limits);
|
||||
glibtop_output (0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_SEM_LIMITS:
|
||||
glibtop_get_sem_limits_l (&server, &data.sem_limits);
|
||||
glibtop_output (sizeof (glibtop_sem_limits),
|
||||
&data.sem_limits);
|
||||
glibtop_output (0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROCLIST:
|
||||
ptr = glibtop_get_proclist_l (&server, &data.proclist);
|
||||
glibtop_output (sizeof (glibtop_proclist),
|
||||
&data.proclist);
|
||||
glibtop_output (data.proclist.total, ptr);
|
||||
glibtop_free_r (&server, ptr);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROC_STATE:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_state_l
|
||||
(&server, &data.proc_state, pid);
|
||||
glibtop_output (sizeof (glibtop_proc_state),
|
||||
&data.proc_state);
|
||||
glibtop_output (0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROC_UID:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_uid_l
|
||||
(&server, &data.proc_uid, pid);
|
||||
glibtop_output (sizeof (glibtop_proc_uid),
|
||||
&data.proc_uid);
|
||||
glibtop_output (0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROC_MEM:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_mem_l
|
||||
(&server, &data.proc_mem, pid);
|
||||
glibtop_output (sizeof (glibtop_proc_mem),
|
||||
&data.proc_mem);
|
||||
glibtop_output (0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROC_TIME:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_time_l
|
||||
(&server, &data.proc_time, pid);
|
||||
glibtop_output (sizeof (glibtop_proc_time),
|
||||
&data.proc_time);
|
||||
glibtop_output (0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROC_SIGNAL:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_signal_l
|
||||
(&server, &data.proc_signal, pid);
|
||||
glibtop_output (sizeof (glibtop_proc_signal),
|
||||
&data.proc_signal);
|
||||
glibtop_output (0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROC_KERNEL:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_kernel_l
|
||||
(&server, &data.proc_kernel, pid);
|
||||
glibtop_output (sizeof (glibtop_proc_kernel),
|
||||
&data.proc_kernel);
|
||||
glibtop_output (0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROC_SEGMENT:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_segment_l
|
||||
(&server, &data.proc_segment, pid);
|
||||
glibtop_output (sizeof (glibtop_proc_segment),
|
||||
&data.proc_segment);
|
||||
glibtop_output (0, NULL);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
_exit(0);
|
||||
}
|
@@ -19,14 +19,13 @@
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <glibtop/cpu.h>
|
||||
#include <glibtop/command.h>
|
||||
|
||||
/* Provides information about cpu usage. */
|
||||
#include <glibtop/output.h>
|
||||
|
||||
void
|
||||
glibtop_get_cpu__r (glibtop *server, glibtop_cpu *buf)
|
||||
glibtop_output (size_t size, const void *buf)
|
||||
{
|
||||
glibtop_init__r (&server);
|
||||
glibtop_call__r (server, GLIBTOP_CMND_CPU, 0, NULL, sizeof (glibtop_cpu), buf);
|
||||
if (write (1, &size, sizeof (size_t)) < 0)
|
||||
_exit (2);
|
||||
if (write (1, buf, size) < 0)
|
||||
_exit (2);
|
||||
}
|
@@ -19,14 +19,13 @@
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <glibtop/mem.h>
|
||||
#include <glibtop/command.h>
|
||||
|
||||
/* Provides information about memory usage. */
|
||||
#include <glibtop/version.h>
|
||||
|
||||
void
|
||||
glibtop_get_mem__r (glibtop *server, glibtop_mem *buf)
|
||||
glibtop_version (void)
|
||||
{
|
||||
glibtop_init__r (&server);
|
||||
glibtop_call__r (server, GLIBTOP_CMND_MEM, 0, NULL, sizeof (glibtop_mem), buf);
|
||||
char buffer [BUFSIZ];
|
||||
|
||||
sprintf (buffer, "%s server %s ready.\n", PACKAGE, VERSION);
|
||||
glibtop_output (strlen (buffer), buffer);
|
||||
}
|
@@ -74,7 +74,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
setreuid (uid, euid); setregid (gid, egid);
|
||||
|
||||
glibtop_open (&server, argv [0]);
|
||||
glibtop_open_r (&server, argv [0], 0, 0);
|
||||
|
||||
if (setreuid (euid, uid)) _exit (1);
|
||||
|
||||
@@ -142,112 +142,146 @@ int main(int argc, char *argv[])
|
||||
|
||||
switch (cmnd.command) {
|
||||
case GLIBTOP_CMND_SYSDEPS:
|
||||
glibtop_get_sysdeps__r (&server, &sysdeps);
|
||||
sysdeps.features = GLIBTOP_SYSDEPS_ALL;
|
||||
glibtop_output (sizeof (glibtop_sysdeps), &sysdeps);
|
||||
glibtop_output (0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_CPU:
|
||||
glibtop_get_cpu__r (&server, &data.cpu);
|
||||
#if GLIBTOP_SUID_CPU
|
||||
glibtop_get_cpu_p (&server, &data.cpu);
|
||||
#endif
|
||||
glibtop_output (sizeof (glibtop_cpu), &data.cpu);
|
||||
glibtop_output (0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_MEM:
|
||||
glibtop_get_mem__r (&server, &data.mem);
|
||||
#if GLIBTOP_SUID_MEM
|
||||
glibtop_get_mem_p (&server, &data.mem);
|
||||
#endif
|
||||
glibtop_output (sizeof (glibtop_mem), &data.mem);
|
||||
glibtop_output (0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_SWAP:
|
||||
glibtop_get_swap__r (&server, &data.swap);
|
||||
#if GLIBTOP_SUID_SWAP
|
||||
glibtop_get_swap_p (&server, &data.swap);
|
||||
#endif
|
||||
glibtop_output (sizeof (glibtop_swap), &data.swap);
|
||||
glibtop_output (0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_UPTIME:
|
||||
glibtop_get_uptime__r (&server, &data.uptime);
|
||||
#if GLIBTOP_SUID_UPTIME
|
||||
glibtop_get_uptime_p (&server, &data.uptime);
|
||||
#endif
|
||||
glibtop_output (sizeof (glibtop_uptime), &data.uptime);
|
||||
glibtop_output (0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_LOADAVG:
|
||||
glibtop_get_loadavg__r (&server, &data.loadavg);
|
||||
#if GLIBTOP_SUID_LOADAVG
|
||||
glibtop_get_loadavg_p (&server, &data.loadavg);
|
||||
#endif
|
||||
glibtop_output (sizeof (glibtop_loadavg), &data.loadavg);
|
||||
glibtop_output (0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_SHM_LIMITS:
|
||||
glibtop_get_shm_limits__r (&server, &data.shm_limits);
|
||||
#if GLIBTOP_SUID_SHM_LIMITS
|
||||
glibtop_get_shm_limits_p (&server, &data.shm_limits);
|
||||
#endif
|
||||
glibtop_output (sizeof (glibtop_shm_limits),
|
||||
&data.shm_limits);
|
||||
glibtop_output (0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_MSG_LIMITS:
|
||||
glibtop_get_msg_limits__r (&server, &data.msg_limits);
|
||||
#if GLIBTOP_SUID_MSG_LIMITS
|
||||
glibtop_get_msg_limits_p (&server, &data.msg_limits);
|
||||
#endif
|
||||
glibtop_output (sizeof (glibtop_msg_limits),
|
||||
&data.msg_limits);
|
||||
glibtop_output (0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_SEM_LIMITS:
|
||||
glibtop_get_sem_limits__r (&server, &data.sem_limits);
|
||||
#if GLIBTOP_SUID_SEM_LIMITS
|
||||
glibtop_get_sem_limits_p (&server, &data.sem_limits);
|
||||
#endif
|
||||
glibtop_output (sizeof (glibtop_sem_limits),
|
||||
&data.sem_limits);
|
||||
glibtop_output (0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROCLIST:
|
||||
ptr = glibtop_get_proclist__r (&server, &data.proclist);
|
||||
#if GLIBTOP_SUID_PROCLIST
|
||||
ptr = glibtop_get_proclist_p (&server, &data.proclist);
|
||||
#else
|
||||
ptr = NULL;
|
||||
#endif
|
||||
glibtop_output (sizeof (glibtop_proclist),
|
||||
&data.proclist);
|
||||
glibtop_output (data.proclist.total, ptr);
|
||||
glibtop_free__r (&server, ptr);
|
||||
glibtop_free_r (&server, ptr);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROC_STATE:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_state__r
|
||||
#if GLIBTOP_SUID_PROC_STATE
|
||||
glibtop_get_proc_state_p
|
||||
(&server, &data.proc_state, pid);
|
||||
#endif
|
||||
glibtop_output (sizeof (glibtop_proc_state),
|
||||
&data.proc_state);
|
||||
glibtop_output (0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROC_UID:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_uid__r
|
||||
#if GLIBTOP_SUID_PROC_UID
|
||||
glibtop_get_proc_uid_p
|
||||
(&server, &data.proc_uid, pid);
|
||||
#endif
|
||||
glibtop_output (sizeof (glibtop_proc_uid),
|
||||
&data.proc_uid);
|
||||
glibtop_output (0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROC_MEM:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_mem__r
|
||||
#if GLIBTOP_SUID_PROC_MEM
|
||||
glibtop_get_proc_mem_p
|
||||
(&server, &data.proc_mem, pid);
|
||||
#endif
|
||||
glibtop_output (sizeof (glibtop_proc_mem),
|
||||
&data.proc_mem);
|
||||
glibtop_output (0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROC_TIME:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_time__r
|
||||
#if GLIBTOP_SUID_PROC_TIME
|
||||
glibtop_get_proc_time_p
|
||||
(&server, &data.proc_time, pid);
|
||||
#endif
|
||||
glibtop_output (sizeof (glibtop_proc_time),
|
||||
&data.proc_time);
|
||||
glibtop_output (0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROC_SIGNAL:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_signal__r
|
||||
#if GLIBTOP_SUID_PROC_SIGNAL
|
||||
glibtop_get_proc_signal_p
|
||||
(&server, &data.proc_signal, pid);
|
||||
#endif
|
||||
glibtop_output (sizeof (glibtop_proc_signal),
|
||||
&data.proc_signal);
|
||||
glibtop_output (0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROC_KERNEL:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_kernel__r
|
||||
#if GLIBTOP_SUID_PROC_KERNEL
|
||||
glibtop_get_proc_kernel_p
|
||||
(&server, &data.proc_kernel, pid);
|
||||
#endif
|
||||
glibtop_output (sizeof (glibtop_proc_kernel),
|
||||
&data.proc_kernel);
|
||||
glibtop_output (0, NULL);
|
||||
break;
|
||||
case GLIBTOP_CMND_PROC_SEGMENT:
|
||||
memcpy (&pid, parameter, sizeof (pid_t));
|
||||
glibtop_get_proc_segment__r
|
||||
#if GLIBTOP_SUID_PROC_SEGMENT
|
||||
glibtop_get_proc_segment_p
|
||||
(&server, &data.proc_segment, pid);
|
||||
#endif
|
||||
glibtop_output (sizeof (glibtop_proc_segment),
|
||||
&data.proc_segment);
|
||||
glibtop_output (0, NULL);
|
||||
|
@@ -12,4 +12,4 @@ endif
|
||||
|
||||
SUBDIRS = @sysdeps_dir@ common $(names_SUBDIRS) $(guile_SUBDIRS)
|
||||
|
||||
DIST_SUBDIRS = common guile linux names osf1 stub sun4
|
||||
DIST_SUBDIRS = common guile linux kernel names osf1 stub sun4
|
||||
|
@@ -8,5 +8,4 @@ CFLAGS = -Wall -W @CFLAGS@
|
||||
|
||||
lib_LTLIBRARIES = libgtop_common.la
|
||||
|
||||
libgtop_common_la_SOURCES = sysdeps.c xmalloc.c error.c
|
||||
|
||||
libgtop_common_la_SOURCES = sysdeps.c xmalloc.c error.c gnuslib.c
|
||||
|
@@ -21,19 +21,64 @@
|
||||
|
||||
#include <glibtop/error.h>
|
||||
|
||||
#define DEFAULT_NAME "ERROR"
|
||||
|
||||
/* Prints error message and exits. */
|
||||
|
||||
void
|
||||
glibtop_error__r (glibtop *server, char *format, ...)
|
||||
glibtop_error_r (glibtop *server, char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start (ap, format);
|
||||
|
||||
fprintf (stderr, "%s: ", server->name);
|
||||
fprintf (stderr, "%s: ", server ? server->name : DEFAULT_NAME);
|
||||
vfprintf (stderr, format, ap);
|
||||
fprintf (stderr, "\n");
|
||||
|
||||
va_end (ap);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
void
|
||||
glibtop_error_io_r (glibtop *server, char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start (ap, format);
|
||||
|
||||
fprintf (stderr, "%s: ", server ? server->name : DEFAULT_NAME);
|
||||
vfprintf (stderr, format, ap);
|
||||
fprintf (stderr, ": %s\n", strerror (errno));
|
||||
|
||||
va_end (ap);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
void
|
||||
glibtop_warn_r (glibtop *server, char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start (ap, format);
|
||||
|
||||
fprintf (stderr, "%s: ", server ? server->name : DEFAULT_NAME);
|
||||
vfprintf (stderr, format, ap);
|
||||
fprintf (stderr, "\n");
|
||||
|
||||
va_end (ap);
|
||||
}
|
||||
|
||||
void
|
||||
glibtop_warn_io_r (glibtop *server, char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start (ap, format);
|
||||
|
||||
fprintf (stderr, "%s: ", server ? server->name : DEFAULT_NAME);
|
||||
vfprintf (stderr, format, ap);
|
||||
fprintf (stderr, ": %s\n", strerror (errno));
|
||||
|
||||
va_end (ap);
|
||||
}
|
||||
|
274
sysdeps/common/fsusage.c
Normal file
274
sysdeps/common/fsusage.c
Normal file
@@ -0,0 +1,274 @@
|
||||
/* fsusage.c -- return space usage of mounted filesystems
|
||||
Copyright (C) 1991, 1992, 1996 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include "fsusage.h"
|
||||
|
||||
int statfs ();
|
||||
|
||||
#if HAVE_SYS_PARAM_H
|
||||
# include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_MOUNT_H
|
||||
# include <sys/mount.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_VFS_H
|
||||
# include <sys/vfs.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_FS_S5PARAM_H /* Fujitsu UXP/V */
|
||||
# include <sys/fs/s5param.h>
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_SYS_FILSYS_H) && !defined (_CRAY)
|
||||
# include <sys/filsys.h> /* SVR2 */
|
||||
#endif
|
||||
|
||||
#if HAVE_FCNTL_H
|
||||
# include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_STATFS_H
|
||||
# include <sys/statfs.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_DUSTAT_H /* AIX PS/2 */
|
||||
# include <sys/dustat.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_STATVFS_H /* SVR4 */
|
||||
# include <sys/statvfs.h>
|
||||
int statvfs ();
|
||||
#endif
|
||||
|
||||
int safe_read ();
|
||||
|
||||
/* Return the number of TOSIZE-byte blocks used by
|
||||
BLOCKS FROMSIZE-byte blocks, rounding away from zero.
|
||||
TOSIZE must be positive. Return -1 if FROMSIZE is not positive. */
|
||||
|
||||
static long
|
||||
adjust_blocks (blocks, fromsize, tosize)
|
||||
long blocks;
|
||||
int fromsize, tosize;
|
||||
{
|
||||
if (tosize <= 0)
|
||||
abort ();
|
||||
if (fromsize <= 0)
|
||||
return -1;
|
||||
|
||||
if (fromsize == tosize) /* e.g., from 512 to 512 */
|
||||
return blocks;
|
||||
else if (fromsize > tosize) /* e.g., from 2048 to 512 */
|
||||
return blocks * (fromsize / tosize);
|
||||
else /* e.g., from 256 to 512 */
|
||||
return (blocks + (blocks < 0 ? -1 : 1)) / (tosize / fromsize);
|
||||
}
|
||||
|
||||
/* Fill in the fields of FSP with information about space usage for
|
||||
the filesystem on which PATH resides.
|
||||
DISK is the device on which PATH is mounted, for space-getting
|
||||
methods that need to know it.
|
||||
Return 0 if successful, -1 if not. When returning -1, ensure that
|
||||
ERRNO is either a system error value, or zero if DISK is NULL
|
||||
on a system that requires a non-NULL value. */
|
||||
int
|
||||
get_fs_usage (path, disk, fsp)
|
||||
const char *path;
|
||||
const char *disk;
|
||||
struct fs_usage *fsp;
|
||||
{
|
||||
#ifdef STAT_STATFS3_OSF1
|
||||
# define CONVERT_BLOCKS(B) adjust_blocks ((B), fsd.f_fsize, 512)
|
||||
|
||||
struct statfs fsd;
|
||||
|
||||
if (statfs (path, &fsd, sizeof (struct statfs)) != 0)
|
||||
return -1;
|
||||
|
||||
#endif /* STAT_STATFS3_OSF1 */
|
||||
|
||||
#ifdef STAT_STATFS2_FS_DATA /* Ultrix */
|
||||
# define CONVERT_BLOCKS(B) adjust_blocks ((B), 1024, 512)
|
||||
|
||||
struct fs_data fsd;
|
||||
|
||||
if (statfs (path, &fsd) != 1)
|
||||
return -1;
|
||||
fsp->fsu_blocks = CONVERT_BLOCKS (fsd.fd_req.btot);
|
||||
fsp->fsu_bfree = CONVERT_BLOCKS (fsd.fd_req.bfree);
|
||||
fsp->fsu_bavail = CONVERT_BLOCKS (fsd.fd_req.bfreen);
|
||||
fsp->fsu_files = fsd.fd_req.gtot;
|
||||
fsp->fsu_ffree = fsd.fd_req.gfree;
|
||||
|
||||
#endif /* STAT_STATFS2_FS_DATA */
|
||||
|
||||
#ifdef STAT_READ_FILSYS /* SVR2 */
|
||||
# ifndef SUPERBOFF
|
||||
# define SUPERBOFF (SUPERB * 512)
|
||||
# endif
|
||||
# define CONVERT_BLOCKS(B) \
|
||||
adjust_blocks ((B), (fsd.s_type == Fs2b ? 1024 : 512), 512)
|
||||
|
||||
struct filsys fsd;
|
||||
int fd;
|
||||
|
||||
if (! disk)
|
||||
{
|
||||
errno = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
fd = open (disk, O_RDONLY);
|
||||
if (fd < 0)
|
||||
return -1;
|
||||
lseek (fd, (long) SUPERBOFF, 0);
|
||||
if (safe_read (fd, (char *) &fsd, sizeof fsd) != sizeof fsd)
|
||||
{
|
||||
close (fd);
|
||||
return -1;
|
||||
}
|
||||
close (fd);
|
||||
fsp->fsu_blocks = CONVERT_BLOCKS (fsd.s_fsize);
|
||||
fsp->fsu_bfree = CONVERT_BLOCKS (fsd.s_tfree);
|
||||
fsp->fsu_bavail = CONVERT_BLOCKS (fsd.s_tfree);
|
||||
fsp->fsu_files = (fsd.s_isize - 2) * INOPB * (fsd.s_type == Fs2b ? 2 : 1);
|
||||
fsp->fsu_ffree = fsd.s_tinode;
|
||||
|
||||
#endif /* STAT_READ_FILSYS */
|
||||
|
||||
#ifdef STAT_STATFS2_BSIZE /* 4.3BSD, SunOS 4, HP-UX, AIX */
|
||||
# define CONVERT_BLOCKS(B) adjust_blocks ((B), fsd.f_bsize, 512)
|
||||
|
||||
struct statfs fsd;
|
||||
|
||||
if (statfs (path, &fsd) < 0)
|
||||
return -1;
|
||||
|
||||
# ifdef STATFS_TRUNCATES_BLOCK_COUNTS
|
||||
|
||||
/* In SunOS 4.1.2, 4.1.3, and 4.1.3_U1, the block counts in the
|
||||
struct statfs are truncated to 2GB. These conditions detect that
|
||||
truncation, presumably without botching the 4.1.1 case, in which
|
||||
the values are not truncated. The correct counts are stored in
|
||||
undocumented spare fields. */
|
||||
if (fsd.f_blocks == 0x1fffff && fsd.f_spare[0] > 0)
|
||||
{
|
||||
fsd.f_blocks = fsd.f_spare[0];
|
||||
fsd.f_bfree = fsd.f_spare[1];
|
||||
fsd.f_bavail = fsd.f_spare[2];
|
||||
}
|
||||
# endif /* STATFS_TRUNCATES_BLOCK_COUNTS */
|
||||
|
||||
#endif /* STAT_STATFS2_BSIZE */
|
||||
|
||||
#ifdef STAT_STATFS2_FSIZE /* 4.4BSD */
|
||||
# define CONVERT_BLOCKS(B) adjust_blocks ((B), fsd.f_fsize, 512)
|
||||
|
||||
struct statfs fsd;
|
||||
|
||||
if (statfs (path, &fsd) < 0)
|
||||
return -1;
|
||||
|
||||
#endif /* STAT_STATFS2_FSIZE */
|
||||
|
||||
#ifdef STAT_STATFS4 /* SVR3, Dynix, Irix, AIX */
|
||||
# if _AIX || defined(_CRAY)
|
||||
# define CONVERT_BLOCKS(B) adjust_blocks ((B), fsd.f_bsize, 512)
|
||||
# ifdef _CRAY
|
||||
# define f_bavail f_bfree
|
||||
# endif
|
||||
# else
|
||||
# define CONVERT_BLOCKS(B) (B)
|
||||
# ifndef _SEQUENT_ /* _SEQUENT_ is DYNIX/ptx */
|
||||
# ifndef DOLPHIN /* DOLPHIN 3.8.alfa/7.18 has f_bavail */
|
||||
# define f_bavail f_bfree
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
|
||||
struct statfs fsd;
|
||||
|
||||
if (statfs (path, &fsd, sizeof fsd, 0) < 0)
|
||||
return -1;
|
||||
/* Empirically, the block counts on most SVR3 and SVR3-derived
|
||||
systems seem to always be in terms of 512-byte blocks,
|
||||
no matter what value f_bsize has. */
|
||||
|
||||
#endif /* STAT_STATFS4 */
|
||||
|
||||
#ifdef STAT_STATVFS /* SVR4 */
|
||||
# define CONVERT_BLOCKS(B) \
|
||||
adjust_blocks ((B), fsd.f_frsize ? fsd.f_frsize : fsd.f_bsize, 512)
|
||||
|
||||
struct statvfs fsd;
|
||||
|
||||
if (statvfs (path, &fsd) < 0)
|
||||
return -1;
|
||||
/* f_frsize isn't guaranteed to be supported. */
|
||||
|
||||
#endif /* STAT_STATVFS */
|
||||
|
||||
#if !defined(STAT_STATFS2_FS_DATA) && !defined(STAT_READ_FILSYS)
|
||||
/* !Ultrix && !SVR2 */
|
||||
|
||||
fsp->fsu_blocks = CONVERT_BLOCKS (fsd.f_blocks);
|
||||
fsp->fsu_bfree = CONVERT_BLOCKS (fsd.f_bfree);
|
||||
fsp->fsu_bavail = CONVERT_BLOCKS (fsd.f_bavail);
|
||||
fsp->fsu_files = fsd.f_files;
|
||||
fsp->fsu_ffree = fsd.f_ffree;
|
||||
|
||||
#endif /* not STAT_STATFS2_FS_DATA && not STAT_READ_FILSYS */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(_AIX) && defined(_I386)
|
||||
/* AIX PS/2 does not supply statfs. */
|
||||
|
||||
int
|
||||
statfs (path, fsb)
|
||||
char *path;
|
||||
struct statfs *fsb;
|
||||
{
|
||||
struct stat stats;
|
||||
struct dustat fsd;
|
||||
|
||||
if (stat (path, &stats))
|
||||
return -1;
|
||||
if (dustat (stats.st_dev, 0, &fsd, sizeof (fsd)))
|
||||
return -1;
|
||||
fsb->f_type = 0;
|
||||
fsb->f_bsize = fsd.du_bsize;
|
||||
fsb->f_blocks = fsd.du_fsize - fsd.du_isize;
|
||||
fsb->f_bfree = fsd.du_tfree;
|
||||
fsb->f_bavail = fsd.du_tfree;
|
||||
fsb->f_files = (fsd.du_isize - 2) * fsd.du_inopb;
|
||||
fsb->f_ffree = fsd.du_tinode;
|
||||
fsb->f_fsid.val[0] = fsd.du_site;
|
||||
fsb->f_fsid.val[1] = fsd.du_pckno;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* _AIX && _I386 */
|
37
sysdeps/common/fsusage.h
Normal file
37
sysdeps/common/fsusage.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/* fsusage.h -- declarations for filesystem space usage info
|
||||
Copyright (C) 1991, 1992 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Space usage statistics for a filesystem. Blocks are 512-byte. */
|
||||
struct fs_usage
|
||||
{
|
||||
long fsu_blocks; /* Total blocks. */
|
||||
long fsu_bfree; /* Free blocks available to superuser. */
|
||||
long fsu_bavail; /* Free blocks available to non-superuser. */
|
||||
long fsu_files; /* Total file nodes. */
|
||||
long fsu_ffree; /* Free file nodes. */
|
||||
};
|
||||
|
||||
#ifndef __P
|
||||
#if defined (__GNUC__) || (defined (__STDC__) && __STDC__)
|
||||
#define __P(args) args
|
||||
#else
|
||||
#define __P(args) ()
|
||||
#endif /* GCC. */
|
||||
#endif /* Not __P. */
|
||||
|
||||
int get_fs_usage __P ((const char *path, const char *disk,
|
||||
struct fs_usage *fsp));
|
372
sysdeps/common/gnuslib.c
Normal file
372
sysdeps/common/gnuslib.c
Normal file
@@ -0,0 +1,372 @@
|
||||
/* -*-C-*-
|
||||
* Common library code for the GNU Emacs server and client.
|
||||
*
|
||||
* This file is part of GNU Emacs.
|
||||
*
|
||||
* Copying is permitted under those conditions described by the GNU
|
||||
* General Public License.
|
||||
*
|
||||
* Copyright (C) 1989 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Andy Norman (ange@hplb.hpl.hp.com), based on
|
||||
* 'etc/server.c' and 'etc/emacsclient.c' from the 18.52 GNU
|
||||
* Emacs distribution.
|
||||
*
|
||||
* Please mail bugs and suggestions to the author at the above address.
|
||||
*/
|
||||
|
||||
/* HISTORY
|
||||
* 11-Nov-1990 bristor@simba
|
||||
* Added EOT stuff.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file incorporates new features added by Bob Weiner <weiner@mot.com>,
|
||||
* Darrell Kindred <dkindred@cmu.edu> and Arup Mukherjee <arup@cmu.edu>.
|
||||
* Please see the note at the end of the README file for details.
|
||||
*
|
||||
* (If gnuserv came bundled with your emacs, the README file is probably
|
||||
* ../etc/gnuserv.README relative to the directory containing this file)
|
||||
*/
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/gnuserv.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef UNIX_DOMAIN_SOCKETS
|
||||
static int connect_to_unix_server __P((void));
|
||||
#endif
|
||||
|
||||
#ifdef INTERNET_DOMAIN_SOCKETS
|
||||
static int connect_to_internet_server __P((const char *, u_short));
|
||||
#endif
|
||||
|
||||
/* On some systems, e.g. DGUX, inet_addr returns a 'struct in_addr'. */
|
||||
#ifdef HAVE_BROKEN_INET_ADDR
|
||||
#define IN_ADDR struct in_addr
|
||||
#define NUMERIC_ADDR_ERROR (numeric_addr.s_addr == -1)
|
||||
#else
|
||||
#if (LONGBITS > 32)
|
||||
#define IN_ADDR unsigned int
|
||||
#else
|
||||
#define IN_ADDR unsigned long
|
||||
#endif
|
||||
#define NUMERIC_ADDR_ERROR (numeric_addr == (IN_ADDR) -1)
|
||||
#endif
|
||||
|
||||
#include <arpa/inet.h>
|
||||
|
||||
int
|
||||
glibtop_make_connection (hostarg, portarg, s)
|
||||
const char *hostarg;
|
||||
int portarg;
|
||||
int *s;
|
||||
{
|
||||
#ifdef INTERNET_DOMAIN_SOCKETS
|
||||
char *ptr;
|
||||
|
||||
if (hostarg == NULL)
|
||||
hostarg = getenv ("LIBGTOP_HOST");
|
||||
if (portarg == 0 && (ptr = getenv ("LIBGTOP_PORT")) != NULL)
|
||||
portarg = atoi (ptr);
|
||||
#endif
|
||||
|
||||
if (hostarg != NULL) {
|
||||
/* hostname was given explicitly, via cmd line arg or
|
||||
* LIBGTOP_HOST, * so obey it. */
|
||||
#ifdef UNIX_DOMAIN_SOCKETS
|
||||
if (!strcmp (hostarg, "unix")) {
|
||||
*s = connect_to_unix_server ();
|
||||
return (int) CONN_UNIX;
|
||||
}
|
||||
#endif /* UNIX_DOMAIN_SOCKETS */
|
||||
#ifdef INTERNET_DOMAIN_SOCKETS
|
||||
*s = connect_to_internet_server (hostarg, portarg);
|
||||
return (int) CONN_INTERNET;
|
||||
#endif
|
||||
} else {
|
||||
/* no hostname given. Use unix-domain/sysv-ipc, or *
|
||||
* internet-domain connection to local host if they're not
|
||||
* available. */
|
||||
#if defined(UNIX_DOMAIN_SOCKETS)
|
||||
*s = connect_to_unix_server ();
|
||||
return (int) CONN_UNIX;
|
||||
#elif defined(INTERNET_DOMAIN_SOCKETS)
|
||||
{
|
||||
char localhost[HOSTNAMSZ];
|
||||
|
||||
gethostname (localhost, HOSTNAMSZ); /* use this
|
||||
* host by
|
||||
* default */
|
||||
*s = connect_to_internet_server (localhost, portarg);
|
||||
return (int) CONN_INTERNET;
|
||||
}
|
||||
#endif /* IPC type */
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(INTERNET_DOMAIN_SOCKETS) || defined(UNIX_DOMAIN_SOCKETS)
|
||||
/*
|
||||
* send_string -- send string to socket.
|
||||
*/
|
||||
#if 0
|
||||
static void
|
||||
send_string (s, msg)
|
||||
int s;
|
||||
const char *msg;
|
||||
{
|
||||
#if 0
|
||||
if (send (s, msg, strlen (msg), 0) < 0) {
|
||||
perror (progname);
|
||||
fprintf (stderr, "%s: unable to send\n", progname);
|
||||
exit (1);
|
||||
}; /* if */
|
||||
#else
|
||||
int len, left = strlen (msg);
|
||||
|
||||
while (left > 0) {
|
||||
if ((len = write (s, msg, min2 (left, GSERV_BUFSZ))) < 0) {
|
||||
/* XEmacs addition: robertl@arnet.com */
|
||||
if (errno == EPIPE) {
|
||||
return;
|
||||
}
|
||||
perror (progname);
|
||||
fprintf (stderr, "%s: unable to send\n", progname);
|
||||
exit (1);
|
||||
}; /* if */
|
||||
left -= len;
|
||||
msg += len;
|
||||
}; /* while */
|
||||
#endif
|
||||
} /* send_string */
|
||||
|
||||
/*
|
||||
* read_line -- read a \n terminated line from a socket
|
||||
*/
|
||||
static int
|
||||
read_line (int s, char *dest)
|
||||
{
|
||||
int length;
|
||||
int offset = 0;
|
||||
char buffer[GSERV_BUFSZ + 1];
|
||||
|
||||
while ((length = read (s, buffer + offset, 1) > 0) && buffer[offset] != '\n'
|
||||
&& buffer[offset] != EOT_CHR) {
|
||||
offset += length;
|
||||
if (offset >= GSERV_BUFSZ)
|
||||
break;
|
||||
}
|
||||
buffer[offset] = '\0';
|
||||
strcpy (dest, buffer);
|
||||
return 1;
|
||||
} /* read_line */
|
||||
#endif
|
||||
#endif /* INTERNET_DOMAIN_SOCKETS || UNIX_DOMAIN_SOCKETS */
|
||||
|
||||
|
||||
#ifdef UNIX_DOMAIN_SOCKETS
|
||||
/*
|
||||
* connect_to_unix_server -- establish connection with server process via a unix-
|
||||
* domain socket. Returns socket descriptor for server
|
||||
* if successful.
|
||||
*/
|
||||
static int
|
||||
connect_to_unix_server (void)
|
||||
{
|
||||
int s; /* connected socket descriptor */
|
||||
struct sockaddr_un server; /* for unix connections */
|
||||
|
||||
if ((s = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
|
||||
glibtop_error_io ("unable to create socket");
|
||||
|
||||
server.sun_family = AF_UNIX;
|
||||
#ifdef HIDE_UNIX_SOCKET
|
||||
sprintf (server.sun_path, "/tmp/lgtddir%d/lgtd", (int) geteuid ());
|
||||
#else /* HIDE_UNIX_SOCKET */
|
||||
sprintf (server.sun_path, "/tmp/lgtd%d", (int) geteuid ());
|
||||
#endif /* HIDE_UNIX_SOCKET */
|
||||
if (connect (s, (struct sockaddr *) &server, strlen (server.sun_path) + 2) < 0)
|
||||
glibtop_error_io ("unable to connect to local");
|
||||
|
||||
return (s);
|
||||
|
||||
} /* connect_to_unix_server */
|
||||
#endif /* UNIX_DOMAIN_SOCKETS */
|
||||
|
||||
|
||||
#ifdef INTERNET_DOMAIN_SOCKETS
|
||||
/*
|
||||
* internet_addr -- return the internet addr of the hostname or
|
||||
* internet address passed. Return -1 on error.
|
||||
*/
|
||||
long
|
||||
glibtop_internet_addr (host)
|
||||
const char *host;
|
||||
{
|
||||
struct hostent *hp; /* pointer to host info for remote host */
|
||||
IN_ADDR numeric_addr; /* host address */
|
||||
|
||||
numeric_addr = inet_addr (host);
|
||||
if (!NUMERIC_ADDR_ERROR)
|
||||
return numeric_addr;
|
||||
else if ((hp = gethostbyname (host)) != NULL)
|
||||
return ((struct in_addr *) (hp->h_addr))->s_addr;
|
||||
else {
|
||||
glibtop_warn_io ("gethostbyname (%s)", host);
|
||||
return -1;
|
||||
}
|
||||
|
||||
} /* glibtop_internet_addr */
|
||||
|
||||
#ifdef AUTH_MAGIC_COOKIE
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xauth.h>
|
||||
|
||||
static Xauth *server_xauth = NULL;
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* connect_to_internet_server -- establish connection with server process via
|
||||
* an internet domain socket. Returns socket
|
||||
* descriptor for server if successful.
|
||||
*/
|
||||
static int
|
||||
connect_to_internet_server (const char *serverhost, u_short port)
|
||||
{
|
||||
int s; /* connected socket descriptor */
|
||||
struct servent *sp; /* pointer to service information */
|
||||
struct sockaddr_in peeraddr_in; /* for peer socket address */
|
||||
char buf[512]; /* temporary buffer */
|
||||
|
||||
/* clear out address structures */
|
||||
memset ((char *) &peeraddr_in, 0, sizeof (struct sockaddr_in));
|
||||
|
||||
/* Set up the peer address to which we will connect. */
|
||||
peeraddr_in.sin_family = AF_INET;
|
||||
|
||||
/* look up the server host's internet address */
|
||||
if (((long) peeraddr_in.sin_addr.s_addr = glibtop_internet_addr (serverhost)) == -1)
|
||||
glibtop_error ("unable to find %s in /etc/hosts or from YP", serverhost);
|
||||
|
||||
if (port == 0) {
|
||||
if ((sp = getservbyname ("gtopd", "tcp")) == NULL)
|
||||
peeraddr_in.sin_port = htons (DEFAULT_PORT + getuid ());
|
||||
else
|
||||
peeraddr_in.sin_port = sp->s_port;
|
||||
}
|
||||
/* if */
|
||||
else
|
||||
peeraddr_in.sin_port = htons (port);
|
||||
|
||||
/* Create the socket. */
|
||||
if ((s = socket (AF_INET, SOCK_STREAM, 0)) == -1)
|
||||
glibtop_error_io ("unable to create socket");
|
||||
|
||||
/* Try to connect to the remote server at the address * which was
|
||||
* just built into peeraddr. */
|
||||
if (connect (s, (struct sockaddr *) &peeraddr_in,
|
||||
sizeof (struct sockaddr_in)) == -1)
|
||||
glibtop_error_io ("unable to connect to remote");
|
||||
|
||||
#ifdef AUTH_MAGIC_COOKIE
|
||||
|
||||
/* send credentials using MIT-MAGIC-COOKIE-1 protocol */
|
||||
|
||||
server_xauth =
|
||||
XauGetAuthByAddr (FamilyInternet,
|
||||
sizeof (peeraddr_in.sin_addr.s_addr),
|
||||
(char *) &peeraddr_in.sin_addr.s_addr,
|
||||
strlen (MCOOKIE_SCREEN), MCOOKIE_SCREEN,
|
||||
strlen (MCOOKIE_X_NAME), MCOOKIE_X_NAME);
|
||||
|
||||
if (server_xauth && server_xauth->data) {
|
||||
sprintf (buf, "%s\n%d\n", MCOOKIE_NAME, server_xauth->data_length);
|
||||
write (s, buf, strlen (buf));
|
||||
write (s, server_xauth->data, server_xauth->data_length);
|
||||
|
||||
return (s);
|
||||
}
|
||||
#endif /* AUTH_MAGIC_COOKIE */
|
||||
|
||||
sprintf (buf, "%s\n", DEFAUTH_NAME);
|
||||
write (s, buf, strlen (buf));
|
||||
|
||||
return (s);
|
||||
|
||||
} /* connect_to_internet_server */
|
||||
#endif /* INTERNET_DOMAIN_SOCKETS */
|
||||
|
||||
|
||||
#if defined(INTERNET_DOMAIN_SOCKETS) || defined(UNIX_DOMAIN_SOCKETS)
|
||||
/*
|
||||
* disconnect_from_server -- inform the server that sending has finished, and wait for
|
||||
* its reply.
|
||||
*/
|
||||
#if 0
|
||||
static void
|
||||
disconnect_from_server (s, echo)
|
||||
int s;
|
||||
int echo;
|
||||
{
|
||||
#if 0
|
||||
char buffer[REPLYSIZ + 1];
|
||||
|
||||
#else
|
||||
char buffer[GSERV_BUFSZ + 1];
|
||||
|
||||
#endif
|
||||
int add_newline = 1;
|
||||
int length;
|
||||
|
||||
send_string (s, EOT_STR); /* make sure server gets string */
|
||||
|
||||
#if !defined (linux) && !defined (_SCO_DS)
|
||||
/*
|
||||
* shutdown is completely hozed under linux. If s is a unix domain socket,
|
||||
* you'll get EOPNOTSUPP back from it. If s is an internet socket, you get
|
||||
* a broken pipe when you try to read a bit later. The latter
|
||||
* problem is fixed for linux versions >= 1.1.46, but the problem
|
||||
* with unix sockets persists. Sigh.
|
||||
*/
|
||||
|
||||
if (shutdown (s, 1) == -1) {
|
||||
perror (progname);
|
||||
fprintf (stderr, "%s: unable to shutdown socket\n", progname);
|
||||
exit (1);
|
||||
}; /* if */
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
while ((length = recv (s, buffer, REPLYSIZ, 0)) > 0) {
|
||||
buffer[length] = '\0';
|
||||
if (echo)
|
||||
fputs (buffer, stdout);
|
||||
add_newline = (buffer[length - 1] != '\n');
|
||||
}; /* while */
|
||||
#else
|
||||
while ((length = read (s, buffer, GSERV_BUFSZ)) > 0 ||
|
||||
(length == -1 && errno == EINTR)) {
|
||||
if (length) {
|
||||
buffer[length] = '\0';
|
||||
if (echo) {
|
||||
fputs (buffer, stdout);
|
||||
add_newline = (buffer[length - 1] != '\n');
|
||||
}; /* if */
|
||||
}; /* if */
|
||||
}; /* while */
|
||||
#endif
|
||||
|
||||
if (echo && add_newline)
|
||||
putchar ('\n');
|
||||
|
||||
if (length < 0) {
|
||||
perror (progname);
|
||||
fprintf (stderr, "%s: unable to read the reply from the server\n", progname);
|
||||
exit (1);
|
||||
}; /* if */
|
||||
|
||||
} /* disconnect_from_server */
|
||||
#endif
|
||||
#endif /* INTERNET_DOMAIN_SOCKETS || UNIX_DOMAIN_SOCKETS */
|
586
sysdeps/common/mountlist.c
Normal file
586
sysdeps/common/mountlist.c
Normal file
@@ -0,0 +1,586 @@
|
||||
/* mountlist.c -- return a list of mounted filesystems
|
||||
Copyright (C) 1991, 1992 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include "mountlist.h"
|
||||
|
||||
#ifdef STDC_HEADERS
|
||||
#include <stdlib.h>
|
||||
#else
|
||||
void free ();
|
||||
#endif
|
||||
#if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/xmalloc.h>
|
||||
|
||||
#undef xmalloc
|
||||
#undef xrealloc
|
||||
#undef xstrdup
|
||||
|
||||
#define xmalloc(p1) glibtop_malloc_r (NULL, p1)
|
||||
#define xrealloc(p1,p2) glibtop_realloc_r (NULL, p1, p2)
|
||||
#define xstrdup(p1) glibtop_strdup_r (NULL, p1)
|
||||
#define xfree(p1) glibtop_free_r (NULL, p1)
|
||||
|
||||
char *strstr ();
|
||||
void error ();
|
||||
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#if defined (MOUNTED_GETFSSTAT) /* __alpha running OSF_1 */
|
||||
# include <sys/mount.h>
|
||||
# include <sys/fs_types.h>
|
||||
#endif /* MOUNTED_GETFSSTAT */
|
||||
|
||||
#ifdef MOUNTED_GETMNTENT1 /* 4.3BSD, SunOS, HP-UX, Dynix, Irix. */
|
||||
#include <mntent.h>
|
||||
#if !defined(MOUNTED)
|
||||
# if defined(MNT_MNTTAB) /* HP-UX. */
|
||||
# define MOUNTED MNT_MNTTAB
|
||||
# endif
|
||||
# if defined(MNTTABNAME) /* Dynix. */
|
||||
# define MOUNTED MNTTABNAME
|
||||
# endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MOUNTED_GETMNTINFO /* 4.4BSD. */
|
||||
#include <sys/mount.h>
|
||||
#endif
|
||||
|
||||
#ifdef MOUNTED_GETMNT /* Ultrix. */
|
||||
#include <sys/mount.h>
|
||||
#include <sys/fs_types.h>
|
||||
#endif
|
||||
|
||||
#ifdef MOUNTED_FREAD /* SVR2. */
|
||||
#include <mnttab.h>
|
||||
#endif
|
||||
|
||||
#ifdef MOUNTED_FREAD_FSTYP /* SVR3. */
|
||||
#include <mnttab.h>
|
||||
#include <sys/fstyp.h>
|
||||
#include <sys/statfs.h>
|
||||
#endif
|
||||
|
||||
#ifdef MOUNTED_LISTMNTENT
|
||||
#include <mntent.h>
|
||||
#endif
|
||||
|
||||
#ifdef MOUNTED_GETMNTENT2 /* SVR4. */
|
||||
#include <sys/mnttab.h>
|
||||
#endif
|
||||
|
||||
#ifdef MOUNTED_VMOUNT /* AIX. */
|
||||
#include <fshelp.h>
|
||||
#include <sys/vfs.h>
|
||||
#endif
|
||||
|
||||
#ifdef DOLPHIN
|
||||
/* So special that it's not worth putting this in autoconf. */
|
||||
#undef MOUNTED_FREAD_FSTYP
|
||||
#define MOUNTED_GETMNTTBL
|
||||
#endif
|
||||
|
||||
#ifdef MOUNTED_GETMNTENT1 /* 4.3BSD, SunOS, HP-UX, Dynix, Irix. */
|
||||
/* Return the value of the hexadecimal number represented by CP.
|
||||
No prefix (like '0x') or suffix (like 'h') is expected to be
|
||||
part of CP. */
|
||||
|
||||
static int
|
||||
xatoi (cp)
|
||||
char *cp;
|
||||
{
|
||||
int val;
|
||||
|
||||
val = 0;
|
||||
while (*cp)
|
||||
{
|
||||
if (*cp >= 'a' && *cp <= 'f')
|
||||
val = val * 16 + *cp - 'a' + 10;
|
||||
else if (*cp >= 'A' && *cp <= 'F')
|
||||
val = val * 16 + *cp - 'A' + 10;
|
||||
else if (*cp >= '0' && *cp <= '9')
|
||||
val = val * 16 + *cp - '0';
|
||||
else
|
||||
break;
|
||||
cp++;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
#endif /* MOUNTED_GETMNTENT1. */
|
||||
|
||||
#if defined (MOUNTED_GETMNTINFO) && !defined (__NetBSD__)
|
||||
static char *
|
||||
fstype_to_string (t)
|
||||
short t;
|
||||
{
|
||||
switch (t)
|
||||
{
|
||||
#ifdef MOUNT_PC
|
||||
case MOUNT_PC:
|
||||
return "pc";
|
||||
#endif
|
||||
#ifdef MOUNT_MFS
|
||||
case MOUNT_MFS:
|
||||
return "mfs";
|
||||
#endif
|
||||
#ifdef MOUNT_LO
|
||||
case MOUNT_LO:
|
||||
return "lo";
|
||||
#endif
|
||||
#ifdef MOUNT_TFS
|
||||
case MOUNT_TFS:
|
||||
return "tfs";
|
||||
#endif
|
||||
#ifdef MOUNT_TMP
|
||||
case MOUNT_TMP:
|
||||
return "tmp";
|
||||
#endif
|
||||
#ifdef MOUNT_UFS
|
||||
case MOUNT_UFS:
|
||||
return "ufs" ;
|
||||
#endif
|
||||
#ifdef MOUNT_NFS
|
||||
case MOUNT_NFS:
|
||||
return "nfs" ;
|
||||
#endif
|
||||
#ifdef MOUNT_MSDOS
|
||||
case MOUNT_MSDOS:
|
||||
return "msdos" ;
|
||||
#endif
|
||||
#ifdef MOUNT_LFS
|
||||
case MOUNT_LFS:
|
||||
return "lfs" ;
|
||||
#endif
|
||||
#ifdef MOUNT_LOFS
|
||||
case MOUNT_LOFS:
|
||||
return "lofs" ;
|
||||
#endif
|
||||
#ifdef MOUNT_FDESC
|
||||
case MOUNT_FDESC:
|
||||
return "fdesc" ;
|
||||
#endif
|
||||
#ifdef MOUNT_PORTAL
|
||||
case MOUNT_PORTAL:
|
||||
return "portal" ;
|
||||
#endif
|
||||
#ifdef MOUNT_NULL
|
||||
case MOUNT_NULL:
|
||||
return "null" ;
|
||||
#endif
|
||||
#ifdef MOUNT_UMAP
|
||||
case MOUNT_UMAP:
|
||||
return "umap" ;
|
||||
#endif
|
||||
#ifdef MOUNT_KERNFS
|
||||
case MOUNT_KERNFS:
|
||||
return "kernfs" ;
|
||||
#endif
|
||||
#ifdef MOUNT_PROCFS
|
||||
case MOUNT_PROCFS:
|
||||
return "procfs" ;
|
||||
#endif
|
||||
#ifdef MOUNT_AFS
|
||||
case MOUNT_AFS:
|
||||
return "afs" ;
|
||||
#endif
|
||||
#ifdef MOUNT_CD9660
|
||||
case MOUNT_CD9660:
|
||||
return "cd9660" ;
|
||||
#endif
|
||||
#ifdef MOUNT_UNION
|
||||
case MOUNT_UNION:
|
||||
return "union" ;
|
||||
#endif
|
||||
#ifdef MOUNT_DEVFS
|
||||
case MOUNT_DEVFS:
|
||||
return "devfs" ;
|
||||
#endif
|
||||
#ifdef MOUNT_EXT2FS
|
||||
case MOUNT_EXT2FS:
|
||||
return "ext2fs" ;
|
||||
#endif
|
||||
default:
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
#endif /* MOUNTED_GETMNTINFO */
|
||||
|
||||
#ifdef MOUNTED_VMOUNT /* AIX. */
|
||||
static char *
|
||||
fstype_to_string (t)
|
||||
int t;
|
||||
{
|
||||
struct vfs_ent *e;
|
||||
|
||||
e = getvfsbytype (t);
|
||||
if (!e || !e->vfsent_name)
|
||||
return "none";
|
||||
else
|
||||
return e->vfsent_name;
|
||||
}
|
||||
#endif /* MOUNTED_VMOUNT */
|
||||
|
||||
/* Return a list of the currently mounted filesystems, or NULL on error.
|
||||
Add each entry to the tail of the list so that they stay in order.
|
||||
If NEED_FS_TYPE is nonzero, ensure that the filesystem type fields in
|
||||
the returned list are valid. Otherwise, they might not be.
|
||||
If ALL_FS is zero, do not return entries for filesystems that
|
||||
are automounter (dummy) entries. */
|
||||
|
||||
struct mount_entry *
|
||||
read_filesystem_list (need_fs_type, all_fs)
|
||||
int need_fs_type, all_fs;
|
||||
{
|
||||
struct mount_entry *mount_list;
|
||||
struct mount_entry *me;
|
||||
struct mount_entry *mtail;
|
||||
|
||||
/* Start the list off with a dummy entry. */
|
||||
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
|
||||
me->me_next = NULL;
|
||||
mount_list = mtail = me;
|
||||
|
||||
#ifdef MOUNTED_LISTMNTENT
|
||||
{
|
||||
struct tabmntent *mntlist, *p;
|
||||
struct mntent *mnt;
|
||||
struct mount_entry *me;
|
||||
|
||||
/* the third and fourth arguments could be used to filter mounts,
|
||||
but Crays doesn't seem to have any mounts that we want to
|
||||
remove. Specifically, automount create normal NFS mounts.
|
||||
*/
|
||||
|
||||
if(listmntent(&mntlist, KMTAB, NULL, NULL) < 0)
|
||||
return NULL;
|
||||
p = mntlist;
|
||||
while(p){
|
||||
mnt = p->ment;
|
||||
me = (struct mount_entry*) xmalloc(sizeof (struct mount_entry));
|
||||
me->me_devname = xstrdup(mnt->mnt_fsname);
|
||||
me->me_mountdir = xstrdup(mnt->mnt_dir);
|
||||
me->me_type = xstrdup(mnt->mnt_type);
|
||||
me->me_dev = -1;
|
||||
me->me_next = NULL;
|
||||
mtail->me_next = me;
|
||||
mtail = me;
|
||||
p = p->next;
|
||||
}
|
||||
freemntlist(mntlist);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MOUNTED_GETMNTENT1 /* 4.3BSD, SunOS, HP-UX, Dynix, Irix. */
|
||||
{
|
||||
struct mntent *mnt;
|
||||
char *table = MOUNTED;
|
||||
FILE *fp;
|
||||
char *devopt;
|
||||
|
||||
fp = setmntent (table, "r");
|
||||
if (fp == NULL)
|
||||
return NULL;
|
||||
|
||||
while ((mnt = getmntent (fp)))
|
||||
{
|
||||
if (!all_fs && (!strcmp (mnt->mnt_type, "ignore")
|
||||
|| !strcmp (mnt->mnt_type, "auto")))
|
||||
continue;
|
||||
|
||||
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
|
||||
me->me_devname = xstrdup (mnt->mnt_fsname);
|
||||
me->me_mountdir = xstrdup (mnt->mnt_dir);
|
||||
me->me_type = xstrdup (mnt->mnt_type);
|
||||
devopt = strstr (mnt->mnt_opts, "dev=");
|
||||
if (devopt)
|
||||
{
|
||||
if (devopt[4] == '0' && (devopt[5] == 'x' || devopt[5] == 'X'))
|
||||
me->me_dev = xatoi (devopt + 6);
|
||||
else
|
||||
me->me_dev = xatoi (devopt + 4);
|
||||
}
|
||||
else
|
||||
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
|
||||
me->me_next = NULL;
|
||||
|
||||
/* Add to the linked list. */
|
||||
mtail->me_next = me;
|
||||
mtail = me;
|
||||
}
|
||||
|
||||
if (endmntent (fp) == 0)
|
||||
return NULL;
|
||||
}
|
||||
#endif /* MOUNTED_GETMNTENT1. */
|
||||
|
||||
#ifdef MOUNTED_GETMNTINFO /* 4.4BSD. */
|
||||
{
|
||||
struct statfs *fsp;
|
||||
int entries;
|
||||
|
||||
entries = getmntinfo (&fsp, MNT_NOWAIT);
|
||||
if (entries < 0)
|
||||
return NULL;
|
||||
while (entries-- > 0)
|
||||
{
|
||||
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
|
||||
me->me_devname = xstrdup (fsp->f_mntfromname);
|
||||
me->me_mountdir = xstrdup (fsp->f_mntonname);
|
||||
#ifdef __NetBSD__
|
||||
me->me_type = xstrdup (fsp->f_fstypename);
|
||||
#else
|
||||
me->me_type = fstype_to_string (fsp->f_type);
|
||||
#endif
|
||||
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
|
||||
me->me_next = NULL;
|
||||
|
||||
/* Add to the linked list. */
|
||||
mtail->me_next = me;
|
||||
mtail = me;
|
||||
fsp++;
|
||||
}
|
||||
}
|
||||
#endif /* MOUNTED_GETMNTINFO */
|
||||
|
||||
#ifdef MOUNTED_GETMNT /* Ultrix. */
|
||||
{
|
||||
int offset = 0;
|
||||
int val;
|
||||
struct fs_data fsd;
|
||||
|
||||
while ((val = getmnt (&offset, &fsd, sizeof (fsd), NOSTAT_MANY,
|
||||
(char *) 0)) > 0)
|
||||
{
|
||||
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
|
||||
me->me_devname = xstrdup (fsd.fd_req.devname);
|
||||
me->me_mountdir = xstrdup (fsd.fd_req.path);
|
||||
me->me_type = gt_names[fsd.fd_req.fstype];
|
||||
me->me_dev = fsd.fd_req.dev;
|
||||
me->me_next = NULL;
|
||||
|
||||
/* Add to the linked list. */
|
||||
mtail->me_next = me;
|
||||
mtail = me;
|
||||
}
|
||||
if (val < 0)
|
||||
return NULL;
|
||||
}
|
||||
#endif /* MOUNTED_GETMNT. */
|
||||
|
||||
#if defined (MOUNTED_GETFSSTAT) /* __alpha running OSF_1 */
|
||||
{
|
||||
int numsys, counter, bufsize;
|
||||
struct statfs *stats;
|
||||
|
||||
numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT);
|
||||
if (numsys < 0)
|
||||
return (NULL);
|
||||
|
||||
bufsize = (1 + numsys) * sizeof (struct statfs);
|
||||
stats = (struct statfs *)xmalloc (bufsize);
|
||||
numsys = getfsstat (stats, bufsize, MNT_WAIT);
|
||||
|
||||
if (numsys < 0)
|
||||
{
|
||||
free (stats);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
for (counter = 0; counter < numsys; counter++)
|
||||
{
|
||||
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
|
||||
me->me_devname = xstrdup (stats[counter].f_mntfromname);
|
||||
me->me_mountdir = xstrdup (stats[counter].f_mntonname);
|
||||
me->me_type = mnt_names[stats[counter].f_type];
|
||||
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
|
||||
me->me_next = NULL;
|
||||
|
||||
/* Add to the linked list. */
|
||||
mtail->me_next = me;
|
||||
mtail = me;
|
||||
}
|
||||
|
||||
free (stats);
|
||||
}
|
||||
#endif /* MOUNTED_GETFSSTAT */
|
||||
|
||||
#if defined (MOUNTED_FREAD) || defined (MOUNTED_FREAD_FSTYP) /* SVR[23]. */
|
||||
{
|
||||
struct mnttab mnt;
|
||||
char *table = "/etc/mnttab";
|
||||
FILE *fp;
|
||||
|
||||
fp = fopen (table, "r");
|
||||
if (fp == NULL)
|
||||
return NULL;
|
||||
|
||||
while (fread (&mnt, sizeof mnt, 1, fp) > 0)
|
||||
{
|
||||
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
|
||||
#ifdef GETFSTYP /* SVR3. */
|
||||
me->me_devname = xstrdup (mnt.mt_dev);
|
||||
#else
|
||||
me->me_devname = xmalloc (strlen (mnt.mt_dev) + 6);
|
||||
strcpy (me->me_devname, "/dev/");
|
||||
strcpy (me->me_devname + 5, mnt.mt_dev);
|
||||
#endif
|
||||
me->me_mountdir = xstrdup (mnt.mt_filsys);
|
||||
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
|
||||
me->me_type = "";
|
||||
#ifdef GETFSTYP /* SVR3. */
|
||||
if (need_fs_type)
|
||||
{
|
||||
struct statfs fsd;
|
||||
char typebuf[FSTYPSZ];
|
||||
|
||||
if (statfs (me->me_mountdir, &fsd, sizeof fsd, 0) != -1
|
||||
&& sysfs (GETFSTYP, fsd.f_fstyp, typebuf) != -1)
|
||||
me->me_type = xstrdup (typebuf);
|
||||
}
|
||||
#endif
|
||||
me->me_next = NULL;
|
||||
|
||||
/* Add to the linked list. */
|
||||
mtail->me_next = me;
|
||||
mtail = me;
|
||||
}
|
||||
|
||||
if (fclose (fp) == EOF)
|
||||
return NULL;
|
||||
}
|
||||
#endif /* MOUNTED_FREAD || MOUNTED_FREAD_FSTYP. */
|
||||
|
||||
#ifdef MOUNTED_GETMNTTBL /* DolphinOS goes it's own way */
|
||||
{
|
||||
struct mntent **mnttbl=getmnttbl(),**ent;
|
||||
for (ent=mnttbl;*ent;ent++)
|
||||
{
|
||||
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
|
||||
me->me_devname = xstrdup ( (*ent)->mt_resource);
|
||||
me->me_mountdir = xstrdup( (*ent)->mt_directory);
|
||||
me->me_type = xstrdup ((*ent)->mt_fstype);
|
||||
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
|
||||
me->me_next = NULL;
|
||||
|
||||
/* Add to the linked list. */
|
||||
mtail->me_next = me;
|
||||
mtail = me;
|
||||
}
|
||||
endmnttbl();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MOUNTED_GETMNTENT2 /* SVR4. */
|
||||
{
|
||||
struct mnttab mnt;
|
||||
char *table = MNTTAB;
|
||||
FILE *fp;
|
||||
int ret;
|
||||
|
||||
fp = fopen (table, "r");
|
||||
if (fp == NULL)
|
||||
return NULL;
|
||||
|
||||
while ((ret = getmntent (fp, &mnt)) == 0)
|
||||
{
|
||||
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
|
||||
me->me_devname = xstrdup (mnt.mnt_special);
|
||||
me->me_mountdir = xstrdup (mnt.mnt_mountp);
|
||||
me->me_type = xstrdup (mnt.mnt_fstype);
|
||||
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
|
||||
me->me_next = NULL;
|
||||
|
||||
/* Add to the linked list. */
|
||||
mtail->me_next = me;
|
||||
mtail = me;
|
||||
}
|
||||
|
||||
if (ret > 0)
|
||||
return NULL;
|
||||
if (fclose (fp) == EOF)
|
||||
return NULL;
|
||||
}
|
||||
#endif /* MOUNTED_GETMNTENT2. */
|
||||
|
||||
#ifdef MOUNTED_VMOUNT /* AIX. */
|
||||
{
|
||||
int bufsize;
|
||||
char *entries, *thisent;
|
||||
struct vmount *vmp;
|
||||
|
||||
/* Ask how many bytes to allocate for the mounted filesystem info. */
|
||||
mntctl (MCTL_QUERY, sizeof bufsize, (struct vmount *) &bufsize);
|
||||
entries = xmalloc (bufsize);
|
||||
|
||||
/* Get the list of mounted filesystems. */
|
||||
mntctl (MCTL_QUERY, bufsize, (struct vmount *) entries);
|
||||
|
||||
for (thisent = entries; thisent < entries + bufsize;
|
||||
thisent += vmp->vmt_length)
|
||||
{
|
||||
vmp = (struct vmount *) thisent;
|
||||
me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
|
||||
if (vmp->vmt_flags & MNT_REMOTE)
|
||||
{
|
||||
char *host, *path;
|
||||
|
||||
/* Prepend the remote pathname. */
|
||||
host = thisent + vmp->vmt_data[VMT_HOSTNAME].vmt_off;
|
||||
path = thisent + vmp->vmt_data[VMT_OBJECT].vmt_off;
|
||||
me->me_devname = xmalloc (strlen (host) + strlen (path) + 2);
|
||||
strcpy (me->me_devname, host);
|
||||
strcat (me->me_devname, ":");
|
||||
strcat (me->me_devname, path);
|
||||
}
|
||||
else
|
||||
{
|
||||
me->me_devname = xstrdup (thisent +
|
||||
vmp->vmt_data[VMT_OBJECT].vmt_off);
|
||||
}
|
||||
me->me_mountdir = xstrdup (thisent + vmp->vmt_data[VMT_STUB].vmt_off);
|
||||
me->me_type = xstrdup (fstype_to_string (vmp->vmt_gfstype));
|
||||
me->me_dev = (dev_t) -1; /* vmt_fsid might be the info we want. */
|
||||
me->me_next = NULL;
|
||||
|
||||
/* Add to the linked list. */
|
||||
mtail->me_next = me;
|
||||
mtail = me;
|
||||
}
|
||||
free (entries);
|
||||
}
|
||||
#endif /* MOUNTED_VMOUNT. */
|
||||
|
||||
/* Free the dummy head. */
|
||||
me = mount_list;
|
||||
mount_list = mount_list->me_next;
|
||||
free (me);
|
||||
return mount_list;
|
||||
}
|
32
sysdeps/common/mountlist.h
Normal file
32
sysdeps/common/mountlist.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/* mountlist.h -- declarations for list of mounted filesystems
|
||||
Copyright (C) 1991, 1992 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* A mount table entry. */
|
||||
struct mount_entry
|
||||
{
|
||||
char *me_devname; /* Device node pathname, including "/dev/". */
|
||||
char *me_mountdir; /* Mount point directory pathname. */
|
||||
char *me_type; /* "nfs", "4.2", etc. */
|
||||
dev_t me_dev; /* Device number of me_mountdir. */
|
||||
struct mount_entry *me_next;
|
||||
};
|
||||
|
||||
#if __STDC__
|
||||
struct mount_entry *read_filesystem_list (int need_fs_type, int all_fs);
|
||||
#else
|
||||
struct mount_entry *read_filesystem_list ();
|
||||
#endif
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user