Compare commits
186 Commits
xemacs_20_
...
LIBGTOP_0_
Author | SHA1 | Date | |
---|---|---|---|
|
22699667aa | ||
|
2565ce18ce | ||
|
c3bac0b4f6 | ||
|
e60200e8de | ||
|
bcadc03194 | ||
|
13e68dbd2b | ||
|
8e540b8fc0 | ||
|
4789169c80 | ||
|
a894d550a1 | ||
|
b41bcfdfb1 | ||
|
4ea818875b | ||
|
d1120fe35d | ||
|
04f157c378 | ||
|
6db51362bf | ||
|
86abb41ef6 | ||
|
61fb170a1e | ||
|
ffbbc1e2e3 | ||
|
40ac07d0e0 | ||
|
7902405bd8 | ||
|
ef7c79a86b | ||
|
c6944b0ac8 | ||
|
333d78590a | ||
|
841cb61ad1 | ||
|
97902ce2dd | ||
|
302b785893 | ||
|
fd6b79d33d | ||
|
96e630a009 | ||
|
7ad67781ef | ||
|
616f4f4eaf | ||
|
513240b350 | ||
|
e0db8f3480 | ||
|
8f2b396347 | ||
|
3d611432e3 | ||
|
561becc92e | ||
|
1dd5bf2568 | ||
|
ad3fa88935 | ||
|
8dba7d8869 | ||
|
a2cacf7d6b | ||
|
bfb4474267 | ||
|
8cd96ef559 | ||
|
2fd0624294 | ||
|
59bb8d0ced | ||
|
739ce693dc | ||
|
77f56522c5 | ||
|
b40e08fb74 | ||
|
36657db940 | ||
|
486cc220c4 | ||
|
baea8b9603 | ||
|
e7b174f995 | ||
|
0f62dc7e3b | ||
|
2e670cc0d8 | ||
|
9248d72018 | ||
|
da622f70c7 | ||
|
a0cb2b913d | ||
|
71310d645d | ||
|
b05cfacb3d | ||
|
2356852a8c | ||
|
59a07e10f1 | ||
|
974eb766de | ||
|
d48e4086d5 | ||
|
d9361d388c | ||
|
b6885555c1 | ||
|
d44df22180 | ||
|
2e4ec2a85c | ||
|
260440e6ee | ||
|
8b8ceec1bf | ||
|
0bb5215f84 | ||
|
59f5f092fb | ||
|
32c0ced22a | ||
|
fd95ab60a4 | ||
|
b4038c9828 | ||
|
e64dc16608 | ||
|
4e25a1dbd5 | ||
|
c0641998cf | ||
|
9cf583b2fa | ||
|
2d1d157fc4 | ||
|
9c97f59c15 | ||
|
82daee6f29 | ||
|
e329617831 | ||
|
6d8c10d4ae | ||
|
13cf3ae4d0 | ||
|
6893d89fd8 | ||
|
35e900692a | ||
|
8e8cb05168 | ||
|
a510ed1271 | ||
|
3b4e0378f9 | ||
|
bb1c7f9192 | ||
|
e7c77a85e9 | ||
|
d72da1bb2f | ||
|
4b3fcf149a | ||
|
09e1353d0d | ||
|
79f5a9c667 | ||
|
864867aeeb | ||
|
8750ff351e | ||
|
bfcc8c3944 | ||
|
bf19661382 | ||
|
20016762a6 | ||
|
0a7bd78704 | ||
|
2e454140f1 | ||
|
fc506344ea | ||
|
e7f5588ee9 | ||
|
b55ee6117f | ||
|
902b6a8f16 | ||
|
d18a6cf2ce | ||
|
8ced0f5889 | ||
|
a33b97ef9d | ||
|
3c3118521d | ||
|
f07551a43d | ||
|
37eb76e767 | ||
|
e2196888ca | ||
|
8b9b984701 | ||
|
aa6d16e47b | ||
|
f3f051ecba | ||
|
51c5c3ac22 | ||
|
61c262dd7e | ||
|
954a78f200 | ||
|
a90bffbbf6 | ||
|
6bf243c901 | ||
|
dd5c4a716b | ||
|
0dc0c2d7f0 | ||
|
a584809b1c | ||
|
5e97af535f | ||
|
7efcda3082 | ||
|
5a1fa089f3 | ||
|
a129a83c45 | ||
|
65fbcf1ea3 | ||
|
d145edb435 | ||
|
fc2d1f07c3 | ||
|
694ad7adb7 | ||
|
d8a7175820 | ||
|
fe56feb875 | ||
|
5e9d34c91a | ||
|
0e086aef25 | ||
|
540385da7e | ||
|
540cd68691 | ||
|
c41d6e5a77 | ||
|
74ca45f795 | ||
|
5f4131f248 | ||
|
4bfef8c254 | ||
|
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 |
@@ -1,8 +1,6 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
alpha-dec-osf1
|
||||
autoh31167
|
||||
config.cache
|
||||
config.h
|
||||
config.h.in
|
||||
@@ -24,3 +22,6 @@ stamp-h
|
||||
sun4
|
||||
sun4sol2
|
||||
support
|
||||
i386-freebsd
|
||||
alpha-dec-osf3.0
|
||||
i686-pc-linux-gnu-linux
|
||||
|
241
ANNOUNCE-0.25
Normal file
241
ANNOUNCE-0.25
Normal file
@@ -0,0 +1,241 @@
|
||||
[Posted to the Gnome Mailing List on Fri Aug 21 1998]
|
||||
|
||||
About this release:
|
||||
------------------
|
||||
|
||||
LibGTop 0.25 is a stable release.
|
||||
|
||||
Of cause it has its bug like any software has, I'm planning
|
||||
to fix as many bugs as possible in _this_ release and then
|
||||
re-release it as libgtop-0.26 or even libgtop-0.30.
|
||||
|
||||
Especially portings to new operating systems should be made
|
||||
in this release.
|
||||
|
||||
This also means that we can safely use this version of LibGTop
|
||||
all over the GNOME project.
|
||||
|
||||
Currently LibGTop-Apps is still a little bit under development -
|
||||
especially the LibGTop-Apps GTop does not yet have the full
|
||||
functionallity of the real GTop.
|
||||
|
||||
We should test this extensively and then decide whether to continue
|
||||
with the `libgtop-apps' module or whether to merge all its code
|
||||
back into the modules it came from. I'd like to hear some comments
|
||||
about this from you !
|
||||
|
||||
Please look at the release notes below for more details about this
|
||||
release.
|
||||
|
||||
Where to get the sources
|
||||
------------------------
|
||||
|
||||
The sources can be found at:
|
||||
|
||||
ftp://ftp.home-of-linux.org/pub/
|
||||
|
||||
Tarballs:
|
||||
|
||||
libgtop-0.25.0.tar.gz
|
||||
libgtop-apps-0.25.0.tar.gz
|
||||
|
||||
Source RPM:
|
||||
|
||||
libgtop-0.25.0-REL.src.rpm
|
||||
libgtop-apps-0.25.0-REL.src.rpm
|
||||
|
||||
Binary RPMS:
|
||||
|
||||
libgtop-0.25.0-REL.i386.rpm
|
||||
libgtop-devel-0.25.0-REL.i386.rpm
|
||||
libgtop-examples-0.25.0-REL.i386.rpm
|
||||
libgtop-apps-0.25.0-REL.i386.rpm
|
||||
|
||||
There is some little problem with the binary RPMS of `libgtop-apps':
|
||||
|
||||
Most of its files will conflict with ones from `gnome-core' and `gnome-utils',
|
||||
so you'll need to use the `--force' parameter to install it.
|
||||
|
||||
Getting the sources from CVS:
|
||||
----------------------------
|
||||
|
||||
You can also fetch the sources from the GNOME CVS tree
|
||||
(see http://www.gnome.org/ for details).
|
||||
|
||||
To get the latest sources:
|
||||
|
||||
$ cvs checkout libgtop
|
||||
$ cvs checkout libgtop-apps
|
||||
|
||||
To get the sources of *this* release:
|
||||
|
||||
$ cvs checkout -r LIBGTOP_0_25 libgtop
|
||||
$ cvs checkout -r LIBGTOP_0_25 libgtop-apps
|
||||
|
||||
To get the sources of this release with all bug-fixes applied:
|
||||
|
||||
$ cvs checkout -r LIBGTOP_0_25_PATCHES libgtop
|
||||
$ cvs checkout -r LIBGTOP_0_25_PATCHES libgtop-apps
|
||||
|
||||
To get a patch to apply to the tarballs to get all bug-fixes:
|
||||
|
||||
$ cvs rdiff -r LIBGTOP_0_25 -r LIBGTOP_0_25_PATCHES libgtop
|
||||
$ cvs rdiff -r LIBGTOP_0_25 -r LIBGTOP_0_25_PATCHES libgtop-apps
|
||||
|
||||
[Note for people having write access to the GNOME CVS tree:
|
||||
|
||||
Please apply bug fixes to the `LIBGTOP_0_25_PATCHES' branch and
|
||||
merge them into the main trunk.
|
||||
|
||||
After merging, please re-tag the branch `libgtop_0_25_after_merge'.
|
||||
|
||||
This will help us to re-release this package when all bugs are
|
||||
fixed.
|
||||
]
|
||||
|
||||
RELEASE NOTES FOR LIBGTOP 0.25 STABLE
|
||||
=====================================
|
||||
|
||||
OVERVIEW
|
||||
--------
|
||||
|
||||
LibGTop is a library that read information about processes and the running
|
||||
systems. This information include:
|
||||
|
||||
General System Information
|
||||
|
||||
cpu - CPU Usage
|
||||
mem - Memory Usage
|
||||
swap - Swap Usage (including paging activity)
|
||||
loadavg - Load average (including nr_running, nr_tasks, last_pid)
|
||||
uptime - Uptime and Idle time, can be calculated from CPU usage
|
||||
|
||||
SYS V IPC Limits:
|
||||
|
||||
shm_limits - Shared Memory Limits
|
||||
msg_limits - Message Queue Limits
|
||||
sem_limits - Semaphore Set Limits
|
||||
|
||||
Process List:
|
||||
|
||||
proclist - List of processes
|
||||
|
||||
Process information:
|
||||
|
||||
proc_state - cmd, state, uid, gid
|
||||
proc_uid - uid,euid,gid,egid,pid,ppid,pgrp
|
||||
session,tty,tpgid,priority,nice
|
||||
proc_mem - size,vsize,resident,share,rss,rss_rlim
|
||||
proc_time - start_time,rtime,utime,stime,cutime,cstime
|
||||
timeout,it_real_value,frequency
|
||||
proc_signal - signal,blocked,sigignore,sigcatch
|
||||
proc_kernel - k_flags,min_flt,maj_flt,cmin_flt,cmaj_flt
|
||||
kstk_esp,kstk_eip,nwchan,wchan
|
||||
proc_segment - text_rss,shlib_rss,data_rss,stack_rss,dirty_size
|
||||
start_code,end_code,start_stack
|
||||
|
||||
Process maps:
|
||||
|
||||
proc_map - Process map (/proc/<pid>/maps under Linux)
|
||||
|
||||
File system usage:
|
||||
|
||||
mountlist - List of currently mounted filesystems
|
||||
fsusage - File system usage
|
||||
|
||||
PORTABILITY:
|
||||
-----------
|
||||
|
||||
LibGtop is designed to be as portable as possible. None of the functions
|
||||
and retrieved information should be specific to a specific operating
|
||||
system. So you only need to port the system dependent part of the library
|
||||
to a new system and all application programs can then use libgtop on this
|
||||
new system.
|
||||
|
||||
CLIENT/SERVER MODEL:
|
||||
-------------------
|
||||
|
||||
Some systems like DEC OSF/1 or BSD require special priviledges for the calling
|
||||
proces to fetch the required information (SUID root/SGID kmem). To solve this
|
||||
problem, I designed a client/server model which makes a call to a SUID/SGID
|
||||
server which fetches the required information whenever it is required. This
|
||||
server is only called for features that really require priviledges, otherwise
|
||||
the sysdeps code is called directory (every user can get the CPU usage on
|
||||
DEC OSF/1, but only root can get information about processes other than the
|
||||
current one).
|
||||
|
||||
There is also some kind of daemon which can be used to fetch information from
|
||||
remote systems (still experimental). This daemon normally runs as nobody and
|
||||
calls the SUID/SGID itself when needed.
|
||||
|
||||
GNOME APPLETS:
|
||||
--------------
|
||||
|
||||
There are some applets and applications which already use LibGTop. They can
|
||||
be found in the `libgtop-apps' module in the GNOME CVS tree:
|
||||
|
||||
* Applets: cpuload, cpumemusage - they need LibGTop to get their information
|
||||
on all systems other than Linux.
|
||||
|
||||
* Applets: diskusage - just uses the mountlist/fsusage features of LibGTop,
|
||||
the one in gnome-core also works on other systems.
|
||||
|
||||
* Applets: multiload - I enhanced the cpuload applet a little bit, it is
|
||||
now a multi applet and can display CPU, Memory and
|
||||
Swap usages.
|
||||
|
||||
GTOP:
|
||||
----
|
||||
|
||||
This cool GNOME app has been ported to use LibGTop. It can be found in
|
||||
`libgtop-apps/gtop' in the GNOME CVS tree.
|
||||
|
||||
You can now use nearly the full functionality of GTop on FreeBSD !
|
||||
|
||||
|
||||
PLATTFORM SPECIFIC NOTES FOR LINUX:
|
||||
==================================
|
||||
|
||||
Under Linux, LibGTop should work without problems and read everything
|
||||
from /proc.
|
||||
|
||||
There is also an experimental kernel interface to read this information
|
||||
directly from the kernel with a system call - but this is still experimental
|
||||
and not well tested while I made this release.
|
||||
|
||||
PLATTFORM SPECIFIC NOTES FOR FREEBSD:
|
||||
====================================
|
||||
|
||||
LibGTop should now work under FreeBSD and give you the full functionality
|
||||
of GTop.
|
||||
|
||||
There are a few caveats:
|
||||
|
||||
* You need to manually make the `$(prefix)/bin/libgtop_server' SGID to kmem
|
||||
after installation and mount the /proc filesystem of FreeBSD
|
||||
(/proc/<pid>/mem is used withing kvm_uread ()).
|
||||
|
||||
* To get the filenames of the process maps displayed in GTop, you need to
|
||||
configure with the `--with-libgtop-inodedb' option (you need GDBM for this
|
||||
to work).
|
||||
|
||||
* You have then to create an inode database which is used to look up to
|
||||
filenames. This is done using the `mkinodedb' program which comes along
|
||||
with libgtop.
|
||||
|
||||
See the file src/inodedb/README for details:
|
||||
|
||||
The `mkinodedb' program which is build in this directory takes two
|
||||
command line arguments: the full pathname of the database to be created
|
||||
and the name of a configuration file consisting of directory and file names
|
||||
each on a line by itself - see `/etc/ld.so.conf' for an example.
|
||||
|
||||
Putting a directory name in this file means all regular files found in this
|
||||
directory are included in the database, but it will not recursively descend
|
||||
into subdirectories (for instance, we want everythink in `/usr/lib' but not
|
||||
every single file in `/usr/lib/sgml'). You can also use filenames to include
|
||||
a single file.
|
||||
|
||||
Have fun,
|
||||
|
||||
Martin <martin@home-of-linux.org>
|
1
AUTHORS
1
AUTHORS
@@ -1 +1,2 @@
|
||||
Martin Baulig (martin@home-of-linux.org)
|
||||
Josh Sled <jsled@scam.XCF.Berkeley.EDU>
|
||||
|
617
ChangeLog
617
ChangeLog
@@ -1,5 +1,622 @@
|
||||
1998-08-29 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* LIBGTOP-VERSION (LIBGTOP_INTERFACE_AGE, LIBGTOP_BINARY_AGE): Added.
|
||||
* configure.in (LIBGTOP_INTERFACE_AGE, LIBGTOP_BINARY_AGE): AC_SUBST.
|
||||
(LT_RELEASE, LT_CURRENT, LT_REVISION, LT_AGE): AC_SUBST.
|
||||
(LT_VERSION_INFO): Sets `-version-info' for libtool.
|
||||
|
||||
1998-08-25 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* src/daemon/ChangeLog: New file.
|
||||
|
||||
* sysdeps/sun4/ChangeLog: New file.
|
||||
|
||||
* sysdeps/stub/ChangeLog: New file.
|
||||
|
||||
* configure.in: Added check for `-lsocket'.
|
||||
(LIBGTOP_INCS): Added $(SUPPORTINCS).
|
||||
(INCLUDES): Added $(SUPPORTINCS).
|
||||
|
||||
* acconfig.h: Added `NEED_DECLARATION_GETHOSTNAME',
|
||||
`NEED_DECLARATION_SETREUID', `NEED_DECLARATION_SETREGID'
|
||||
and `NEED_DECLARATION_GETPAGESIZE'.
|
||||
|
||||
* includue/glibtop/global.h (<gnomesupport.h>): Include this.
|
||||
|
||||
* lib/init.c (_init_server): Declared `static'.
|
||||
|
||||
* lib/read_data.c: Added cast to `const void *' in calls to
|
||||
`recv' and `read' to avoid compiler warnings.
|
||||
|
||||
* configure.in (INCLUDES): No longer using installed header files.
|
||||
|
||||
1998-08-23 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* features.def (mountlist): Using `int(fs_usage)'.
|
||||
|
||||
1998-08-21 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* ANNOUNCE-0.25: Released LibGTop 0.25 stable.
|
||||
|
||||
1998-08-18 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* LIBGTOP-VERSION: Set version number to 0.25.0. There is now really
|
||||
a feature freeze until it's released, bug fixes only ...
|
||||
|
||||
* include/glibtop/procmap (glibtop_map_entry): Added `flags' and
|
||||
`filename' fields.
|
||||
|
||||
* LIBGTOP-VERSION: Added `LIBGTOP_MICRO_VERSION'.
|
||||
* libgtopConf.sh.in: Likewise.
|
||||
|
||||
* libgtopConf.sh.in: Added `LIBGTOP_EXTRA_LIBS'.
|
||||
|
||||
* sysdeps/linux/procmap.c: Added implementation.
|
||||
|
||||
1998-08-17 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* include/glibtop/procmap (glibtop_map_entry): Added `offset' and
|
||||
`perm' fields.
|
||||
|
||||
* src/inodedb: New directory.
|
||||
* src/inodedb/README: New file - read it to know what this is about.
|
||||
|
||||
* configure.in (--with-libgtop-inodedb): New `configure' parameter.
|
||||
* include/glibtop/inodedb.h: New file.
|
||||
* sysdeps/common/inodedb.c: New file.
|
||||
|
||||
1998-08-17 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* LIBGTOP-VERSION: Released libgtop-0.25pre1. With this
|
||||
release I made what Linus calles a ``feature freeze'' until
|
||||
0.25 is out. A Tarball and RPMS can be found at my site:
|
||||
`ftp://ftp.home-of-linux.org/pub/'.
|
||||
|
||||
1998-08-17 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* libgtop-conf.in: New file.
|
||||
|
||||
1998-08-16 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* include/glibtop/loadavg.h (glibtop_loadavg): Added new
|
||||
fields `nr_running', `nr_tasks', `last_pid'.
|
||||
* features.def (loadavg): Added new fields `nr_running',
|
||||
`nr_tasks', `last_pid'.
|
||||
|
||||
1998-08-12 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* include/glibtop/procsegment.h (glibtop_proc_segment): Using
|
||||
`text_rss', `shlib_rss', `data_rss' and `dirty_size' instead of
|
||||
`tsr', `lrs', `drs' and `dt'. New field `stack_rss'.
|
||||
|
||||
* sysdeps/linux/procmem.c: Memory sizes now correctly in bytes.
|
||||
* sysdeps/linux/procsegment.c: Dito.
|
||||
|
||||
* sysdeps/kernel/procsegment.c: Stack pages are reported via
|
||||
`stack_rss' and no longer count towards `data_rss'
|
||||
* kernel/table.h (table_proc_segment): Added `srs' field.
|
||||
* kernel/table21/module.c (TBL_PROC_SEGMENT): Added kernel support
|
||||
for this.
|
||||
|
||||
* sysdeps/{linux, kernel, stub}/procmap.c: New files.
|
||||
|
||||
1998-08-11 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* guile/features.awk: New file.
|
||||
* guile/make-docbook.scm: Improved automatical generation of
|
||||
the documentation file `reference.sgml'.
|
||||
* guile/reference.sgml: This file is automatically generated,
|
||||
but many people have problems with it, so we add it to CVS.
|
||||
|
||||
1998-08-10 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* include/glibtop/procmap.h (glibtop_proc_map): New file.
|
||||
* features.def: Added definition of `proc_map'.
|
||||
|
||||
* include/glibtop/proctime.h (glibtop_proc_time): Added new
|
||||
fields `rtime' and `frequency'.
|
||||
|
||||
1998-08-09 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* include/glibtop/prockernel.h (glibtop_proc_kernel): Renamed
|
||||
`wchan' field to `nwchan'; added `wchan' which is of type `char [40]'.
|
||||
|
||||
* features.def: Changed format of this file to support multiple
|
||||
arguments to be passed to a function.
|
||||
|
||||
* include/glibtop/proclist.h: `glibtop_get_proclist' now takes two
|
||||
more arguments `method' and `param'.
|
||||
|
||||
1998-08-07 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* sysdeps/freebsd/ChangeLog: New file.
|
||||
|
||||
* src/server: Removed.
|
||||
* src/daemon/{server, version}.c: New files.
|
||||
* src/daemon/Makefile.am: Added `libgtop_server'; this has been
|
||||
moved here from `src/server' since it shares some source code files
|
||||
with the `libgtop_daemon'.
|
||||
|
||||
* LIBGTOP-VERSION: Added `LIBGTOP_SERVER_VERSION'.
|
||||
* src/daemon/gnuserv.c, lib/open.c: Improved version check between
|
||||
client and server.
|
||||
|
||||
* include/glibtop/output.h: Removed.
|
||||
|
||||
* sysdeps/stub_suid: New directory. This is mainly used as example
|
||||
for people porting libgtop to other systems.
|
||||
|
||||
* sysdeps/common/sysdeps_suid.c: New file.
|
||||
Defines `glibtop_init_hook_p'.
|
||||
|
||||
* sysdeps/osf1/*.c (glibtop_init_<no-suid-feature>_s): New functions.
|
||||
(glibtop_init_<suid-feature>_p): New functions.
|
||||
|
||||
1998-08-07 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* glibtop.h (_glibtop): New fields `error_method', `sysdeps' and
|
||||
`required'. I added an improved error handling: the client can tell
|
||||
the libraries which fields are absolutely required for each features
|
||||
and if it fails to set one of them, this will create an error which
|
||||
is handled depending upon the `error_method'.
|
||||
|
||||
* include/glibtop/open.h: Define some constants for `error_method'.
|
||||
|
||||
* lib/sysdeps.c (glibtop_get_sysdeps_r): No longer actually call any
|
||||
sysdeps function, it now simply copies `server->sysdeps'.
|
||||
(_glibtop_init_hook_s): Added. List of functions to be called during
|
||||
`glibtop_init_s' set to `glibtop_init_<no-suid-feature>_s'.
|
||||
|
||||
* include/glibtop/sysdeps.h (<glibtop/union.h>): Removed.
|
||||
(glibtop_init_func_t): New typedef.
|
||||
(_glibtop_init_hook_s): Added.
|
||||
|
||||
* sysdeps/linux/*.c (glibtop_init_<feature>_s): New functions.
|
||||
(glibtop_get_proc_*): Zero is now a valid pid.
|
||||
|
||||
* sysdeps/kernel/*.c (glibtop_init_<feature>_s): New functions.
|
||||
(glibtop_get_proc_*): Zero is now a valid pid.
|
||||
|
||||
1998-08-06 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* configure.in (HAVE_SOCKETS, HAVE_SOCKADDR_SUN_LEN): New checks.
|
||||
|
||||
* include/glibtop/*.h: Using `GLIBTOP_GUILE' instead of `HAVE_GUILE'
|
||||
so one should be able to use libgtop without guile in an application
|
||||
even if guile is installed.
|
||||
|
||||
* sysdeps/common/mountlist.c: Fixed some `xstrdup' problems.
|
||||
|
||||
* lib/open.c: Now correctly reading server features for
|
||||
`GLIBTOP_METHOD_PIPE'.
|
||||
|
||||
* sysdeps/freebsd: New directory.
|
||||
|
||||
1998-08-01 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* include/glibtop/swap.h (glibtop_swap): Added `pagein' and `pageout'.
|
||||
|
||||
* kernel/table20/table.h: Removed.
|
||||
* kernel/table21/table.h: Removed.
|
||||
* kernel/table.h: Added. Things are now binary compatible between
|
||||
both kernel versions.
|
||||
|
||||
1998-07-30 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* acconfig.h (u_int64_t, int64_t): Added.
|
||||
|
||||
* lib/lib.awk: Using correct `(1 << GLIBTOP_SYSDEPS_<feature>)'
|
||||
in call to `glibtop_init_r'.
|
||||
|
||||
* configure.in (GNOME_LIBGTOP_TYPES): New check.
|
||||
|
||||
* include/glibtop/*.h: Using `u_int64_t' instead of `unsigned long'
|
||||
and `long' to avoid problems when client is on a 32bit system and
|
||||
the server on a 64bit system.
|
||||
|
||||
* sysdeps/common/gnuslib.c: Using `0xffffffff' instead of -1
|
||||
as error code for inet_addr () since on 64bit systems,
|
||||
`inet_addr (some_error) != (INET_ADDR) -1'.
|
||||
|
||||
* configure.in: Only defining guile stuff if
|
||||
we really have guile.
|
||||
|
||||
1998-07-29 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* guile/ChangeLog: New file.
|
||||
|
||||
* features.def: New format - now includes type of return value
|
||||
and parameters.
|
||||
|
||||
* lib/lib.awk: Changed to use new `features.def'.
|
||||
* sysdeps/guile/guile.awk: Dito;
|
||||
* sysdeps/guile/names/guile-names.awk: Dito.
|
||||
|
||||
* libgtopConf.sh.in: Added
|
||||
`LIBGTOP_NAMES_LIBS', `LIBGTOP_NAMES_INCS',
|
||||
`LIBGTOP_GUILE_NAMES_LIBS', `LIBGTOP_GUILE_NAMES_INCS',
|
||||
`LIBGTOP_MAJOR_VERSION', `LIBGTOP_MINOR_VERSION'
|
||||
`LIBGTOP_VERSION', `libgtop_sysdeps_dir'.
|
||||
|
||||
* acinclude.m4 (AC_LC_SYSDEPS): Removed since this has been
|
||||
replaced with `GNOME_LIBGTOP_SYSDEPS' long ago.
|
||||
|
||||
* LIBGTOP-VERSION: New file.
|
||||
|
||||
* */Makefile.am (INCLUDES): Removed; now defined in `configure.in'.
|
||||
|
||||
* sysdeps/names/mountlist.c: New file.
|
||||
|
||||
* lib/{init, open}.c (GTOP_SERVER): Renamed to `LIBGTOP_SERVER'.
|
||||
|
||||
* configure.in (INCLUDES): Added definition.
|
||||
(libgtop_want_names): Always true; `libgtop_names.la' is now
|
||||
always created since some other programs rely upon it - but
|
||||
have to use `LIBGTOP_NAMES_LIBS' and `LIBGTOP_NAMES_INCS' to
|
||||
use it in your application.
|
||||
(libgtop_want_guile_names): Always true; but you have to use
|
||||
`LIBGTOP_GUILE_NAMES_LIBS' and `LIBGTOP_GUILE_NAMES_INCS' to
|
||||
use it in your application.
|
||||
(LIBGTOP_LIBS): Removed `-lgtop_names' and `-lgtop_guile_names'.
|
||||
(LIBGTOP_NAMES_LIBS): New variable. Use it to link your
|
||||
application with the names interface.
|
||||
(LIBGTOP_NAMES_INCS): New variable. Also #defines `GLIBTOP_NAMES'
|
||||
which is now required if your application wants to use the names
|
||||
interface.
|
||||
(LIBGTOP_GUILE_NAMES_LIBS): New variable. Use it to link your
|
||||
application with the guile names interface.
|
||||
(LIBGTOP_GUILE_NAMES_INCS): New variable. Also #defines
|
||||
`GLIBTOP_NAMES' and `GLIBTOP_GUILE_NAMES' which are now required
|
||||
if your application wants to use the guile names interface.
|
||||
|
||||
1998-07-24 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* sysdeps/common/mountlist.c (glibtop_get_mountlist_s):
|
||||
Added `all_fs' parameter.
|
||||
|
||||
* sysdeps/{kernel, linux}/*.c: Replaced `glibtop_init_r' with
|
||||
`glibtop_init_s'.
|
||||
|
||||
* sysdeps/sun4/open.c (glibtop_init_p): Removed `program_name'
|
||||
parameter.
|
||||
|
||||
* sysdeps/osf1/glibtop_suid.h: New file.
|
||||
|
||||
* sysdeps/osf1/glibtop_server.h: Now correctly using
|
||||
`(1 << GLIBTOP_SYSDEPS_*)' instead of `GLIBTOP_SYSDEPS_*'.
|
||||
|
||||
* sysdeps/osf1/open_suid.c (glibtop_init_p): New function.
|
||||
|
||||
* sysdeps/osf1/proc*.c: Done some more work here.
|
||||
|
||||
1998-07-23 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* include/glibtop/procsignal.h (glibtop_proc_signal):
|
||||
Changed type for `signal', `blocked', `sigignore' and
|
||||
`sigcatch' to `unsigned long long'.
|
||||
|
||||
1998-07-22 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* include/glibtop/fsusage.h: New file.
|
||||
|
||||
* features.def: Added new feature `fsusage'.
|
||||
|
||||
* sysdeps/common/fsusage.c (glibtop_get_fsusage_s): New function.
|
||||
(get_fs_usage): Declared as `static'.
|
||||
|
||||
* sysdeps/names/fsusage.c: New file.
|
||||
|
||||
* include/glibtop/mountlist.h: New file.
|
||||
|
||||
* features.def: Added new feature `mountlist'.
|
||||
|
||||
* sysdeps/common/mountlist.c (glibtop_get_mountlist_s): New function.
|
||||
(read_filesystem_list): Declared as `static'.
|
||||
|
||||
* sysdeps/common/Makefile.am (libgtop_common_la_SOURCES):
|
||||
Added `fsusage.[ch]' and `mountlist.[ch]'.
|
||||
|
||||
* include/glibtop/signal.h: New file.
|
||||
|
||||
* sysdeps/{kernel, linux, osf1, sun4, stub}/siglist.c: New files.
|
||||
|
||||
1998-07-22 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* lib/init.c (glibtop_init_s): Added this init function of
|
||||
the sysdeps directory `libgtop_sysdeps.la'.
|
||||
|
||||
* lib/open.c (glibtop_open_l): Unconditionally calling
|
||||
`glibtop_init_s' after server initialization.
|
||||
|
||||
* lib/lib.awk: Removed references to functions from
|
||||
`libgtop_sysdeps_suid.la' to avoid undefined symbols.
|
||||
|
||||
* sysdeps/stub/open.c (glibtop_open_s): Renamed this
|
||||
function from `glibtop_open_r'.
|
||||
|
||||
* sysdeps/stub/close.c (glibtop_close_s): Renamed this
|
||||
function from `glibtop_close_l'.
|
||||
|
||||
* sysdeps/kernel/open.c (glibtop_open_s): Renamed this
|
||||
function from `glibtop_open_r'.
|
||||
|
||||
* sysdeps/kernel/close.c (glibtop_close_s): Renamed this
|
||||
function from `glibtop_close_l'.
|
||||
|
||||
* sysdeps/linux/open.c (glibtop_open_s): Renamed this
|
||||
function from `glibtop_open_r'.
|
||||
|
||||
* sysdeps/linux/close.c (glibtop_close_s): Renamed this
|
||||
function from `glibtop_close_l'.
|
||||
|
||||
* sysdeps/osf1/Makefile.am (lib_LTLIBRARIES): Added
|
||||
`libgtop_sysdeps_suid.la' for the suid server.
|
||||
|
||||
* sysdeps/osf1/open_suid.c (glibtop_open_p): New file.
|
||||
Contains all stuff that was formerly in `open.c'.
|
||||
|
||||
* sysdeps/osf1/open.c: Moved everything from here into
|
||||
the new file `open_suid.c'.
|
||||
|
||||
* sysdeps/osf1/open.c (glibtop_open_s): New function.
|
||||
|
||||
* sysdeps/osf1/close_suid.c (glibtop_close_p): New file.
|
||||
|
||||
* sysdeps/osf1/close.c (glibtop_close_s): New function.
|
||||
|
||||
* sysdeps/osf1/*.c: Using the new init, open and close
|
||||
functions.
|
||||
|
||||
* sysdeps/sun4/Makefile.am (lib_LTLIBRARIES): Added
|
||||
`libgtop_sysdeps_suid.la' for the suid server.
|
||||
|
||||
* sysdeps/sun4/nosuid.c (glibtop_open_s, glibtop_close_s): New file
|
||||
|
||||
* sysdeps/sun4/*.c: All functions now have the `_p' suffix.
|
||||
|
||||
* sysdeps/common/Makefile.am (lib_LTLIBRARIES): Added
|
||||
`libgtop_suid_common.la' which only contains stuff that is
|
||||
needed in the suid parts.
|
||||
|
||||
* sysdeps/common/xmalloc.c: Using `glibtop_error_io_r' instead
|
||||
of `glibtop_error_r'.
|
||||
|
||||
* sysdeps/{kernel, linux, osf1, sun4, stub}/init.c: Removed.
|
||||
`glibtop_init_s' has been moved into `lib/init.c' since it's the
|
||||
same in all the sysdeps directories.
|
||||
|
||||
* src/server/main.c: It is now an error to request a feature that
|
||||
does not need the suid server.
|
||||
|
||||
* src/proxy: Removed.
|
||||
|
||||
1998-07-21 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* doc/ChangeLog: New file.
|
||||
|
||||
* sysdeps/kernel/*.c: Using `glibtop_error_io_r' instead
|
||||
of `glibtop_error_r'.
|
||||
|
||||
* sysdeps/kernel/proclist.c: Now using the table () function, too.
|
||||
This means that currently the table () function can fetch all
|
||||
information for libgtop and you can even unmount /proc !
|
||||
|
||||
1998-07-18 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* lib/{init, open}.c: Added `GLIBTOP_METHOD_PIPE' again.
|
||||
|
||||
* src/server/main.c: Removed gettext stuff.
|
||||
|
||||
1998-07-17 Martin Baulig <baulig@Stud.Informatik.uni-trier.de>
|
||||
|
||||
* sysdeps/common/sysdeps.c (glibtop_get_sysdeps_r): Using
|
||||
library functions with '_l' prefix instead of directly calling
|
||||
sysdeps code with '_r' prefix. This is necessary for client/server
|
||||
mode.
|
||||
|
||||
* lib/lib.awk (glibtop_get_*): Now correctly using
|
||||
`(1 << GLIBTOP_SYSDEPS_*)' instead of `GLIBTOP_SYSDEPS_*'.
|
||||
|
||||
* sysdeps/sun4/proclist.c (glibtop_get_proclist_p): Added
|
||||
implementation of that feature.
|
||||
|
||||
* sysdeps/sun4/proc_{uid, state}.c: Now working quite well.
|
||||
|
||||
* sysdeps/sun4/proc_{mem, time, signal, kernel, segment}.c: Added
|
||||
some basic implementation; this isn't really working yet.
|
||||
|
||||
* sysdeps/linux/sem_limits.c: Applied patch from Albert K T Hui
|
||||
<avatar@deva.net> for glibc 2.1.
|
||||
|
||||
1998-07-15 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* sysdeps/sun4/loadavg.h: New file. Imported from top 3.4.
|
||||
|
||||
* sysdeps/sun4/uptime.c (glibtop_get_uptime_p): Added
|
||||
implementation of that function using glibtop_get_cpu ().
|
||||
|
||||
* sysdeps/sun4/loadavg.c (glibtop_get_loadavg_p): Added
|
||||
implementation of that feature.
|
||||
|
||||
* sysdeps/sun4/{shm_limits.c, msg_limits.c, shm_limits.c}:
|
||||
Added implementation of this features.
|
||||
|
||||
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'.
|
||||
|
23
LIBGTOP-VERSION
Normal file
23
LIBGTOP-VERSION
Normal file
@@ -0,0 +1,23 @@
|
||||
# Making releases:
|
||||
# LIBGTOP_MICRO_VERSION += 1;
|
||||
# LIBGTOP_INTERFACE_AGE += 1;
|
||||
# LIBGTOP_BINARY_AGE += 1;
|
||||
# if any functions have been added, set LIBGTOP_INTERFACE_AGE to 0.
|
||||
# if backwards compatibility has been broken,
|
||||
# set LIBGTOP_BINARY_AGE and LIBGTOP_INTERFACE_AGE to 0.
|
||||
#
|
||||
LIBGTOP_MAJOR_VERSION=0
|
||||
LIBGTOP_MINOR_VERSION=25
|
||||
LIBGTOP_MICRO_VERSION=1
|
||||
|
||||
LIBGTOP_INTERFACE_AGE=0
|
||||
LIBGTOP_BINARY_AGE=0
|
||||
|
||||
LIBGTOP_VERSION=$LIBGTOP_MAJOR_VERSION.$LIBGTOP_MINOR_VERSION.$LIBGTOP_MICRO_VERSION
|
||||
|
||||
# Increase each time you change the client/server protocol.
|
||||
LIBGTOP_SERVER_VERSION=1
|
||||
|
||||
# For automake.
|
||||
VERSION=$LIBGTOP_VERSION
|
||||
PACKAGE=libgtop
|
69
Makefile.am
69
Makefile.am
@@ -1,18 +1,28 @@
|
||||
## Process this file with automake to produce Makefile.in.
|
||||
|
||||
if GLIBTOP_EXAMPLES
|
||||
examples_SUBDIRS = examples
|
||||
if EXAMPLES
|
||||
examples_SUBDIRS = examples
|
||||
else
|
||||
examples_SUBDIRS =
|
||||
endif
|
||||
|
||||
built_SUBDIRS = include sysdeps lib src
|
||||
if GUILE
|
||||
guile_SUBDIRS = guile
|
||||
else
|
||||
guile_SUBDIRS =
|
||||
endif
|
||||
|
||||
SUBDIRS = po intl support macros $(built_SUBDIRS) $(examples_SUBDIRS)
|
||||
|
||||
DIST_SUBDIRS = po intl macros include sysdeps src lib examples
|
||||
SUBDIRS = po intl support macros include sysdeps lib src \
|
||||
$(examples_SUBDIRS)
|
||||
|
||||
DIST_SUBDIRS = po intl support macros include sysdeps src lib guile examples
|
||||
|
||||
include_HEADERS = glibtop.h
|
||||
|
||||
EXTRA_DIST = autogen.sh libgtop.spec copyright.txt libgtopConf.sh.in
|
||||
EXTRA_DIST = autogen.sh libgtop.spec copyright.txt libgtopConf.sh.in \
|
||||
LIBGTOP-VERSION features.def perl/Makefile.PL.in perl/perl.awk \
|
||||
perl/MANIFEST perl/Changes libgtop-config.in RELNOTES-0.25
|
||||
|
||||
release:
|
||||
$(MAKE) dist distdir=$(PACKAGE)$(VERSION)
|
||||
@@ -22,6 +32,11 @@ release:
|
||||
confexecdir=$(libdir)
|
||||
confexec_DATA = $(top_builddir)/libgtopConf.sh
|
||||
|
||||
bin_SCRIPTS = $(top_builddir)/libgtop-config
|
||||
|
||||
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
|
||||
@@ -33,6 +48,40 @@ confexec_DATA = $(top_builddir)/libgtopConf.sh
|
||||
## the value NONE in configure if the user doesn't specify them (this
|
||||
## is an autoconf feature, not a bug).
|
||||
libgtopConf.sh: libgtopConf.sh.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_EXTRA_LIBS\@,$(LIBGTOP_EXTRA_LIBS),g' \
|
||||
-e 's,\@LIBGTOP_LIBS\@,$(LIBGTOP_LIBS),g' \
|
||||
-e 's,\@LIBGTOP_INCS\@,$(LIBGTOP_INCS),g' \
|
||||
-e 's,\@LIBGTOP_NAMES_LIBS\@,$(LIBGTOP_NAMES_LIBS),g' \
|
||||
-e 's,\@LIBGTOP_NAMES_INCS\@,$(LIBGTOP_NAMES_INCS),g' \
|
||||
-e 's,\@LIBGTOP_GUILE_LIBS\@,$(LIBGTOP_GUILE_LIBS),g' \
|
||||
-e 's,\@LIBGTOP_GUILE_INCS\@,$(LIBGTOP_GUILE_INCS),g' \
|
||||
-e 's,\@LIBGTOP_GUILE_NAMES_LIBS\@,$(LIBGTOP_GUILE_NAMES_LIBS),g' \
|
||||
-e 's,\@LIBGTOP_GUILE_NAMES_INCS\@,$(LIBGTOP_GUILE_NAMES_INCS),g' \
|
||||
-e 's,\@LIBGTOP_BINDIR\@,$(LIBGTOP_BINDIR),g' \
|
||||
-e 's,\@LIBGTOP_SERVER\@,$(LIBGTOP_SERVER),g' \
|
||||
-e 's,\@LIBGTOP_MAJOR_VERSION\@,$(LIBGTOP_MAJOR_VERSION),g' \
|
||||
-e 's,\@LIBGTOP_MINOR_VERSION\@,$(LIBGTOP_MINOR_VERSION),g' \
|
||||
-e 's,\@LIBGTOP_MICRO_VERSION\@,$(LIBGTOP_MICRO_VERSION),g' \
|
||||
-e 's,\@LIBGTOP_VERSION\@,$(LIBGTOP_VERSION),g' \
|
||||
-e 's,\@LIBGTOP_SERVER_VERSION\@,$(LIBGTOP_SERVER_VERSION),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_examples\@,$(libgtop_want_examples),g' \
|
||||
< $(srcdir)/libgtopConf.sh.in > libgtopConf.tmp \
|
||||
&& mv libgtopConf.tmp libgtopConf.sh
|
||||
|
||||
libgtop-config: libgtop-config.in Makefile
|
||||
sed -e 's,\@LIBGTOP_LIBDIR\@,$(libdir),g' \
|
||||
< $(srcdir)/libgtop-config.in > libgtop-config.tmp \
|
||||
&& mv libgtop-config.tmp libgtop-config && \
|
||||
chmod 755 libgtop-config
|
||||
|
||||
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' \
|
||||
@@ -49,5 +98,9 @@ libgtopConf.sh: libgtopConf.sh.in Makefile
|
||||
-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)/libgtopConf.sh.in > libgtopConf.tmp \
|
||||
&& mv libgtopConf.tmp libgtopConf.sh
|
||||
< $(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
|
||||
|
146
RELNOTES-0.25
Normal file
146
RELNOTES-0.25
Normal file
@@ -0,0 +1,146 @@
|
||||
RELEASE NOTES FOR LIBGTOP 0.25 STABLE
|
||||
=====================================
|
||||
|
||||
OVERVIEW
|
||||
--------
|
||||
|
||||
LibGTop is a library that read information about processes and the running
|
||||
systems. This information include:
|
||||
|
||||
General System Information
|
||||
|
||||
cpu - CPU Usage
|
||||
mem - Memory Usage
|
||||
swap - Swap Usage (including paging activity)
|
||||
loadavg - Load average (including nr_running, nr_tasks, last_pid)
|
||||
uptime - Uptime and Idle time, can be calculated from CPU usage
|
||||
|
||||
SYS V IPC Limits:
|
||||
|
||||
shm_limits - Shared Memory Limits
|
||||
msg_limits - Message Queue Limits
|
||||
sem_limits - Semaphore Set Limits
|
||||
|
||||
Process List:
|
||||
|
||||
proclist - List of processes
|
||||
|
||||
Process information:
|
||||
|
||||
proc_state - cmd, state, uid, gid
|
||||
proc_uid - uid,euid,gid,egid,pid,ppid,pgrp
|
||||
session,tty,tpgid,priority,nice
|
||||
proc_mem - size,vsize,resident,share,rss,rss_rlim
|
||||
proc_time - start_time,rtime,utime,stime,cutime,cstime
|
||||
timeout,it_real_value,frequency
|
||||
proc_signal - signal,blocked,sigignore,sigcatch
|
||||
proc_kernel - k_flags,min_flt,maj_flt,cmin_flt,cmaj_flt
|
||||
kstk_esp,kstk_eip,nwchan,wchan
|
||||
proc_segment - text_rss,shlib_rss,data_rss,stack_rss,dirty_size
|
||||
start_code,end_code,start_stack
|
||||
|
||||
Process maps:
|
||||
|
||||
proc_map - Process map (/proc/<pid>/maps under Linux)
|
||||
|
||||
File system usage:
|
||||
|
||||
mountlist - List of currently mounted filesystems
|
||||
fsusage - File system usage
|
||||
|
||||
PORTABILITY:
|
||||
-----------
|
||||
|
||||
LibGtop is designed to be as portable as possible. None of the functions
|
||||
and retrieved information should be specific to a specific operating
|
||||
system. So you only need to port the system dependent part of the library
|
||||
to a new system and all application programs can then use libgtop on this
|
||||
new system.
|
||||
|
||||
CLIENT/SERVER MODEL:
|
||||
-------------------
|
||||
|
||||
Some systems like DEC OSF/1 or BSD require special priviledges for the calling
|
||||
proces to fetch the required information (SUID root/SGID kmem). To solve this
|
||||
problem, I designed a client/server model which makes a call to a SUID/SGID
|
||||
server which fetches the required information whenever it is required. This
|
||||
server is only called for features that really require priviledges, otherwise
|
||||
the sysdeps code is called directory (every user can get the CPU usage on
|
||||
DEC OSF/1, but only root can get information about processes other than the
|
||||
current one).
|
||||
|
||||
There is also some kind of daemon which can be used to fetch information from
|
||||
remote systems (still experimental). This daemon normally runs as nobody and
|
||||
calls the SUID/SGID itself when needed.
|
||||
|
||||
GNOME APPLETS:
|
||||
--------------
|
||||
|
||||
There are some applets and applications which already use LibGTop. They can
|
||||
be found in the `libgtop-apps' module in the GNOME CVS tree:
|
||||
|
||||
* Applets: cpuload, cpumemusage - they need LibGTop to get their information
|
||||
on all systems other than Linux.
|
||||
|
||||
* Applets: diskusage - just uses the mountlist/fsusage features of LibGTop,
|
||||
the one in gnome-core also works on other systems.
|
||||
|
||||
* Applets: multiload - I enhanced the cpuload applet a little bit, it is
|
||||
now a multi applet and can display CPU, Memory and
|
||||
Swap usages.
|
||||
|
||||
GTOP:
|
||||
----
|
||||
|
||||
This cool GNOME app has been ported to use LibGTop. It can be found in
|
||||
`libgtop-apps/gtop' in the GNOME CVS tree.
|
||||
|
||||
You can now use nearly the full functionality of GTop on FreeBSD !
|
||||
|
||||
|
||||
PLATTFORM SPECIFIC NOTES FOR LINUX:
|
||||
==================================
|
||||
|
||||
Under Linux, LibGTop should work without problems and read everything
|
||||
from /proc.
|
||||
|
||||
There is also an experimental kernel interface to read this information
|
||||
directly from the kernel with a system call - but this is still experimental
|
||||
and not well tested while I made this release.
|
||||
|
||||
PLATTFORM SPECIFIC NOTES FOR FREEBSD:
|
||||
====================================
|
||||
|
||||
LibGTop should now work under FreeBSD and give you the full functionality
|
||||
of GTop.
|
||||
|
||||
There are a few caveats:
|
||||
|
||||
* You need to manually make the `$(prefix)/bin/libgtop_server' SGID to kmem
|
||||
after installation and mount the /proc filesystem of FreeBSD
|
||||
(/proc/<pid>/mem is used withing kvm_uread ()).
|
||||
|
||||
* To get the filenames of the process maps displayed in GTop, you need to
|
||||
configure with the `--with-libgtop-inodedb' option (you need GDBM for this
|
||||
to work).
|
||||
|
||||
* You have then to create an inode database which is used to look up to
|
||||
filenames. This is done using the `mkinodedb' program which comes along
|
||||
with libgtop.
|
||||
|
||||
See the file src/inodedb/README for details:
|
||||
|
||||
The `mkinodedb' program which is build in this directory takes two
|
||||
command line arguments: the full pathname of the database to be created
|
||||
and the name of a configuration file consisting of directory and file names
|
||||
each on a line by itself - see `/etc/ld.so.conf' for an example.
|
||||
|
||||
Putting a directory name in this file means all regular files found in this
|
||||
directory are included in the database, but it will not recursively descend
|
||||
into subdirectories (for instance, we want everythink in `/usr/lib' but not
|
||||
every single file in `/usr/lib/sgml'). You can also use filenames to include
|
||||
a single file.
|
||||
|
||||
Have fun,
|
||||
|
||||
Martin <martin@home-of-linux.org>
|
103
acconfig.h
103
acconfig.h
@@ -1,3 +1,18 @@
|
||||
|
||||
/* Define if gethostname () must be declared. */
|
||||
#undef NEED_DECLARATION_GETHOSTNAME
|
||||
|
||||
/* Define if setreuid () must be declared. */
|
||||
#undef NEED_DECLARATION_SETREUID
|
||||
|
||||
/* Define if setregid () must be declared. */
|
||||
#undef NEED_DECLARATION_SETREGID
|
||||
|
||||
/* Define if getpagesize () must be declared. */
|
||||
#undef NEED_DECLARATION_GETPAGESIZE
|
||||
|
||||
@TOP@
|
||||
|
||||
#undef ENABLE_NLS
|
||||
#undef HAVE_CATGETS
|
||||
#undef HAVE_GETTEXT
|
||||
@@ -12,10 +27,92 @@
|
||||
|
||||
/* 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
|
||||
|
||||
#undef HAVE_SOCKETS
|
||||
#undef HAVE_SOCKADDR_SUN_LEN
|
||||
|
||||
#undef HAVE_LIBJPEG
|
||||
#undef HAVE_LIBGIF
|
||||
#undef HAVE_LIBTIFF
|
||||
@@ -24,16 +121,22 @@
|
||||
#undef GNOME_ENABLE_DEBUG
|
||||
#undef HAVE_GMP2_INCLUDE_DIR
|
||||
#undef HAVE_GUILE
|
||||
|
||||
#undef ssize_t
|
||||
#undef u_int64_t
|
||||
#undef int64_t
|
||||
|
||||
#undef HAVE_GLIBTOP_MACHINE_H
|
||||
|
||||
#undef GLIBTOP_NAMES
|
||||
#undef GLIBTOP_GUILE
|
||||
#undef GLIBTOP_GUILE_NAMES
|
||||
#undef GLIBTOP_EXAMPLES
|
||||
#undef GLIBTOP_INODEDB
|
||||
|
||||
#undef NEED_LIBGTOP
|
||||
|
||||
#undef HAVE_LINUX_TABLE
|
||||
|
||||
#undef HAVE_XAUTH
|
||||
|
||||
|
91
acinclude.m4
91
acinclude.m4
@@ -10,97 +10,6 @@ dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
dnl PARTICULAR PURPOSE.
|
||||
|
||||
AC_DEFUN([AC_LC_CANONICAL_HOST],[
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
# The way shlib-versions is used to generate soversions.mk uses a
|
||||
# fairly simplistic model for name recognition that can't distinguish
|
||||
# i486-pc-linux-gnu fully from i486-pc-gnu. So we mutate a $host_os
|
||||
# of `gnu*' here to be `gnu-gnu*' just so that shlib-versions can
|
||||
# tell. This doesn't get used much beyond that, so it's fairly safe.
|
||||
case "$host_os" in
|
||||
linux*)
|
||||
;;
|
||||
gnu*)
|
||||
host_os=`echo $host_os | sed -e 's/gnu/gnu-gnu/'`
|
||||
;;
|
||||
esac
|
||||
])
|
||||
|
||||
|
||||
AC_DEFUN([AC_LC_SYSDEPS],[
|
||||
AC_REQUIRE([AC_LC_CANONICAL_HOST])
|
||||
AC_REQUIRE([GNOME_LIBGTOP_SYSDEPS])
|
||||
|
||||
AC_MSG_CHECKING(whether we need the gtop_server)
|
||||
|
||||
AC_ARG_ENABLE(libgtop-server,
|
||||
[ --enable-libgtop-server use gtop_server [default=auto]],
|
||||
[if test "x$enableval" = "xyes" ; then
|
||||
libgtop_need_server=yes
|
||||
elif test "x$enableval" = "xno" ; then
|
||||
libgtop_need_server=no
|
||||
fi])
|
||||
|
||||
AC_MSG_RESULT($libgtop_need_server)
|
||||
|
||||
AC_MSG_CHECKING(whether building of libgtop names is requested)
|
||||
|
||||
AC_ARG_ENABLE(libgtop-names,
|
||||
[ --enable-libgtop-names enable building of 'names' subdirs [default=yes]],
|
||||
[if test "x$enableval" = "xyes" ; then
|
||||
libgtop_want_names=yes
|
||||
else
|
||||
libgtop_want_names=$enableval
|
||||
fi],[libgtop_want_names=yes])
|
||||
|
||||
AC_MSG_RESULT($libgtop_want_names)
|
||||
|
||||
if test x$libgtop_want_names = xyes ; then
|
||||
AC_DEFINE(GLIBTOP_NAMES)
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(GLIBTOP_NAMES, test x$libgtop_want_names = xyes)
|
||||
|
||||
AC_MSG_CHECKING(whether building of the guile interface is requested)
|
||||
|
||||
AC_ARG_ENABLE(libgtop-guile,
|
||||
[ --enable-libgtop-guile enable building of the guile interface [default=yes]],
|
||||
[if test "x$enableval" = "xyes" ; then
|
||||
libgtop_want_guile=yes
|
||||
else
|
||||
libgtop_want_guile=$enableval
|
||||
fi],[libgtop_want_guile=yes])
|
||||
|
||||
AC_MSG_RESULT($libgtop_want_guile)
|
||||
|
||||
AC_MSG_CHECKING(whether building of the examples is requested)
|
||||
|
||||
AC_ARG_ENABLE(libgtop-examples,
|
||||
[ --disable-libgtop-examples disable building of the examples],
|
||||
[if test "x$enableval" = "xyes" ; then
|
||||
libgtop_want_examples=yes
|
||||
else
|
||||
libgtop_want_examples=$enableval
|
||||
fi],[libgtop_want_examples=yes])
|
||||
|
||||
AC_MSG_RESULT($libgtop_want_examples)
|
||||
|
||||
if test x$libgtop_want_examples = xyes ; then
|
||||
AC_DEFINE(GLIBTOP_EXAMPLES)
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(GLIBTOP_EXAMPLES, test x$libgtop_want_examples = xyes)
|
||||
|
||||
if test x$libgtop_use_machine_h = xyes ; then
|
||||
machine_incs="-I\$(top_srcdir)/sysdeps/$sysdeps_dir"
|
||||
fi
|
||||
|
||||
AC_SUBST(machine_incs)
|
||||
AC_SUBST(libgtop_want_names)
|
||||
AC_SUBST(libgtop_want_guile)
|
||||
AC_SUBST(libgtop_want_examples)
|
||||
])
|
||||
|
||||
######################################################################
|
||||
# progtest.m4 from gettext 0.32
|
||||
######################################################################
|
||||
|
292
configure.in
292
configure.in
@@ -6,6 +6,29 @@ AC_INIT(copyright.txt)
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
AC_CANONICAL_SYSTEM
|
||||
|
||||
. $srcdir/LIBGTOP-VERSION
|
||||
AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
|
||||
|
||||
AC_SUBST(LIBGTOP_MAJOR_VERSION)
|
||||
AC_SUBST(LIBGTOP_MINOR_VERSION)
|
||||
AC_SUBST(LIBGTOP_MICRO_VERSION)
|
||||
AC_SUBST(LIBGTOP_INTERFACE_AGE)
|
||||
AC_SUBST(LIBGTOP_BINARY_AGE)
|
||||
AC_SUBST(LIBGTOP_SERVER_VERSION)
|
||||
AC_SUBST(LIBGTOP_VERSION)
|
||||
|
||||
# libtool versioning
|
||||
LT_RELEASE=$LIBGTOP_MAJOR_VERSION.$LIBGTOP_MINOR_VERSION
|
||||
LT_CURRENT=`expr $LIBGTOP_MICRO_VERSION - $LIBGTOP_INTERFACE_AGE`
|
||||
LT_REVISION=$LIBGTOP_INTERFACE_AGE
|
||||
LT_AGE=`expr $LIBGTOP_BINARY_AGE - $LIBGTOP_INTERFACE_AGE`
|
||||
LT_VERSION_INFO='-version-info ${LT_CURRENT}:${LT_REVISION}:${LT_AGE}'
|
||||
AC_SUBST(LT_VERSION_INFO)
|
||||
AC_SUBST(LT_RELEASE)
|
||||
AC_SUBST(LT_CURRENT)
|
||||
AC_SUBST(LT_REVISION)
|
||||
AC_SUBST(LT_AGE)
|
||||
|
||||
AM_ACLOCAL_INCLUDE(macros)
|
||||
|
||||
AC_ISC_POSIX
|
||||
@@ -13,7 +36,10 @@ AC_PROG_CC
|
||||
AC_STDC_HEADERS
|
||||
AC_ARG_PROGRAM
|
||||
|
||||
AC_PROG_AWK
|
||||
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(RANLIB,ranlib)
|
||||
@@ -32,8 +58,6 @@ export cross_compiling
|
||||
|
||||
AM_PROG_LIBTOOL
|
||||
|
||||
AM_INIT_AUTOMAKE(libgtop, 0.01)
|
||||
|
||||
dnl If you want to use libgtop without gnome, comment the following line out.
|
||||
GNOME_INIT_HOOK(gnome_found=yes)
|
||||
|
||||
@@ -44,21 +68,46 @@ else
|
||||
AM_CONDITIONAL(CROSS_COMPILING, test "x$cross_compiling" = xyes)
|
||||
fi
|
||||
|
||||
AC_LC_SYSDEPS
|
||||
GNOME_LIBGTOP_SYSDEPS
|
||||
GNOME_LIBGTOP_TYPES
|
||||
|
||||
if test x$libgtop_want_guile = xyes ; then
|
||||
GNOME_CHECK_GUILE
|
||||
if test x$ac_cv_guile_found = xyes ; then
|
||||
if test x$libgtop_want_names = xyes ; then
|
||||
AC_DEFINE(GLIBTOP_GUILE_NAMES)
|
||||
fi
|
||||
guile_examples='third third_static'
|
||||
guile_subdirs='guile'
|
||||
else
|
||||
guile_examples=
|
||||
guile_subdirs=
|
||||
fi
|
||||
GNOME_CHECK_GUILE
|
||||
|
||||
dnl For Solaris
|
||||
AC_CHECK_LIB(socket, socket)
|
||||
|
||||
AC_ARG_WITH(libgtop-guile,
|
||||
[ --with-libgtop-guile Build the libgtop guile interface (default=yes)],
|
||||
[build_guile="$withval"], [build_guile=yes])
|
||||
|
||||
test x$build_guile = xno && ac_cv_guile_found=no
|
||||
|
||||
AC_ARG_WITH(libgtop-inodedb,
|
||||
[ --with-libgtop-inodedb Build the inodedb stuff (default=no)],
|
||||
[build_inodedb="$withval"], [build_inodedb=no])
|
||||
|
||||
LIBGTOP_EXTRA_LIBS=
|
||||
|
||||
if test x$build_inodedb = xyes ; then
|
||||
AC_CHECK_LIB(gdbm, gdbm_open, LIBGTOP_EXTRA_LIBS='-lgdbm', build_inodedb=no)
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(INODEDB, test x$build_inodedb = xyes)
|
||||
|
||||
if test x$build_inodedb = xyes ; then
|
||||
AC_DEFINE(GLIBTOP_INODEDB)
|
||||
fi
|
||||
|
||||
AC_DEFINE(GLIBTOP_NAMES)
|
||||
|
||||
if test x$ac_cv_guile_found = xyes ; then
|
||||
AC_DEFINE(GLIBTOP_GUILE)
|
||||
AC_DEFINE(GLIBTOP_GUILE_NAMES)
|
||||
libgtop_guile_found=yes
|
||||
guile_examples='third third_static'
|
||||
guile_subdirs='guile'
|
||||
else
|
||||
libgtop_guile_found=no
|
||||
guile_examples=
|
||||
guile_subdirs=
|
||||
fi
|
||||
@@ -92,6 +141,21 @@ AC_CHECK_LIB(kvm, kvm_open)
|
||||
dnl For DEC OSF1
|
||||
AC_CHECK_LIB(mach, vm_statistics)
|
||||
|
||||
dnl Check for Internet sockets.
|
||||
AC_CHECK_FUNC(socket,
|
||||
[AC_CHECK_HEADER(netinet/in.h,
|
||||
[AC_CHECK_HEADER(arpa/inet.h, [
|
||||
AC_DEFINE(HAVE_SOCKETS)
|
||||
AC_MSG_CHECKING("for sun_len member in struct sockaddr_un")
|
||||
AC_TRY_LINK([
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
],
|
||||
[static struct sockaddr_un x; x.sun_len = 1;],
|
||||
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOCKADDR_SUN_LEN)],
|
||||
[AC_MSG_RESULT(no)])])])])
|
||||
|
||||
dnl Checks for library functions.
|
||||
AC_FUNC_ALLOCA
|
||||
AC_FUNC_MMAP
|
||||
@@ -121,99 +185,15 @@ test -z "$with_xauth" && { AC_CHECK_LIB(Xau, XauGetAuthByAddr,[:],with_xauth=no,
|
||||
test -z "$with_xauth" && with_xauth=yes
|
||||
if test "$with_xauth" = "yes"; then
|
||||
AC_DEFINE(HAVE_XAUTH)
|
||||
XE_SPACE(libs_xauth, $X_EXTRA_LIBS -lXau $libs_x $X_PRE_LIBS)
|
||||
XE_SPACE(libs_xauth, $X_LIBS -lXau)
|
||||
fi
|
||||
AC_SUBST(libs_xauth)
|
||||
|
||||
|
||||
CFLAGS="$CFLAGS -D_IN_LIBGTOP"
|
||||
|
||||
AC_SUBST(CFLAGS)
|
||||
AC_SUBST(CPPFLAGS)
|
||||
AC_SUBST(LDFLAGS)
|
||||
dnl For diskusage stuff
|
||||
GNOME_FILEUTILS_CHECKS
|
||||
|
||||
AC_ARG_ENABLE(debug, [ --enable-debug turn on debugging [default=no]],AC_DEFINE(GNOME_ENABLE_DEBUG),)
|
||||
|
||||
dnl If you want to use libgtop without gnome, uncomment the following paragraph:
|
||||
dnl LIBSUPPORT=
|
||||
dnl SUPPORTINCS=
|
||||
dnl if test "$need_gnome_support" = yes; then
|
||||
dnl LIBSUPPORT='$(top_builddir)/support/libgnomesupport.la'
|
||||
dnl SUPPORTINCS='-I$(top_srcdir)/support'
|
||||
dnl fi
|
||||
dnl AC_SUBST(LIBSUPPORT)
|
||||
dnl AC_SUBST(SUPPORTINCS)
|
||||
|
||||
dnl Some ugly hack; if '-lgnomesupport' is part of $GNOME_LIBS, we include it here.
|
||||
echo "$GNOME_LIBS" | grep -q -e '-lgnomesupport'
|
||||
if test $? = 0 ; then
|
||||
LIBSUPPORT="$GNOME_LIBDIR -lgnomesupport"
|
||||
SUPPORTINCS="$GNOME_INCLUDEDIR"
|
||||
fi
|
||||
AC_SUBST(LIBSUPPORT)
|
||||
AC_SUBST(SUPPORTINCS)
|
||||
|
||||
dnl These definitions are expanded in make.
|
||||
LIBGTOP_LIBS='-L$(libdir)'
|
||||
LIBGTOP_INCS='-I$(includedir)'
|
||||
LIBGTOP_GUILE_LIBS="$LIBGTOP_LIBS"
|
||||
LIBGTOP_GUILE_INCS="$LIBGTOP_INCS"
|
||||
LIBGTOP_BINDIR='$(bindir)'
|
||||
LIBGTOP_SERVER='$(bindir)/gtop_server'
|
||||
|
||||
sysdeps_dir="$libgtop_sysdeps_dir"
|
||||
AC_SUBST(sysdeps_dir)
|
||||
|
||||
if test x$ac_cv_guile_found = xyes ; then
|
||||
LIBGTOP_GUILE_LIBS="$LIBGTOP_GUILE_LIBS -lgtop_guile"
|
||||
libgtop_guile_found=yes
|
||||
else
|
||||
libgtop_guile_found=no
|
||||
fi
|
||||
|
||||
AC_SUBST(libgtop_guile_found)
|
||||
|
||||
if test x$libgtop_want_names = xyes ; then
|
||||
if test x$ac_cv_guile_found = xyes ; then
|
||||
LIBGTOP_GUILE_LIBS="$LIBGTOP_GUILE_LIBS -lgtop_guile_names"
|
||||
libgtop_want_guile_names=yes
|
||||
else
|
||||
libgtop_want_guile_names=no
|
||||
fi
|
||||
LIBGTOP_LIBS="$LIBGTOP_LIBS -lgtop_names"
|
||||
LIBGTOP_GUILE_LIBS="$LIBGTOP_GUILE_LIBS -lgtop_names"
|
||||
fi
|
||||
|
||||
AC_SUBST(libgtop_want_guile_names)
|
||||
|
||||
LIBGTOP_LIBS="$LIBGTOP_LIBS -lgtop_common"
|
||||
LIBGTOP_GUILE_LIBS="$LIBGTOP_GUILE_LIBS -lgtop_common"
|
||||
|
||||
if test "x$need_server" = "xyes" ; then
|
||||
LIBGTOP_LIBS="$LIBGTOP_LIBS -lgtop"
|
||||
LIBGTOP_GUILE_LIBS="$LIBGTOP_GUILE_LIBS -lgtop"
|
||||
else
|
||||
LIBGTOP_LIBS="$LIBGTOP_LIBS -lgtop_sysdeps"
|
||||
LIBGTOP_GUILE_LIBS="$LIBGTOP_GUILE_LIBS -lgtop_sysdeps"
|
||||
fi
|
||||
|
||||
if test "x$ac_cv_guile_found" = "xyes" ; then
|
||||
LIBGTOP_INCS="$LIBGTOP_INCS $GUILE_INCS"
|
||||
LIBGTOP_GUILE_INCS="$LIBGTOP_INCS $GUILE_INCS"
|
||||
LIBGTOP_GUILE_LIBS="$LIBGTOP_GUILE_LIBS $GUILE_LIBS"
|
||||
fi
|
||||
|
||||
machine_incs='-I$(top_srcdir)/sysdeps/@sysdeps_dir@'
|
||||
|
||||
AC_SUBST(machine_incs)
|
||||
|
||||
AC_SUBST(LIBGTOP_LIBS)
|
||||
AC_SUBST(LIBGTOP_INCS)
|
||||
AC_SUBST(LIBGTOP_GUILE_LIBS)
|
||||
AC_SUBST(LIBGTOP_GUILE_INCS)
|
||||
AC_SUBST(LIBGTOP_BINDIR)
|
||||
AC_SUBST(LIBGTOP_SERVER)
|
||||
|
||||
LIBSUPPORT=
|
||||
SUPPORTINCS=
|
||||
if test "$need_gnome_support" = yes; then
|
||||
@@ -226,6 +206,105 @@ if test "$need_gnome_support" = yes; then
|
||||
fi
|
||||
fi
|
||||
|
||||
dnl Some ugly hack; if '-lgnomesupport' is part of $GNOME_LIBS,
|
||||
dnl we include it here.
|
||||
echo "$GNOME_LIBS" | grep -q -e '-lgnomesupport'
|
||||
if test $? = 0 ; then
|
||||
LIBSUPPORT="$GNOME_LIBDIR -lgnomesupport"
|
||||
SUPPORTINCS="$GNOME_INCLUDEDIR"
|
||||
fi
|
||||
AC_SUBST(LIBSUPPORT)
|
||||
AC_SUBST(SUPPORTINCS)
|
||||
|
||||
dnl These definitions are expanded in make.
|
||||
LIBGTOP_LIBS='-L$(libdir) -lgtop'
|
||||
LIBGTOP_INCS='-I$(includedir)'
|
||||
|
||||
if test x$build_inodedb = xyes ; then
|
||||
LIBGTOP_INCS="$LIBGTOP_INCS -DGLIBTOP_INODEDB"
|
||||
fi
|
||||
|
||||
LIBGTOP_INCS="$LIBGTOP_INCS $SUPPORTINCS"
|
||||
|
||||
LIBGTOP_GUILE_LIBS="$LIBGTOP_LIBS"
|
||||
LIBGTOP_GUILE_INCS="$LIBGTOP_INCS"
|
||||
LIBGTOP_BINDIR='$(bindir)'
|
||||
LIBGTOP_SERVER='$(bindir)/libgtop_server'
|
||||
|
||||
sysdeps_dir="$libgtop_sysdeps_dir"
|
||||
AC_SUBST(sysdeps_dir)
|
||||
|
||||
if test x$ac_cv_guile_found = xyes ; then
|
||||
LIBGTOP_GUILE_LIBS="$LIBGTOP_GUILE_LIBS -lgtop_guile"
|
||||
libgtop_guile_found=yes
|
||||
else
|
||||
libgtop_guile_found=no
|
||||
fi
|
||||
|
||||
AC_SUBST(libgtop_guile_found)
|
||||
|
||||
if test -z $LIBGTOP_EXTRA_LIBS ; then
|
||||
LIBGTOP_EXTRA_LIBS="$libs_xauth"
|
||||
else
|
||||
LIBGTOP_EXTRA_LIBS="$LIBGTOP_EXTRA_LIBS $libs_xauth"
|
||||
fi
|
||||
|
||||
LIBGTOP_LIBS="$LIBGTOP_LIBS -lgtop_common -lgtop_sysdeps"
|
||||
LIBGTOP_GUILE_LIBS="$LIBGTOP_GUILE_LIBS -lgtop_common -lgtop_sysdeps"
|
||||
|
||||
LIBGTOP_NAMES_LIBS="$LIBGTOP_LIBS -lgtop_names"
|
||||
LIBGTOP_GUILE_NAMES_LIBS="$LIBGTOP_GUILE_LIBS -lgtop_guile_names"
|
||||
LIBGTOP_GUILE_NAMES_LIBS="$LIBGTOP_GUILE_LIBS -lgtop_names"
|
||||
|
||||
LIBGTOP_LIBS="$LIBGTOP_LIBS"
|
||||
LIBGTOP_NAMES_LIBS="$LIBGTOP_NAMES_LIBS"
|
||||
LIBGTOP_GUILE_LIBS="$LIBGTOP_GUILE_LIBS"
|
||||
LIBGTOP_GUILE_NAMES_LIBS="$LIBGTOP_GUILE_NAMES_LIBS"
|
||||
|
||||
LIBGTOP_GUILE_LIBS="$LIBGTOP_GUILE_LIBS $GUILE_LIBS"
|
||||
LIBGTOP_GUILE_INCS="$LIBGTOP_GUILE_INCS $GUILE_INCS -DGLIBTOP_GUILE"
|
||||
|
||||
LIBGTOP_NAMES_INCS="$LIBGTOP_INCS -DGLIBTOP_NAMES"
|
||||
LIBGTOP_GUILE_NAMES_INCS="$LIBGTOP_GUILE_INCS -DGLIBTOP_GUILE_NAMES"
|
||||
LIBGTOP_GUILE_NAMES_INCS="$LIBGTOP_GUILE_INCS -DGLIBTOP_NAMES"
|
||||
|
||||
machine_incs="-I\$(top_srcdir)/sysdeps/$sysdeps_dir"
|
||||
|
||||
AC_SUBST(machine_incs)
|
||||
|
||||
if test x$libgtop_guile_found = xyes ; then
|
||||
guile_def="-DGLIBTOP_GUILE -DGLIBTOP_GUILE_NAMES $GUILE_INCS "
|
||||
else
|
||||
guile_def=""
|
||||
fi
|
||||
|
||||
INCLUDES="-D_IN_LIBGTOP -D_GNU_SOURCE -DGLIBTOP_NAMES -I\$(top_builddir) -I\$(top_srcdir) -I\$(top_srcdir)/sysdeps/$sysdeps_dir -I\$(top_srcdir)/include -I\$(top_srcdir)/intl $SUPPORTINCS -W -Wall -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith $CFLAGS $guile_def "'-DGTOPLOCALEDIR=\"$(datadir)/locale\" -DLIBGTOP_VERSION=\"'"$LIBGTOP_VERSION"'\" -DLIBGTOP_SERVER_VERSION=\"'"$LIBGTOP_SERVER_VERSION"'\" -DLIBGTOP_SERVER=\"'"$LIBGTOP_SERVER"'\"'
|
||||
|
||||
AC_SUBST(INCLUDES)
|
||||
|
||||
AC_SUBST(LIBGTOP_EXTRA_LIBS)
|
||||
|
||||
AC_SUBST(LIBGTOP_LIBS)
|
||||
AC_SUBST(LIBGTOP_INCS)
|
||||
AC_SUBST(LIBGTOP_NAMES_LIBS)
|
||||
AC_SUBST(LIBGTOP_NAMES_INCS)
|
||||
AC_SUBST(LIBGTOP_GUILE_LIBS)
|
||||
AC_SUBST(LIBGTOP_GUILE_INCS)
|
||||
AC_SUBST(LIBGTOP_GUILE_NAMES_LIBS)
|
||||
AC_SUBST(LIBGTOP_GUILE_NAMES_INCS)
|
||||
AC_SUBST(LIBGTOP_BINDIR)
|
||||
AC_SUBST(LIBGTOP_SERVER)
|
||||
|
||||
if test x$libgtop_need_server = xyes ; then
|
||||
sysdeps_suid_lib="\$(top_builddir)/sysdeps/\$(sysdeps_dir)/libgtop_sysdeps_suid.la"
|
||||
server_programs='libgtop_server'
|
||||
else
|
||||
sysdeps_suid_lib=
|
||||
server_programs=
|
||||
fi
|
||||
AC_SUBST(sysdeps_suid_lib)
|
||||
AC_SUBST(server_programs)
|
||||
|
||||
AC_OUTPUT([
|
||||
Makefile
|
||||
po/Makefile.in
|
||||
@@ -238,15 +317,18 @@ sysdeps/names/Makefile
|
||||
sysdeps/guile/Makefile
|
||||
sysdeps/guile/names/Makefile
|
||||
sysdeps/stub/Makefile
|
||||
sysdeps/stub_suid/Makefile
|
||||
sysdeps/sun4/Makefile
|
||||
sysdeps/osf1/Makefile
|
||||
sysdeps/linux/Makefile
|
||||
sysdeps/kernel/Makefile
|
||||
sysdeps/freebsd/Makefile
|
||||
src/Makefile
|
||||
src/server/Makefile
|
||||
src/proxy/Makefile
|
||||
src/daemon/Makefile
|
||||
src/inodedb/Makefile
|
||||
lib/Makefile
|
||||
guile/Makefile
|
||||
examples/Makefile
|
||||
perl/Makefile.PL
|
||||
support/Makefile
|
||||
macros/Makefile],[sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile])
|
||||
|
@@ -1,22 +1,10 @@
|
||||
*.shml
|
||||
*.ced
|
||||
.timestamp
|
||||
.timestamp2
|
||||
.timestamp3
|
||||
dbtohtml-1.shtml
|
||||
dbtohtml-2.shtml
|
||||
dbtohtml-3.shtml
|
||||
dbtohtml.shtml
|
||||
.timestamp4
|
||||
gnome-hackers
|
||||
gnome-hackers.ced
|
||||
libgtop
|
||||
libgtop-1.shtml
|
||||
libgtop-2.shtml
|
||||
libgtop-3.shtml
|
||||
libgtop-4.shtml
|
||||
libgtop-5.shtml
|
||||
libgtop-INDEX.shtml
|
||||
libgtop-ref
|
||||
libgtop-ref.ced
|
||||
libgtop.ced
|
||||
libgtop.fot
|
||||
libgtop.shtml
|
||||
table
|
||||
|
18
doc/ChangeLog
Normal file
18
doc/ChangeLog
Normal file
@@ -0,0 +1,18 @@
|
||||
1998-08-12 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* features: New directory.
|
||||
* gnome-hackers.sgml: Updated documentation.
|
||||
|
||||
1998-08-11 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* gnome-hackers.sgml: Updated documentation.
|
||||
* autoconf.sgml: New file, included from `gnome-hackers.sgml'.
|
||||
|
||||
1998-07-21 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* gnome-hackers.sgml: Added note that this file is
|
||||
currently out of date and a link to the documentation
|
||||
of the table () function.
|
||||
|
||||
* table.sgml: New file - basic documentation for the
|
||||
table () system call.
|
33
doc/Makefile
33
doc/Makefile
@@ -1,22 +1,39 @@
|
||||
all: .timestamp .timestamp2 .timestamp3
|
||||
all: .timestamp .timestamp2 .timestamp3 .timestamp4
|
||||
|
||||
clean:
|
||||
-rm -f .timestamp*
|
||||
-rm -rf libgtop gnome-hackers libgtop-ref table
|
||||
|
||||
.timestamp: libgtop.sgml
|
||||
rm -rf libgtop
|
||||
-rm -rf libgtop
|
||||
mkdir libgtop
|
||||
jade -D /usr/lib/sgml/jade_dsl -d libgtop.dsl -t sgml \
|
||||
-rm -f .timestamp
|
||||
jade -D /usr/lib/sgml -d libgtop.dsl -t sgml \
|
||||
-V %no-make-index% libgtop.sgml > /dev/null && \
|
||||
touch .timestamp
|
||||
|
||||
.timestamp2: gnome-hackers.sgml
|
||||
rm -rf gnome-hackers
|
||||
.timestamp2: gnome-hackers.sgml autoconf.sgml ../guile/reference.sgml \
|
||||
features/uptime.sgml features/uptime.txt features/proclist.sgml \
|
||||
features/procmem.sgml
|
||||
-rm -rf gnome-hackers
|
||||
mkdir gnome-hackers
|
||||
jade -D /usr/lib/sgml/jade_dsl -d gnome-hackers.dsl -t sgml \
|
||||
-rm -f .timestamp2
|
||||
jade -D /usr/lib/sgml -d gnome-hackers.dsl -t sgml \
|
||||
-V %no-make-index% gnome-hackers.sgml > /dev/null && \
|
||||
touch .timestamp2
|
||||
|
||||
.timestamp3: libgtop-ref.sgml ../guile/reference.sgml
|
||||
rm -rf libgtop-ref
|
||||
-rm -rf libgtop-ref
|
||||
mkdir libgtop-ref
|
||||
jade -D /usr/lib/sgml/jade_dsl -d libgtop-ref.dsl -t sgml \
|
||||
-rm -f .timestamp3
|
||||
jade -D /usr/lib/sgml -d libgtop-ref.dsl -t sgml \
|
||||
-V %no-make-index% libgtop-ref.sgml > /dev/null && \
|
||||
touch .timestamp3
|
||||
|
||||
.timestamp4: table.sgml
|
||||
-rm -rf table
|
||||
mkdir table
|
||||
-rm -f .timestamp4
|
||||
jade -D /usr/lib/sgml -d table.dsl -t sgml \
|
||||
-V %no-make-index% table.sgml > /dev/null && \
|
||||
touch .timestamp4
|
||||
|
253
doc/autoconf.sgml
Normal file
253
doc/autoconf.sgml
Normal file
@@ -0,0 +1,253 @@
|
||||
<sect1 id="macros">
|
||||
<title>Autoconf macros</title>
|
||||
|
||||
<para>
|
||||
All you need to check for &libgtop; is in &gnome-libgtop-check.m4;,
|
||||
just use <function>GNOME_INIT_LIBGTOP</function> with an optional
|
||||
<parameter>fail</parameter> argument in the same way like
|
||||
<function>GNOME_INIT</function>:
|
||||
|
||||
<example>
|
||||
<title>Warn if &libgtop; cannot be found</title>
|
||||
|
||||
<programlisting>GNOME_INIT_LIBGTOP</programlisting>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<title>Abort if &libgtop; cannot be found</title>
|
||||
|
||||
<programlisting>GNOME_INIT_LIBGTOP(fail)</programlisting>
|
||||
</example>
|
||||
|
||||
<para>
|
||||
This will define a <function>HAVE_LIBGTOP</function> automake
|
||||
conditional and everything from the configuration script of
|
||||
&libgtop;.
|
||||
|
||||
<sect1 id="libgtopConf.sh">
|
||||
<title>The configuration script of &libgtop; (&libgtopConf.sh;)</title>
|
||||
|
||||
<para>
|
||||
After a successful build of &libgtop;, a &libgtopConf.sh; script
|
||||
containing useful configuration variables is created.
|
||||
|
||||
<para>
|
||||
It defines the following variables which you can use in your
|
||||
<filename>Makefile.am</filename>:
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>LIBGTOP_LIBDIR</parameter></term>
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
The directory where the library files of &libgtop; are installed.
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>LIBGTOP_INCLUDEDIR</parameter></term>
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
The directory where the header files of &libgtop; are installed.
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>LIBGTOP_LIBS</parameter></term>
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
Use this to link your program with &libgtop;.
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>LIBGTOP_INCS</parameter></term>
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
Use this to get the header files for &libgtop;.
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>LIBGTOP_NAMES_LIBS</parameter></term>
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
Use this to link your program with &libgtop; and its
|
||||
names interface.
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>LIBGTOP_NAMES_INCS</parameter></term>
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
Use this to get the header files for &libgtop; and the
|
||||
required <literal>-DGLIBTOP_NAMES</literal> to get its
|
||||
names interface.
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>LIBGTOP_GUILE_LIBS</parameter></term>
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
Use this to link your program with &libgtop; and its
|
||||
guile interface. This will also include all the required
|
||||
guile libraries.
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>LIBGTOP_GUILE_INCS</parameter></term>
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
Use this to get the header files for &libgtop; and guile
|
||||
and the required <literal>-DGLIBTOP_GUILE</literal> to get
|
||||
the guile interface of &libgtop;.
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>LIBGTOP_GUILE_NAMES_LIBS</parameter></term>
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
Use this to link your program with &libgtop; and both its
|
||||
names and its guile interface. This will also include all the
|
||||
required guile libraries.
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>LIBGTOP_GUILE_NAMES_INCS</parameter></term>
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
Use this to get the header files for &libgtop;, its guile
|
||||
and its names interface, the guile header files and the
|
||||
required <literal>-DGLIBTOP_GUILE</literal> and
|
||||
<literal>-DGLIBTOP_NAMES</literal>.
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>LIBGTOP_BINDIR</parameter></term>
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
The directory where the binaries of &libgtop; are installed.
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>LIBGTOP_SERVER</parameter></term>
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
Full pathname of the &libgtop; server.
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>LIBGTOP_MAJOR_VERSION</parameter></term>
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
Major version of &libgtop;.
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>LIBGTOP_MINOR_VERSION</parameter></term>
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
Minor version of &libgtop;.
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>LIBGTOP_VERSION</parameter></term>
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
Full version of &libgtop;.
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>LIBGTOP_SERVER_VERSION</parameter></term>
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
Version of the &libgtop; server. This is incremented each
|
||||
time the client/server protocol changes.
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>libgtop_sysdeps_dir</parameter></term>
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
The sysdeps directory that is used on your system.
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>libgtop_need_server</parameter></term>
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
Either <literal>yes</literal> or <literal>no</literal>.
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>libgtop_use_machine_h</parameter></term>
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
Either <literal>yes</literal> or <literal>no</literal>.
|
||||
Intended for <emphasis>internal use only</emphasis>
|
||||
and may be removed in future versions.
|
||||
|
||||
<note>
|
||||
<title>Note for &libgtop; hackers</title>
|
||||
|
||||
<para>
|
||||
This variable gets set in
|
||||
<filename>macros/gnome-libgtop-sysdeps.m4</filename>.
|
||||
|
||||
<para>
|
||||
If this is enabled, you need to put a
|
||||
<filename>glibtop_machine.h</filename> header file in the
|
||||
sysdeps directory which needs to define a structure of
|
||||
type <type>glibtop_machine</type>.
|
||||
|
||||
<para>
|
||||
This structure represents the
|
||||
<structfield>machine</structfield> field of
|
||||
<type>glibtop</type> defined in
|
||||
<filename>glibtop.h</filename>
|
||||
and can be used to store some
|
||||
machine dependent data.
|
||||
</note>
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>libgtop_guile_found</parameter></term>
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
Either <literal>yes</literal> or <literal>no</literal>.
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>libgtop_want_examples</parameter></term>
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
Considered obsolete.
|
||||
|
||||
</variablelist>
|
||||
|
||||
<para>
|
||||
All this variables are taken from the
|
||||
&libgtopConf.sh; script which is created during
|
||||
the installation of &libgtop;.
|
||||
|
||||
<example>
|
||||
<title>
|
||||
Sample &libgtopConf.sh; (gnome and guile are installed in
|
||||
<filename>/home/baulig/INSTALL</filename> and &libgtop; in
|
||||
<filename>/home/norwegen/TEST</filename>)
|
||||
</title>
|
||||
|
||||
<programlisting>&example-libgtopConf-sh;</programlisting>
|
||||
</example>
|
||||
|
||||
</sect1>
|
||||
|
||||
<!--
|
||||
Local Variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:2
|
||||
sgml-indent-data: t
|
||||
sgml-parent-document: ("gnome-hackers.sgml" "book" "chapter" "")
|
||||
End:
|
||||
-->
|
153
doc/features/proclist.sgml
Normal file
153
doc/features/proclist.sgml
Normal file
@@ -0,0 +1,153 @@
|
||||
<para>
|
||||
This functions takes the following additional parameters:
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>which</parameter></term>
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
You can use the following constants (defined in
|
||||
<filename>glibtop/proclist.h</filename>) to tell
|
||||
<function>glibtop_get_proclist ()</function> which processes
|
||||
to fetch:
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>GLIBTOP_KERN_PROC_ALL</parameter></term>
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
Fetch all processes.
|
||||
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>GLIBTOP_KERN_PROC_PID</parameter></term>
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
Fetch process with pid <parameter>arg</parameter> or
|
||||
nothing if no such process exists.
|
||||
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>GLIBTOP_KERN_PROC_PGRP</parameter></term>
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
Fetch only processes which are in process group
|
||||
<parameter>arg</parameter>.
|
||||
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>GLIBTOP_KERN_PROC_SESSION</parameter></term>
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
Fetch only processes with session id
|
||||
<parameter>arg</parameter>.
|
||||
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>GLIBTOP_KERN_PROC_TTY</parameter></term>
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
Fetch only processes with tty id
|
||||
<parameter>arg</parameter>.
|
||||
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>GLIBTOP_KERN_PROC_UID</parameter></term>
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
Fetch only processes with effective user id
|
||||
<parameter>arg</parameter>.
|
||||
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>GLIBTOP_KERN_PROC_RUID</parameter></term>
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
Fetch only processes with real user id
|
||||
<parameter>arg</parameter>.
|
||||
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
|
||||
<para>
|
||||
You can use one or more of the following flags (with a
|
||||
logical or) to hide some processes:
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>GLIBTOP_EXCLUDE_IDLE</parameter></term>
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
Don't fetch idle processes.
|
||||
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>GLIBTOP_EXCLUDE_SYSTEM</parameter></term>
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
Don't fetch system processes.
|
||||
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>GLIBTOP_EXCLUDE_NOTTY</parameter></term>
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
Don't fetch processes that have no controlling tty.
|
||||
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>arg</parameter></term>
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
Additional argument depending upon the
|
||||
<parameter>which</parameter> argument.
|
||||
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
|
||||
<para>
|
||||
This function returns a pointer (of type <type>unsigned *</type>) to
|
||||
the list of process ids.
|
||||
|
||||
<para>
|
||||
You have to manually &glibtop-free; this pointer once finished with it.
|
||||
|
||||
<!--
|
||||
Local Variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:2
|
||||
sgml-indent-data: t
|
||||
sgml-parent-document: ("../gnome-hackers.sgml" "book" "sect1" "")
|
||||
End:
|
||||
-->
|
||||
|
103
doc/features/procmem.sgml
Normal file
103
doc/features/procmem.sgml
Normal file
@@ -0,0 +1,103 @@
|
||||
<para>
|
||||
The automatically generated description above is taken from the
|
||||
manual page of the <filename>/proc</filename> filesystem under Linux
|
||||
and is a little bit confusing, so I make this clear here.
|
||||
|
||||
<note>
|
||||
<title>Note for people porting &libgtop; to other systems</title>
|
||||
|
||||
<para>
|
||||
Well, every operating system has its own idea about the memory usage
|
||||
of a processes, and also system utilities like <filename>ps</filename>
|
||||
show different things on different systems.
|
||||
|
||||
<para>
|
||||
Nevertheless, we should try to make &libgtop; as system independent
|
||||
as possible, so I give you some hints here how &glibtop-get-procmem;
|
||||
should work.
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
When you use &mmap; with either &MAP-SHARED; or &MAP-PRIVATE;,
|
||||
this should only affect the &pmem-vsize; of the process and
|
||||
none of its &pmem-size;, &pmem-resident;, &pmem-shared; and
|
||||
&pmem-rss; sizes.
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
As soon as you read some of the &mmap;ed pages, they will be
|
||||
demand-loaded and thus count towards the &pmem-size; of the
|
||||
process. Also - we assume there is enough free memory - they
|
||||
are resident in memory until they get stolen or swapped out
|
||||
and thus increase the &pmem-resident; and &pmem-rss; sizes of
|
||||
the process.
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
If the process has used &MAP-SHARED; and another process
|
||||
attaches the same file also &MAP-SHARED; some of the pages
|
||||
are shared with this process and thus increase the &pmem-shared;
|
||||
sizes of both processes.
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
If the process has used &MAP-PRIVATE; and writes to the &mmap;ed
|
||||
pages, the only difference to reading from them is that they
|
||||
get dirty and cannot be stolen any longer but will get swapped
|
||||
out.
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
If memory gets rare, clean pages are normally stolen which
|
||||
decreases the &pmem-size;, &pmem-resident;, &pmem-shared; and
|
||||
&pmem-rss; sizes of the process.
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
When dirty pages are swapped out, this will
|
||||
<emphasis>not</emphasis> decrease the &pmem-size; of the
|
||||
process but only its &pmem-resident; and &pmem-rss; sizes
|
||||
(dirty pages cannot be shared).
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
The &pmem-vsize; of a process can <emphasis>only</emphasis>
|
||||
be changed by the process itself when it requests or frees
|
||||
memory but <emphasis>never</emphasis> due to swapping
|
||||
activity of the system.
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
If the &pmem-shared; size changes, this
|
||||
<emphasis>only</emphasis> means that the number of pages that
|
||||
are currently shared with other processes has changed; if this
|
||||
happens, this will <emphasis>never</emphasis> affect any of the
|
||||
other sizes of the process.
|
||||
|
||||
</itemizedlist>
|
||||
|
||||
</note>
|
||||
|
||||
<para>
|
||||
The hints above describe how it works under Linux - and we should try to
|
||||
make &glibtop-get-procmem; show the same behavior under every other
|
||||
system.
|
||||
|
||||
<para>
|
||||
If you want to make any comments, flames, suggestions about this, please
|
||||
feel free to do so.
|
||||
|
||||
<!--
|
||||
Local Variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:2
|
||||
sgml-indent-data: t
|
||||
sgml-parent-document: ("../gnome-hackers.sgml" "book" "sect1" "")
|
||||
End:
|
||||
-->
|
||||
|
23
doc/features/uptime.sgml
Normal file
23
doc/features/uptime.sgml
Normal file
@@ -0,0 +1,23 @@
|
||||
<note>
|
||||
|
||||
<para>
|
||||
You can calculate this from the CPU usage (this one is taken
|
||||
from the FreeBSD port):
|
||||
|
||||
<programlisting>&include-uptime.txt;</programlisting>
|
||||
|
||||
</note>
|
||||
|
||||
<!--
|
||||
Local Variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:2
|
||||
sgml-indent-data: t
|
||||
sgml-parent-document: ("../gnome-hackers.sgml" "book" "sect1" "")
|
||||
End:
|
||||
-->
|
||||
|
40
doc/features/uptime.txt
Normal file
40
doc/features/uptime.txt
Normal file
@@ -0,0 +1,40 @@
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/uptime.h>
|
||||
|
||||
#include <glibtop/cpu.h>
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_uptime =
|
||||
(1 << GLIBTOP_UPTIME_UPTIME) + (1 << GLIBTOP_UPTIME_IDLETIME);
|
||||
|
||||
static const unsigned long _required_cpu_flags =
|
||||
(1 << GLIBTOP_CPU_TOTAL) + (1 << GLIBTOP_CPU_IDLE) +
|
||||
(1 << GLIBTOP_CPU_FREQUENCY);
|
||||
|
||||
void
|
||||
glibtop_get_uptime_p (glibtop *server, glibtop_uptime *buf)
|
||||
{
|
||||
glibtop_cpu cpu;
|
||||
|
||||
glibtop_init_p (server, GLIBTOP_SYSDEPS_UPTIME, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_uptime));
|
||||
|
||||
/* We simply calculate it from the CPU usage. */
|
||||
|
||||
glibtop_get_cpu_p (server, &cpu);
|
||||
|
||||
/* Make sure all required fields are present. */
|
||||
|
||||
if ((cpu.flags & _required_cpu_flags) != _required_cpu_flags)
|
||||
return;
|
||||
|
||||
/* Calculate values. */
|
||||
|
||||
buf->uptime = (double) cpu.total / (double) cpu.frequency;
|
||||
buf->idletime = (double) cpu.idle / (double) cpu.frequency;
|
||||
|
||||
buf->flags = _glibtop_sysdeps_uptime;
|
||||
}
|
@@ -1,11 +1,67 @@
|
||||
<!-- $Id$ -->
|
||||
|
||||
<!doctype book PUBLIC "-//Davenport//DTD DocBook V3.0//EN" [
|
||||
<!entity libgtopConf.sh SYSTEM "../libgtopConf.sh" >
|
||||
<!-- Site-specific entities, change them if you want to copy this
|
||||
document somewhere else. -->
|
||||
<!entity home-of-linux "http://www.home-of-linux.org/">
|
||||
|
||||
<!-- Some general entities -->
|
||||
|
||||
<!entity libgtop "<productname>libgtop</productname>">
|
||||
|
||||
<!-- Some abbreviations for often used filenames and functions. -->
|
||||
|
||||
<!entity gnome-libgtop-check.m4 "<filename>macros/gnome-libgtop-check.m4</filename>">
|
||||
<!entity libgtopConf.sh "<filename>libgtopConf.sh</filename>">
|
||||
<!entity glibtop-free "<function>glibtop_free ()</function>">
|
||||
<!entity glibtop-get-procmem "<function>glibtop_get_proc_mem ()</function>">
|
||||
<!entity mmap "<function>mmap ()</function>">
|
||||
<!entity MAP-SHARED "<parameter>MAP_SHARED</parameter>">
|
||||
<!entity MAP-PRIVATE "<parameter>MAP_PRIVATE</parameter>">
|
||||
<!entity pmem-vsize "<structfield>procmem.vsize</structfield>">
|
||||
<!entity pmem-size "<structfield>procmem.size</structfield>">
|
||||
<!entity pmem-resident "<structfield>procmem.resident</structfield>">
|
||||
<!entity pmem-shared "<structfield>procmem.shared</structfield>">
|
||||
<!entity pmem-rss "<structfield>procmem.rss</structfield>">
|
||||
|
||||
<!-- This will include a sample `libgtopConf.sh'. -->
|
||||
|
||||
<!entity example-libgtopConf-sh SYSTEM "libgtopConf.sh">
|
||||
|
||||
<!-- Some entities to include other files. -->
|
||||
|
||||
<!entity include-autoconf.sgml SYSTEM "autoconf.sgml">
|
||||
<!entity include-reference.sgml SYSTEM "../guile/reference.sgml">
|
||||
|
||||
<!-- The following entities are used in the automatically generated
|
||||
`reference.sgml' to include custom descriptions of the features.
|
||||
-->
|
||||
|
||||
<!entity include-cpu.sgml "">
|
||||
<!entity include-mem.sgml "">
|
||||
<!entity include-swap.sgml "">
|
||||
<!entity include-uptime.sgml SYSTEM "features/uptime.sgml">
|
||||
<!entity include-loadavg.sgml "">
|
||||
<!entity include-shm-limits.sgml "">
|
||||
<!entity include-msg-limits.sgml "">
|
||||
<!entity include-sem-limits.sgml "">
|
||||
<!entity include-proclist.sgml SYSTEM "features/proclist.sgml">
|
||||
<!entity include-proc-state.sgml "">
|
||||
<!entity include-proc-uid.sgml "">
|
||||
<!entity include-proc-mem.sgml SYSTEM "features/procmem.sgml">
|
||||
<!entity include-proc-time.sgml "">
|
||||
<!entity include-proc-signal.sgml "">
|
||||
<!entity include-proc-kernel.sgml "">
|
||||
<!entity include-proc-segment.sgml "">
|
||||
<!entity include-proc-map.sgml "">
|
||||
<!entity include-mountlist.sgml "">
|
||||
<!entity include-fsusage.sgml "">
|
||||
|
||||
<!entity include-uptime.txt SYSTEM "features/uptime.txt">
|
||||
]>
|
||||
<book>
|
||||
<bookinfo>
|
||||
<title>Using LibGTop in the Gnome Project</title>
|
||||
<title>Using Libgtop in the Gnome Project</title>
|
||||
<authorgroup>
|
||||
<author>
|
||||
<firstname>Martin</firstname>
|
||||
@@ -21,7 +77,7 @@
|
||||
<year>1998</year>
|
||||
<holder>Martin Baulig</holder>
|
||||
</copyright>
|
||||
|
||||
|
||||
<legalnotice>
|
||||
|
||||
<para>
|
||||
@@ -46,11 +102,15 @@
|
||||
|
||||
<para>
|
||||
For more details see the file COPYING in the source
|
||||
distribution of LibGTop.</para>
|
||||
distribution of &libgtop;.</para>
|
||||
|
||||
</legalnotice>
|
||||
|
||||
<abstract>
|
||||
<para>
|
||||
<literal>
|
||||
$Id$
|
||||
</literal>
|
||||
|
||||
<para>
|
||||
This is a short introduction in how to use
|
||||
@@ -59,335 +119,69 @@
|
||||
takes and the information stored in the automatically generated
|
||||
<filename>libgtopConf.sh</filename> configuration script.
|
||||
|
||||
<note>
|
||||
<para>
|
||||
Documentation about the new <function>table ()</function>
|
||||
function can be found here:
|
||||
|
||||
<itemizedlist>
|
||||
<listitem><para>
|
||||
<ulink url="&home-of-linux;kernel/table/">
|
||||
&home-of-linux;kernel/table/
|
||||
</ulink>
|
||||
</itemizedlist>
|
||||
</note>
|
||||
|
||||
</abstract>
|
||||
|
||||
</bookinfo>
|
||||
|
||||
<toc></toc>
|
||||
|
||||
<chapter id="macros">
|
||||
<title>Autoconf macros</title>
|
||||
|
||||
<sect1 id="gnome-libgtop-check">
|
||||
<title><filename>macros/gnome-libgtop-check.m4</filename></title>
|
||||
|
||||
<para>
|
||||
Contains all that you need to include libgtop in any Gnome application. It defines
|
||||
<function>GNOME_INIT_LIBGTOP</function> which you can use in the same way like
|
||||
<function>GNOME_INIT</function> to check whether libgtop is installed and to read
|
||||
its <filename>libgtopConf.sh</filename> script. It automatically invokes
|
||||
<function>GNOME_LIBGTOP_SYSDEPS</function>.
|
||||
|
||||
<para>
|
||||
When libgtop can be found, it defines <parameter>HAVE_LIBGTOP</parameter>. There's
|
||||
also an automake conditional <parameter>HAVE_LIBGTOP</parameter> which you can use.
|
||||
|
||||
<sect1 id="gnome-libgtop-sysdeps">
|
||||
<title><filename>macros/gnome-libgtop-sysdeps.m4</filename></title>
|
||||
|
||||
<para>
|
||||
This file defines <function>GNOME_LIBGTOP_SYSDEPS</function> which you can
|
||||
use to check which sysdeps directory <productname>libgtop</productname> should
|
||||
use and whether the <filename>gtop_server</filename> is needed.
|
||||
|
||||
<para>
|
||||
It defines the following variables:
|
||||
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>libgtop_sysdeps_dir</parameter>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
The sysdeps dir <productname>libgtop</productname> uses.
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>libgtop_use_machine_h</parameter></term>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Some of the system dependent parts of <productname>libgtop</productname>
|
||||
provide a structure <structname>_glibtop_machine</structname> defined in
|
||||
a header file <filename>glibtop_machine.h</filename> they provide. This
|
||||
structure gets inserted into the <structfield>machine</structfield> member
|
||||
of <structname>_glibtop</structname> when <filename>config.h</filename>
|
||||
defines <parameter>HAVE_GLIBTOP_MACHINE_H</parameter>.
|
||||
|
||||
<para>
|
||||
This variable is either <literal>yes</literal> or <literal>no</literal> and
|
||||
tells you whether this is the case. If it is true, this macro wil automatically
|
||||
define <parameter>HAVE_GLIBTOP_MACHINE_H</parameter>.
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>libgtop_need_server</parameter></term>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Is either <literal>yes</literal> or <literal>no</literal> and tells you
|
||||
whether the server is needed. If it is needed, it will automatically
|
||||
define <parameter>NEED_LIBGTOP</parameter>.
|
||||
|
||||
<para>
|
||||
This macro also provides a conditional <parameter>NEED_LIBGTOP</parameter>
|
||||
which you can use in you <filename>Makefile.am</filename>.
|
||||
|
||||
</variablelist>
|
||||
|
||||
</sect1>
|
||||
|
||||
<chapter id="configure">
|
||||
<chapter id="autoconf-automake">
|
||||
<title>Configuration</title>
|
||||
|
||||
<para>
|
||||
The <filename>configure</filename> script of <productname>libgtop</productname>
|
||||
takes some non-standard options to let you decide which parts of the library
|
||||
should be build.
|
||||
&include-autoconf.sgml;
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
</chapter>
|
||||
|
||||
<para>
|
||||
Normally, <filename>configure</filename> decides whether or not using the
|
||||
server is required. Depending upon this decision, it adds either
|
||||
<literal>-lgtop</literal> (when it's needed) or
|
||||
<literal>-lgtop_systems</literal> (when it's not needed) to
|
||||
<parameter>LIBGTOP_LIBS</parameter> and <parameter>LIBGTOP_GUILE_LIBS</parameter>.
|
||||
|
||||
<para>
|
||||
You can change this behaviour with the following options:
|
||||
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>--enable-libgtop-server</parameter>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Use the server regardless whether or not it is required.
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>--disable-libgtop-server</parameter></term>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Do not use the server regardless wheter or not it is required.
|
||||
|
||||
</variablelist>
|
||||
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
Normally, the guile interface of <productname>libgtop</productname> is build
|
||||
when <productname>guile</productname> can be found on the system.
|
||||
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>--disable-libgtop-guile</parameter>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Disables building the guile interface even if you have
|
||||
<productname>guile</productname> installed.
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>--enable-libgtop-guile</parameter></term>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Has no effect at all since you cannot build the guile interface without
|
||||
having <productname>guile</productname> installed on your system.
|
||||
|
||||
</variablelist>
|
||||
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
If you do not need the <filename>names</filename> subdirs, you can disable
|
||||
their building with the following option:
|
||||
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>--disable-libgtop-names</parameter>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Disables building of the <filename>names</filename> subdirs.
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>--enable-libgtop-names</parameter></term>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Is the default.
|
||||
|
||||
</variablelist>
|
||||
|
||||
<para>
|
||||
If it is enables, <parameter>GLIBTOP_NAMES</parameter> will be defined.
|
||||
|
||||
<listitem>
|
||||
|
||||
<para>
|
||||
To disable building of the examples, you can say:
|
||||
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>--without-examples</parameter>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Disables building of the examples.
|
||||
|
||||
</variablelist>
|
||||
|
||||
</itemizedlist>
|
||||
<chapter id="functions">
|
||||
<title>Function Reference List</title>
|
||||
|
||||
<chapter id="libgtopConf">
|
||||
<title>The <filename>libgtopConf.sh</filename> script</title>
|
||||
&include-reference.sgml;
|
||||
|
||||
</chapter>
|
||||
|
||||
<chapter id="porting-libgtop">
|
||||
<title>Porting &libgtop; to other systems</title>
|
||||
|
||||
<para>
|
||||
After a successful build of <productname>libgtop</productname>, a
|
||||
<filename>libgtopConf.sh</filename> script is generated which will later
|
||||
be used to decide how to link a program with <filename>libgtop</filename>.
|
||||
Here are some comments for people porting &libgtop; to other systems.
|
||||
|
||||
<para>
|
||||
It defines the following variables:
|
||||
<sect1>
|
||||
<title>&glibtop-get-procmem; - Process Memory information</title>
|
||||
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>LIBGTOP_LIBDIR</parameter>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Defaults to <literal>$(prefix)/lib</literal>. It is the directory
|
||||
where the <productname>libgtop</productname> libraries get installed.
|
||||
<para>
|
||||
This section is copied here from the description of
|
||||
&glibtop-get-procmem;.
|
||||
</para>
|
||||
|
||||
&include-proc-mem.sgml;
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>LIBGTOP_INCLUDEDIR</parameter></term>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Defaults to <literal>$(prefix)/include</literal>. It is the directory
|
||||
where the <productname>libgtop</productname> header files get installed.
|
||||
</sect1>
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>LIBGTOP_LIBS</parameter></term>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Contains everything that you need to add to the <parameter>_LDADD</parameter>
|
||||
variable of <productname>automake</productname> to link a program with
|
||||
<productname>libgtop</productname>.
|
||||
</chapter>
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>LIBGTOP_INCS</parameter></term>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Contains everything that you need to add to the <parameter>_INCLUDES</parameter>
|
||||
variable of <productname>automake</productname> to compile a program that uses
|
||||
<productname>libgtop</productname>.
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>LIBGTOP_GUILE_INCS</parameter></term>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Contains everything that you need to add to the <parameter>_INCLUDES</parameter>
|
||||
variable of <productname>automake</productname> to compile a program that uses both
|
||||
<productname>libgtop</productname> and its guile interface.
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>LIBGTOP_BINDIR</parameter></term>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Defaults to <literal>$(bindir)</literal>. It is the directory where the
|
||||
<productname>libgtop</productname> binaries get installed.
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>LIBGTOP_SERVER</parameter></term>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Defaults to <literal>$(bindir)/gtop_server</literal>. It is the full pathname
|
||||
where the server gets installed.
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>libgtop_sysdeps_dir</parameter></term>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
The sysdeps directory that is used on your system.
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>libgtop_need_server</parameter></term>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Is either <literal>yes</literal> or <literal>no</literal> and tells you
|
||||
whether using the server is needed or not.
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>libgtop_use_machine_h</parameter></term>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Is either <literal>yes</literal> or <literal>no</literal> and tells you
|
||||
whether <filename>glibtop_machine_h</filename> should be included in
|
||||
<filename>glibtop.h</filename>.
|
||||
|
||||
The system dependent part of the library may provide an additional header
|
||||
file, <filename>glibtop_machine_h</filename>. In this case, they define
|
||||
a structure <structname>_glibtop_machine</structname> in this header file.
|
||||
This structure represents the <structfield>machine</structfield> member of
|
||||
<structname>_glibtop</structname>.
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>libgtop_guile_found</parameter></term>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Is either <literal>yes</literal> or <literal>no</literal> and tells you
|
||||
whether <productname>guile</productname> has been found on your system
|
||||
(or if building the guile interface was disabled).
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>libgtop_want_names</parameter></term>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Is either <literal>yes</literal> or <literal>no</literal> and tells you
|
||||
whether the <filename>sysdeps/names</filename> subdirectory was build.
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>libgtop_want_guile_names</parameter></term>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Is either <literal>yes</literal> or <literal>no</literal> and tells you
|
||||
whether the <filename>sysdeps/guile/names</filename> subdirectory was build.
|
||||
|
||||
<varlistentry>
|
||||
<term><parameter>libgtop_want_examples</parameter></term>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Is either <literal>yes</literal> or <literal>no</literal> and tells you
|
||||
whether the examples were build.
|
||||
|
||||
</variablelist>
|
||||
|
||||
<example>
|
||||
<title>Sample <filename>libgtopConf.sh</filename></title>
|
||||
|
||||
<programlisting>&libgtopConf.sh;</programlisting>
|
||||
</example>
|
||||
|
||||
|
||||
</book>
|
||||
|
||||
<!--
|
||||
Local Variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:2
|
||||
sgml-indent-data: t
|
||||
End:
|
||||
-->
|
||||
|
@@ -1,7 +1,31 @@
|
||||
<!-- $Id$ -->
|
||||
|
||||
<!doctype book PUBLIC "-//Davenport//DTD DocBook V3.0//EN" [
|
||||
<!entity reference.sgml SYSTEM "../guile/reference.sgml" >
|
||||
<!entity include-reference.sgml SYSTEM "../guile/reference.sgml" >
|
||||
|
||||
<!-- The following entities are used in the automatically generated
|
||||
`reference.sgml' to include custom descriptions of the features.
|
||||
-->
|
||||
|
||||
<!entity include-cpu.sgml "">
|
||||
<!entity include-mem.sgml "">
|
||||
<!entity include-swap.sgml "">
|
||||
<!entity include-uptime.sgml "">
|
||||
<!entity include-loadavg.sgml "">
|
||||
<!entity include-shm-limits.sgml "">
|
||||
<!entity include-msg-limits.sgml "">
|
||||
<!entity include-sem-limits.sgml "">
|
||||
<!entity include-proclist.sgml "">
|
||||
<!entity include-proc-state.sgml "">
|
||||
<!entity include-proc-uid.sgml "">
|
||||
<!entity include-proc-mem.sgml "">
|
||||
<!entity include-proc-time.sgml "">
|
||||
<!entity include-proc-signal.sgml "">
|
||||
<!entity include-proc-kernel.sgml "">
|
||||
<!entity include-proc-segment.sgml "">
|
||||
<!entity include-proc-map.sgml "">
|
||||
<!entity include-mountlist.sgml "">
|
||||
<!entity include-fsusage.sgml "">
|
||||
]>
|
||||
<book>
|
||||
<bookinfo>
|
||||
@@ -22,9 +46,11 @@
|
||||
<literal>$Id$</literal>
|
||||
|
||||
<para>
|
||||
This reference manual is automatically generated from <filename>doc/make-docbook.scm</filename>.
|
||||
It uses the guile interface of <productname>libgtop</productname> to get the names of all
|
||||
features the library defines and a description of the structures.
|
||||
This reference manual is automatically generated from
|
||||
<filename>doc/make-docbook.scm</filename>. It uses the
|
||||
guile interface of <productname>libgtop</productname> to
|
||||
get the names of all features the library defines and a
|
||||
description of the structures.
|
||||
</abstract>
|
||||
|
||||
<copyright>
|
||||
@@ -62,6 +88,21 @@
|
||||
|
||||
<toc></toc>
|
||||
|
||||
&reference.sgml;
|
||||
<chapter id="functions">
|
||||
<title>Function Reference List</title>
|
||||
|
||||
&include-reference.sgml;
|
||||
|
||||
</book>
|
||||
|
||||
<!--
|
||||
Local Variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:2
|
||||
sgml-indent-data: t
|
||||
End:
|
||||
-->
|
||||
|
35
doc/libgtopConf.sh
Normal file
35
doc/libgtopConf.sh
Normal file
@@ -0,0 +1,35 @@
|
||||
#
|
||||
# Configuration of the libgtop package
|
||||
#
|
||||
|
||||
LIBGTOP_LIBDIR="/home/baulig/TEST/lib"
|
||||
LIBGTOP_INCLUDEDIR="/home/baulig/TEST/include"
|
||||
|
||||
LIBGTOP_LIBS="-L/home/baulig/TEST/lib -lgtop -lgtop_common -lgtop_sysdeps -L/usr/X11R6/lib -lXau"
|
||||
LIBGTOP_INCS="-I/home/baulig/TEST/include"
|
||||
|
||||
LIBGTOP_NAMES_LIBS="-L/home/baulig/TEST/lib -lgtop -lgtop_common -lgtop_sysdeps -lgtop_names -L/usr/X11R6/lib -lXau"
|
||||
LIBGTOP_NAMES_INCS="-I/home/baulig/TEST/include -DGLIBTOP_NAMES"
|
||||
|
||||
LIBGTOP_GUILE_LIBS="-L/home/baulig/TEST/lib -lgtop -lgtop_guile -lgtop_common -lgtop_sysdeps -L/usr/X11R6/lib -lXau -L/home/baulig/INSTALL/lib -lguile -ldl -lreadline -ltermcap -lm"
|
||||
LIBGTOP_GUILE_INCS="-I/home/baulig/TEST/include -I/home/baulig/INSTALL/include -DGLIBTOP_GUILE"
|
||||
|
||||
LIBGTOP_GUILE_NAMES_LIBS="-L/home/baulig/TEST/lib -lgtop -lgtop_guile -lgtop_common -lgtop_sysdeps -lgtop_names -L/usr/X11R6/lib -lXau"
|
||||
LIBGTOP_GUILE_NAMES_INCS="-I/home/baulig/TEST/include -I/home/baulig/INSTALL/include -DGLIBTOP_GUILE -DGLIBTOP_NAMES"
|
||||
|
||||
LIBGTOP_BINDIR="/home/baulig/TEST/bin"
|
||||
LIBGTOP_SERVER="/home/baulig/TEST/bin/libgtop_server"
|
||||
|
||||
LIBGTOP_MAJOR_VERSION="0"
|
||||
LIBGTOP_MINOR_VERSION="2a"
|
||||
LIBGTOP_VERSION="0.2a"
|
||||
|
||||
LIBGTOP_SERVER_VERSION="1"
|
||||
|
||||
libgtop_sysdeps_dir="linux"
|
||||
libgtop_need_server="no"
|
||||
libgtop_use_machine_h="no"
|
||||
|
||||
libgtop_guile_found="yes"
|
||||
|
||||
libgtop_want_examples=""
|
161
doc/table.announce.txt
Normal file
161
doc/table.announce.txt
Normal file
@@ -0,0 +1,161 @@
|
||||
Path: news.uni-stuttgart.de!fu-berlin.de!taurus.uni-trier.DE!baulig
|
||||
From: Martin Baulig <baulig@merkur.uni-trier.de>
|
||||
Newsgroups: comp.os.linux.development.system
|
||||
Subject: RFC: New system call for /proc information ?
|
||||
Date: 07 Jun 1998 20:22:47 +0200
|
||||
Lines: 143
|
||||
Sender: baulig@Taurus.uni-trier.de
|
||||
Message-ID: <of7zpfprs08.fsf@Taurus.uni-trier.de>
|
||||
NNTP-Posting-Host: taurus.uni-trier.de (136.199.14.201)
|
||||
Mime-Version: 1.0
|
||||
Content-Type: text/plain; charset=iso-8859-1
|
||||
Content-Transfer-Encoding: 8bit
|
||||
NNTP-Posting-User: baulig
|
||||
X-Access: 16 1542 1543
|
||||
X-Trace: fu-berlin.de 897243777 29527 baulig 136.199.14.201
|
||||
X-Newsreader: Gnus v5.6.11/XEmacs 20.3 - "Vatican City"
|
||||
Xref: news.uni-stuttgart.de comp.os.linux.development.system:73539
|
||||
|
||||
[Posted to the Gnome Mailing List and to comp.os.linux.development.system]
|
||||
|
||||
Request for Comments:
|
||||
====================
|
||||
|
||||
Should we have a new system call under Linux which fetches information
|
||||
from the /proc filesytem similar to the table() function of DEC OSF/1 ?
|
||||
|
||||
The whole story:
|
||||
===============
|
||||
|
||||
I am currently working on libgtop, a library that fetches information
|
||||
from the proc filesystem for user processes. This library uses a suid
|
||||
server on system where this is required. On Linux, the information are
|
||||
fetched directly from the proc filesystem.
|
||||
|
||||
Now, I made some profilings (fetches 50000 times cpu, memory, swap,
|
||||
uptime and loadavg):
|
||||
|
||||
Each sample counts as 0.01 seconds.
|
||||
% cumulative self self total
|
||||
time seconds seconds calls ns/call ns/call name
|
||||
91.86 348.03 348.03 read
|
||||
3.07 359.67 11.64 open
|
||||
0.67 362.22 2.55 close
|
||||
0.16 363.55 0.62 memset
|
||||
0.16 364.14 0.59 __ipc
|
||||
0.03 368.84 0.12 vsscanf (iovsscanf.c:31)
|
||||
0.01 374.49 0.05 sscanf (sscanf.c:28)
|
||||
0.00 378.71 0.01 semctl (semctl.c:32)
|
||||
0.00 378.73 0.01 shmctl (shmctl.c:30)
|
||||
|
||||
granularity: each sample hit covers 4 byte(s) for 0.00% of 378.88 seconds
|
||||
|
||||
index % time self children called name
|
||||
[1] 91.9 348.03 0.00 read [1]
|
||||
-----------------------------------------------
|
||||
[2] 3.1 11.64 0.00 open [2]
|
||||
-----------------------------------------------
|
||||
[3] 0.7 2.55 0.00 close [3]
|
||||
-----------------------------------------------
|
||||
[5] 0.2 0.62 0.00 memset [5]
|
||||
-----------------------------------------------
|
||||
[6] 0.2 0.59 0.00 __ipc [6]
|
||||
-----------------------------------------------
|
||||
[35] 0.0 0.12 0.00 vsscanf (iovsscanf.c:31) [35]
|
||||
-----------------------------------------------
|
||||
[96] 0.0 0.05 0.00 sscanf (sscanf.c:28) [96]
|
||||
-----------------------------------------------
|
||||
|
||||
You see, it spends a lot of time in read() which is only used to read the
|
||||
data from the files in /proc. Well, basically one can say that these
|
||||
timings are not so bad, normally a process periodically fetches those
|
||||
information say 10 times a seconds which makes 36000 invocations per
|
||||
hour.
|
||||
|
||||
This will make a total of about 250 seconds per hour or on even say:
|
||||
|
||||
``a program fetching those information at a frequency of 10 will take
|
||||
about 7 % of each hour just for reading files from /proc''.
|
||||
|
||||
Now look at timings of __ipc, they're about 350 times better 'cause this
|
||||
is done using system calls.
|
||||
|
||||
So far so good, now look at how this is done on the DEC OSF/1 port of the
|
||||
library (the following code is part of libgtop - GPL/LGPL):
|
||||
|
||||
CPU usage:
|
||||
{
|
||||
struct tbl_sysinfo sysinfo;
|
||||
int ret;
|
||||
|
||||
ret = table (TBL_SYSINFO, 0, (char *) &sysinfo, 1,
|
||||
sizeof (struct tbl_sysinfo));
|
||||
|
||||
buf->user = sysinfo.si_user;
|
||||
buf->nice = sysinfo.si_nice;
|
||||
buf->sys = sysinfo.si_sys;
|
||||
buf->idle = sysinfo.si_idle;
|
||||
}
|
||||
|
||||
Well, the table() command of DEC OSF/1 has may disadvantages, too - such
|
||||
as requiring to be root to fetch any information about processes (well, for
|
||||
each process that is not the current one).
|
||||
|
||||
But this works using system calls rather that reading and parsing files
|
||||
and should be about as fast as getting the IPC information on Linux.
|
||||
|
||||
Under Linux, the current trend seems to be to move anything into the /proc
|
||||
filesystem, but if you look at the timings, wouldn't it be better to also
|
||||
implement a system call interface ?
|
||||
|
||||
Don't understand me wrong:
|
||||
=========================
|
||||
|
||||
I *do not want* to *replace* the /proc filesystem - it's an excellent
|
||||
idea to be able to fetch all information on the command line without
|
||||
any program just a simple 'cat' - I want to *add* a *new* system call
|
||||
to allow programmers to fetch those information faster that reading
|
||||
from /proc.
|
||||
|
||||
To come to the point:
|
||||
=====================
|
||||
|
||||
Is there any public interest in having a new system call under Linux
|
||||
which can be used to fetch all information that are currently in the
|
||||
/proc filesystem.
|
||||
|
||||
Basically, this system would be defined like this:
|
||||
|
||||
asmlinkage int
|
||||
sys_table (int command, struct sysinfo_table *buf)
|
||||
|
||||
and be invoked like this:
|
||||
|
||||
#include <sys/table.h>
|
||||
|
||||
{
|
||||
struct sysinfo_cpu cpu;
|
||||
struct sysinfo_mem mem;
|
||||
|
||||
ret = table (TABLE_CPU, &cpu);
|
||||
if (ret == -1) return; /* or invoke any error handler */
|
||||
|
||||
ret = table (TABLE_MEM, &mem);
|
||||
if (ret == -1) return;
|
||||
}
|
||||
|
||||
What do you think, folks. Should we have such a system call under Linux ?
|
||||
I can do the implementation of this system call, but I want to have some
|
||||
feedback first.
|
||||
|
||||
Martin
|
||||
|
||||
--
|
||||
-----------------------------------------------------------------
|
||||
Martin Baulig - Angewandte Mathematik - Universitaet Trier
|
||||
|
||||
baulig@castor.uni-trier.de, http://www.home-of-linux.com/
|
||||
Key: 1024-bit key with ID C8178435 created 1997/01/24
|
||||
ID: 67 C1 84 A0 47 F5 11 C5 5F 68 4C 84 99 05 C3 92
|
||||
Finger me for public key or fetch finger.txt from the url above
|
||||
------------------------------------------------------------------
|
12
doc/table.dsl
Normal file
12
doc/table.dsl
Normal file
@@ -0,0 +1,12 @@
|
||||
<!doctype style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" [
|
||||
<!ENTITY dbtohtml.dsl SYSTEM "dbtohtml.dsl" CDATA DSSSL >
|
||||
]>
|
||||
|
||||
<style-specification id="tabledbotohtml" use="dbtohtml">
|
||||
|
||||
(define %output-basename% "table")
|
||||
(define %output-directory% "table")
|
||||
|
||||
</style-specification>
|
||||
|
||||
<external-specification id="dbtohtml" document="dbtohtml.dsl">
|
193
doc/table.sgml
Normal file
193
doc/table.sgml
Normal file
@@ -0,0 +1,193 @@
|
||||
<!-- $Id$ -->
|
||||
|
||||
<!doctype book PUBLIC "-//Davenport//DTD DocBook V3.0//EN" [
|
||||
<!entity libgtopConf.sh SYSTEM "../libgtopConf.sh" >
|
||||
<!entity home-of-linux "http://www.home-of-linux.org/">
|
||||
<!entity table-announce-first "&home-of-linux;kernel/table/ANNOUNCE.FIRST">
|
||||
<!entity table20-tgz "&home-of-linux;kernel/table/table20.tgz">
|
||||
<!entity table21-tgz "&home-of-linux;kernel/table/table21.tgz">
|
||||
<!entity news-c-o-l-d-s "comp.os.linux.development.system">
|
||||
<!entity libgtop "<productname>libgtop</productname>">
|
||||
<!entity table "<function>table ()</function>">
|
||||
]>
|
||||
<book>
|
||||
<bookinfo>
|
||||
<title>The &table; system call under Linux</title>
|
||||
<authorgroup>
|
||||
<author>
|
||||
<firstname>Martin</firstname>
|
||||
<surname>Baulig</surname>
|
||||
<affiliation>
|
||||
<address>
|
||||
<email>martin@home-of-linux.org</email>
|
||||
</address>
|
||||
</affiliation>
|
||||
</author>
|
||||
</authorgroup>
|
||||
<copyright>
|
||||
<year>1998</year>
|
||||
<holder>Martin Baulig</holder>
|
||||
</copyright>
|
||||
|
||||
<legalnotice>
|
||||
|
||||
<para>
|
||||
This documentation 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 of the License, or (at your option) any later
|
||||
version.
|
||||
|
||||
<para>
|
||||
This 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 General Public License for more
|
||||
details.
|
||||
|
||||
<para>
|
||||
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
|
||||
|
||||
<para>
|
||||
For more details see the file COPYING in the source
|
||||
distribution of LibGTop.</para>
|
||||
|
||||
</legalnotice>
|
||||
|
||||
<abstract>
|
||||
<para>
|
||||
<literal>$Id$</literal>
|
||||
|
||||
<para>
|
||||
Under <productname>Linux</productname>, reading from
|
||||
<filename>/proc</filename> is somehow slow because the data
|
||||
needs to be converted into a stringified representation from
|
||||
the kernel and to be parsed from the application program to
|
||||
get the original data back.
|
||||
|
||||
While doing the <productname>DEC OSF/1</productname> port of
|
||||
&libgtop; I got the idea to add something similar to the &table;
|
||||
function there to the Linux kernel.
|
||||
|
||||
This is what this document is about.
|
||||
</abstract>
|
||||
|
||||
</bookinfo>
|
||||
|
||||
<toc></toc>
|
||||
|
||||
<chapter id="why-not-sysctl">
|
||||
<title>Why not <function>sysctl</function>?</title>
|
||||
|
||||
<para>
|
||||
Some weeks ago, I posted the initial proposal of the project to
|
||||
<ulink url="news:&news-c-o-l-d-s;">&news-c-o-l-d-s;</ulink> with
|
||||
Message-ID <literal><of7zpfprs08.fsf@Taurus.uni-trier.de></literal>.
|
||||
|
||||
<para>
|
||||
You can also read this article at my site:
|
||||
|
||||
<itemizedlist>
|
||||
<listitem><para>
|
||||
<ulink url="&table-announce-first;">&table-announce-first;</ulink>
|
||||
</itemizedlist>
|
||||
|
||||
<para>
|
||||
Some people told me to include all the stuff into
|
||||
<function>sysctl</function> instead of inventing a new system call.
|
||||
|
||||
<para>
|
||||
Basically this is a good idea, but the main problem with
|
||||
<function>sysctl</function> is that this should be applied to standard
|
||||
kernels and not just as a short patch. Well, AFAIK something similar
|
||||
is on the "wish list" for 2.2er kernels - but of cause it'll need some
|
||||
time until we have a real replacement of the <filename>/proc</filename>
|
||||
filesystem in <function>sysctl</function>.
|
||||
|
||||
<para>
|
||||
If someone thinks that this absolutely should be included in
|
||||
<function>sysctl</function>: think about some kind of interface,
|
||||
discuss it with the kernel developers, ...
|
||||
|
||||
<chapter id="about-table">
|
||||
<title>About the &table; function</title>
|
||||
|
||||
<para>
|
||||
Using the &table; function will not affect any existing kernel
|
||||
structures and can be done independent from kernel development.
|
||||
|
||||
<para>
|
||||
So it can easily be used in &libgtop; until we have something
|
||||
simliar in standard kernels.
|
||||
|
||||
<para>
|
||||
If you want to use the &table; function in your own programs, be
|
||||
aware that it is just intended to be some kind of quick solution
|
||||
for &libgtop; until there's something better in standard kernels.
|
||||
|
||||
<chapter id="how-to-use">
|
||||
<title>How to use the &table; function in &libgtop;</title>
|
||||
|
||||
<para>
|
||||
The source code of the &table; function is distributed together with
|
||||
&libgtop;. It can be found in the <filename>kernel/table20</filename>
|
||||
directory for 2.0.xx kernels and in the <filename>kernel/table21</filename>
|
||||
directory for 2.1.xx kernels.
|
||||
|
||||
<para>
|
||||
You can also download it from my site:
|
||||
|
||||
<itemizedlist>
|
||||
<listitem><para>
|
||||
<ulink url="&table20-tgz;">&table20-tgz</ulink>
|
||||
(for kernel 2.0.xx)
|
||||
<listitem><para>
|
||||
<ulink url="&table21-tgz;">&table21-tgz</ulink>
|
||||
(for kernel 2.1.xx)
|
||||
</itemizedlist>
|
||||
|
||||
<para>
|
||||
Copy the contents of the appropriate directory to
|
||||
<filename>/usr/src/linux/table</filename>, apply the
|
||||
patch to the kernel and re-configure &libgtop;.
|
||||
|
||||
<para>
|
||||
After that, you can unmount <filename>/proc</filename> and
|
||||
&libgtop; will still work !
|
||||
|
||||
<note>
|
||||
<para>
|
||||
Maybe one could consider this as a bug, but currently there
|
||||
isn't a configuration option to disable the &table; function
|
||||
once you applied the patch ...
|
||||
</note>
|
||||
|
||||
<note>
|
||||
<para>
|
||||
Currently I'm working on the 2.1.x version to implement some
|
||||
features newer kernels have - so the 2.0.x version may not
|
||||
have all features the 2.1.x one has.
|
||||
</note>
|
||||
|
||||
<note>
|
||||
<para>
|
||||
The 2.1.x version of the &table; function is implemented
|
||||
as a kernel module. You have to do a
|
||||
<command>insmod table/module.o</command> manually to use it.
|
||||
|
||||
<para>
|
||||
This has the advantage that you don't need to reboot if you
|
||||
want to play around with the code a little bit.
|
||||
</note>
|
||||
|
||||
</book>
|
||||
|
||||
<!--
|
||||
Local Variables:
|
||||
mode: sgml
|
||||
sgml-indent-data: t
|
||||
End:
|
||||
-->
|
@@ -1,3 +1,22 @@
|
||||
1998-08-25 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* first.c, second.c, procmap.c: Fixed some compiler warnings.
|
||||
|
||||
1998-08-18 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* procmap.c: We now display filenames when compiled
|
||||
`--with-libgtop-inodedb'.
|
||||
|
||||
1998-08-12 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* second.c: Works a little bit more like `ps' - you can
|
||||
give an optional command line argument to get information
|
||||
about a single process.
|
||||
|
||||
1998-07-22 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* mountlist.c: New file.
|
||||
|
||||
1998-06-12 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* test.scm: New file.
|
||||
|
@@ -2,43 +2,54 @@
|
||||
|
||||
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@ -O0
|
||||
|
||||
DEFS = @DEFS@
|
||||
|
||||
bin_PROGRAMS = first first_static second second_static \
|
||||
# We install it in `libexec' since this will make it more easy
|
||||
# to put the examples into an extra RPM package.
|
||||
|
||||
libexec_PROGRAMS = first first_static second second_static \
|
||||
mountlist mountlist_static \
|
||||
procmap procmap_static \
|
||||
@guile_examples@
|
||||
|
||||
EXTRA_PROGRAMS = third third_static
|
||||
|
||||
first_SOURCES = first.c
|
||||
first_LDADD = $(top_builddir)/sysdeps/common/libgtop_common.la \
|
||||
$(top_builddir)/lib/libgtop.la \
|
||||
first_LDADD = $(top_builddir)/lib/libgtop.la \
|
||||
$(top_builddir)/sysdeps/common/libgtop_common.la \
|
||||
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \
|
||||
@INTLLIBS@ @LIBSUPPORT@
|
||||
@INTLLIBS@ @LIBSUPPORT@ @LIBGTOP_EXTRA_LIBS@
|
||||
|
||||
first_static_SOURCES = $(first_SOURCES)
|
||||
first_static_LDADD = $(first_LDADD)
|
||||
first_static_LDFLAGS = -static
|
||||
|
||||
second_SOURCES = second.c
|
||||
second_LDADD = $(top_builddir)/sysdeps/common/libgtop_common.la \
|
||||
$(top_builddir)/lib/libgtop.la \
|
||||
second_LDADD = $(top_builddir)/lib/libgtop.la \
|
||||
$(top_builddir)/sysdeps/common/libgtop_common.la \
|
||||
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \
|
||||
@INTLLIBS@ @LIBSUPPORT@
|
||||
@INTLLIBS@ @LIBSUPPORT@ @LIBGTOP_EXTRA_LIBS@
|
||||
|
||||
second_static_SOURCES = $(second_SOURCES)
|
||||
second_static_LDADD = $(second_LDADD)
|
||||
second_static_LDFLAGS = -static
|
||||
|
||||
if GLIBTOP_NAMES
|
||||
procmap_SOURCES = procmap.c
|
||||
procmap_LDADD = $(top_builddir)/lib/libgtop.la \
|
||||
$(top_builddir)/sysdeps/common/libgtop_common.la \
|
||||
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \
|
||||
@INTLLIBS@ @LIBSUPPORT@ @LIBGTOP_EXTRA_LIBS@
|
||||
|
||||
procmap_static_SOURCES = $(procmap_SOURCES)
|
||||
procmap_static_LDADD = $(procmap_LDADD)
|
||||
procmap_static_LDFLAGS = -static
|
||||
|
||||
|
||||
|
||||
third_guile_names_LIBS = $(top_builddir)/sysdeps/guile/names/libgtop_guile_names.la
|
||||
third_names_LIBS = $(top_builddir)/sysdeps/names/libgtop_names.la
|
||||
endif
|
||||
|
||||
third_SOURCES = third.c
|
||||
third_LDADD = $(top_builddir)/sysdeps/guile/libgtop_guile.la \
|
||||
@@ -46,8 +57,20 @@ third_LDADD = $(top_builddir)/sysdeps/guile/libgtop_guile.la \
|
||||
$(top_builddir)/lib/libgtop.la \
|
||||
$(top_builddir)/sysdeps/common/libgtop_common.la \
|
||||
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \
|
||||
@GUILE_LIBS@ @INTLLIBS@ @LIBSUPPORT@
|
||||
@GUILE_LIBS@ @INTLLIBS@ @LIBSUPPORT@ \
|
||||
@LIBGTOP_EXTRA_LIBS@
|
||||
|
||||
third_static_SOURCES = $(third_SOURCES)
|
||||
third_static_LDADD = $(third_LDADD)
|
||||
third_static_LDFLAGS = -static
|
||||
|
||||
mountlist_SOURCES = mountlist.c
|
||||
mountlist_LDADD = $(top_builddir)/lib/libgtop.la \
|
||||
$(top_builddir)/sysdeps/common/libgtop_common.la \
|
||||
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \
|
||||
@INTLLIBS@ @LIBSUPPORT@ @LIBGTOP_EXTRA_LIBS@
|
||||
|
||||
mountlist_static_SOURCES= $(mountlist_SOURCES)
|
||||
mountlist_static_LDADD = $(mountlist_LDADD)
|
||||
mountlist_static_LDFLAGS= -static
|
||||
|
||||
|
609
examples/first.c
609
examples/first.c
@@ -26,9 +26,13 @@
|
||||
#include <glibtop/close.h>
|
||||
#include <glibtop/xmalloc.h>
|
||||
|
||||
#include <glibtop/parameter.h>
|
||||
|
||||
#include <glibtop/union.h>
|
||||
#include <glibtop/sysdeps.h>
|
||||
|
||||
#include <sys/resource.h>
|
||||
|
||||
#ifndef PROFILE_COUNT
|
||||
#define PROFILE_COUNT 1
|
||||
#endif
|
||||
@@ -38,7 +42,8 @@ main (int argc, char *argv [])
|
||||
{
|
||||
glibtop_union data;
|
||||
glibtop_sysdeps sysdeps;
|
||||
unsigned c, count, i, *ptr;
|
||||
unsigned c, method, count, port, i, *ptr;
|
||||
char buffer [BUFSIZ];
|
||||
pid_t pid, ppid;
|
||||
|
||||
count = PROFILE_COUNT;
|
||||
@@ -47,98 +52,163 @@ main (int argc, char *argv [])
|
||||
bindtextdomain (PACKAGE, GTOPLOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
glibtop_init ();
|
||||
glibtop_init_r (&glibtop_global_server, 0, GLIBTOP_INIT_NO_OPEN);
|
||||
|
||||
for (c = 0; c < count; c++)
|
||||
glibtop_get_parameter (GLIBTOP_PARAM_METHOD, &method, sizeof (method));
|
||||
|
||||
printf ("Method = %d\n", method);
|
||||
|
||||
count = glibtop_get_parameter (GLIBTOP_PARAM_COMMAND, buffer, BUFSIZ);
|
||||
buffer [count] = 0;
|
||||
|
||||
printf ("Command = '%s'\n", buffer);
|
||||
|
||||
count = glibtop_get_parameter (GLIBTOP_PARAM_HOST, buffer, BUFSIZ);
|
||||
buffer [count] = 0;
|
||||
|
||||
glibtop_get_parameter (GLIBTOP_PARAM_PORT, &port, sizeof (port));
|
||||
|
||||
printf ("Host = '%s' - %u\n\n", buffer, port);
|
||||
|
||||
glibtop_init_r (&glibtop_global_server, 0, 0);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_cpu (&data.cpu);
|
||||
|
||||
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 ("CPU (0x%08lx): %lu, %lu, %lu, %lu, %lu, %lu\n",
|
||||
(unsigned long) data.cpu.flags,
|
||||
(unsigned long) data.cpu.total,
|
||||
(unsigned long) data.cpu.user,
|
||||
(unsigned long) data.cpu.nice,
|
||||
(unsigned long) data.cpu.sys,
|
||||
(unsigned long) data.cpu.idle,
|
||||
(unsigned long) data.cpu.frequency);
|
||||
|
||||
for (c = 0; c < count; c++)
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_mem (&data.mem);
|
||||
|
||||
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 ("Memory (0x%08lx): "
|
||||
"%lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu\n",
|
||||
(unsigned long) data.mem.flags,
|
||||
(unsigned long) data.mem.total,
|
||||
(unsigned long) data.mem.used,
|
||||
(unsigned long) data.mem.free,
|
||||
(unsigned long) data.mem.shared,
|
||||
(unsigned long) data.mem.buffer,
|
||||
(unsigned long) data.mem.cached,
|
||||
(unsigned long) data.mem.user,
|
||||
(unsigned long) data.mem.locked);
|
||||
|
||||
for (c = 0; c < count; c++)
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_swap (&data.swap);
|
||||
|
||||
fprintf (stderr, "Swap (0x%08lx): %lu, %lu, %lu\n", data.swap.flags,
|
||||
data.swap.total, data.swap.used, data.swap.free);
|
||||
printf ("Swap (0x%08lx): %lu, %lu, %lu, %lu, %lu\n",
|
||||
(unsigned long) data.swap.flags,
|
||||
(unsigned long) data.swap.total,
|
||||
(unsigned long) data.swap.used,
|
||||
(unsigned long) data.swap.free,
|
||||
(unsigned long) data.swap.pagein,
|
||||
(unsigned long) data.swap.pageout);
|
||||
|
||||
for (c = 0; c < count; c++)
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_uptime (&data.uptime);
|
||||
|
||||
fprintf (stderr, "Uptime (0x%08lx): %f, %f\n", data.uptime.flags,
|
||||
data.uptime.uptime, data.uptime.idletime);
|
||||
printf ("Uptime (0x%08lx): %f, %f\n",
|
||||
(unsigned long) data.uptime.flags,
|
||||
data.uptime.uptime, data.uptime.idletime);
|
||||
|
||||
for (c = 0; c < count; c++)
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_loadavg (&data.loadavg);
|
||||
|
||||
fprintf (stderr, "Loadavg (0x%08lx): %f, %f, %f\n", data.loadavg.flags,
|
||||
data.loadavg.loadavg [0], data.loadavg.loadavg [1],
|
||||
data.loadavg.loadavg [2]);
|
||||
printf ("Loadavg (0x%08lx): %f, %f, %f - %lu, %lu, %lu\n",
|
||||
(unsigned long) data.loadavg.flags,
|
||||
(double) data.loadavg.loadavg [0],
|
||||
(double) data.loadavg.loadavg [1],
|
||||
(double) data.loadavg.loadavg [2],
|
||||
(unsigned long) data.loadavg.nr_running,
|
||||
(unsigned long) data.loadavg.nr_tasks,
|
||||
(unsigned long) data.loadavg.last_pid);
|
||||
|
||||
for (c = 0; c < count; c++)
|
||||
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): %lu, %lu, %lu, %lu, %lu\n",
|
||||
(unsigned long) data.shm_limits.flags,
|
||||
(unsigned long) data.shm_limits.shmmax,
|
||||
(unsigned long) data.shm_limits.shmmin,
|
||||
(unsigned long) data.shm_limits.shmmni,
|
||||
(unsigned long) data.shm_limits.shmseg,
|
||||
(unsigned long) data.shm_limits.shmall);
|
||||
|
||||
for (c = 0; c < count; c++)
|
||||
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): %lu, %lu, %lu, %lu, %lu, %lu, %lu\n",
|
||||
(unsigned long) data.msg_limits.flags,
|
||||
(unsigned long) data.msg_limits.msgpool,
|
||||
(unsigned long) data.msg_limits.msgmap,
|
||||
(unsigned long) data.msg_limits.msgmax,
|
||||
(unsigned long) data.msg_limits.msgmnb,
|
||||
(unsigned long) data.msg_limits.msgmni,
|
||||
(unsigned long) data.msg_limits.msgssz,
|
||||
(unsigned long) data.msg_limits.msgtql);
|
||||
|
||||
for (c = 0; c < count; c++)
|
||||
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): "
|
||||
"%lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu\n",
|
||||
(unsigned long) data.sem_limits.flags,
|
||||
(unsigned long) data.sem_limits.semmap,
|
||||
(unsigned long) data.sem_limits.semmni,
|
||||
(unsigned long) data.sem_limits.semmns,
|
||||
(unsigned long) data.sem_limits.semmnu,
|
||||
(unsigned long) data.sem_limits.semmsl,
|
||||
(unsigned long) data.sem_limits.semopm,
|
||||
(unsigned long) data.sem_limits.semume,
|
||||
(unsigned long) data.sem_limits.semusz,
|
||||
(unsigned long) data.sem_limits.semvmx,
|
||||
(unsigned long) 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",
|
||||
(unsigned long) sysdeps.flags,
|
||||
(unsigned long) sysdeps.cpu,
|
||||
(unsigned long) sysdeps.mem,
|
||||
(unsigned long) sysdeps.swap,
|
||||
(unsigned long) sysdeps.uptime,
|
||||
(unsigned long) sysdeps.loadavg,
|
||||
(unsigned long) sysdeps.shm_limits,
|
||||
(unsigned long) sysdeps.msg_limits,
|
||||
(unsigned long) sysdeps.sem_limits,
|
||||
(unsigned long) sysdeps.proclist,
|
||||
(unsigned long) sysdeps.proc_state,
|
||||
(unsigned long) sysdeps.proc_uid,
|
||||
(unsigned long) sysdeps.proc_mem,
|
||||
(unsigned long) sysdeps.proc_time,
|
||||
(unsigned long) sysdeps.proc_signal,
|
||||
(unsigned long) sysdeps.proc_kernel,
|
||||
(unsigned long) sysdeps.proc_segment);
|
||||
|
||||
fprintf (stderr, "\n");
|
||||
printf ("\n");
|
||||
|
||||
ptr = glibtop_get_proclist (&data.proclist);
|
||||
ptr = glibtop_get_proclist (&data.proclist, 0, 0);
|
||||
|
||||
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): %lu, %lu, %lu\n",
|
||||
(unsigned long) data.proclist.flags,
|
||||
(unsigned long) data.proclist.number,
|
||||
(unsigned long) data.proclist.size,
|
||||
(unsigned long) 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);
|
||||
@@ -146,218 +216,291 @@ main (int argc, char *argv [])
|
||||
pid = getpid ();
|
||||
ppid = getppid ();
|
||||
|
||||
fprintf (stderr, "\n");
|
||||
printf ("\n");
|
||||
|
||||
for (c = 0; c < count; c++)
|
||||
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 %5d (0x%08lx): '%s', %c, %lu, %lu\n",
|
||||
(int) pid, (unsigned long) data.proc_state.flags,
|
||||
data.proc_state.cmd, data.proc_state.state,
|
||||
(unsigned long) data.proc_state.uid,
|
||||
(unsigned long) data.proc_state.gid);
|
||||
|
||||
for (c = 0; c < count; c++)
|
||||
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 %5d (0x%08lx): "
|
||||
"%d %d %d %d %d %d %d %d %d %d %d %d\n", (int) pid,
|
||||
(unsigned long) 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);
|
||||
|
||||
for (c = 0; c < count; c++)
|
||||
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 %5d (0x%08lx): "
|
||||
"%lu %lu %lu %lu %lu %lu\n", (int) pid,
|
||||
(unsigned long) data.proc_mem.flags,
|
||||
(unsigned long) data.proc_mem.size,
|
||||
(unsigned long) data.proc_mem.vsize,
|
||||
(unsigned long) data.proc_mem.resident,
|
||||
(unsigned long) data.proc_mem.share,
|
||||
(unsigned long) data.proc_mem.rss,
|
||||
(unsigned long) data.proc_mem.rss_rlim);
|
||||
|
||||
for (c = 0; c < 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);
|
||||
|
||||
for (c = 0; c < 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);
|
||||
|
||||
for (c = 0; c < 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);
|
||||
|
||||
for (c = 0; c < count; c++)
|
||||
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 %5d (0x%08lx): "
|
||||
"%lu %lu %lu %lu %lu %lu %lu %lu\n", (int) pid,
|
||||
(unsigned long) data.proc_segment.flags,
|
||||
(unsigned long) data.proc_segment.text_rss,
|
||||
(unsigned long) data.proc_segment.shlib_rss,
|
||||
(unsigned long) data.proc_segment.data_rss,
|
||||
(unsigned long) data.proc_segment.stack_rss,
|
||||
(unsigned long) data.proc_segment.dirty_size,
|
||||
(unsigned long) data.proc_segment.start_code,
|
||||
(unsigned long) data.proc_segment.end_code,
|
||||
(unsigned long) data.proc_segment.start_stack);
|
||||
|
||||
fprintf (stderr, "\n");
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_time (&data.proc_time, pid);
|
||||
|
||||
for (c = 0; c < count; c++)
|
||||
printf ("Proc_Time PID %5d (0x%08lx): "
|
||||
"%lu %lu %lu %lu %lu %lu %lu %lu %lu\n", (int) pid,
|
||||
(unsigned long) data.proc_time.flags,
|
||||
(unsigned long) data.proc_time.start_time,
|
||||
(unsigned long) data.proc_time.rtime,
|
||||
(unsigned long) data.proc_time.utime,
|
||||
(unsigned long) data.proc_time.stime,
|
||||
(unsigned long) data.proc_time.cutime,
|
||||
(unsigned long) data.proc_time.cstime,
|
||||
(unsigned long) data.proc_time.timeout,
|
||||
(unsigned long) data.proc_time.it_real_value,
|
||||
(unsigned long) data.proc_time.frequency);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_signal (&data.proc_signal, pid);
|
||||
|
||||
printf ("Proc_Signal PID %5d (0x%08lx): "
|
||||
"%lu %lu %lu %lu\n", (int) pid,
|
||||
(unsigned long) data.proc_signal.flags,
|
||||
(unsigned long) data.proc_signal.signal,
|
||||
(unsigned long) data.proc_signal.blocked,
|
||||
(unsigned long) data.proc_signal.sigignore,
|
||||
(unsigned long) data.proc_signal.sigcatch);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_kernel (&data.proc_kernel, pid);
|
||||
|
||||
printf ("Proc_Kernel PID %5d (0x%08lx): "
|
||||
"%lu %lu %lu %lu %lu %lu %lu %lu (%s)\n", (int) pid,
|
||||
(unsigned long) data.proc_kernel.flags,
|
||||
(unsigned long) data.proc_kernel.k_flags,
|
||||
(unsigned long) data.proc_kernel.min_flt,
|
||||
(unsigned long) data.proc_kernel.maj_flt,
|
||||
(unsigned long) data.proc_kernel.cmin_flt,
|
||||
(unsigned long) data.proc_kernel.cmaj_flt,
|
||||
(unsigned long) data.proc_kernel.kstk_esp,
|
||||
(unsigned long) data.proc_kernel.kstk_eip,
|
||||
(unsigned long) data.proc_kernel.nwchan,
|
||||
data.proc_kernel.wchan);
|
||||
|
||||
printf ("\n");
|
||||
|
||||
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 %5d (0x%08lx): '%s', %c, %lu, %lu\n",
|
||||
(int) ppid, (unsigned long) data.proc_state.flags,
|
||||
data.proc_state.cmd, data.proc_state.state,
|
||||
(unsigned long) data.proc_state.uid,
|
||||
(unsigned long) data.proc_state.gid);
|
||||
|
||||
for (c = 0; c < count; c++)
|
||||
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 %5d (0x%08lx): "
|
||||
"%d %d %d %d %d %d %d %d %d %d %d %d\n", (int) ppid,
|
||||
(unsigned long) 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);
|
||||
|
||||
for (c = 0; c < count; c++)
|
||||
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 %5d (0x%08lx): "
|
||||
"%lu %lu %lu %lu %lu %lu\n", (int) ppid,
|
||||
(unsigned long) data.proc_mem.flags,
|
||||
(unsigned long) data.proc_mem.size,
|
||||
(unsigned long) data.proc_mem.vsize,
|
||||
(unsigned long) data.proc_mem.resident,
|
||||
(unsigned long) data.proc_mem.share,
|
||||
(unsigned long) data.proc_mem.rss,
|
||||
(unsigned long) data.proc_mem.rss_rlim);
|
||||
|
||||
for (c = 0; c < 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);
|
||||
|
||||
for (c = 0; c < 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);
|
||||
|
||||
for (c = 0; c < 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);
|
||||
|
||||
for (c = 0; c < count; c++)
|
||||
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 %5d (0x%08lx): "
|
||||
"%lu %lu %lu %lu %lu %lu %lu %lu\n", (int) ppid,
|
||||
(unsigned long) data.proc_segment.flags,
|
||||
(unsigned long) data.proc_segment.text_rss,
|
||||
(unsigned long) data.proc_segment.shlib_rss,
|
||||
(unsigned long) data.proc_segment.data_rss,
|
||||
(unsigned long) data.proc_segment.stack_rss,
|
||||
(unsigned long) data.proc_segment.dirty_size,
|
||||
(unsigned long) data.proc_segment.start_code,
|
||||
(unsigned long) data.proc_segment.end_code,
|
||||
(unsigned long) data.proc_segment.start_stack);
|
||||
|
||||
fprintf (stderr, "\n");
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_time (&data.proc_time, ppid);
|
||||
|
||||
for (c = 0; c < count; c++)
|
||||
printf ("Proc_Time PPID %5d (0x%08lx): "
|
||||
"%lu %lu %lu %lu %lu %lu %lu %lu %lu\n", (int) ppid,
|
||||
(unsigned long) data.proc_time.flags,
|
||||
(unsigned long) data.proc_time.start_time,
|
||||
(unsigned long) data.proc_time.rtime,
|
||||
(unsigned long) data.proc_time.utime,
|
||||
(unsigned long) data.proc_time.stime,
|
||||
(unsigned long) data.proc_time.cutime,
|
||||
(unsigned long) data.proc_time.cstime,
|
||||
(unsigned long) data.proc_time.timeout,
|
||||
(unsigned long) data.proc_time.it_real_value,
|
||||
(unsigned long) data.proc_time.frequency);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_signal (&data.proc_signal, ppid);
|
||||
|
||||
printf ("Proc_Signal PPID %5d (0x%08lx): %lu %lu %lu %lu\n",
|
||||
(int) ppid, (unsigned long) data.proc_signal.flags,
|
||||
(unsigned long) data.proc_signal.signal,
|
||||
(unsigned long) data.proc_signal.blocked,
|
||||
(unsigned long) data.proc_signal.sigignore,
|
||||
(unsigned long) data.proc_signal.sigcatch);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_kernel (&data.proc_kernel, ppid);
|
||||
|
||||
printf ("Proc_Kernel PPID %5d (0x%08lx): "
|
||||
"%lu %lu %lu %lu %lu %lu %lu %lu (%s)\n", (int) ppid,
|
||||
(unsigned long) data.proc_kernel.flags,
|
||||
(unsigned long) data.proc_kernel.k_flags,
|
||||
(unsigned long) data.proc_kernel.min_flt,
|
||||
(unsigned long) data.proc_kernel.maj_flt,
|
||||
(unsigned long) data.proc_kernel.cmin_flt,
|
||||
(unsigned long) data.proc_kernel.cmaj_flt,
|
||||
(unsigned long) data.proc_kernel.kstk_esp,
|
||||
(unsigned long) data.proc_kernel.kstk_eip,
|
||||
(unsigned long) data.proc_kernel.nwchan,
|
||||
data.proc_kernel.wchan);
|
||||
|
||||
printf ("\n");
|
||||
|
||||
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 %5d (0x%08lx): '%s', %c, %lu, %lu\n", 1,
|
||||
(unsigned long) data.proc_state.flags,
|
||||
data.proc_state.cmd, data.proc_state.state,
|
||||
(unsigned long) data.proc_state.uid,
|
||||
(unsigned long) data.proc_state.gid);
|
||||
|
||||
for (c = 0; c < count; c++)
|
||||
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 %5d (0x%08lx): "
|
||||
"%d %d %d %d %d %d %d %d %d %d %d %d\n", 1,
|
||||
(unsigned long) 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);
|
||||
|
||||
for (c = 0; c < count; c++)
|
||||
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 %5d (0x%08lx): "
|
||||
"%lu %lu %lu %lu %lu %lu\n", 1,
|
||||
(unsigned long) data.proc_mem.flags,
|
||||
(unsigned long) data.proc_mem.size,
|
||||
(unsigned long) data.proc_mem.vsize,
|
||||
(unsigned long) data.proc_mem.resident,
|
||||
(unsigned long) data.proc_mem.share,
|
||||
(unsigned long) data.proc_mem.rss,
|
||||
(unsigned long) data.proc_mem.rss_rlim);
|
||||
|
||||
for (c = 0; c < 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);
|
||||
|
||||
for (c = 0; c < 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);
|
||||
|
||||
for (c = 0; c < 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);
|
||||
|
||||
for (c = 0; c < count; c++)
|
||||
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 %5d (0x%08lx): "
|
||||
"%lu %lu %lu %lu %lu %lu %lu %lu\n", 1,
|
||||
(unsigned long) data.proc_segment.flags,
|
||||
(unsigned long) data.proc_segment.text_rss,
|
||||
(unsigned long) data.proc_segment.shlib_rss,
|
||||
(unsigned long) data.proc_segment.data_rss,
|
||||
(unsigned long) data.proc_segment.stack_rss,
|
||||
(unsigned long) data.proc_segment.dirty_size,
|
||||
(unsigned long) data.proc_segment.start_code,
|
||||
(unsigned long) data.proc_segment.end_code,
|
||||
(unsigned long) data.proc_segment.start_stack);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_time (&data.proc_time, 1);
|
||||
|
||||
printf ("Proc_Time INIT %5d (0x%08lx): "
|
||||
"%lu %lu %lu %lu %lu %lu %lu %lu %lu\n", 1,
|
||||
(unsigned long) data.proc_time.flags,
|
||||
(unsigned long) data.proc_time.start_time,
|
||||
(unsigned long) data.proc_time.rtime,
|
||||
(unsigned long) data.proc_time.utime,
|
||||
(unsigned long) data.proc_time.stime,
|
||||
(unsigned long) data.proc_time.cutime,
|
||||
(unsigned long) data.proc_time.cstime,
|
||||
(unsigned long) data.proc_time.timeout,
|
||||
(unsigned long) data.proc_time.it_real_value,
|
||||
(unsigned long) data.proc_time.frequency);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_signal (&data.proc_signal, 1);
|
||||
|
||||
printf ("Proc_Signal INIT %5d (0x%08lx): "
|
||||
"%lu %lu %lu %lu\n", 1,
|
||||
(unsigned long) data.proc_signal.flags,
|
||||
(unsigned long) data.proc_signal.signal,
|
||||
(unsigned long) data.proc_signal.blocked,
|
||||
(unsigned long) data.proc_signal.sigignore,
|
||||
(unsigned long) data.proc_signal.sigcatch);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_kernel (&data.proc_kernel, 1);
|
||||
|
||||
printf ("Proc_Kernel INIT %5d (0x%08lx): "
|
||||
"%lu %lu %lu %lu %lu %lu %lu %lu (%s)\n", 1,
|
||||
(unsigned long) data.proc_kernel.flags,
|
||||
(unsigned long) data.proc_kernel.k_flags,
|
||||
(unsigned long) data.proc_kernel.min_flt,
|
||||
(unsigned long) data.proc_kernel.maj_flt,
|
||||
(unsigned long) data.proc_kernel.cmin_flt,
|
||||
(unsigned long) data.proc_kernel.cmaj_flt,
|
||||
(unsigned long) data.proc_kernel.kstk_esp,
|
||||
(unsigned long) data.proc_kernel.kstk_eip,
|
||||
(unsigned long) data.proc_kernel.nwchan,
|
||||
data.proc_kernel.wchan);
|
||||
|
||||
glibtop_close ();
|
||||
|
||||
exit (0);
|
||||
}
|
||||
|
111
examples/mountlist.c
Normal file
111
examples/mountlist.c
Normal file
@@ -0,0 +1,111 @@
|
||||
/* $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 <locale.h>
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/open.h>
|
||||
#include <glibtop/close.h>
|
||||
#include <glibtop/xmalloc.h>
|
||||
|
||||
#include <glibtop/parameter.h>
|
||||
|
||||
#include <glibtop/mountlist.h>
|
||||
#include <glibtop/fsusage.h>
|
||||
|
||||
#ifndef PROFILE_COUNT
|
||||
#define PROFILE_COUNT 1000
|
||||
#endif
|
||||
|
||||
int
|
||||
main (int argc, char *argv [])
|
||||
{
|
||||
glibtop_fsusage fsusage;
|
||||
glibtop_mountlist mount_list;
|
||||
glibtop_mountentry *mount_entries;
|
||||
unsigned c, index, method, count, port;
|
||||
char buffer [BUFSIZ];
|
||||
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, GTOPLOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
glibtop_init_r (&glibtop_global_server, 0, GLIBTOP_INIT_NO_OPEN);
|
||||
|
||||
glibtop_get_parameter (GLIBTOP_PARAM_METHOD, &method, sizeof (method));
|
||||
|
||||
printf ("Method = %d\n", method);
|
||||
|
||||
count = glibtop_get_parameter (GLIBTOP_PARAM_COMMAND, buffer, BUFSIZ);
|
||||
buffer [count] = 0;
|
||||
|
||||
printf ("Command = '%s'\n", buffer);
|
||||
|
||||
count = glibtop_get_parameter (GLIBTOP_PARAM_HOST, buffer, BUFSIZ);
|
||||
buffer [count] = 0;
|
||||
|
||||
glibtop_get_parameter (GLIBTOP_PARAM_PORT, &port, sizeof (port));
|
||||
|
||||
printf ("Host = '%s' - %u\n\n", buffer, port);
|
||||
|
||||
printf ("sbrk (0) = %p\n\n", sbrk (0));
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++) {
|
||||
mount_entries = glibtop_get_mountlist (&mount_list, 1);
|
||||
|
||||
glibtop_free (mount_entries);
|
||||
}
|
||||
|
||||
printf ("sbrk (0) = %p\n\n", sbrk (0));
|
||||
|
||||
mount_entries = glibtop_get_mountlist (&mount_list, 1);
|
||||
|
||||
if (mount_entries == NULL)
|
||||
_exit (1);
|
||||
|
||||
for (index = 0; index < mount_list.number; index++)
|
||||
printf ("Mount_Entry: %-30s %-10s %-20s\n",
|
||||
mount_entries [index].mountdir,
|
||||
mount_entries [index].type,
|
||||
mount_entries [index].devname);
|
||||
|
||||
printf ("\n\n%-23s %9s %9s %9s %9s %9s\n\n",
|
||||
"", "Blocks", "Free", "Avail", "Files", "Free");
|
||||
|
||||
for (index = 0; index < mount_list.number; index++) {
|
||||
glibtop_get_fsusage (&fsusage,
|
||||
mount_entries [index].mountdir);
|
||||
|
||||
printf ("Usage: %-16s %9Lu %9Lu %9Lu %9Lu %9Lu\n",
|
||||
mount_entries [index].mountdir,
|
||||
fsusage.blocks, fsusage.bfree,
|
||||
fsusage.bavail, fsusage.files,
|
||||
fsusage.ffree);
|
||||
}
|
||||
|
||||
glibtop_free (mount_entries);
|
||||
|
||||
printf ("\nsbrk (0) = %p\n\n", sbrk (0));
|
||||
|
||||
glibtop_close ();
|
||||
|
||||
exit (0);
|
||||
}
|
145
examples/procmap.c
Normal file
145
examples/procmap.c
Normal file
@@ -0,0 +1,145 @@
|
||||
/* $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 <locale.h>
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/open.h>
|
||||
#include <glibtop/close.h>
|
||||
#include <glibtop/xmalloc.h>
|
||||
|
||||
#include <glibtop/parameter.h>
|
||||
|
||||
#include <glibtop/procmap.h>
|
||||
|
||||
#ifdef GLIBTOP_INODEDB
|
||||
#include <glibtop/inodedb.h>
|
||||
#endif
|
||||
|
||||
#include <sys/resource.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#ifndef PROFILE_COUNT
|
||||
#define PROFILE_COUNT 1
|
||||
#endif
|
||||
|
||||
int
|
||||
main (int argc, char *argv [])
|
||||
{
|
||||
#ifdef GLIBTOP_INODEDB
|
||||
glibtop_inodedb *inodedb;
|
||||
#endif
|
||||
glibtop_proc_map procmap;
|
||||
glibtop_map_entry *maps;
|
||||
unsigned method, count, port, i;
|
||||
char buffer [BUFSIZ];
|
||||
pid_t pid;
|
||||
|
||||
count = PROFILE_COUNT;
|
||||
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, GTOPLOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
glibtop_init_r (&glibtop_global_server, 0, GLIBTOP_INIT_NO_OPEN);
|
||||
|
||||
glibtop_get_parameter (GLIBTOP_PARAM_METHOD, &method, sizeof (method));
|
||||
|
||||
printf ("Method = %d\n", method);
|
||||
|
||||
count = glibtop_get_parameter (GLIBTOP_PARAM_COMMAND, buffer, BUFSIZ);
|
||||
buffer [count] = 0;
|
||||
|
||||
printf ("Command = '%s'\n", buffer);
|
||||
|
||||
count = glibtop_get_parameter (GLIBTOP_PARAM_HOST, buffer, BUFSIZ);
|
||||
buffer [count] = 0;
|
||||
|
||||
glibtop_get_parameter (GLIBTOP_PARAM_PORT, &port, sizeof (port));
|
||||
|
||||
printf ("Host = '%s' - %u\n\n", buffer, port);
|
||||
|
||||
glibtop_init_r (&glibtop_global_server, 0, 0);
|
||||
|
||||
if ((argc != 2) || (sscanf (argv [1], "%d", (int *) &pid) != 1))
|
||||
glibtop_error ("Usage: %s pid", argv [0]);
|
||||
|
||||
#ifdef GLIBTOP_INODEDB
|
||||
inodedb = glibtop_inodedb_open (0, 0);
|
||||
#endif
|
||||
|
||||
fprintf (stderr, "Getting memory maps for pid %d.\n\n", (int) pid);
|
||||
|
||||
maps = glibtop_get_proc_map (&procmap, pid);
|
||||
|
||||
for (i = 0; i < procmap.number; i++) {
|
||||
const char *filename = NULL;
|
||||
unsigned device, device_major, device_minor;
|
||||
char perm [5];
|
||||
|
||||
if (maps [i].flags & (1 << GLIBTOP_MAP_ENTRY_FILENAME))
|
||||
filename = maps [i].filename;
|
||||
|
||||
#ifdef GLIBTOP_INODEDB
|
||||
if (inodedb && !filename)
|
||||
filename = glibtop_inodedb_lookup
|
||||
(inodedb, maps [i].device, maps [i].inode);
|
||||
#endif
|
||||
|
||||
perm [0] = (maps [i].perm & GLIBTOP_MAP_PERM_READ) ? 'r' : '-';
|
||||
perm [1] = (maps [i].perm & GLIBTOP_MAP_PERM_WRITE) ? 'w' : '-';
|
||||
perm [2] = (maps [i].perm & GLIBTOP_MAP_PERM_EXECUTE) ? 'x' : '-';
|
||||
perm [3] = (maps [i].perm & GLIBTOP_MAP_PERM_SHARED) ? 's' : '-';
|
||||
perm [4] = (maps [i].perm & GLIBTOP_MAP_PERM_PRIVATE) ? 'p' : '-';
|
||||
|
||||
device = (unsigned long) maps [i].device;
|
||||
device_minor = (device & 255);
|
||||
device_major = ((device >> 8) & 255);
|
||||
|
||||
if (filename)
|
||||
fprintf (stderr, "%08lx-%08lx %08lx - "
|
||||
"%02x:%02x %08lu - %4s - %s\n",
|
||||
(unsigned long) maps [i].start,
|
||||
(unsigned long) maps [i].end,
|
||||
(unsigned long) maps [i].offset,
|
||||
device_major, device_minor,
|
||||
(unsigned long) maps [i].inode,
|
||||
perm, filename);
|
||||
else
|
||||
fprintf (stderr, "%08lx-%08lx %08lx - "
|
||||
"%02x:%02x %08lu - %4s\n",
|
||||
(unsigned long) maps [i].start,
|
||||
(unsigned long) maps [i].end,
|
||||
(unsigned long) maps [i].offset,
|
||||
device_major, device_minor,
|
||||
(unsigned long) maps [i].inode,
|
||||
perm);
|
||||
|
||||
if (filename && (filename != maps [i].filename))
|
||||
glibtop_free (filename);
|
||||
}
|
||||
|
||||
glibtop_free (maps);
|
||||
|
||||
glibtop_close ();
|
||||
|
||||
exit (0);
|
||||
}
|
@@ -29,10 +29,106 @@
|
||||
#include <glibtop/union.h>
|
||||
#include <glibtop/sysdeps.h>
|
||||
|
||||
static void
|
||||
output (pid_t pid)
|
||||
{
|
||||
glibtop_union data;
|
||||
|
||||
printf ("\n");
|
||||
|
||||
glibtop_get_proc_state (&data.proc_state, pid);
|
||||
|
||||
printf ("Proc_State PID %5d (0x%08lx): "
|
||||
"'%s', %c, %lu, %lu\n", (int) pid,
|
||||
(unsigned long) data.proc_state.flags,
|
||||
data.proc_state.cmd, data.proc_state.state,
|
||||
(unsigned long) data.proc_state.uid,
|
||||
(unsigned long) data.proc_state.gid);
|
||||
|
||||
glibtop_get_proc_uid (&data.proc_uid, pid);
|
||||
|
||||
printf ("Proc_Uid PID %5d (0x%08lx): "
|
||||
"%d %d %d %d %d %d %d %d %d %d %d %d\n", (int) pid,
|
||||
(unsigned long) 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);
|
||||
|
||||
printf ("Proc_Mem PID %5d (0x%08lx): "
|
||||
"%lu %lu %lu %lu %lu %lu\n", (int) pid,
|
||||
(unsigned long) data.proc_mem.flags,
|
||||
(unsigned long) data.proc_mem.size,
|
||||
(unsigned long) data.proc_mem.vsize,
|
||||
(unsigned long) data.proc_mem.resident,
|
||||
(unsigned long) data.proc_mem.share,
|
||||
(unsigned long) data.proc_mem.rss,
|
||||
(unsigned long) data.proc_mem.rss_rlim);
|
||||
|
||||
glibtop_get_proc_segment (&data.proc_segment, pid);
|
||||
|
||||
printf ("Proc_Segment PID %5d (0x%08lx): "
|
||||
"%lu %lu %lu %lu %lu %lu %lu %lu\n", (int) pid,
|
||||
(unsigned long) data.proc_segment.flags,
|
||||
(unsigned long) data.proc_segment.text_rss,
|
||||
(unsigned long) data.proc_segment.shlib_rss,
|
||||
(unsigned long) data.proc_segment.data_rss,
|
||||
(unsigned long) data.proc_segment.stack_rss,
|
||||
(unsigned long) data.proc_segment.dirty_size,
|
||||
(unsigned long) data.proc_segment.start_code,
|
||||
(unsigned long) data.proc_segment.end_code,
|
||||
(unsigned long) data.proc_segment.start_stack);
|
||||
|
||||
glibtop_get_proc_time (&data.proc_time, pid);
|
||||
|
||||
printf ("Proc_Time PID %5d (0x%08lx): "
|
||||
"%lu %lu %lu %lu %lu %lu %lu %lu %lu\n", (int) pid,
|
||||
(unsigned long) data.proc_time.flags,
|
||||
(unsigned long) data.proc_time.start_time,
|
||||
(unsigned long) data.proc_time.rtime,
|
||||
(unsigned long) data.proc_time.utime,
|
||||
(unsigned long) data.proc_time.stime,
|
||||
(unsigned long) data.proc_time.cutime,
|
||||
(unsigned long) data.proc_time.cstime,
|
||||
(unsigned long) data.proc_time.timeout,
|
||||
(unsigned long) data.proc_time.it_real_value,
|
||||
(unsigned long) data.proc_time.frequency);
|
||||
|
||||
glibtop_get_proc_signal (&data.proc_signal, pid);
|
||||
|
||||
printf ("Proc_Signal PID %5d (0x%08lx): "
|
||||
"%lu %lu %lu %lu\n", (int) pid,
|
||||
(unsigned long) data.proc_signal.flags,
|
||||
(unsigned long) data.proc_signal.signal,
|
||||
(unsigned long) data.proc_signal.blocked,
|
||||
(unsigned long) data.proc_signal.sigignore,
|
||||
(unsigned long) data.proc_signal.sigcatch);
|
||||
|
||||
glibtop_get_proc_kernel (&data.proc_kernel, pid);
|
||||
|
||||
printf ("Proc_Kernel PID %5d (0x%08lx): "
|
||||
"%lu %lu %lu %lu %lu %lu %lu %lu (%s)\n", (int) pid,
|
||||
(unsigned long) data.proc_kernel.flags,
|
||||
(unsigned long) data.proc_kernel.k_flags,
|
||||
(unsigned long) data.proc_kernel.min_flt,
|
||||
(unsigned long) data.proc_kernel.maj_flt,
|
||||
(unsigned long) data.proc_kernel.cmin_flt,
|
||||
(unsigned long) data.proc_kernel.cmaj_flt,
|
||||
(unsigned long) data.proc_kernel.kstk_esp,
|
||||
(unsigned long) data.proc_kernel.kstk_eip,
|
||||
(unsigned long) data.proc_kernel.nwchan,
|
||||
data.proc_kernel.wchan);
|
||||
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv [])
|
||||
{
|
||||
glibtop_union data;
|
||||
glibtop_proclist proclist;
|
||||
glibtop_sysdeps sysdeps;
|
||||
unsigned *ptr, pid, i;
|
||||
@@ -45,23 +141,41 @@ main (int argc, char *argv [])
|
||||
|
||||
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",
|
||||
(unsigned long) sysdeps.flags,
|
||||
(unsigned long) sysdeps.cpu,
|
||||
(unsigned long) sysdeps.mem,
|
||||
(unsigned long) sysdeps.swap,
|
||||
(unsigned long) sysdeps.uptime,
|
||||
(unsigned long) sysdeps.loadavg,
|
||||
(unsigned long) sysdeps.shm_limits,
|
||||
(unsigned long) sysdeps.msg_limits,
|
||||
(unsigned long) sysdeps.sem_limits,
|
||||
(unsigned long) sysdeps.proclist,
|
||||
(unsigned long) sysdeps.proc_state,
|
||||
(unsigned long) sysdeps.proc_uid,
|
||||
(unsigned long) sysdeps.proc_mem,
|
||||
(unsigned long) sysdeps.proc_time,
|
||||
(unsigned long) sysdeps.proc_signal,
|
||||
(unsigned long) sysdeps.proc_kernel,
|
||||
(unsigned long) sysdeps.proc_segment);
|
||||
|
||||
fprintf (stderr, "\n");
|
||||
|
||||
ptr = glibtop_get_proclist (&proclist);
|
||||
if ((argc == 2) && (sscanf (argv [1], "%d", &pid) == 1)) {
|
||||
output (pid);
|
||||
|
||||
fprintf (stderr, "Proclist (0x%08lx): %ld, %ld, %ld\n",
|
||||
proclist.flags, proclist.number, proclist.size,
|
||||
proclist.total);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
printf ("\n");
|
||||
|
||||
ptr = glibtop_get_proclist (&proclist, 0, 0);
|
||||
|
||||
printf ("Proclist (0x%08lx): %lu, %lu, %lu\n",
|
||||
(unsigned long) proclist.flags,
|
||||
(unsigned long) proclist.number,
|
||||
(unsigned long) proclist.size,
|
||||
(unsigned long) proclist.total);
|
||||
|
||||
if (!ptr) exit (1);
|
||||
|
||||
@@ -69,71 +183,7 @@ main (int argc, char *argv [])
|
||||
|
||||
pid = ptr [i];
|
||||
|
||||
fprintf (stderr, "\n");
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
fprintf (stderr, "\n");
|
||||
output (pid);
|
||||
}
|
||||
|
||||
glibtop_free (ptr);
|
||||
|
35
features.def
35
features.def
@@ -1,16 +1,19 @@
|
||||
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)
|
||||
void|cpu|ulong(total,user,nice,sys,idle,frequency)
|
||||
void|mem|ulong(total,used,free,shared,buffer,cached,user,locked)
|
||||
void|swap|ulong(total,used,free,pagein,pageout)
|
||||
void|uptime|double(uptime,idletime)
|
||||
void|loadavg|double(loadavg[0],loadavg[1],loadavg[2]):ulong(nr_running,nr_tasks,last_pid)
|
||||
void|shm_limits|ulong(shmmax,shmmin,shmmni,shmseg,shmall)
|
||||
void|msg_limits|ulong(msgpool,msgmap,msgmax,msgmnb,msgmni,msgssz,msgtql)
|
||||
void|sem_limits|ulong(semmap,semmni,semmns,semmnu,semmsl,semopm,semume,semusz,semvmx,semaem)
|
||||
unsigned *|proclist|ulong(number,size,total)|long(which,arg)
|
||||
void|proc_state|str(cmd):char(state):ulong(uid,gid)|pid_t(pid)
|
||||
void|proc_uid|long(uid,euid,gid,egid,pid,ppid,pgrp,session,tty,tpgid,priority,nice)|pid_t(pid)
|
||||
void|proc_mem|long(size,vsize,resident,share,rss,rss_rlim)|pid_t(pid)
|
||||
void|proc_time|long(start_time,rtime,utime,stime,cutime,cstime,timeout,it_real_value,frequency)|pid_t(pid)
|
||||
void|proc_signal|ulong(signal,blocked,sigignore,sigcatch)|pid_t(pid)
|
||||
void|proc_kernel|ulong(k_flags,min_flt,maj_flt,cmin_flt,cmaj_flt,kstk_esp,kstk_eip,nwchan):str(wchan)|pid_t(pid)
|
||||
void|proc_segment|ulong(text_rss,shlib_rss,data_rss,stack_rss,dirty_size,start_code,end_code,start_stack)|pid_t(pid)
|
||||
glibtop_map_entry *|proc_map|ulong(number,size,total)|pid_t(pid)
|
||||
glibtop_mountentry *|@mountlist|ulong(number,size,total)|int(all_fs)
|
||||
void|@fsusage|ulong(blocks,bfree,bavail,files,ffree)|string|mount_dir
|
||||
|
21
glibtop.h
21
glibtop.h
@@ -31,16 +31,25 @@
|
||||
#include <glibtop_machine.h>
|
||||
#endif
|
||||
|
||||
#ifndef GLIBTOP_MOUNTENTRY_LEN
|
||||
#define GLIBTOP_MOUNTENTRY_LEN 79
|
||||
#endif
|
||||
|
||||
typedef struct _glibtop glibtop;
|
||||
|
||||
#include <glibtop/sysdeps.h>
|
||||
|
||||
struct _glibtop
|
||||
{
|
||||
int fd; /* Server file descriptor */
|
||||
unsigned flags;
|
||||
unsigned method; /* Server Method */
|
||||
unsigned error_method; /* Error 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 */
|
||||
@@ -48,6 +57,9 @@ struct _glibtop
|
||||
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 */
|
||||
glibtop_sysdeps sysdeps; /* Detailed feature list */
|
||||
glibtop_sysdeps required; /* Required feature list */
|
||||
pid_t pid; /* PID of the server */
|
||||
};
|
||||
|
||||
@@ -57,11 +69,12 @@ extern const unsigned long glibtop_server_features;
|
||||
|
||||
#define glibtop_init() glibtop_init_r(&glibtop_global_server, 0, 0);
|
||||
|
||||
#define glibtop_close() glibtop_close_r(&glibtop_global_server);
|
||||
#define glibtop_close() glibtop_close_r(glibtop_global_server);
|
||||
|
||||
extern glibtop *glibtop_init_r __P((glibtop **, const unsigned long, const unsigned));
|
||||
extern glibtop *glibtop_init_r __P((glibtop **, unsigned long, unsigned));
|
||||
extern glibtop *glibtop_init_s __P((glibtop **, unsigned long, unsigned));
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
#ifdef GLIBTOP_GUILE
|
||||
|
||||
/* You need to link with -lgtop_guile to get this stuff here. */
|
||||
|
||||
|
@@ -1 +1,3 @@
|
||||
reference.sgml
|
||||
Makefile.in
|
||||
Makefile
|
||||
features.scm
|
||||
|
9
guile/ChangeLog
Normal file
9
guile/ChangeLog
Normal file
@@ -0,0 +1,9 @@
|
||||
1998-07-29 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* dynamic.c, dynamic_names.c: New files.
|
||||
|
||||
* Makefile.am: New file. Creates `libgtop.so' and
|
||||
`libnames.so' which will be installed in
|
||||
`$(datadir)/guile/libgtop'; just do a
|
||||
`(use-modules (libgtop libgtop) (libgtop names))' in
|
||||
guile to use them.
|
60
guile/Makefile.am
Normal file
60
guile/Makefile.am
Normal file
@@ -0,0 +1,60 @@
|
||||
LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@
|
||||
|
||||
CFLAGS = -Wall -W @CFLAGS@
|
||||
|
||||
sitedir = $(datadir)/guile/site
|
||||
libgtopmoduledir = $(datadir)/guile/libgtop
|
||||
|
||||
libgtopmodule_LTLIBRARIES = libgtop.la libnames.la
|
||||
|
||||
libgtop_la_SOURCES = dynamic.c
|
||||
|
||||
libnames_la_SOURCES = dynamic_names.c
|
||||
|
||||
libgtop_la_LIBADD = ../sysdeps/guile/guile.lo \
|
||||
../lib/init.lo \
|
||||
../lib/open.lo \
|
||||
../lib/close.lo \
|
||||
../lib/command.lo \
|
||||
../lib/read.lo \
|
||||
../lib/read_data.lo \
|
||||
../lib/write.lo \
|
||||
../lib/lib.lo \
|
||||
../lib/parameter.lo \
|
||||
../lib/sysdeps.lo \
|
||||
../sysdeps/common/error.lo \
|
||||
../sysdeps/common/fsusage.lo \
|
||||
../sysdeps/common/gnuslib.lo \
|
||||
../sysdeps/common/mountlist.lo \
|
||||
../sysdeps/common/xmalloc.lo \
|
||||
../sysdeps/@sysdeps_dir@/close.lo \
|
||||
../sysdeps/@sysdeps_dir@/proclist.lo \
|
||||
../sysdeps/@sysdeps_dir@/sem_limits.lo \
|
||||
../sysdeps/@sysdeps_dir@/cpu.lo \
|
||||
../sysdeps/@sysdeps_dir@/procmem.lo \
|
||||
../sysdeps/@sysdeps_dir@/shm_limits.lo \
|
||||
../sysdeps/@sysdeps_dir@/loadavg.lo \
|
||||
../sysdeps/@sysdeps_dir@/procsegment.lo \
|
||||
../sysdeps/@sysdeps_dir@/siglist.lo \
|
||||
../sysdeps/@sysdeps_dir@/mem.lo \
|
||||
../sysdeps/@sysdeps_dir@/procsignal.lo \
|
||||
../sysdeps/@sysdeps_dir@/swap.lo \
|
||||
../sysdeps/@sysdeps_dir@/msg_limits.lo \
|
||||
../sysdeps/@sysdeps_dir@/procstate.lo \
|
||||
../sysdeps/@sysdeps_dir@/uptime.lo \
|
||||
../sysdeps/@sysdeps_dir@/open.lo \
|
||||
../sysdeps/@sysdeps_dir@/proctime.lo \
|
||||
../sysdeps/@sysdeps_dir@/prockernel.lo \
|
||||
../sysdeps/@sysdeps_dir@/procuid.lo \
|
||||
../sysdeps/@sysdeps_dir@/procmap.lo
|
||||
|
||||
libnames_la_LIBADD = ../sysdeps/guile/names/guile-names.lo
|
||||
|
||||
EXTRA_DIST = features.awk
|
||||
|
||||
CLEANFILES = features.scm
|
||||
|
||||
features.scm: features.awk $(top_builddir)/config.h $(top_srcdir)/features.def
|
||||
$(AWK) -f $(srcdir)/features.awk < $(top_srcdir)/features.def > tmp-t
|
||||
mv tmp-t features.scm
|
||||
|
@@ -19,13 +19,11 @@
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <glibtop/output.h>
|
||||
#include <glibtop.h>
|
||||
#include <libguile/dynl.h>
|
||||
|
||||
void
|
||||
glibtop_output (size_t size, const void *buf)
|
||||
scm_init_libgtop_libgtop_module (void)
|
||||
{
|
||||
if (write (1, &size, sizeof (size_t)) < 0)
|
||||
_exit (2);
|
||||
if (write (1, buf, size) < 0)
|
||||
_exit (2);
|
||||
scm_register_module_xxx ("libgtop libgtop", glibtop_boot_guile);
|
||||
}
|
@@ -19,13 +19,11 @@
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <glibtop/output.h>
|
||||
#include <glibtop.h>
|
||||
#include <libguile/dynl.h>
|
||||
|
||||
void
|
||||
glibtop_output (size_t size, const void *buf)
|
||||
scm_init_libgtop_names_module (void)
|
||||
{
|
||||
if (write (1, &size, sizeof (size_t)) < 0)
|
||||
_exit (2);
|
||||
if (write (1, buf, size) < 0)
|
||||
_exit (2);
|
||||
scm_register_module_xxx ("libgtop names", glibtop_boot_guile_names);
|
||||
}
|
61
guile/features.awk
Normal file
61
guile/features.awk
Normal file
@@ -0,0 +1,61 @@
|
||||
BEGIN {
|
||||
string = "";
|
||||
names = "";
|
||||
}
|
||||
|
||||
function output(line) {
|
||||
split (line, line_fields, /\|/);
|
||||
retval = line_fields[1];
|
||||
feature = line_fields[2];
|
||||
param_def = line_fields[4];
|
||||
|
||||
orig = feature; sub(/^@/,"",feature);
|
||||
space = feature; gsub(/./," ",space);
|
||||
|
||||
if (string == "")
|
||||
string = " '(";
|
||||
else
|
||||
string = string" ";
|
||||
string = string"(\""feature"\" (\""retval"\"";
|
||||
|
||||
feature_nounder = feature;
|
||||
sub(/_/, "-", feature_nounder);
|
||||
|
||||
if (names == "")
|
||||
names = " '(";
|
||||
else
|
||||
names = names" ";
|
||||
names = names"(\""feature"\" \""feature_nounder"\")\n";
|
||||
|
||||
nr_params = split (param_def, params, /:/);
|
||||
for (param = 1; param <= nr_params; param++) {
|
||||
list = params[param];
|
||||
type = params[param];
|
||||
sub(/\(.*/, "", type);
|
||||
sub(/^\w+\(/, "", list); sub(/\)$/, "", list);
|
||||
|
||||
string = string" (\""type"\"";
|
||||
|
||||
count = split (list, fields, /,/);
|
||||
for (field = 1; field <= count; field++) {
|
||||
string = string" \""fields[field]"\"";
|
||||
}
|
||||
|
||||
string = string")";
|
||||
}
|
||||
|
||||
string = string"))\n";
|
||||
}
|
||||
|
||||
/^[^#]/ { output($0) }
|
||||
|
||||
|
||||
END {
|
||||
print "(define libgtop-features";
|
||||
print string" )";
|
||||
print ")\n";
|
||||
|
||||
print "(define libgtop-feature-names";
|
||||
print names" )";
|
||||
print ")\n";
|
||||
}
|
@@ -1,12 +1,18 @@
|
||||
;; $Id$
|
||||
|
||||
(load "features.scm")
|
||||
|
||||
(define sysdeps-list '())
|
||||
|
||||
(define type-names '("void"
|
||||
"int64_t" "u_int64_t" "double"
|
||||
"int" "char" "const char *"))
|
||||
|
||||
(define make-sysdeps-list
|
||||
(lambda ()
|
||||
(letrec ((names (glibtop-names-sysdeps))
|
||||
(labels (glibtop-labels-sysdeps))
|
||||
(descriptions (glibtop-descriptions-sysdeps))
|
||||
(letrec ((names (cdr (glibtop-names-sysdeps)))
|
||||
(labels (cdr (glibtop-labels-sysdeps)))
|
||||
(descriptions (cdr (glibtop-descriptions-sysdeps)))
|
||||
)
|
||||
(for-each (lambda (feature)
|
||||
(let* ((label (car labels))
|
||||
@@ -31,11 +37,13 @@
|
||||
(let* ((names (eval-string (string "(glibtop-names-" feature ")")))
|
||||
(types (eval-string (string "(glibtop-types-" feature ")")))
|
||||
(labels (eval-string (string "(glibtop-labels-" feature ")")))
|
||||
(sysdeps (assoc-ref sysdeps-list feature)) (retval "void")
|
||||
(sysdeps (assoc-ref sysdeps-list feature))
|
||||
(retval (car (car (assoc-ref libgtop-features feature))))
|
||||
(name (assoc-ref sysdeps 'name))
|
||||
(label (assoc-ref sysdeps 'label))
|
||||
(description (assoc-ref sysdeps 'description))
|
||||
(descriptions (eval-string (string "(glibtop-descriptions-" feature ")")))
|
||||
(feature_nounder (car (assoc-ref libgtop-feature-names feature)))
|
||||
(decl-list '()) (field-list '())
|
||||
|
||||
(synopsis-start-string
|
||||
@@ -73,14 +81,43 @@
|
||||
|
||||
(funcdef-string
|
||||
(string "<funcdef>" retval " "
|
||||
"<function>glibtop_get_" feature "__r</function>"
|
||||
"<function>glibtop_get_" feature "_l</function>"
|
||||
"</funcdef>\n")
|
||||
)
|
||||
|
||||
(paramdef-string
|
||||
(string "<paramdef>glibtop *<parameter>server</parameter>, "
|
||||
"glibtop_" feature " *<parameter>" feature "</parameter>\n"
|
||||
"</paramdef>")
|
||||
(lambda ()
|
||||
(let ((start (string "<paramdef>glibtop *<parameter>"
|
||||
"server</parameter>, glibtop_"
|
||||
feature " *<parameter>" feature
|
||||
"</parameter>")
|
||||
)
|
||||
(param_string (string))
|
||||
(end (string "\n</paramdef>"))
|
||||
(param_lists
|
||||
(cdr (car (assoc-ref libgtop-features feature))))
|
||||
)
|
||||
(for-each
|
||||
(lambda (x)
|
||||
(let ((type (car x))
|
||||
(params (cdr x))
|
||||
)
|
||||
(for-each
|
||||
(lambda (param)
|
||||
(set! param_string (string param_string
|
||||
", " type
|
||||
" <parameter>"
|
||||
param
|
||||
"</parameter>"
|
||||
)
|
||||
)
|
||||
)
|
||||
params)
|
||||
)
|
||||
)
|
||||
param_lists)
|
||||
(string start param_string end))
|
||||
)
|
||||
)
|
||||
|
||||
(funcdef-noserver-string
|
||||
@@ -163,6 +200,7 @@
|
||||
(lambda (x)
|
||||
(set! new-type (car type-list))
|
||||
(set! type-list (cdr type-list))
|
||||
(set! new-type (list-ref type-names new-type))
|
||||
(if (equal? old-type new-type)
|
||||
(set-car! fields
|
||||
(append (list new-type)
|
||||
@@ -213,8 +251,8 @@
|
||||
(string "typedef struct _glibtop_" name)
|
||||
5)
|
||||
(string "glibtop_" name ";\n\n"
|
||||
"struct glibtop_" name "\n{\n\t"
|
||||
"unsigned long\tflags;\n")
|
||||
"struct _glibtop_" name "\n{\n\t"
|
||||
"u_int64_t\tflags;\n")
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -269,7 +307,7 @@
|
||||
(string "</funcsynopsis>\n")
|
||||
(string "<funcsynopsis>\n")
|
||||
funcdef-string
|
||||
paramdef-string
|
||||
(paramdef-string)
|
||||
(string "</funcsynopsis>\n</blockquote>\n")
|
||||
definition-start-string
|
||||
(string "<blockquote>\n<literallayout>\n")
|
||||
@@ -279,6 +317,7 @@
|
||||
"<variablelist>\n\n"
|
||||
(make-param-description)
|
||||
"</variablelist>\n\n"
|
||||
"&include-" feature_nounder ".sgml;\n\n"
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -299,13 +338,9 @@
|
||||
|
||||
(begin
|
||||
(make-sysdeps-list)
|
||||
|
||||
(display (string "<chapter id=\"functions\">\n"
|
||||
"<title>Function Reference List</title>\n\n")
|
||||
)
|
||||
|
||||
|
||||
(for-each (lambda (x)
|
||||
(display (make-function-reference x))
|
||||
)
|
||||
(glibtop-names-sysdeps))
|
||||
(cdr (glibtop-names-sysdeps)))
|
||||
)
|
||||
|
1784
guile/reference.sgml
Normal file
1784
guile/reference.sgml
Normal file
File diff suppressed because it is too large
Load Diff
@@ -5,4 +5,6 @@ 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
|
||||
procsignal.h read_data.h union.h types.h gnuserv.h \
|
||||
parameter.h mountlist.h fsusage.h procmap.h signal.h \
|
||||
inodedb.h
|
||||
|
@@ -28,6 +28,9 @@ __BEGIN_DECLS
|
||||
|
||||
extern void glibtop_close_r __P((glibtop *));
|
||||
|
||||
extern void glibtop_close_s __P((glibtop *));
|
||||
extern void glibtop_close_p __P((glibtop *));
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
|
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/sysdeps.h>
|
||||
#include <glibtop/union.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
@@ -47,16 +48,38 @@ __BEGIN_DECLS
|
||||
#define GLIBTOP_CMND_PROC_SIGNAL 15
|
||||
#define GLIBTOP_CMND_PROC_KERNEL 16
|
||||
#define GLIBTOP_CMND_PROC_SEGMENT 17
|
||||
#define GLIBTOP_CMND_PROC_MAP 18
|
||||
|
||||
#define GLIBTOP_MAX_CMND 18
|
||||
#define GLIBTOP_CMND_MOUNTLIST 19
|
||||
#define GLIBTOP_CMND_FSUSAGE 20
|
||||
|
||||
typedef struct _glibtop_command glibtop_command;
|
||||
#define GLIBTOP_MAX_CMND 21
|
||||
|
||||
#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;
|
||||
u_int64_t command;
|
||||
u_int64_t size, data_size;
|
||||
char parameter [_GLIBTOP_PARAM_SIZE];
|
||||
};
|
||||
|
||||
union _glibtop_response_union
|
||||
{
|
||||
glibtop_union data;
|
||||
glibtop_sysdeps sysdeps;
|
||||
};
|
||||
|
||||
struct _glibtop_response
|
||||
{
|
||||
int64_t offset;
|
||||
u_int64_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)
|
||||
|
@@ -40,7 +40,7 @@ typedef struct _glibtop_cpu glibtop_cpu;
|
||||
|
||||
struct _glibtop_cpu
|
||||
{
|
||||
unsigned long flags,
|
||||
u_int64_t flags,
|
||||
total, /* GLIBTOP_CPU_TOTAL */
|
||||
user, /* GLIBTOP_CPU_USER */
|
||||
nice, /* GLIBTOP_CPU_NICE */
|
||||
@@ -60,12 +60,14 @@ struct _glibtop_cpu
|
||||
extern void glibtop_get_cpu_l __P((glibtop *, glibtop_cpu *));
|
||||
|
||||
#if GLIBTOP_SUID_CPU
|
||||
extern void glibtop_init_cpu_p __P((glibtop *));
|
||||
extern void glibtop_get_cpu_p __P((glibtop *, glibtop_cpu *));
|
||||
#else
|
||||
extern void glibtop_init_cpu_s __P((glibtop *));
|
||||
extern void glibtop_get_cpu_s __P((glibtop *, glibtop_cpu *));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
#ifdef GLIBTOP_GUILE
|
||||
|
||||
/* You need to link with -lgtop_guile to get this stuff here. */
|
||||
|
||||
|
90
include/glibtop/fsusage.h
Normal file
90
include/glibtop/fsusage.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/* $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. */
|
||||
|
||||
#ifndef __GLIBTOP_FSUSAGE_H__
|
||||
#define __GLIBTOP_FSUSAGE_H__
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/global.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define GLIBTOP_FSUSAGE_BLOCKS 0
|
||||
#define GLIBTOP_FSUSAGE_BFREE 1
|
||||
#define GLIBTOP_FSUSAGE_BAVAIL 2
|
||||
#define GLIBTOP_FSUSAGE_FILES 3
|
||||
#define GLIBTOP_FSUSAGE_FFREE 4
|
||||
|
||||
#define GLIBTOP_MAX_FSUSAGE 5
|
||||
|
||||
typedef struct _glibtop_fsusage glibtop_fsusage;
|
||||
|
||||
struct _glibtop_fsusage
|
||||
{
|
||||
u_int64_t flags,
|
||||
blocks, /* Total blocks. */
|
||||
bfree, /* Free blocks available to superuser. */
|
||||
bavail, /* Free blocks available to non-superuser. */
|
||||
files, /* Total file nodes. */
|
||||
ffree; /* Free file nodes. */
|
||||
};
|
||||
|
||||
#define glibtop_get_fsusage(fsusage,disk) glibtop_get_fsusage_l(glibtop_global_server, fsusage, disk)
|
||||
|
||||
#define glibtop_get_fsusage_r glibtop_get_fsusage_s
|
||||
|
||||
extern void glibtop_get_fsusage_l __P((glibtop *, glibtop_fsusage *, const char *));
|
||||
|
||||
extern void glibtop_get_fsusage_s __P((glibtop *, glibtop_fsusage *, const char *));
|
||||
|
||||
#ifdef GLIBTOP_GUILE
|
||||
|
||||
/* You need to link with -lgtop_guile to get this stuff here. */
|
||||
|
||||
extern SCM glibtop_guile_get_fsusage __P((SCM));
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef GLIBTOP_GUILE_NAMES
|
||||
|
||||
/* You need to link with -lgtop_guile_names to get this stuff here. */
|
||||
|
||||
extern SCM glibtop_guile_names_fsusage __P((void));
|
||||
extern SCM glibtop_guile_types_fsusage __P((void));
|
||||
extern SCM glibtop_guile_labels_fsusage __P((void));
|
||||
extern SCM glibtop_guile_descriptions_fsusage __P((void));
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef GLIBTOP_NAMES
|
||||
|
||||
/* You need to link with -lgtop_names to get this stuff here. */
|
||||
|
||||
extern const char *glibtop_names_fsusage [];
|
||||
extern const unsigned glibtop_types_fsusage [];
|
||||
extern const char *glibtop_labels_fsusage [];
|
||||
extern const char *glibtop_descriptions_fsusage [];
|
||||
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
@@ -62,7 +62,16 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
#ifdef NEED_GNOMESUPPORT_H
|
||||
#include <gnomesupport.h>
|
||||
#endif
|
||||
|
||||
#ifdef WITHOUT_GUILE
|
||||
#undef GLIBTOP_GUILE
|
||||
#undef GLIBTOP_GUILE_NAMES
|
||||
#endif
|
||||
|
||||
#ifdef GLIBTOP_GUILE
|
||||
#include <guile/gh.h>
|
||||
#endif
|
||||
|
||||
|
@@ -54,10 +54,8 @@ static char header_rcsid [] = "!Header: gnuserv.h,v 2.4 95/02/16 11:58:11 arup a
|
||||
* sockets with sysv ipc
|
||||
*/
|
||||
|
||||
|
||||
#define INTERNET_DOMAIN_SOCKETS
|
||||
#define UNIX_DOMAIN_SOCKETS
|
||||
/* #define SYSV_IPC */
|
||||
#define UNIX_DOMAIN_SOCKETS
|
||||
|
||||
/*
|
||||
* Define additional authentication protocols to be used. These methods will
|
||||
@@ -77,7 +75,7 @@ static char header_rcsid [] = "!Header: gnuserv.h,v 2.4 95/02/16 11:58:11 arup a
|
||||
* stuff related to supporting MIT-MAGIC-COOKIE-1
|
||||
*/
|
||||
|
||||
#define MCOOKIE_SCREEN "999" /* screen # to use as the gnuserv cookie */
|
||||
#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 */
|
||||
|
||||
@@ -91,15 +89,13 @@ static char header_rcsid [] = "!Header: gnuserv.h,v 2.4 95/02/16 11:58:11 arup a
|
||||
* Pick a default communication scheme, if none was specified.
|
||||
*/
|
||||
|
||||
#if !defined(SYSV_IPC) && !defined(UNIX_DOMAIN_SOCKETS) && !defined(INTERNET_DOMAIN_SOCKETS)
|
||||
#if !defined(UNIX_DOMAIN_SOCKETS) && !defined(INTERNET_DOMAIN_SOCKETS)
|
||||
|
||||
#ifdef HAVE_SYSVIPC
|
||||
#define SYSV_IPC /* SYSV systems use SYSV IPC by default */
|
||||
#endif /* HAVE_SYSVIPC */
|
||||
/* BSD systems use Unix Domain sockets by default */
|
||||
|
||||
#ifdef BSD
|
||||
#define UNIX_DOMAIN_SOCKETS /* BSD systems use Unix Domain sockets by default */
|
||||
#endif /* BSD */
|
||||
#define UNIX_DOMAIN_SOCKETS
|
||||
#endif
|
||||
|
||||
#endif /* No communication method pre-defined */
|
||||
|
||||
@@ -111,24 +107,6 @@ static char header_rcsid [] = "!Header: gnuserv.h,v 2.4 95/02/16 11:58:11 arup a
|
||||
* what you want.
|
||||
*/
|
||||
|
||||
# define GSERV_BUFSZ BUFSIZ
|
||||
|
||||
|
||||
#ifdef SYSV_IPC
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/msg.h>
|
||||
|
||||
#define send_string(s,str) \
|
||||
if (strlen(msgp->mtext) + strlen(str) < GSERV_BUFSZ) \
|
||||
strcat(msgp->mtext,str); \
|
||||
else \
|
||||
{ \
|
||||
fprintf(stderr,"%s: not enough message buffer space\n",progname); \
|
||||
exit(1); \
|
||||
} \
|
||||
|
||||
#endif /* SYSV_IPC */
|
||||
|
||||
#if defined(INTERNET_DOMAIN_SOCKETS) || defined(UNIX_DOMAIN_SOCKETS)
|
||||
#include <sys/socket.h>
|
||||
#endif /* INTERNET_DOMAIN_SOCKETS || UNIX_DOMAIN_SOCKETS */
|
||||
@@ -155,10 +133,6 @@ static char header_rcsid [] = "!Header: gnuserv.h,v 2.4 95/02/16 11:58:11 arup a
|
||||
#undef TRUE
|
||||
#define TRUE 1
|
||||
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
extern char *progname;
|
||||
|
||||
/* 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))
|
||||
@@ -177,15 +151,8 @@ extern char *progname;
|
||||
#define CONN_IPC 2
|
||||
|
||||
/* function declarations */
|
||||
int make_connection (char *hostarg, int portarg, int *s);
|
||||
#ifdef SYSV_IPC
|
||||
void disconnect_from_ipc_server();
|
||||
#endif
|
||||
#if defined(INTERNET_DOMAIN_SOCKETS) || defined(UNIX_DOMAIN_SOCKETS)
|
||||
void send_string (int s, const char *msg);
|
||||
void disconnect_from_server (int s, int echo);
|
||||
int read_line (int s, char *dest);
|
||||
#endif
|
||||
extern int glibtop_make_connection __P((const char *, int, int *));
|
||||
|
||||
#ifdef INTERNET_DOMAIN_SOCKETS
|
||||
int internet_addr (char *host);
|
||||
extern long glibtop_internet_addr __P((const char *));
|
||||
#endif
|
||||
|
58
include/glibtop/inodedb.h
Normal file
58
include/glibtop/inodedb.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/* 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. */
|
||||
|
||||
#ifndef __GLIBTOP_INODEDB_H__
|
||||
#define __GLIBTOP_INODEDB_H__
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <gdbm.h>
|
||||
|
||||
#define GLIBTOP_INODEDB_SYSTEM 1
|
||||
#define GLIBTOP_INODEDB_USER 2
|
||||
#define GLIBTOP_INODEDB_CACHE 4
|
||||
|
||||
#define GLIBTOP_INODEDB_ALL 7
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
typedef struct _glibtop_inodedb glibtop_inodedb;
|
||||
|
||||
typedef struct _glibtop_inodedb_key glibtop_inodedb_key;
|
||||
|
||||
struct _glibtop_inodedb_key
|
||||
{
|
||||
u_int64_t device, inode;
|
||||
};
|
||||
|
||||
struct _glibtop_inodedb
|
||||
{
|
||||
GDBM_FILE system_dbf, user_dbf;
|
||||
};
|
||||
|
||||
#define glibtop_inodedb_open(p1,p2) glibtop_inodedb_open_s(glibtop_global_server, p1, p2)
|
||||
#define glibtop_inodedb_lookup(p1,p2,p3) glibtop_inodedb_lookup_s(glibtop_global_server, p1, p2, p3)
|
||||
#define glibtop_inodedb_close(p1) glibtop_inodedb_close_s(glibtop_global_server)
|
||||
|
||||
extern glibtop_inodedb *glibtop_inodedb_open_s __P((glibtop *, unsigned, unsigned long));
|
||||
extern const char *glibtop_inodedb_lookup_s __P((glibtop *, glibtop_inodedb *, u_int64_t, u_int64_t));
|
||||
extern void glibtop_inodedb_close_s __P((glibtop *, glibtop_inodedb *));
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
@@ -28,15 +28,21 @@
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define GLIBTOP_LOADAVG_LOADAVG 0
|
||||
#define GLIBTOP_LOADAVG_NR_RUNNING 1
|
||||
#define GLIBTOP_LOADAVG_NR_TASKS 2
|
||||
#define GLIBTOP_LOADAVG_LAST_PID 3
|
||||
|
||||
#define GLIBTOP_MAX_LOADAVG 1
|
||||
#define GLIBTOP_MAX_LOADAVG 4
|
||||
|
||||
typedef struct _glibtop_loadavg glibtop_loadavg;
|
||||
|
||||
struct _glibtop_loadavg
|
||||
{
|
||||
unsigned long flags;
|
||||
u_int64_t flags;
|
||||
double loadavg [3]; /* GLIBTOP_LOADAVG_LOADAVG */
|
||||
u_int64_t nr_running, /* GLIBTOP_LOADAVG_NR_RUNNING */
|
||||
nr_tasks, /* GLIBTOP_LOADAVG_NR_TASKS */
|
||||
last_pid; /* GLIBTOP_LOADAVG_LAST_PID */
|
||||
};
|
||||
|
||||
#define glibtop_get_loadavg(loadavg) glibtop_get_loadavg_l(glibtop_global_server, loadavg)
|
||||
@@ -50,12 +56,14 @@ struct _glibtop_loadavg
|
||||
extern void glibtop_get_loadavg_l __P((glibtop *, glibtop_loadavg *));
|
||||
|
||||
#if GLIBTOP_SUID_LOADAVG
|
||||
extern void glibtop_init_loadavg_p __P((glibtop *));
|
||||
extern void glibtop_get_loadavg_p __P((glibtop *, glibtop_loadavg *));
|
||||
#else
|
||||
extern void glibtop_init_loadavg_s __P((glibtop *));
|
||||
extern void glibtop_get_loadavg_s __P((glibtop *, glibtop_loadavg *));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
#ifdef GLIBTOP_GUILE
|
||||
|
||||
/* You need to link with -lgtop_guile to get this stuff here. */
|
||||
|
||||
|
@@ -42,7 +42,7 @@ typedef struct _glibtop_mem glibtop_mem;
|
||||
|
||||
struct _glibtop_mem
|
||||
{
|
||||
unsigned long flags,
|
||||
u_int64_t flags,
|
||||
total, /* GLIBTOP_MEM_TOTAL */
|
||||
used, /* GLIBTOP_MEM_USED */
|
||||
free, /* GLIBTOP_MEM_FREE */
|
||||
@@ -64,12 +64,14 @@ struct _glibtop_mem
|
||||
extern void glibtop_get_mem_l __P((glibtop *, glibtop_mem *));
|
||||
|
||||
#if GLIBTOP_SUID_MEM
|
||||
extern void glibtop_init_mem_p __P((glibtop *));
|
||||
extern void glibtop_get_mem_p __P((glibtop *, glibtop_mem *));
|
||||
#else
|
||||
extern void glibtop_init_mem_s __P((glibtop *));
|
||||
extern void glibtop_get_mem_s __P((glibtop *, glibtop_mem *));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
#ifdef GLIBTOP_GUILE
|
||||
|
||||
/* You need to link with -lgtop_guile to get this stuff here. */
|
||||
|
||||
|
96
include/glibtop/mountlist.h
Normal file
96
include/glibtop/mountlist.h
Normal file
@@ -0,0 +1,96 @@
|
||||
/* $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. */
|
||||
|
||||
#ifndef __GLIBTOP_MOUNTLIST_H__
|
||||
#define __GLIBTOP_MOUNTLIST_H__
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/global.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define GLIBTOP_MOUNTLIST_NUMBER 0
|
||||
#define GLIBTOP_MOUNTLIST_TOTAL 1
|
||||
#define GLIBTOP_MOUNTLIST_SIZE 2
|
||||
|
||||
#define GLIBTOP_MAX_MOUNTLIST 3
|
||||
|
||||
typedef struct _glibtop_mountentry glibtop_mountentry;
|
||||
|
||||
typedef struct _glibtop_mountlist glibtop_mountlist;
|
||||
|
||||
struct _glibtop_mountentry
|
||||
{
|
||||
u_int64_t dev;
|
||||
char devname [GLIBTOP_MOUNTENTRY_LEN+1];
|
||||
char mountdir [GLIBTOP_MOUNTENTRY_LEN+1];
|
||||
char type [GLIBTOP_MOUNTENTRY_LEN+1];
|
||||
};
|
||||
|
||||
struct _glibtop_mountlist
|
||||
{
|
||||
u_int64_t flags,
|
||||
number, /* GLIBTOP_MOUNTLIST_NUMBER */
|
||||
total, /* GLIBTOP_MOUNTLIST_TOTAL */
|
||||
size; /* GLIBTOP_MOUNTLIST_SIZE */
|
||||
};
|
||||
|
||||
#define glibtop_get_mountlist(mountlist,all_fs) glibtop_get_mountlist_l(glibtop_global_server, mountlist, all_fs)
|
||||
|
||||
#define glibtop_get_mountlist_r glibtop_get_mountlist_s
|
||||
|
||||
extern glibtop_mountentry *glibtop_get_mountlist_l __P((glibtop *, glibtop_mountlist *, int));
|
||||
|
||||
extern glibtop_mountentry *glibtop_get_mountlist_s __P((glibtop *, glibtop_mountlist *, int));
|
||||
|
||||
#ifdef GLIBTOP_GUILE
|
||||
|
||||
/* You need to link with -lgtop_guile to get this stuff here. */
|
||||
|
||||
extern SCM glibtop_guile_get_mountlist __P((SCM));
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef GLIBTOP_GUILE_NAMES
|
||||
|
||||
/* You need to link with -lgtop_guile_names to get this stuff here. */
|
||||
|
||||
extern SCM glibtop_guile_names_mountlist __P((void));
|
||||
extern SCM glibtop_guile_types_mountlist __P((void));
|
||||
extern SCM glibtop_guile_labels_mountlist __P((void));
|
||||
extern SCM glibtop_guile_descriptions_mountlist __P((void));
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef GLIBTOP_NAMES
|
||||
|
||||
/* You need to link with -lgtop_names to get this stuff here. */
|
||||
|
||||
extern const char *glibtop_names_mountlist [];
|
||||
extern const unsigned glibtop_types_mountlist [];
|
||||
extern const char *glibtop_labels_mountlist [];
|
||||
extern const char *glibtop_descriptions_mountlist [];
|
||||
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
@@ -41,7 +41,7 @@ typedef struct _glibtop_msg_limits glibtop_msg_limits;
|
||||
|
||||
struct _glibtop_msg_limits
|
||||
{
|
||||
unsigned long flags,
|
||||
u_int64_t flags,
|
||||
msgpool, /* GLIBTOP_IPC_MSGPOOL */
|
||||
msgmap, /* GLIBTOP_IPC_MSGMAP */
|
||||
msgmax, /* GLIBTOP_IPC_MSGMAX */
|
||||
@@ -62,12 +62,14 @@ struct _glibtop_msg_limits
|
||||
extern void glibtop_get_msg_limits_l __P((glibtop *, glibtop_msg_limits *));
|
||||
|
||||
#if GLIBTOP_SUID_MSG_LIMITS
|
||||
extern void glibtop_init_msg_limits_p __P((glibtop *));
|
||||
extern void glibtop_get_msg_limits_p __P((glibtop *, glibtop_msg_limits *));
|
||||
#else
|
||||
extern void glibtop_init_msg_limits_s __P((glibtop *));
|
||||
extern void glibtop_get_msg_limits_s __P((glibtop *, glibtop_msg_limits *));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
#ifdef GLIBTOP_GUILE
|
||||
|
||||
/* You need to link with -lgtop_guile to get this stuff here. */
|
||||
|
||||
|
@@ -26,11 +26,34 @@
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define GLIBTOP_OPEN_NO_OVERRIDE 1
|
||||
#define _GLIBTOP_INIT_STATE_INIT 0x10000
|
||||
#define _GLIBTOP_INIT_STATE_OPEN 0x20000
|
||||
#define _GLIBTOP_INIT_STATE_SERVER 0x40000
|
||||
#define _GLIBTOP_INIT_STATE_SYSDEPS 0x80000
|
||||
|
||||
#define GLIBTOP_INIT_NO_OPEN 1
|
||||
#define GLIBTOP_INIT_NO_INIT 2
|
||||
|
||||
#define GLIBTOP_FEATURES_NO_SERVER 4
|
||||
#define GLIBTOP_FEATURES_EXCEPT 8
|
||||
|
||||
#define GLIBTOP_METHOD_DIRECT 1
|
||||
#define GLIBTOP_METHOD_PIPE 2
|
||||
#define GLIBTOP_METHOD_INET 3
|
||||
#define GLIBTOP_METHOD_UNIX 4
|
||||
|
||||
#define GLIBTOP_ERROR_METHOD_IGNORE 0
|
||||
#define GLIBTOP_ERROR_METHOD_WARN_ONCE 1
|
||||
#define GLIBTOP_ERROR_METHOD_WARN 2
|
||||
#define GLIBTOP_ERROR_METHOD_ABORT 3
|
||||
|
||||
#define GLIBTOP_ERROR_METHOD_DEFAULT GLIBTOP_ERROR_METHOD_WARN_ONCE
|
||||
|
||||
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));
|
||||
extern void glibtop_init_p __P((glibtop *, const unsigned long, const unsigned));
|
||||
extern void glibtop_open_p __P((glibtop *, const char *, const unsigned long, const unsigned));
|
||||
extern void glibtop_open_s __P((glibtop *, const char *, const unsigned long, const unsigned));
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
43
include/glibtop/parameter.h
Normal file
43
include/glibtop/parameter.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/* 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. */
|
||||
|
||||
#ifndef __GLIBTOP_PARAMETER_H__
|
||||
#define __GLIBTOP_PARAMETER_H__
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/open.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#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
|
||||
#define GLIBTOP_PARAM_ERROR_METHOD 6
|
||||
|
||||
#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)
|
||||
|
||||
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));
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
@@ -34,9 +34,10 @@ __BEGIN_DECLS
|
||||
#define GLIBTOP_PROC_KERNEL_CMAJ_FLT 4
|
||||
#define GLIBTOP_PROC_KERNEL_KSTK_ESP 5
|
||||
#define GLIBTOP_PROC_KERNEL_KSTK_EIP 6
|
||||
#define GLIBTOP_PROC_KERNEL_WCHAN 7
|
||||
#define GLIBTOP_PROC_KERNEL_NWCHAN 7
|
||||
#define GLIBTOP_PROC_KERNEL_WCHAN 8
|
||||
|
||||
#define GLIBTOP_MAX_PROC_KERNEL 8
|
||||
#define GLIBTOP_MAX_PROC_KERNEL 9
|
||||
|
||||
typedef struct _glibtop_proc_kernel glibtop_proc_kernel;
|
||||
|
||||
@@ -44,8 +45,8 @@ typedef struct _glibtop_proc_kernel glibtop_proc_kernel;
|
||||
|
||||
struct _glibtop_proc_kernel
|
||||
{
|
||||
unsigned long flags;
|
||||
unsigned long k_flags, /* kernel flags for the process */
|
||||
u_int64_t flags;
|
||||
u_int64_t k_flags, /* kernel flags for the process */
|
||||
min_flt, /* number of minor page faults since
|
||||
* process start */
|
||||
maj_flt, /* number of major page faults since
|
||||
@@ -56,8 +57,9 @@ struct _glibtop_proc_kernel
|
||||
* child processes */
|
||||
kstk_esp, /* kernel stack pointer */
|
||||
kstk_eip, /* kernel stack pointer */
|
||||
wchan; /* address of kernel wait channel
|
||||
nwchan; /* address of kernel wait channel
|
||||
* proc is sleeping in */
|
||||
char wchan [40];
|
||||
};
|
||||
|
||||
#define glibtop_get_proc_kernel(p1, p2) glibtop_get_proc_kernel_l(glibtop_global_server, p1, p2)
|
||||
@@ -71,12 +73,14 @@ struct _glibtop_proc_kernel
|
||||
extern void glibtop_get_proc_kernel_l __P((glibtop *, glibtop_proc_kernel *, pid_t));
|
||||
|
||||
#if GLIBTOP_SUID_PROC_KERNEL
|
||||
extern void glibtop_init_proc_kernel_p __P((glibtop *));
|
||||
extern void glibtop_get_proc_kernel_p __P((glibtop *, glibtop_proc_kernel *, pid_t));
|
||||
#else
|
||||
extern void glibtop_init_proc_kernel_s __P((glibtop *));
|
||||
extern void glibtop_get_proc_kernel_s __P((glibtop *, glibtop_proc_kernel *, pid_t));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
#ifdef GLIBTOP_GUILE
|
||||
|
||||
/* You need to link with -lgtop_guile to get this stuff here. */
|
||||
|
||||
|
@@ -33,17 +33,34 @@ __BEGIN_DECLS
|
||||
|
||||
#define GLIBTOP_MAX_PROCLIST 3
|
||||
|
||||
/* You can use the folowing constants as the `which' member of
|
||||
* glibtop_get_proclist () to specify which processes to fetch. */
|
||||
|
||||
#define GLIBTOP_KERN_PROC_ALL 0 /* all processes */
|
||||
#define GLIBTOP_KERN_PROC_PID 1
|
||||
#define GLIBTOP_KERN_PROC_PGRP 2
|
||||
#define GLIBTOP_KERN_PROC_SESSION 3
|
||||
#define GLIBTOP_KERN_PROC_TTY 4
|
||||
#define GLIBTOP_KERN_PROC_UID 5
|
||||
#define GLIBTOP_KERN_PROC_RUID 6
|
||||
|
||||
#define GLIBTOP_KERN_PROC_MASK 15
|
||||
|
||||
#define GLIBTOP_EXCLUDE_IDLE 0x1000
|
||||
#define GLIBTOP_EXCLUDE_SYSTEM 0x2000
|
||||
#define GLIBTOP_EXCLUDE_NOTTY 0x4000
|
||||
|
||||
typedef struct _glibtop_proclist glibtop_proclist;
|
||||
|
||||
struct _glibtop_proclist
|
||||
{
|
||||
unsigned long flags,
|
||||
u_int64_t flags,
|
||||
number, /* GLIBTOP_PROCLIST_NUMBER */
|
||||
total, /* GLIBTOP_PROCLIST_TOTAL */
|
||||
size; /* GLIBTOP_PROCLIST_SIZE */
|
||||
};
|
||||
|
||||
#define glibtop_get_proclist(proclist) glibtop_get_proclist_l(glibtop_global_server, proclist)
|
||||
#define glibtop_get_proclist(proclist,which,arg) glibtop_get_proclist_l(glibtop_global_server, proclist, which, arg)
|
||||
|
||||
#if GLIBTOP_SUID_PROCLIST
|
||||
#define glibtop_get_proclist_r glibtop_get_proclist_p
|
||||
@@ -51,19 +68,21 @@ struct _glibtop_proclist
|
||||
#define glibtop_get_proclist_r glibtop_get_proclist_s
|
||||
#endif
|
||||
|
||||
extern unsigned *glibtop_get_proclist_l __P((glibtop *, glibtop_proclist *));
|
||||
extern unsigned *glibtop_get_proclist_l __P((glibtop *, glibtop_proclist *, int64_t, int64_t));
|
||||
|
||||
#if GLIBTOP_SUID_PROCLIST
|
||||
extern unsigned *glibtop_get_proclist_p __P((glibtop *, glibtop_proclist *));
|
||||
extern void glibtop_init_proclist_p __P((glibtop *));
|
||||
extern unsigned *glibtop_get_proclist_p __P((glibtop *, glibtop_proclist *, int64_t, int64_t));
|
||||
#else
|
||||
extern unsigned *glibtop_get_proclist_s __P((glibtop *, glibtop_proclist *));
|
||||
extern void glibtop_init_proclist_s __P((glibtop *));
|
||||
extern unsigned *glibtop_get_proclist_s __P((glibtop *, glibtop_proclist *, int64_t, int64_t));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
#ifdef GLIBTOP_GUILE
|
||||
|
||||
/* You need to link with -lgtop_guile to get this stuff here. */
|
||||
|
||||
extern SCM glibtop_guile_get_proclist __P((void));
|
||||
extern SCM glibtop_guile_get_proclist __P((SCM, SCM));
|
||||
|
||||
#endif
|
||||
|
||||
|
122
include/glibtop/procmap.h
Normal file
122
include/glibtop/procmap.h
Normal file
@@ -0,0 +1,122 @@
|
||||
/* $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. */
|
||||
|
||||
#ifndef __GLIBTOP_PROC_MAP_H__
|
||||
#define __GLIBTOP_PROC_MAP_H__
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/global.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define GLIBTOP_PROC_MAP_NUMBER 0
|
||||
#define GLIBTOP_PROC_MAP_TOTAL 1
|
||||
#define GLIBTOP_PROC_MAP_SIZE 2
|
||||
|
||||
#define GLIBTOP_MAX_PROC_MAP 3
|
||||
|
||||
#define GLIBTOP_MAP_ENTRY_START 1
|
||||
#define GLIBTOP_MAP_ENTRY_END 2
|
||||
#define GLIBTOP_MAP_ENTRY_OFFSET 3
|
||||
#define GLIBTOP_MAP_ENTRY_PERM 4
|
||||
#define GLIBTOP_MAP_ENTRY_INODE 5
|
||||
#define GLIBTOP_MAP_ENTRY_DEVICE 6
|
||||
#define GLIBTOP_MAP_ENTRY_FILENAME 7
|
||||
|
||||
#define GLIBTOP_MAX_MAP_ENTRY 8
|
||||
|
||||
#define GLIBTOP_MAP_FILENAME_LEN 215
|
||||
|
||||
#define GLIBTOP_MAP_PERM_READ 1
|
||||
#define GLIBTOP_MAP_PERM_WRITE 2
|
||||
#define GLIBTOP_MAP_PERM_EXECUTE 4
|
||||
#define GLIBTOP_MAP_PERM_SHARED 8
|
||||
#define GLIBTOP_MAP_PERM_PRIVATE 16
|
||||
|
||||
typedef struct _glibtop_map_entry glibtop_map_entry;
|
||||
|
||||
typedef struct _glibtop_proc_map glibtop_proc_map;
|
||||
|
||||
struct _glibtop_map_entry
|
||||
{
|
||||
u_int64_t flags, start, end, offset, perm, inode, device;
|
||||
char filename [GLIBTOP_MAP_FILENAME_LEN+1];
|
||||
};
|
||||
|
||||
struct _glibtop_proc_map
|
||||
{
|
||||
u_int64_t flags,
|
||||
number, /* GLIBTOP_PROC_MAP_NUMBER */
|
||||
total, /* GLIBTOP_PROC_MAP_TOTAL */
|
||||
size; /* GLIBTOP_PROC_MAP_SIZE */
|
||||
};
|
||||
|
||||
#define glibtop_get_proc_map(proc_map,pid) glibtop_get_proc_map_l(glibtop_global_server, proc_map, pid)
|
||||
|
||||
#if GLIBTOP_SUID_PROC_MAP
|
||||
#define glibtop_get_proc_map_r glibtop_get_proc_map_p
|
||||
#else
|
||||
#define glibtop_get_proc_map_r glibtop_get_proc_map_s
|
||||
#endif
|
||||
|
||||
extern glibtop_map_entry *glibtop_get_proc_map_l __P((glibtop *, glibtop_proc_map *, pid_t));
|
||||
|
||||
#if GLIBTOP_SUID_PROC_MAP
|
||||
extern void glibtop_init_proc_map_p __P((glibtop *));
|
||||
extern glibtop_map_entry *glibtop_get_proc_map_p __P((glibtop *, glibtop_proc_map *, pid_t));
|
||||
#else
|
||||
extern void glibtop_init_proc_map_s __P((glibtop *));
|
||||
extern glibtop_map_entry *glibtop_get_proc_map_s __P((glibtop *, glibtop_proc_map *, pid_t));
|
||||
#endif
|
||||
|
||||
#ifdef GLIBTOP_GUILE
|
||||
|
||||
/* You need to link with -lgtop_guile to get this stuff here. */
|
||||
|
||||
extern SCM glibtop_guile_get_proc_map __P((SCM));
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef GLIBTOP_GUILE_NAMES
|
||||
|
||||
/* You need to link with -lgtop_guile_names to get this stuff here. */
|
||||
|
||||
extern SCM glibtop_guile_names_proc_map __P((void));
|
||||
extern SCM glibtop_guile_types_proc_map __P((void));
|
||||
extern SCM glibtop_guile_labels_proc_map __P((void));
|
||||
extern SCM glibtop_guile_descriptions_proc_map __P((void));
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef GLIBTOP_NAMES
|
||||
|
||||
/* You need to link with -lgtop_names to get this stuff here. */
|
||||
|
||||
extern const char *glibtop_names_proc_map [];
|
||||
extern const unsigned glibtop_types_proc_map [];
|
||||
extern const char *glibtop_labels_proc_map [];
|
||||
extern const char *glibtop_descriptions_proc_map [];
|
||||
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
@@ -42,8 +42,8 @@ typedef struct _glibtop_proc_mem glibtop_proc_mem;
|
||||
|
||||
struct _glibtop_proc_mem
|
||||
{
|
||||
unsigned long flags;
|
||||
long size, /* total # of pages of memory */
|
||||
u_int64_t flags,
|
||||
size, /* total # of pages of memory */
|
||||
vsize, /* number of pages of virtual memory ... */
|
||||
resident, /* number of resident set
|
||||
* (non-swapped) pages (4k) */
|
||||
@@ -64,12 +64,14 @@ struct _glibtop_proc_mem
|
||||
extern void glibtop_get_proc_mem_l __P((glibtop *, glibtop_proc_mem *, pid_t));
|
||||
|
||||
#if GLIBTOP_SUID_PROC_MEM
|
||||
extern void glibtop_init_proc_mem_p __P((glibtop *));
|
||||
extern void glibtop_get_proc_mem_p __P((glibtop *, glibtop_proc_mem *, pid_t));
|
||||
#else
|
||||
extern void glibtop_init_proc_mem_s __P((glibtop *));
|
||||
extern void glibtop_get_proc_mem_s __P((glibtop *, glibtop_proc_mem *, pid_t));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
#ifdef GLIBTOP_GUILE
|
||||
|
||||
/* You need to link with -lgtop_guile to get this stuff here. */
|
||||
|
||||
|
@@ -27,15 +27,16 @@
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define GLIBTOP_PROC_SEGMENT_TRS 0
|
||||
#define GLIBTOP_PROC_SEGMENT_LRS 1
|
||||
#define GLIBTOP_PROC_SEGMENT_DRS 2
|
||||
#define GLIBTOP_PROC_SEGMENT_DT 3
|
||||
#define GLIBTOP_PROC_SEGMENT_START_CODE 4
|
||||
#define GLIBTOP_PROC_SEGMENT_END_CODE 5
|
||||
#define GLIBTOP_PROC_SEGMENT_START_STACK 6
|
||||
#define GLIBTOP_PROC_SEGMENT_TEXT_RSS 0
|
||||
#define GLIBTOP_PROC_SEGMENT_SHLIB_RSS 1
|
||||
#define GLIBTOP_PROC_SEGMENT_DATA_RSS 2
|
||||
#define GLIBTOP_PROC_SEGMENT_STACK_RSS 3
|
||||
#define GLIBTOP_PROC_SEGMENT_DIRTY_SIZE 4
|
||||
#define GLIBTOP_PROC_SEGMENT_START_CODE 5
|
||||
#define GLIBTOP_PROC_SEGMENT_END_CODE 6
|
||||
#define GLIBTOP_PROC_SEGMENT_START_STACK 7
|
||||
|
||||
#define GLIBTOP_MAX_PROC_SEGMENT 7
|
||||
#define GLIBTOP_MAX_PROC_SEGMENT 8
|
||||
|
||||
typedef struct _glibtop_proc_segment glibtop_proc_segment;
|
||||
|
||||
@@ -43,12 +44,13 @@ typedef struct _glibtop_proc_segment glibtop_proc_segment;
|
||||
|
||||
struct _glibtop_proc_segment
|
||||
{
|
||||
unsigned long flags;
|
||||
long trs, /* text resident set size */
|
||||
lrs, /* shared-lib resident set size */
|
||||
drs, /* data resident set size */
|
||||
dt; /* dirty pages */
|
||||
unsigned long start_code,
|
||||
u_int64_t flags,
|
||||
text_rss, /* text resident set size */
|
||||
shlib_rss, /* shared-lib resident set size */
|
||||
data_rss, /* data resident set size */
|
||||
stack_rss, /* stack resident set size */
|
||||
dirty_size, /* size of dirty pages */
|
||||
start_code,
|
||||
/* address of beginning of code segment */
|
||||
end_code, /* address of end of code segment */
|
||||
start_stack; /* address of the bottom of stack segment */
|
||||
@@ -65,12 +67,14 @@ struct _glibtop_proc_segment
|
||||
extern void glibtop_get_proc_segment_l __P((glibtop *, glibtop_proc_segment *, pid_t));
|
||||
|
||||
#if GLIBTOP_SUID_PROC_SEGMENT
|
||||
extern void glibtop_init_proc_segment_p __P((glibtop *));
|
||||
extern void glibtop_get_proc_segment_p __P((glibtop *, glibtop_proc_segment *, pid_t));
|
||||
#else
|
||||
extern void glibtop_init_proc_segment_s __P((glibtop *));
|
||||
extern void glibtop_get_proc_segment_s __P((glibtop *, glibtop_proc_segment *, pid_t));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
#ifdef GLIBTOP_GUILE
|
||||
|
||||
/* You need to link with -lgtop_guile to get this stuff here. */
|
||||
|
||||
|
@@ -40,11 +40,11 @@ typedef struct _glibtop_proc_signal glibtop_proc_signal;
|
||||
|
||||
struct _glibtop_proc_signal
|
||||
{
|
||||
unsigned long flags;
|
||||
int signal, /* mask of pending signals */
|
||||
blocked, /* mask of blocked signals */
|
||||
sigignore, /* mask of ignored signals */
|
||||
sigcatch; /* mask of caught signals */
|
||||
u_int64_t flags,
|
||||
signal, /* mask of pending signals */
|
||||
blocked, /* mask of blocked signals */
|
||||
sigignore, /* mask of ignored signals */
|
||||
sigcatch; /* mask of caught signals */
|
||||
};
|
||||
|
||||
#define glibtop_get_proc_signal(p1, p2) glibtop_get_proc_signal_l(glibtop_global_server, p1, p2)
|
||||
@@ -58,12 +58,14 @@ struct _glibtop_proc_signal
|
||||
extern void glibtop_get_proc_signal_l __P((glibtop *, glibtop_proc_signal *, pid_t));
|
||||
|
||||
#if GLIBTOP_SUID_PROC_SIGNAL
|
||||
extern void glibtop_init_proc_signal_p __P((glibtop *));
|
||||
extern void glibtop_get_proc_signal_p __P((glibtop *, glibtop_proc_signal *, pid_t));
|
||||
#else
|
||||
extern void glibtop_init_proc_signal_s __P((glibtop *));
|
||||
extern void glibtop_get_proc_signal_s __P((glibtop *, glibtop_proc_signal *, pid_t));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
#ifdef GLIBTOP_GUILE
|
||||
|
||||
/* You need to link with -lgtop_guile to get this stuff here. */
|
||||
|
||||
|
@@ -40,7 +40,7 @@ typedef struct _glibtop_proc_state glibtop_proc_state;
|
||||
|
||||
struct _glibtop_proc_state
|
||||
{
|
||||
unsigned long flags;
|
||||
u_int64_t flags;
|
||||
char cmd[40], /* basename of executable file in
|
||||
* call to exec(2) */
|
||||
state; /* single-char code for process state
|
||||
@@ -65,12 +65,14 @@ struct _glibtop_proc_state
|
||||
extern void glibtop_get_proc_state_l __P((glibtop *, glibtop_proc_state *, pid_t));
|
||||
|
||||
#if GLIBTOP_SUID_PROC_STATE
|
||||
extern void glibtop_init_proc_state_p __P((glibtop *));
|
||||
extern void glibtop_get_proc_state_p __P((glibtop *, glibtop_proc_state *, pid_t));
|
||||
#else
|
||||
extern void glibtop_init_proc_state_s __P((glibtop *));
|
||||
extern void glibtop_get_proc_state_s __P((glibtop *, glibtop_proc_state *, pid_t));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
#ifdef GLIBTOP_GUILE
|
||||
|
||||
/* You need to link with -lgtop_guile to get this stuff here. */
|
||||
|
||||
|
@@ -28,14 +28,16 @@
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define GLIBTOP_PROC_TIME_START_TIME 0
|
||||
#define GLIBTOP_PROC_TIME_UTIME 1
|
||||
#define GLIBTOP_PROC_TIME_STIME 2
|
||||
#define GLIBTOP_PROC_TIME_CUTIME 3
|
||||
#define GLIBTOP_PROC_TIME_CSTIME 4
|
||||
#define GLIBTOP_PROC_TIME_TIMEOUT 5
|
||||
#define GLIBTOP_PROC_TIME_IT_REAL_VALUE 6
|
||||
#define GLIBTOP_PROC_TIME_RTIME 1
|
||||
#define GLIBTOP_PROC_TIME_UTIME 2
|
||||
#define GLIBTOP_PROC_TIME_STIME 3
|
||||
#define GLIBTOP_PROC_TIME_CUTIME 4
|
||||
#define GLIBTOP_PROC_TIME_CSTIME 5
|
||||
#define GLIBTOP_PROC_TIME_TIMEOUT 6
|
||||
#define GLIBTOP_PROC_TIME_IT_REAL_VALUE 7
|
||||
#define GLIBTOP_PROC_TIME_FREQUENCY 8
|
||||
|
||||
#define GLIBTOP_MAX_PROC_TIME 7
|
||||
#define GLIBTOP_MAX_PROC_TIME 9
|
||||
|
||||
typedef struct _glibtop_proc_time glibtop_proc_time;
|
||||
|
||||
@@ -43,9 +45,10 @@ typedef struct _glibtop_proc_time glibtop_proc_time;
|
||||
|
||||
struct _glibtop_proc_time
|
||||
{
|
||||
unsigned long flags;
|
||||
long start_time, /* start time of process --
|
||||
u_int64_t flags,
|
||||
start_time, /* start time of process --
|
||||
* seconds since 1-1-70 */
|
||||
rtime, /* real time accumulated by process */
|
||||
utime, /* user-mode CPU time accumulated by process */
|
||||
stime, /* kernel-mode CPU time accumulated by process */
|
||||
cutime, /* cumulative utime of process and
|
||||
@@ -54,9 +57,10 @@ struct _glibtop_proc_time
|
||||
* reaped children */
|
||||
timeout, /* The time (in jiffies) of the process's
|
||||
* next timeout */
|
||||
it_real_value; /* The time (in jiffies) before the
|
||||
it_real_value, /* The time (in jiffies) before the
|
||||
* next SIGALRM is sent to the process
|
||||
* due to an interval timer. */
|
||||
frequency; /* Tick frequency. */
|
||||
};
|
||||
|
||||
#define glibtop_get_proc_time(p1, p2) glibtop_get_proc_time_l(glibtop_global_server, p1, p2)
|
||||
@@ -70,12 +74,14 @@ struct _glibtop_proc_time
|
||||
extern void glibtop_get_proc_time_l __P((glibtop *, glibtop_proc_time *, pid_t));
|
||||
|
||||
#if GLIBTOP_SUID_PROC_TIME
|
||||
extern void glibtop_init_proc_time_p __P((glibtop *));
|
||||
extern void glibtop_get_proc_time_p __P((glibtop *, glibtop_proc_time *, pid_t));
|
||||
#else
|
||||
extern void glibtop_init_proc_time_s __P((glibtop *));
|
||||
extern void glibtop_get_proc_time_s __P((glibtop *, glibtop_proc_time *, pid_t));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
#ifdef GLIBTOP_GUILE
|
||||
|
||||
/* You need to link with -lgtop_guile to get this stuff here. */
|
||||
|
||||
|
@@ -48,7 +48,7 @@ typedef struct _glibtop_proc_uid glibtop_proc_uid;
|
||||
|
||||
struct _glibtop_proc_uid
|
||||
{
|
||||
unsigned long flags;
|
||||
u_int64_t flags;
|
||||
int uid, /* user id */
|
||||
euid, /* effective user id */
|
||||
gid, /* group id */
|
||||
@@ -74,12 +74,14 @@ struct _glibtop_proc_uid
|
||||
extern void glibtop_get_proc_uid_l __P((glibtop *, glibtop_proc_uid *, pid_t));
|
||||
|
||||
#if GLIBTOP_SUID_PROC_UID
|
||||
extern void glibtop_init_proc_uid_p __P((glibtop *));
|
||||
extern void glibtop_get_proc_uid_p __P((glibtop *, glibtop_proc_uid *, pid_t));
|
||||
#else
|
||||
extern void glibtop_init_proc_uid_s __P((glibtop *));
|
||||
extern void glibtop_get_proc_uid_s __P((glibtop *, glibtop_proc_uid *, pid_t));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
#ifdef GLIBTOP_GUILE
|
||||
|
||||
/* You need to link with -lgtop_guile to get this stuff here. */
|
||||
|
||||
|
@@ -44,7 +44,7 @@ typedef struct _glibtop_sem_limits glibtop_sem_limits;
|
||||
|
||||
struct _glibtop_sem_limits
|
||||
{
|
||||
unsigned long flags,
|
||||
u_int64_t flags,
|
||||
semmap, /* GLIBTOP_IPC_SEMMAP */
|
||||
semmni, /* GLIBTOP_IPC_SEMMNI */
|
||||
semmns, /* GLIBTOP_IPC_SEMMNS */
|
||||
@@ -68,12 +68,14 @@ struct _glibtop_sem_limits
|
||||
extern void glibtop_get_sem_limits_l __P((glibtop *, glibtop_sem_limits *));
|
||||
|
||||
#if GLIBTOP_SUID_SEM_LIMITS
|
||||
extern void glibtop_init_sem_limits_p __P((glibtop *));
|
||||
extern void glibtop_get_sem_limits_p __P((glibtop *, glibtop_sem_limits *));
|
||||
#else
|
||||
extern void glibtop_init_sem_limits_s __P((glibtop *));
|
||||
extern void glibtop_get_sem_limits_s __P((glibtop *, glibtop_sem_limits *));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
#ifdef GLIBTOP_GUILE
|
||||
|
||||
/* You need to link with -lgtop_guile to get this stuff here. */
|
||||
|
||||
|
@@ -39,7 +39,7 @@ typedef struct _glibtop_shm_limits glibtop_shm_limits;
|
||||
|
||||
struct _glibtop_shm_limits
|
||||
{
|
||||
unsigned long flags,
|
||||
u_int64_t flags,
|
||||
shmmax, /* GLIBTOP_IPC_SHMMAX */
|
||||
shmmin, /* GLIBTOP_IPC_SHMMIN */
|
||||
shmmni, /* GLIBTOP_IPC_SHMMNI */
|
||||
@@ -58,12 +58,14 @@ struct _glibtop_shm_limits
|
||||
extern void glibtop_get_shm_limits_l __P((glibtop *, glibtop_shm_limits *));
|
||||
|
||||
#if GLIBTOP_SUID_SHM_LIMITS
|
||||
extern void glibtop_init_shm_limits_p __P((glibtop *));
|
||||
extern void glibtop_get_shm_limits_p __P((glibtop *, glibtop_shm_limits *));
|
||||
#else
|
||||
extern void glibtop_init_shm_limits_s __P((glibtop *));
|
||||
extern void glibtop_get_shm_limits_s __P((glibtop *, glibtop_shm_limits *));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
#ifdef GLIBTOP_GUILE
|
||||
|
||||
/* You need to link with -lgtop_guile to get this stuff here. */
|
||||
|
||||
|
45
include/glibtop/signal.h
Normal file
45
include/glibtop/signal.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/* $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. */
|
||||
|
||||
#ifndef __GLIBTOP_SIGNAL_H__
|
||||
#define __GLIBTOP_SIGNAL_H__
|
||||
|
||||
#include <glibtop.h>
|
||||
|
||||
#ifdef HAVE_SYS_SIGNAL_H
|
||||
#include <sys/signal.h>
|
||||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
typedef struct _glibtop_signame glibtop_signame;
|
||||
|
||||
struct _glibtop_signame
|
||||
{
|
||||
const int number;
|
||||
const char *name, *label;
|
||||
};
|
||||
|
||||
extern const glibtop_signame glibtop_sys_siglist [];
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
@@ -30,17 +30,21 @@ __BEGIN_DECLS
|
||||
#define GLIBTOP_SWAP_TOTAL 0
|
||||
#define GLIBTOP_SWAP_USED 1
|
||||
#define GLIBTOP_SWAP_FREE 2
|
||||
#define GLIBTOP_SWAP_PAGEIN 3
|
||||
#define GLIBTOP_SWAP_PAGEOUT 4
|
||||
|
||||
#define GLIBTOP_MAX_SWAP 3
|
||||
#define GLIBTOP_MAX_SWAP 5
|
||||
|
||||
typedef struct _glibtop_swap glibtop_swap;
|
||||
|
||||
struct _glibtop_swap
|
||||
{
|
||||
unsigned long flags,
|
||||
u_int64_t flags,
|
||||
total, /* GLIBTOP_SWAP_TOTAL */
|
||||
used, /* GLIBTOP_SWAP_USED */
|
||||
free; /* GLIBTOP_SWAP_FREE */
|
||||
free, /* GLIBTOP_SWAP_FREE */
|
||||
pagein, /* GLIBTOP_SWAP_PAGEIN */
|
||||
pageout; /* GLIBTOP_SWAP_PAGEOUT */
|
||||
};
|
||||
|
||||
#define glibtop_get_swap(swap) glibtop_get_swap_l(glibtop_global_server, swap)
|
||||
@@ -54,12 +58,14 @@ struct _glibtop_swap
|
||||
extern void glibtop_get_swap_l __P((glibtop *, glibtop_swap *));
|
||||
|
||||
#if GLIBTOP_SUID_SWAP
|
||||
extern void glibtop_init_swap_p __P((glibtop *));
|
||||
extern void glibtop_get_swap_p __P((glibtop *, glibtop_swap *));
|
||||
#else
|
||||
extern void glibtop_init_swap_s __P((glibtop *));
|
||||
extern void glibtop_get_swap_s __P((glibtop *, glibtop_swap *));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
#ifdef GLIBTOP_GUILE
|
||||
|
||||
/* You need to link with -lgtop_guile to get this stuff here. */
|
||||
|
||||
|
@@ -23,7 +23,6 @@
|
||||
#define __GLIBTOP_SYSDEPS_H__
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/union.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
@@ -44,16 +43,23 @@ __BEGIN_DECLS
|
||||
#define GLIBTOP_SYSDEPS_PROC_SIGNAL 14
|
||||
#define GLIBTOP_SYSDEPS_PROC_KERNEL 15
|
||||
#define GLIBTOP_SYSDEPS_PROC_SEGMENT 16
|
||||
#define GLIBTOP_SYSDEPS_PROC_MAP 17
|
||||
#define GLIBTOP_SYSDEPS_MOUNTLIST 18
|
||||
#define GLIBTOP_SYSDEPS_FSUSAGE 19
|
||||
|
||||
#define GLIBTOP_MAX_SYSDEPS 17
|
||||
#define GLIBTOP_MAX_SYSDEPS 20
|
||||
|
||||
#define GLIBTOP_SYSDEPS_ALL ((1 << GLIBTOP_MAX_SYSDEPS) - 1)
|
||||
|
||||
typedef void (*glibtop_init_func_t) (glibtop *);
|
||||
extern glibtop_init_func_t _glibtop_init_hook_s [];
|
||||
extern glibtop_init_func_t _glibtop_init_hook_p [];
|
||||
|
||||
typedef struct _glibtop_sysdeps glibtop_sysdeps;
|
||||
|
||||
struct _glibtop_sysdeps
|
||||
{
|
||||
unsigned long flags,
|
||||
u_int64_t flags,
|
||||
features, /* server features */
|
||||
cpu, /* glibtop_cpu */
|
||||
mem, /* glibtop_mem */
|
||||
@@ -70,14 +76,17 @@ struct _glibtop_sysdeps
|
||||
proc_time, /* glibtop_proc_time */
|
||||
proc_signal, /* glibtop_proc_signal */
|
||||
proc_kernel, /* glibtop_proc_kernel */
|
||||
proc_segment; /* glibtop_proc_segment */
|
||||
proc_segment, /* glibtop_proc_segment */
|
||||
proc_map, /* glibtop_proc_map */
|
||||
mountlist, /* glibtop_mountlist */
|
||||
fsusage; /* glibtop_fsusage */
|
||||
};
|
||||
|
||||
#define glibtop_get_sysdeps(sysdeps) glibtop_get_sysdeps_r(glibtop_global_server,sysdeps)
|
||||
|
||||
extern void glibtop_get_sysdeps_r __P((glibtop *, glibtop_sysdeps *));
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
#ifdef GLIBTOP_GUILE
|
||||
|
||||
/* You need to link with -lgtop_guile to get this stuff here. */
|
||||
|
||||
|
@@ -39,6 +39,10 @@
|
||||
#include <glibtop/procsignal.h>
|
||||
#include <glibtop/prockernel.h>
|
||||
#include <glibtop/procsegment.h>
|
||||
#include <glibtop/procmap.h>
|
||||
|
||||
#include <glibtop/mountlist.h>
|
||||
#include <glibtop/fsusage.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
@@ -62,6 +66,9 @@ union _glibtop_union
|
||||
glibtop_proc_signal proc_signal;
|
||||
glibtop_proc_kernel proc_kernel;
|
||||
glibtop_proc_segment proc_segment;
|
||||
glibtop_proc_map proc_map;
|
||||
glibtop_mountlist mountlist;
|
||||
glibtop_fsusage fsusage;
|
||||
};
|
||||
|
||||
__END_DECLS
|
||||
|
@@ -36,7 +36,7 @@ typedef struct _glibtop_uptime glibtop_uptime;
|
||||
|
||||
struct _glibtop_uptime
|
||||
{
|
||||
unsigned long flags;
|
||||
u_int64_t flags;
|
||||
double uptime, /* GLIBTOP_UPTIME_UPTIME */
|
||||
idletime; /* GLIBTOP_UPTIME_IDLETIME */
|
||||
};
|
||||
@@ -52,12 +52,14 @@ struct _glibtop_uptime
|
||||
extern void glibtop_get_uptime_l __P((glibtop *, glibtop_uptime *));
|
||||
|
||||
#if GLIBTOP_SUID_UPTIME
|
||||
extern void glibtop_init_uptime_p __P((glibtop *));
|
||||
extern void glibtop_get_uptime_p __P((glibtop *, glibtop_uptime *));
|
||||
#else
|
||||
extern void glibtop_init_uptime_s __P((glibtop *));
|
||||
extern void glibtop_get_uptime_s __P((glibtop *, glibtop_uptime *));
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GUILE
|
||||
#ifdef GLIBTOP_GUILE
|
||||
|
||||
/* You need to link with -lgtop_guile to get this stuff here. */
|
||||
|
||||
|
@@ -20,11 +20,20 @@
|
||||
#ifndef __GLIBTOP_VERSION_H__
|
||||
#define __GLIBTOP_VERSION_H__
|
||||
|
||||
#include <glibtop/output.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/union.h>
|
||||
#include <glibtop/sysdeps.h>
|
||||
#include <glibtop/command.h>
|
||||
|
||||
#define LIBGTOP_VERSION_STRING "Libgtop %s server version %s (%u,%u,%u,%u)."
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
extern void glibtop_version __P((void));
|
||||
#if _IN_LIBGTOP
|
||||
|
||||
extern void glibtop_send_version __P((glibtop *, int));
|
||||
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
@@ -30,11 +30,13 @@ __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_strdup(p1) 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 char *glibtop_strdup_r __P((glibtop *, const char *));
|
||||
extern void glibtop_free_r __P((glibtop *, void *));
|
||||
|
||||
__END_DECLS
|
||||
|
@@ -1,3 +1,11 @@
|
||||
1998-07-21 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* table20: New directory for 2.0.xx kernels.
|
||||
|
||||
* table21: New directory for 2.1.xx kernels.
|
||||
|
||||
* *: Moved into `table20' and `table21'.
|
||||
|
||||
1998-06-14 Martin Baulig <baulig@taurus.uni-trier.de>
|
||||
|
||||
* README: Added README.
|
||||
|
@@ -3,21 +3,38 @@
|
||||
|
||||
#ifdef _KERNEL
|
||||
#include <linux/types.h>
|
||||
#else
|
||||
#define NR_TASKS 512
|
||||
#endif
|
||||
|
||||
#define TABLE_KERN_PROC_ALL 0 /* all processes */
|
||||
#define TABLE_KERN_PROC_PID 1
|
||||
#define TABLE_KERN_PROC_PGRP 2
|
||||
#define TABLE_KERN_PROC_SESSION 3
|
||||
#define TABLE_KERN_PROC_TTY 4
|
||||
#define TABLE_KERN_PROC_UID 5
|
||||
#define TABLE_KERN_PROC_RUID 6
|
||||
|
||||
#define TABLE_KERN_PROC_MASK 15
|
||||
|
||||
#define TABLE_EXCLUDE_IDLE 0x1000
|
||||
#define TABLE_EXCLUDE_SYSTEM 0x2000
|
||||
#define TABLE_EXCLUDE_NOTTY 0x4000
|
||||
|
||||
#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
|
||||
#define TABLE_PROCLIST 6
|
||||
#define TABLE_PROC_UID 7
|
||||
#define TABLE_PROC_MEM 8
|
||||
#define TABLE_PROC_SEGMENT 9
|
||||
#define TABLE_PROC_TIME 10
|
||||
#define TABLE_PROC_STATE 11
|
||||
#define TABLE_PROC_SIGNAL 12
|
||||
#define TABLE_PROC_KERNEL 13
|
||||
|
||||
/* CPU Usage (in jiffies = 1/100th seconds) */
|
||||
|
||||
@@ -50,6 +67,8 @@ struct table_swap
|
||||
unsigned long total; /* Total swap space */
|
||||
unsigned long used; /* Used swap space */
|
||||
unsigned long free; /* Free swap space */
|
||||
unsigned long pagein; /* Total # of pages swapped in */
|
||||
unsigned long pageout; /* Total # of pages swapped out */
|
||||
};
|
||||
|
||||
/* Load average */
|
||||
@@ -70,6 +89,19 @@ struct table_uptime
|
||||
unsigned long idle;
|
||||
};
|
||||
|
||||
/* Process list. */
|
||||
|
||||
struct proclist_args
|
||||
{
|
||||
int which, arg;
|
||||
};
|
||||
|
||||
struct table_proclist
|
||||
{
|
||||
int nr_running, nr_tasks, last_pid;
|
||||
unsigned pids [NR_TASKS];
|
||||
};
|
||||
|
||||
/* Information about processes. */
|
||||
|
||||
struct table_proc_state
|
||||
@@ -77,6 +109,7 @@ struct table_proc_state
|
||||
long state;
|
||||
unsigned long flags;
|
||||
char comm[16];
|
||||
int uid, gid;
|
||||
};
|
||||
|
||||
struct table_proc_uid
|
||||
@@ -104,8 +137,8 @@ struct table_proc_mem
|
||||
struct table_proc_segment
|
||||
{
|
||||
unsigned long vsize;
|
||||
int size, resident, shared;
|
||||
int trs, lrs, drs, dt;
|
||||
unsigned long size, resident, shared;
|
||||
unsigned long trs, lrs, drs, srs, dt;
|
||||
};
|
||||
|
||||
struct table_proc_time
|
||||
@@ -118,10 +151,10 @@ struct table_proc_time
|
||||
|
||||
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 */
|
||||
unsigned long long signal,
|
||||
blocked, /* bitmap of masked signals */
|
||||
ignored, /* mask of ignored signals */
|
||||
caught; /* mask of caught signals */
|
||||
};
|
||||
|
||||
struct table_proc_kernel
|
||||
@@ -140,6 +173,7 @@ union table
|
||||
struct table_swap swap;
|
||||
struct table_loadavg loadavg;
|
||||
struct table_uptime uptime;
|
||||
struct table_proclist proclist;
|
||||
struct table_proc_uid proc_uid;
|
||||
struct table_proc_mem proc_mem;
|
||||
struct table_proc_segment proc_segment;
|
||||
|
706
kernel/table20/entry-i386.S
Normal file
706
kernel/table20/entry-i386.S
Normal file
@@ -0,0 +1,706 @@
|
||||
/*
|
||||
* linux/arch/i386/entry.S
|
||||
*
|
||||
* Copyright (C) 1991, 1992 Linus Torvalds
|
||||
*/
|
||||
|
||||
/*
|
||||
* entry.S contains the system-call and fault low-level handling routines.
|
||||
* This also contains the timer-interrupt handler, as well as all interrupts
|
||||
* and faults that can result in a task-switch.
|
||||
*
|
||||
* NOTE: This code handles signal-recognition, which happens every time
|
||||
* after a timer-interrupt and after each system call.
|
||||
*
|
||||
* I changed all the .align's to 4 (16 byte alignment), as that's faster
|
||||
* on a 486.
|
||||
*
|
||||
* Stack layout in 'ret_from_system_call':
|
||||
* ptrace needs to have all regs on the stack.
|
||||
* if the order here is changed, it needs to be
|
||||
* updated in fork.c:copy_process, signal.c:do_signal,
|
||||
* ptrace.c and ptrace.h
|
||||
*
|
||||
* 0(%esp) - %ebx
|
||||
* 4(%esp) - %ecx
|
||||
* 8(%esp) - %edx
|
||||
* C(%esp) - %esi
|
||||
* 10(%esp) - %edi
|
||||
* 14(%esp) - %ebp
|
||||
* 18(%esp) - %eax
|
||||
* 1C(%esp) - %ds
|
||||
* 20(%esp) - %es
|
||||
* 24(%esp) - %fs
|
||||
* 28(%esp) - %gs
|
||||
* 2C(%esp) - orig_eax
|
||||
* 30(%esp) - %eip
|
||||
* 34(%esp) - %cs
|
||||
* 38(%esp) - %eflags
|
||||
* 3C(%esp) - %oldesp
|
||||
* 40(%esp) - %oldss
|
||||
*/
|
||||
|
||||
#include <linux/sys.h>
|
||||
#include <linux/linkage.h>
|
||||
#include <asm/segment.h>
|
||||
#define ASSEMBLY
|
||||
#include <asm/smp.h>
|
||||
|
||||
EBX = 0x00
|
||||
ECX = 0x04
|
||||
EDX = 0x08
|
||||
ESI = 0x0C
|
||||
EDI = 0x10
|
||||
EBP = 0x14
|
||||
EAX = 0x18
|
||||
DS = 0x1C
|
||||
ES = 0x20
|
||||
FS = 0x24
|
||||
GS = 0x28
|
||||
ORIG_EAX = 0x2C
|
||||
EIP = 0x30
|
||||
CS = 0x34
|
||||
EFLAGS = 0x38
|
||||
OLDESP = 0x3C
|
||||
OLDSS = 0x40
|
||||
|
||||
CF_MASK = 0x00000001
|
||||
IF_MASK = 0x00000200
|
||||
NT_MASK = 0x00004000
|
||||
VM_MASK = 0x00020000
|
||||
|
||||
/*
|
||||
* these are offsets into the task-struct.
|
||||
*/
|
||||
state = 0
|
||||
counter = 4
|
||||
priority = 8
|
||||
signal = 12
|
||||
blocked = 16
|
||||
flags = 20
|
||||
dbgreg6 = 52
|
||||
dbgreg7 = 56
|
||||
exec_domain = 60
|
||||
|
||||
ENOSYS = 38
|
||||
|
||||
#define SAVE_ALL \
|
||||
cld; \
|
||||
push %gs; \
|
||||
push %fs; \
|
||||
push %es; \
|
||||
push %ds; \
|
||||
pushl %eax; \
|
||||
pushl %ebp; \
|
||||
pushl %edi; \
|
||||
pushl %esi; \
|
||||
pushl %edx; \
|
||||
pushl %ecx; \
|
||||
pushl %ebx; \
|
||||
movl $(KERNEL_DS),%edx; \
|
||||
mov %dx,%ds; \
|
||||
mov %dx,%es; \
|
||||
movl $(USER_DS),%edx; \
|
||||
mov %dx,%fs;
|
||||
|
||||
#ifdef __SMP__
|
||||
|
||||
#define GET_PROCESSOR_ID \
|
||||
movl SYMBOL_NAME(apic_reg), %edx; \
|
||||
movl 32(%edx), %eax;\
|
||||
movl %eax,SYMBOL_NAME(apic_retval); \
|
||||
shrl $24,%eax; \
|
||||
andb $0x0F,%al;
|
||||
|
||||
/*
|
||||
* Get the processor ID multiplied by 4
|
||||
*/
|
||||
|
||||
#define GET_PROCESSOR_OFFSET(x) \
|
||||
movl SYMBOL_NAME(apic_reg), x ; \
|
||||
movl 32( x ), x ; \
|
||||
shrl $22, x ; \
|
||||
andl $0x3C, x ;
|
||||
|
||||
/* macro LEAVE_KERNEL decrements kernel_counter and resets kernel_flag and
|
||||
saves processor variables if zero */
|
||||
#define LEAVE_KERNEL \
|
||||
pushfl; \
|
||||
cli; \
|
||||
GET_PROCESSOR_ID \
|
||||
btrl $ SMP_FROM_SYSCALL,SYMBOL_NAME(smp_proc_in_lock)(,%eax,4); \
|
||||
decl SYMBOL_NAME(syscall_count); \
|
||||
decl SYMBOL_NAME(kernel_counter); \
|
||||
jnz 1f; \
|
||||
movb SYMBOL_NAME(saved_active_kernel_processor), %al; \
|
||||
movb %al, SYMBOL_NAME(active_kernel_processor); \
|
||||
cmpb $(NO_PROC_ID), %al; \
|
||||
jnz 1f; \
|
||||
lock; \
|
||||
btrl $0, SYMBOL_NAME(kernel_flag); \
|
||||
1: popfl;
|
||||
|
||||
/* macro ENTER_KERNEL waits for entering the kernel, increments
|
||||
kernel_counter, and reloads the processor variables if necessary
|
||||
uses : %eax, %edx (pushed and popped)
|
||||
|
||||
Note: We go to great pains to minimise the number of locked operations.
|
||||
We want to spin without locking, and lock when we attempt an update.
|
||||
The pentium has a MESI cache so the spin without lock will exit when
|
||||
another CPU write invalidates our cache, and the lock is avoided when
|
||||
possible so we don't play ping-pong games with the cache line.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __SMP_PROF__
|
||||
|
||||
#define SMP_PROF_A
|
||||
#define SMP_PROF_B
|
||||
|
||||
#else
|
||||
|
||||
#define SMP_PROF_A movl $0,SYMBOL_NAME(smp_spins_syscall_cur)(,%eax,4);
|
||||
#define SMP_PROF_B incl SYMBOL_NAME(smp_spins_syscall)(,%eax,4); \
|
||||
incl SYMBOL_NAME(smp_spins_syscall_cur)(,%eax,4);
|
||||
#endif
|
||||
|
||||
#define ENTER_KERNEL \
|
||||
pushl %eax; \
|
||||
pushl %ebx; \
|
||||
pushl %ecx; \
|
||||
pushl %edx; \
|
||||
pushfl; \
|
||||
cli; \
|
||||
movl $6000, %ebx; \
|
||||
movl SYMBOL_NAME(smp_loops_per_tick), %ecx; \
|
||||
GET_PROCESSOR_ID \
|
||||
btsl $ SMP_FROM_SYSCALL,SYMBOL_NAME(smp_proc_in_lock)(,%eax,4); \
|
||||
SMP_PROF_A \
|
||||
1: lock; \
|
||||
btsl $0, SYMBOL_NAME(kernel_flag); \
|
||||
jnc 3f; \
|
||||
cmpb SYMBOL_NAME(active_kernel_processor), %al; \
|
||||
je 4f; \
|
||||
2: SMP_PROF_B \
|
||||
btl %eax, SYMBOL_NAME(smp_invalidate_needed); \
|
||||
jnc 5f; \
|
||||
lock; \
|
||||
btrl %eax, SYMBOL_NAME(smp_invalidate_needed); \
|
||||
jnc 5f; \
|
||||
movl %cr3,%edx; \
|
||||
movl %edx,%cr3; \
|
||||
5: sti; \
|
||||
decl %ecx; \
|
||||
cli; \
|
||||
jne 7f; \
|
||||
decl %ebx; \
|
||||
jne 6f; \
|
||||
call SYMBOL_NAME(non_irq_deadlock_detected); \
|
||||
6: movl SYMBOL_NAME(smp_loops_per_tick), %ecx; \
|
||||
cmpb SYMBOL_NAME(boot_cpu_id), %al; \
|
||||
jne 7f; \
|
||||
incl SYMBOL_NAME(jiffies); \
|
||||
7: btl $0, SYMBOL_NAME(kernel_flag); \
|
||||
jc 2b; \
|
||||
jmp 1b; \
|
||||
3: movb %al, SYMBOL_NAME(active_kernel_processor); \
|
||||
4: incl SYMBOL_NAME(kernel_counter); \
|
||||
incl SYMBOL_NAME(syscall_count); \
|
||||
popfl; \
|
||||
popl %edx; \
|
||||
popl %ecx; \
|
||||
popl %ebx; \
|
||||
popl %eax;
|
||||
|
||||
|
||||
#define RESTORE_ALL \
|
||||
cmpw $(KERNEL_CS),CS(%esp); \
|
||||
je 1f; \
|
||||
GET_PROCESSOR_OFFSET(%edx) \
|
||||
movl SYMBOL_NAME(current_set)(,%edx), %eax ; ; \
|
||||
movl dbgreg7(%eax),%ebx; \
|
||||
movl %ebx,%db7; \
|
||||
1: LEAVE_KERNEL \
|
||||
popl %ebx; \
|
||||
popl %ecx; \
|
||||
popl %edx; \
|
||||
popl %esi; \
|
||||
popl %edi; \
|
||||
popl %ebp; \
|
||||
popl %eax; \
|
||||
pop %ds; \
|
||||
pop %es; \
|
||||
pop %fs; \
|
||||
pop %gs; \
|
||||
addl $4,%esp; \
|
||||
iret
|
||||
|
||||
#else
|
||||
|
||||
#define RESTORE_ALL \
|
||||
cmpw $(KERNEL_CS),CS(%esp); \
|
||||
je 1f; \
|
||||
movl SYMBOL_NAME(current_set),%eax; \
|
||||
movl dbgreg7(%eax),%ebx; \
|
||||
movl %ebx,%db7; \
|
||||
1: \
|
||||
popl %ebx; \
|
||||
popl %ecx; \
|
||||
popl %edx; \
|
||||
popl %esi; \
|
||||
popl %edi; \
|
||||
popl %ebp; \
|
||||
popl %eax; \
|
||||
pop %ds; \
|
||||
pop %es; \
|
||||
pop %fs; \
|
||||
pop %gs; \
|
||||
addl $4,%esp; \
|
||||
iret
|
||||
#endif
|
||||
|
||||
ENTRY(lcall7)
|
||||
pushfl # We get a different stack layout with call gates,
|
||||
pushl %eax # which has to be cleaned up later..
|
||||
SAVE_ALL
|
||||
#ifdef __SMP__
|
||||
ENTER_KERNEL
|
||||
#endif
|
||||
movl EIP(%esp),%eax # due to call gates, this is eflags, not eip..
|
||||
movl CS(%esp),%edx # this is eip..
|
||||
movl EFLAGS(%esp),%ecx # and this is cs..
|
||||
movl %eax,EFLAGS(%esp) #
|
||||
movl %edx,EIP(%esp) # Now we move them to their "normal" places
|
||||
movl %ecx,CS(%esp) #
|
||||
movl %esp,%eax
|
||||
#ifdef __SMP__
|
||||
GET_PROCESSOR_OFFSET(%edx) # Processor offset into edx
|
||||
movl SYMBOL_NAME(current_set)(,%edx),%edx
|
||||
#else
|
||||
movl SYMBOL_NAME(current_set),%edx
|
||||
#endif
|
||||
pushl %eax
|
||||
movl exec_domain(%edx),%edx # Get the execution domain
|
||||
movl 4(%edx),%edx # Get the lcall7 handler for the domain
|
||||
call *%edx
|
||||
popl %eax
|
||||
jmp ret_from_sys_call
|
||||
|
||||
ALIGN
|
||||
handle_bottom_half:
|
||||
incl SYMBOL_NAME(intr_count)
|
||||
call SYMBOL_NAME(do_bottom_half)
|
||||
decl SYMBOL_NAME(intr_count)
|
||||
jmp 9f
|
||||
ALIGN
|
||||
reschedule:
|
||||
pushl $ret_from_sys_call
|
||||
jmp SYMBOL_NAME(schedule) # test
|
||||
|
||||
ENTRY(system_call)
|
||||
pushl %eax # save orig_eax
|
||||
SAVE_ALL
|
||||
#ifdef __SMP__
|
||||
ENTER_KERNEL
|
||||
#endif
|
||||
movl $-ENOSYS,EAX(%esp)
|
||||
cmpl $(NR_syscalls),%eax
|
||||
jae ret_from_sys_call
|
||||
movl SYMBOL_NAME(sys_call_table)(,%eax,4),%eax
|
||||
testl %eax,%eax
|
||||
je ret_from_sys_call
|
||||
#ifdef __SMP__
|
||||
GET_PROCESSOR_OFFSET(%edx)
|
||||
movl SYMBOL_NAME(current_set)(,%edx),%ebx
|
||||
#else
|
||||
movl SYMBOL_NAME(current_set),%ebx
|
||||
#endif
|
||||
andl $~CF_MASK,EFLAGS(%esp) # clear carry - assume no errors
|
||||
movl %db6,%edx
|
||||
movl %edx,dbgreg6(%ebx) # save current hardware debugging status
|
||||
testb $0x20,flags(%ebx) # PF_TRACESYS
|
||||
jne 1f
|
||||
call *%eax
|
||||
movl %eax,EAX(%esp) # save the return value
|
||||
jmp ret_from_sys_call
|
||||
ALIGN
|
||||
1: call SYMBOL_NAME(syscall_trace)
|
||||
movl ORIG_EAX(%esp),%eax
|
||||
call SYMBOL_NAME(sys_call_table)(,%eax,4)
|
||||
movl %eax,EAX(%esp) # save the return value
|
||||
#ifdef __SMP__
|
||||
GET_PROCESSOR_OFFSET(%eax)
|
||||
movl SYMBOL_NAME(current_set)(,%eax),%eax
|
||||
#else
|
||||
movl SYMBOL_NAME(current_set),%eax
|
||||
#endif
|
||||
call SYMBOL_NAME(syscall_trace)
|
||||
|
||||
ALIGN
|
||||
.globl ret_from_sys_call
|
||||
ret_from_sys_call:
|
||||
cmpl $0,SYMBOL_NAME(intr_count)
|
||||
jne 2f
|
||||
9: movl SYMBOL_NAME(bh_mask),%eax
|
||||
andl SYMBOL_NAME(bh_active),%eax
|
||||
jne handle_bottom_half
|
||||
#ifdef __SMP__
|
||||
cmpb $(NO_PROC_ID), SYMBOL_NAME(saved_active_kernel_processor)
|
||||
jne 2f
|
||||
#endif
|
||||
movl EFLAGS(%esp),%eax # check VM86 flag: CS/SS are
|
||||
testl $(VM_MASK),%eax # different then
|
||||
jne 1f
|
||||
cmpw $(KERNEL_CS),CS(%esp) # was old code segment supervisor ?
|
||||
je 2f
|
||||
1: sti
|
||||
orl $(IF_MASK),%eax # these just try to make sure
|
||||
andl $~NT_MASK,%eax # the program doesn't do anything
|
||||
movl %eax,EFLAGS(%esp) # stupid
|
||||
cmpl $0,SYMBOL_NAME(need_resched)
|
||||
jne reschedule
|
||||
#ifdef __SMP__
|
||||
GET_PROCESSOR_OFFSET(%eax)
|
||||
movl SYMBOL_NAME(current_set)(,%eax), %eax
|
||||
#else
|
||||
movl SYMBOL_NAME(current_set),%eax
|
||||
#endif
|
||||
cmpl SYMBOL_NAME(task),%eax # task[0] cannot have signals
|
||||
je 2f
|
||||
movl blocked(%eax),%ecx
|
||||
movl %ecx,%ebx # save blocked in %ebx for signal handling
|
||||
notl %ecx
|
||||
andl signal(%eax),%ecx
|
||||
jne signal_return
|
||||
2: RESTORE_ALL
|
||||
ALIGN
|
||||
signal_return:
|
||||
movl %esp,%ecx
|
||||
pushl %ecx
|
||||
testl $(VM_MASK),EFLAGS(%ecx)
|
||||
jne v86_signal_return
|
||||
pushl %ebx
|
||||
call SYMBOL_NAME(do_signal)
|
||||
popl %ebx
|
||||
popl %ebx
|
||||
RESTORE_ALL
|
||||
ALIGN
|
||||
v86_signal_return:
|
||||
call SYMBOL_NAME(save_v86_state)
|
||||
movl %eax,%esp
|
||||
pushl %eax
|
||||
pushl %ebx
|
||||
call SYMBOL_NAME(do_signal)
|
||||
popl %ebx
|
||||
popl %ebx
|
||||
RESTORE_ALL
|
||||
|
||||
ENTRY(divide_error)
|
||||
pushl $0 # no error code
|
||||
pushl $ SYMBOL_NAME(do_divide_error)
|
||||
ALIGN
|
||||
error_code:
|
||||
push %fs
|
||||
push %es
|
||||
push %ds
|
||||
pushl %eax
|
||||
xorl %eax,%eax
|
||||
pushl %ebp
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
pushl %edx
|
||||
decl %eax # eax = -1
|
||||
pushl %ecx
|
||||
pushl %ebx
|
||||
cld
|
||||
xorl %ebx,%ebx # zero ebx
|
||||
xchgl %eax, ORIG_EAX(%esp) # orig_eax (get the error code. )
|
||||
mov %gs,%bx # get the lower order bits of gs
|
||||
movl %esp,%edx
|
||||
xchgl %ebx, GS(%esp) # get the address and save gs.
|
||||
pushl %eax # push the error code
|
||||
pushl %edx
|
||||
movl $(KERNEL_DS),%edx
|
||||
mov %dx,%ds
|
||||
mov %dx,%es
|
||||
movl $(USER_DS),%edx
|
||||
mov %dx,%fs
|
||||
#ifdef __SMP__
|
||||
ENTER_KERNEL
|
||||
GET_PROCESSOR_OFFSET(%eax)
|
||||
movl SYMBOL_NAME(current_set)(,%eax), %eax
|
||||
#else
|
||||
movl SYMBOL_NAME(current_set),%eax
|
||||
#endif
|
||||
movl %db6,%edx
|
||||
movl %edx,dbgreg6(%eax) # save current hardware debugging status
|
||||
call *%ebx
|
||||
addl $8,%esp
|
||||
jmp ret_from_sys_call
|
||||
|
||||
ENTRY(coprocessor_error)
|
||||
pushl $0
|
||||
pushl $ SYMBOL_NAME(do_coprocessor_error)
|
||||
jmp error_code
|
||||
|
||||
ENTRY(device_not_available)
|
||||
pushl $-1 # mark this as an int
|
||||
SAVE_ALL
|
||||
#ifdef __SMP__
|
||||
ENTER_KERNEL
|
||||
#endif
|
||||
pushl $ret_from_sys_call
|
||||
movl %cr0,%eax
|
||||
testl $0x4,%eax # EM (math emulation bit)
|
||||
je SYMBOL_NAME(math_state_restore)
|
||||
pushl $0 # temporary storage for ORIG_EIP
|
||||
call SYMBOL_NAME(math_emulate)
|
||||
addl $4,%esp
|
||||
ret
|
||||
|
||||
ENTRY(debug)
|
||||
pushl $0
|
||||
pushl $ SYMBOL_NAME(do_debug)
|
||||
jmp error_code
|
||||
|
||||
ENTRY(nmi)
|
||||
pushl $0
|
||||
pushl $ SYMBOL_NAME(do_nmi)
|
||||
jmp error_code
|
||||
|
||||
ENTRY(int3)
|
||||
pushl $0
|
||||
pushl $ SYMBOL_NAME(do_int3)
|
||||
jmp error_code
|
||||
|
||||
ENTRY(overflow)
|
||||
pushl $0
|
||||
pushl $ SYMBOL_NAME(do_overflow)
|
||||
jmp error_code
|
||||
|
||||
ENTRY(bounds)
|
||||
pushl $0
|
||||
pushl $ SYMBOL_NAME(do_bounds)
|
||||
jmp error_code
|
||||
|
||||
ENTRY(invalid_op)
|
||||
pushl $0
|
||||
pushl $ SYMBOL_NAME(do_invalid_op)
|
||||
jmp error_code
|
||||
|
||||
ENTRY(coprocessor_segment_overrun)
|
||||
pushl $0
|
||||
pushl $ SYMBOL_NAME(do_coprocessor_segment_overrun)
|
||||
jmp error_code
|
||||
|
||||
ENTRY(reserved)
|
||||
pushl $0
|
||||
pushl $ SYMBOL_NAME(do_reserved)
|
||||
jmp error_code
|
||||
|
||||
ENTRY(double_fault)
|
||||
pushl $ SYMBOL_NAME(do_double_fault)
|
||||
jmp error_code
|
||||
|
||||
ENTRY(invalid_TSS)
|
||||
pushl $ SYMBOL_NAME(do_invalid_TSS)
|
||||
jmp error_code
|
||||
|
||||
ENTRY(segment_not_present)
|
||||
pushl $ SYMBOL_NAME(do_segment_not_present)
|
||||
jmp error_code
|
||||
|
||||
ENTRY(stack_segment)
|
||||
pushl $ SYMBOL_NAME(do_stack_segment)
|
||||
jmp error_code
|
||||
|
||||
ENTRY(general_protection)
|
||||
pushl $ SYMBOL_NAME(do_general_protection)
|
||||
jmp error_code
|
||||
|
||||
ENTRY(alignment_check)
|
||||
pushl $ SYMBOL_NAME(do_alignment_check)
|
||||
jmp error_code
|
||||
|
||||
ENTRY(page_fault)
|
||||
pushl $ SYMBOL_NAME(do_page_fault)
|
||||
jmp error_code
|
||||
|
||||
ENTRY(spurious_interrupt_bug)
|
||||
pushl $0
|
||||
pushl $ SYMBOL_NAME(do_spurious_interrupt_bug)
|
||||
jmp error_code
|
||||
|
||||
.data
|
||||
ENTRY(sys_call_table)
|
||||
.long SYMBOL_NAME(sys_setup) /* 0 */
|
||||
.long SYMBOL_NAME(sys_exit)
|
||||
.long SYMBOL_NAME(sys_fork)
|
||||
.long SYMBOL_NAME(sys_read)
|
||||
.long SYMBOL_NAME(sys_write)
|
||||
.long SYMBOL_NAME(sys_open) /* 5 */
|
||||
.long SYMBOL_NAME(sys_close)
|
||||
.long SYMBOL_NAME(sys_waitpid)
|
||||
.long SYMBOL_NAME(sys_creat)
|
||||
.long SYMBOL_NAME(sys_link)
|
||||
.long SYMBOL_NAME(sys_unlink) /* 10 */
|
||||
.long SYMBOL_NAME(sys_execve)
|
||||
.long SYMBOL_NAME(sys_chdir)
|
||||
.long SYMBOL_NAME(sys_time)
|
||||
.long SYMBOL_NAME(sys_mknod)
|
||||
.long SYMBOL_NAME(sys_chmod) /* 15 */
|
||||
.long SYMBOL_NAME(sys_chown)
|
||||
.long SYMBOL_NAME(sys_break)
|
||||
.long SYMBOL_NAME(sys_stat)
|
||||
.long SYMBOL_NAME(sys_lseek)
|
||||
.long SYMBOL_NAME(sys_getpid) /* 20 */
|
||||
.long SYMBOL_NAME(sys_mount)
|
||||
.long SYMBOL_NAME(sys_umount)
|
||||
.long SYMBOL_NAME(sys_setuid)
|
||||
.long SYMBOL_NAME(sys_getuid)
|
||||
.long SYMBOL_NAME(sys_stime) /* 25 */
|
||||
.long SYMBOL_NAME(sys_ptrace)
|
||||
.long SYMBOL_NAME(sys_alarm)
|
||||
.long SYMBOL_NAME(sys_fstat)
|
||||
.long SYMBOL_NAME(sys_pause)
|
||||
.long SYMBOL_NAME(sys_utime) /* 30 */
|
||||
.long SYMBOL_NAME(sys_stty)
|
||||
.long SYMBOL_NAME(sys_gtty)
|
||||
.long SYMBOL_NAME(sys_access)
|
||||
.long SYMBOL_NAME(sys_nice)
|
||||
.long SYMBOL_NAME(sys_ftime) /* 35 */
|
||||
.long SYMBOL_NAME(sys_sync)
|
||||
.long SYMBOL_NAME(sys_kill)
|
||||
.long SYMBOL_NAME(sys_rename)
|
||||
.long SYMBOL_NAME(sys_mkdir)
|
||||
.long SYMBOL_NAME(sys_rmdir) /* 40 */
|
||||
.long SYMBOL_NAME(sys_dup)
|
||||
.long SYMBOL_NAME(sys_pipe)
|
||||
.long SYMBOL_NAME(sys_times)
|
||||
.long SYMBOL_NAME(sys_prof)
|
||||
.long SYMBOL_NAME(sys_brk) /* 45 */
|
||||
.long SYMBOL_NAME(sys_setgid)
|
||||
.long SYMBOL_NAME(sys_getgid)
|
||||
.long SYMBOL_NAME(sys_signal)
|
||||
.long SYMBOL_NAME(sys_geteuid)
|
||||
.long SYMBOL_NAME(sys_getegid) /* 50 */
|
||||
.long SYMBOL_NAME(sys_acct)
|
||||
.long SYMBOL_NAME(sys_phys)
|
||||
.long SYMBOL_NAME(sys_lock)
|
||||
.long SYMBOL_NAME(sys_ioctl)
|
||||
.long SYMBOL_NAME(sys_fcntl) /* 55 */
|
||||
.long SYMBOL_NAME(sys_mpx)
|
||||
.long SYMBOL_NAME(sys_setpgid)
|
||||
.long SYMBOL_NAME(sys_ulimit)
|
||||
.long SYMBOL_NAME(sys_olduname)
|
||||
.long SYMBOL_NAME(sys_umask) /* 60 */
|
||||
.long SYMBOL_NAME(sys_chroot)
|
||||
.long SYMBOL_NAME(sys_ustat)
|
||||
.long SYMBOL_NAME(sys_dup2)
|
||||
.long SYMBOL_NAME(sys_getppid)
|
||||
.long SYMBOL_NAME(sys_getpgrp) /* 65 */
|
||||
.long SYMBOL_NAME(sys_setsid)
|
||||
.long SYMBOL_NAME(sys_sigaction)
|
||||
.long SYMBOL_NAME(sys_sgetmask)
|
||||
.long SYMBOL_NAME(sys_ssetmask)
|
||||
.long SYMBOL_NAME(sys_setreuid) /* 70 */
|
||||
.long SYMBOL_NAME(sys_setregid)
|
||||
.long SYMBOL_NAME(sys_sigsuspend)
|
||||
.long SYMBOL_NAME(sys_sigpending)
|
||||
.long SYMBOL_NAME(sys_sethostname)
|
||||
.long SYMBOL_NAME(sys_setrlimit) /* 75 */
|
||||
.long SYMBOL_NAME(sys_getrlimit)
|
||||
.long SYMBOL_NAME(sys_getrusage)
|
||||
.long SYMBOL_NAME(sys_gettimeofday)
|
||||
.long SYMBOL_NAME(sys_settimeofday)
|
||||
.long SYMBOL_NAME(sys_getgroups) /* 80 */
|
||||
.long SYMBOL_NAME(sys_setgroups)
|
||||
.long SYMBOL_NAME(old_select)
|
||||
.long SYMBOL_NAME(sys_symlink)
|
||||
.long SYMBOL_NAME(sys_lstat)
|
||||
.long SYMBOL_NAME(sys_readlink) /* 85 */
|
||||
.long SYMBOL_NAME(sys_uselib)
|
||||
.long SYMBOL_NAME(sys_swapon)
|
||||
.long SYMBOL_NAME(sys_reboot)
|
||||
.long SYMBOL_NAME(old_readdir)
|
||||
.long SYMBOL_NAME(old_mmap) /* 90 */
|
||||
.long SYMBOL_NAME(sys_munmap)
|
||||
.long SYMBOL_NAME(sys_truncate)
|
||||
.long SYMBOL_NAME(sys_ftruncate)
|
||||
.long SYMBOL_NAME(sys_fchmod)
|
||||
.long SYMBOL_NAME(sys_fchown) /* 95 */
|
||||
.long SYMBOL_NAME(sys_getpriority)
|
||||
.long SYMBOL_NAME(sys_setpriority)
|
||||
.long SYMBOL_NAME(sys_profil)
|
||||
.long SYMBOL_NAME(sys_statfs)
|
||||
.long SYMBOL_NAME(sys_fstatfs) /* 100 */
|
||||
.long SYMBOL_NAME(sys_ioperm)
|
||||
.long SYMBOL_NAME(sys_socketcall)
|
||||
.long SYMBOL_NAME(sys_syslog)
|
||||
.long SYMBOL_NAME(sys_setitimer)
|
||||
.long SYMBOL_NAME(sys_getitimer) /* 105 */
|
||||
.long SYMBOL_NAME(sys_newstat)
|
||||
.long SYMBOL_NAME(sys_newlstat)
|
||||
.long SYMBOL_NAME(sys_newfstat)
|
||||
.long SYMBOL_NAME(sys_uname)
|
||||
.long SYMBOL_NAME(sys_iopl) /* 110 */
|
||||
.long SYMBOL_NAME(sys_vhangup)
|
||||
.long SYMBOL_NAME(sys_idle)
|
||||
.long SYMBOL_NAME(sys_vm86old)
|
||||
.long SYMBOL_NAME(sys_wait4)
|
||||
.long SYMBOL_NAME(sys_swapoff) /* 115 */
|
||||
.long SYMBOL_NAME(sys_sysinfo)
|
||||
.long SYMBOL_NAME(sys_ipc)
|
||||
.long SYMBOL_NAME(sys_fsync)
|
||||
.long SYMBOL_NAME(sys_sigreturn)
|
||||
.long SYMBOL_NAME(sys_clone) /* 120 */
|
||||
.long SYMBOL_NAME(sys_setdomainname)
|
||||
.long SYMBOL_NAME(sys_newuname)
|
||||
.long SYMBOL_NAME(sys_modify_ldt)
|
||||
.long SYMBOL_NAME(sys_adjtimex)
|
||||
.long SYMBOL_NAME(sys_mprotect) /* 125 */
|
||||
.long SYMBOL_NAME(sys_sigprocmask)
|
||||
.long SYMBOL_NAME(sys_create_module)
|
||||
.long SYMBOL_NAME(sys_init_module)
|
||||
.long SYMBOL_NAME(sys_delete_module)
|
||||
.long SYMBOL_NAME(sys_get_kernel_syms) /* 130 */
|
||||
.long SYMBOL_NAME(sys_quotactl)
|
||||
.long SYMBOL_NAME(sys_getpgid)
|
||||
.long SYMBOL_NAME(sys_fchdir)
|
||||
.long SYMBOL_NAME(sys_bdflush)
|
||||
.long SYMBOL_NAME(sys_sysfs) /* 135 */
|
||||
.long SYMBOL_NAME(sys_personality)
|
||||
.long 0 /* for afs_syscall */
|
||||
.long SYMBOL_NAME(sys_setfsuid)
|
||||
.long SYMBOL_NAME(sys_setfsgid)
|
||||
.long SYMBOL_NAME(sys_llseek) /* 140 */
|
||||
.long SYMBOL_NAME(sys_getdents)
|
||||
.long SYMBOL_NAME(sys_select)
|
||||
.long SYMBOL_NAME(sys_flock)
|
||||
.long SYMBOL_NAME(sys_msync)
|
||||
.long SYMBOL_NAME(sys_readv) /* 145 */
|
||||
.long SYMBOL_NAME(sys_writev)
|
||||
.long SYMBOL_NAME(sys_getsid)
|
||||
.long SYMBOL_NAME(sys_fdatasync)
|
||||
.long SYMBOL_NAME(sys_sysctl)
|
||||
.long SYMBOL_NAME(sys_mlock) /* 150 */
|
||||
.long SYMBOL_NAME(sys_munlock)
|
||||
.long SYMBOL_NAME(sys_mlockall)
|
||||
.long SYMBOL_NAME(sys_munlockall)
|
||||
.long SYMBOL_NAME(sys_sched_setparam)
|
||||
.long SYMBOL_NAME(sys_sched_getparam) /* 155 */
|
||||
.long SYMBOL_NAME(sys_sched_setscheduler)
|
||||
.long SYMBOL_NAME(sys_sched_getscheduler)
|
||||
.long SYMBOL_NAME(sys_sched_yield)
|
||||
.long SYMBOL_NAME(sys_sched_get_priority_max)
|
||||
.long SYMBOL_NAME(sys_sched_get_priority_min) /* 160 */
|
||||
.long SYMBOL_NAME(sys_sched_rr_get_interval)
|
||||
.long SYMBOL_NAME(sys_nanosleep)
|
||||
.long SYMBOL_NAME(sys_mremap)
|
||||
.long 0,0
|
||||
.long SYMBOL_NAME(sys_vm86)
|
||||
.long 0,0,0,0 /* 170 */
|
||||
.long 0,0,0,0,0,0,0,0,0,0 /* 180 */
|
||||
.long 0,0,0,0,0,0,0
|
||||
.long SYMBOL_NAME(sys_table)
|
||||
.space (NR_syscalls-188)*4
|
@@ -28,14 +28,16 @@ diff -ur linux-2.0.32/Makefile linux-hacked/Makefile
|
||||
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 @@
|
||||
@@ -699,4 +699,8 @@
|
||||
.long SYMBOL_NAME(sys_mremap)
|
||||
.long 0,0
|
||||
.long SYMBOL_NAME(sys_vm86)
|
||||
- .space (NR_syscalls-166)*4
|
||||
+ .long 0
|
||||
+ .long 0,0,0,0 /* 170 */
|
||||
+ .long 0,0,0,0,0,0,0,0,0,0 /* 180 */
|
||||
+ .long 0,0,0,0,0,0,0
|
||||
+ .long SYMBOL_NAME(sys_table)
|
||||
+ .space (NR_syscalls-168)*4
|
||||
+ .space (NR_syscalls-188)*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
|
||||
@@ -43,7 +45,7 @@ diff -ur linux-2.0.32/include/asm-i386/unistd.h linux-hacked/include/asm-i386/un
|
||||
#define __NR_sched_rr_get_interval 161
|
||||
#define __NR_nanosleep 162
|
||||
#define __NR_mremap 163
|
||||
+#define __NR_table 168
|
||||
+#define __NR_table 188
|
||||
|
||||
/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
|
||||
#define _syscall0(type,name) \
|
@@ -189,8 +189,11 @@ sys_table (int type, union table *buf, const void *param)
|
||||
union table tbl;
|
||||
struct sysinfo i;
|
||||
struct task_struct *tsk = NULL;
|
||||
struct ip_chain *chain;
|
||||
struct ip_fwkernel *rule;
|
||||
char devname [9];
|
||||
int index, err;
|
||||
pid_t pid;
|
||||
int err;
|
||||
|
||||
if (type == TABLE_VERSION)
|
||||
return _TABLE_VERSION;
|
||||
@@ -219,17 +222,36 @@ sys_table (int type, union table *buf, const void *param)
|
||||
if (tsk == NULL)
|
||||
return -ESRCH;
|
||||
break;
|
||||
case TABLE_NETACCT:
|
||||
err = verify_area (VERIFY_READ, param, 5);
|
||||
if (err)
|
||||
return err;
|
||||
copy_from_user (devname, param, 5);
|
||||
devname [5] = 0;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
/* Main function dispatcher */
|
||||
|
||||
switch (type) {
|
||||
case TABLE_PROCLIST:
|
||||
tsk = task [0];
|
||||
for (index = 0; index < nr_tasks; index++) {
|
||||
tbl.proclist.pids [index] = tsk->pid;
|
||||
tsk = tsk->next_task;
|
||||
}
|
||||
tbl.proclist.nr_running = nr_running;
|
||||
tbl.proclist.nr_tasks = nr_tasks;
|
||||
tbl.proclist.last_pid = last_pid;
|
||||
break;
|
||||
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.idle = tbl.cpu.total -
|
||||
(tbl.cpu.user + tbl.cpu.nice + tbl.cpu.sys);
|
||||
tbl.cpu.frequency = HZ;
|
||||
break;
|
||||
case TABLE_MEM:
|
||||
@@ -246,6 +268,8 @@ sys_table (int type, union table *buf, const void *param)
|
||||
tbl.swap.total = i.totalswap;
|
||||
tbl.swap.used = i.totalswap - i.freeswap;
|
||||
tbl.swap.free = i.freeswap;
|
||||
tbl.swap.pagein = kstat.pswpin;
|
||||
tbl.swap.pageout = kstat.pswpout;
|
||||
break;
|
||||
case TABLE_LOADAVG:
|
||||
tbl.loadavg.loadavg [0] = (double) avenrun [0] / (1 << FSHIFT);
|
||||
@@ -262,7 +286,8 @@ sys_table (int type, union table *buf, const void *param)
|
||||
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));
|
||||
memcpy (tbl.proc_state.comm, tsk->comm,
|
||||
sizeof (tbl.proc_state.comm));
|
||||
break;
|
||||
case TABLE_PROC_UID:
|
||||
tbl.proc_uid.uid = tsk->uid;
|
||||
@@ -280,7 +305,8 @@ sys_table (int type, union table *buf, const void *param)
|
||||
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.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;
|
||||
@@ -337,7 +363,8 @@ sys_table (int type, union table *buf, const void *param)
|
||||
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;
|
||||
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) {
|
||||
@@ -410,6 +437,24 @@ sys_table (int type, union table *buf, const void *param)
|
||||
|
||||
tbl.proc_kernel.wchan = get_wchan (tsk);
|
||||
break;
|
||||
case TABLE_NETACCT:
|
||||
for (chain = ip_fw_chains; chain; chain = chain->next) {
|
||||
for (rule = chain->chain; rule; rule = rule->next) {
|
||||
const char *name = rule->ipfw.fw_vianame;
|
||||
int k;
|
||||
|
||||
if (name [0] && !strncmp (param, name, 5))
|
||||
continue;
|
||||
|
||||
for (k = 0; k < NUM_SLOTS; k++) {
|
||||
tbl.netacct.packets +=
|
||||
rule->counters[k].pcnt;
|
||||
tbl.netacct.bytes +=
|
||||
rule->counters[k].bcnt;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
324
kernel/table20/unistd-i386.h
Normal file
324
kernel/table20/unistd-i386.h
Normal file
@@ -0,0 +1,324 @@
|
||||
#ifndef _ASM_I386_UNISTD_H_
|
||||
#define _ASM_I386_UNISTD_H_
|
||||
|
||||
/*
|
||||
* This file contains the system call numbers.
|
||||
*/
|
||||
|
||||
#define __NR_setup 0 /* used only by init, to get system going */
|
||||
#define __NR_exit 1
|
||||
#define __NR_fork 2
|
||||
#define __NR_read 3
|
||||
#define __NR_write 4
|
||||
#define __NR_open 5
|
||||
#define __NR_close 6
|
||||
#define __NR_waitpid 7
|
||||
#define __NR_creat 8
|
||||
#define __NR_link 9
|
||||
#define __NR_unlink 10
|
||||
#define __NR_execve 11
|
||||
#define __NR_chdir 12
|
||||
#define __NR_time 13
|
||||
#define __NR_mknod 14
|
||||
#define __NR_chmod 15
|
||||
#define __NR_chown 16
|
||||
#define __NR_break 17
|
||||
#define __NR_oldstat 18
|
||||
#define __NR_lseek 19
|
||||
#define __NR_getpid 20
|
||||
#define __NR_mount 21
|
||||
#define __NR_umount 22
|
||||
#define __NR_setuid 23
|
||||
#define __NR_getuid 24
|
||||
#define __NR_stime 25
|
||||
#define __NR_ptrace 26
|
||||
#define __NR_alarm 27
|
||||
#define __NR_oldfstat 28
|
||||
#define __NR_pause 29
|
||||
#define __NR_utime 30
|
||||
#define __NR_stty 31
|
||||
#define __NR_gtty 32
|
||||
#define __NR_access 33
|
||||
#define __NR_nice 34
|
||||
#define __NR_ftime 35
|
||||
#define __NR_sync 36
|
||||
#define __NR_kill 37
|
||||
#define __NR_rename 38
|
||||
#define __NR_mkdir 39
|
||||
#define __NR_rmdir 40
|
||||
#define __NR_dup 41
|
||||
#define __NR_pipe 42
|
||||
#define __NR_times 43
|
||||
#define __NR_prof 44
|
||||
#define __NR_brk 45
|
||||
#define __NR_setgid 46
|
||||
#define __NR_getgid 47
|
||||
#define __NR_signal 48
|
||||
#define __NR_geteuid 49
|
||||
#define __NR_getegid 50
|
||||
#define __NR_acct 51
|
||||
#define __NR_phys 52
|
||||
#define __NR_lock 53
|
||||
#define __NR_ioctl 54
|
||||
#define __NR_fcntl 55
|
||||
#define __NR_mpx 56
|
||||
#define __NR_setpgid 57
|
||||
#define __NR_ulimit 58
|
||||
#define __NR_oldolduname 59
|
||||
#define __NR_umask 60
|
||||
#define __NR_chroot 61
|
||||
#define __NR_ustat 62
|
||||
#define __NR_dup2 63
|
||||
#define __NR_getppid 64
|
||||
#define __NR_getpgrp 65
|
||||
#define __NR_setsid 66
|
||||
#define __NR_sigaction 67
|
||||
#define __NR_sgetmask 68
|
||||
#define __NR_ssetmask 69
|
||||
#define __NR_setreuid 70
|
||||
#define __NR_setregid 71
|
||||
#define __NR_sigsuspend 72
|
||||
#define __NR_sigpending 73
|
||||
#define __NR_sethostname 74
|
||||
#define __NR_setrlimit 75
|
||||
#define __NR_getrlimit 76
|
||||
#define __NR_getrusage 77
|
||||
#define __NR_gettimeofday 78
|
||||
#define __NR_settimeofday 79
|
||||
#define __NR_getgroups 80
|
||||
#define __NR_setgroups 81
|
||||
#define __NR_select 82
|
||||
#define __NR_symlink 83
|
||||
#define __NR_oldlstat 84
|
||||
#define __NR_readlink 85
|
||||
#define __NR_uselib 86
|
||||
#define __NR_swapon 87
|
||||
#define __NR_reboot 88
|
||||
#define __NR_readdir 89
|
||||
#define __NR_mmap 90
|
||||
#define __NR_munmap 91
|
||||
#define __NR_truncate 92
|
||||
#define __NR_ftruncate 93
|
||||
#define __NR_fchmod 94
|
||||
#define __NR_fchown 95
|
||||
#define __NR_getpriority 96
|
||||
#define __NR_setpriority 97
|
||||
#define __NR_profil 98
|
||||
#define __NR_statfs 99
|
||||
#define __NR_fstatfs 100
|
||||
#define __NR_ioperm 101
|
||||
#define __NR_socketcall 102
|
||||
#define __NR_syslog 103
|
||||
#define __NR_setitimer 104
|
||||
#define __NR_getitimer 105
|
||||
#define __NR_stat 106
|
||||
#define __NR_lstat 107
|
||||
#define __NR_fstat 108
|
||||
#define __NR_olduname 109
|
||||
#define __NR_iopl 110
|
||||
#define __NR_vhangup 111
|
||||
#define __NR_idle 112
|
||||
#define __NR_vm86 113
|
||||
#define __NR_wait4 114
|
||||
#define __NR_swapoff 115
|
||||
#define __NR_sysinfo 116
|
||||
#define __NR_ipc 117
|
||||
#define __NR_fsync 118
|
||||
#define __NR_sigreturn 119
|
||||
#define __NR_clone 120
|
||||
#define __NR_setdomainname 121
|
||||
#define __NR_uname 122
|
||||
#define __NR_modify_ldt 123
|
||||
#define __NR_adjtimex 124
|
||||
#define __NR_mprotect 125
|
||||
#define __NR_sigprocmask 126
|
||||
#define __NR_create_module 127
|
||||
#define __NR_init_module 128
|
||||
#define __NR_delete_module 129
|
||||
#define __NR_get_kernel_syms 130
|
||||
#define __NR_quotactl 131
|
||||
#define __NR_getpgid 132
|
||||
#define __NR_fchdir 133
|
||||
#define __NR_bdflush 134
|
||||
#define __NR_sysfs 135
|
||||
#define __NR_personality 136
|
||||
#define __NR_afs_syscall 137 /* Syscall for Andrew File System */
|
||||
#define __NR_setfsuid 138
|
||||
#define __NR_setfsgid 139
|
||||
#define __NR__llseek 140
|
||||
#define __NR_getdents 141
|
||||
#define __NR__newselect 142
|
||||
#define __NR_flock 143
|
||||
#define __NR_msync 144
|
||||
#define __NR_readv 145
|
||||
#define __NR_writev 146
|
||||
#define __NR_getsid 147
|
||||
#define __NR_fdatasync 148
|
||||
#define __NR__sysctl 149
|
||||
#define __NR_mlock 150
|
||||
#define __NR_munlock 151
|
||||
#define __NR_mlockall 152
|
||||
#define __NR_munlockall 153
|
||||
#define __NR_sched_setparam 154
|
||||
#define __NR_sched_getparam 155
|
||||
#define __NR_sched_setscheduler 156
|
||||
#define __NR_sched_getscheduler 157
|
||||
#define __NR_sched_yield 158
|
||||
#define __NR_sched_get_priority_max 159
|
||||
#define __NR_sched_get_priority_min 160
|
||||
#define __NR_sched_rr_get_interval 161
|
||||
#define __NR_nanosleep 162
|
||||
#define __NR_mremap 163
|
||||
#define __NR_table 188
|
||||
|
||||
/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
|
||||
#define _syscall0(type,name) \
|
||||
type name(void) \
|
||||
{ \
|
||||
long __res; \
|
||||
__asm__ volatile ("int $0x80" \
|
||||
: "=a" (__res) \
|
||||
: "0" (__NR_##name)); \
|
||||
if (__res >= 0) \
|
||||
return (type) __res; \
|
||||
errno = -__res; \
|
||||
return -1; \
|
||||
}
|
||||
|
||||
#define _syscall1(type,name,type1,arg1) \
|
||||
type name(type1 arg1) \
|
||||
{ \
|
||||
long __res; \
|
||||
__asm__ volatile ("int $0x80" \
|
||||
: "=a" (__res) \
|
||||
: "0" (__NR_##name),"b" ((long)(arg1))); \
|
||||
if (__res >= 0) \
|
||||
return (type) __res; \
|
||||
errno = -__res; \
|
||||
return -1; \
|
||||
}
|
||||
|
||||
#define _syscall2(type,name,type1,arg1,type2,arg2) \
|
||||
type name(type1 arg1,type2 arg2) \
|
||||
{ \
|
||||
long __res; \
|
||||
__asm__ volatile ("int $0x80" \
|
||||
: "=a" (__res) \
|
||||
: "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2))); \
|
||||
if (__res >= 0) \
|
||||
return (type) __res; \
|
||||
errno = -__res; \
|
||||
return -1; \
|
||||
}
|
||||
|
||||
#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
|
||||
type name(type1 arg1,type2 arg2,type3 arg3) \
|
||||
{ \
|
||||
long __res; \
|
||||
__asm__ volatile ("int $0x80" \
|
||||
: "=a" (__res) \
|
||||
: "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \
|
||||
"d" ((long)(arg3))); \
|
||||
if (__res>=0) \
|
||||
return (type) __res; \
|
||||
errno=-__res; \
|
||||
return -1; \
|
||||
}
|
||||
|
||||
#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
|
||||
type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
|
||||
{ \
|
||||
long __res; \
|
||||
__asm__ volatile ("int $0x80" \
|
||||
: "=a" (__res) \
|
||||
: "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \
|
||||
"d" ((long)(arg3)),"S" ((long)(arg4))); \
|
||||
if (__res>=0) \
|
||||
return (type) __res; \
|
||||
errno=-__res; \
|
||||
return -1; \
|
||||
}
|
||||
|
||||
#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
|
||||
type5,arg5) \
|
||||
type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
|
||||
{ \
|
||||
long __res; \
|
||||
__asm__ volatile ("int $0x80" \
|
||||
: "=a" (__res) \
|
||||
: "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \
|
||||
"d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5))); \
|
||||
if (__res>=0) \
|
||||
return (type) __res; \
|
||||
errno=-__res; \
|
||||
return -1; \
|
||||
}
|
||||
|
||||
#ifdef __KERNEL_SYSCALLS__
|
||||
|
||||
/*
|
||||
* we need this inline - forking from kernel space will result
|
||||
* in NO COPY ON WRITE (!!!), until an execve is executed. This
|
||||
* is no problem, but for the stack. This is handled by not letting
|
||||
* main() use the stack at all after fork(). Thus, no function
|
||||
* calls - which means inline code for fork too, as otherwise we
|
||||
* would use the stack upon exit from 'fork()'.
|
||||
*
|
||||
* Actually only pause and fork are needed inline, so that there
|
||||
* won't be any messing with the stack from main(), but we define
|
||||
* some others too.
|
||||
*/
|
||||
#define __NR__exit __NR_exit
|
||||
static inline _syscall0(int,idle)
|
||||
static inline _syscall0(int,fork)
|
||||
static inline _syscall2(int,clone,unsigned long,flags,char *,esp)
|
||||
static inline _syscall0(int,pause)
|
||||
static inline _syscall0(int,setup)
|
||||
static inline _syscall0(int,sync)
|
||||
static inline _syscall0(pid_t,setsid)
|
||||
static inline _syscall3(int,write,int,fd,const char *,buf,off_t,count)
|
||||
static inline _syscall1(int,dup,int,fd)
|
||||
static inline _syscall3(int,execve,const char *,file,char **,argv,char **,envp)
|
||||
static inline _syscall3(int,open,const char *,file,int,flag,int,mode)
|
||||
static inline _syscall1(int,close,int,fd)
|
||||
static inline _syscall1(int,_exit,int,exitcode)
|
||||
static inline _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
|
||||
|
||||
static inline pid_t wait(int * wait_stat)
|
||||
{
|
||||
return waitpid(-1,wait_stat,0);
|
||||
}
|
||||
|
||||
/*
|
||||
* This is the mechanism for creating a new kernel thread.
|
||||
*
|
||||
* NOTE! Only a kernel-only process(ie the swapper or direct descendants
|
||||
* who haven't done an "execve()") should use this: it will work within
|
||||
* a system call from a "real" process, but the process memory space will
|
||||
* not be free'd until both the parent and the child have exited.
|
||||
*/
|
||||
static inline pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
|
||||
{
|
||||
long retval;
|
||||
|
||||
__asm__ __volatile__(
|
||||
"movl %%esp,%%esi\n\t"
|
||||
"int $0x80\n\t" /* Linux/i386 system call */
|
||||
"cmpl %%esp,%%esi\n\t" /* child or parent? */
|
||||
"je 1f\n\t" /* parent - jump */
|
||||
"pushl %3\n\t" /* push argument */
|
||||
"call *%4\n\t" /* call fn */
|
||||
"movl %2,%0\n\t" /* exit */
|
||||
"int $0x80\n"
|
||||
"1:\t"
|
||||
:"=a" (retval)
|
||||
:"0" (__NR_clone), "i" (__NR_exit),
|
||||
"r" (arg), "r" (fn),
|
||||
"b" (flags | CLONE_VM)
|
||||
:"si");
|
||||
return retval;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _ASM_I386_UNISTD_H_ */
|
1
kernel/table20/version.h
Normal file
1
kernel/table20/version.h
Normal file
@@ -0,0 +1 @@
|
||||
#define _TABLE_VERSION 1
|
4
kernel/table21/.cvsignore
Normal file
4
kernel/table21/.cvsignore
Normal file
@@ -0,0 +1,4 @@
|
||||
kernel.patch
|
||||
.main.o.flags
|
||||
.table.o.flags
|
||||
.module.o.flags
|
16
kernel/table21/Makefile
Normal file
16
kernel/table21/Makefile
Normal file
@@ -0,0 +1,16 @@
|
||||
#
|
||||
# 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
|
||||
OX_OBJS := main.o
|
||||
|
||||
M_TARGET := table_mod.o
|
||||
MX_OBJS := module.o
|
||||
|
||||
include $(TOPDIR)/Rules.make
|
21
kernel/table21/README
Normal file
21
kernel/table21/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
|
571
kernel/table21/entry-i386.S
Normal file
571
kernel/table21/entry-i386.S
Normal file
@@ -0,0 +1,571 @@
|
||||
/*
|
||||
* linux/arch/i386/entry.S
|
||||
*
|
||||
* Copyright (C) 1991, 1992 Linus Torvalds
|
||||
*/
|
||||
|
||||
/*
|
||||
* entry.S contains the system-call and fault low-level handling routines.
|
||||
* This also contains the timer-interrupt handler, as well as all interrupts
|
||||
* and faults that can result in a task-switch.
|
||||
*
|
||||
* NOTE: This code handles signal-recognition, which happens every time
|
||||
* after a timer-interrupt and after each system call.
|
||||
*
|
||||
* I changed all the .align's to 4 (16 byte alignment), as that's faster
|
||||
* on a 486.
|
||||
*
|
||||
* Stack layout in 'ret_from_system_call':
|
||||
* ptrace needs to have all regs on the stack.
|
||||
* if the order here is changed, it needs to be
|
||||
* updated in fork.c:copy_process, signal.c:do_signal,
|
||||
* ptrace.c and ptrace.h
|
||||
*
|
||||
* 0(%esp) - %ebx
|
||||
* 4(%esp) - %ecx
|
||||
* 8(%esp) - %edx
|
||||
* C(%esp) - %esi
|
||||
* 10(%esp) - %edi
|
||||
* 14(%esp) - %ebp
|
||||
* 18(%esp) - %eax
|
||||
* 1C(%esp) - %ds
|
||||
* 20(%esp) - %es
|
||||
* 24(%esp) - orig_eax
|
||||
* 28(%esp) - %eip
|
||||
* 2C(%esp) - %cs
|
||||
* 30(%esp) - %eflags
|
||||
* 34(%esp) - %oldesp
|
||||
* 38(%esp) - %oldss
|
||||
*
|
||||
* "current" is in register %ebx during any slow entries.
|
||||
*/
|
||||
|
||||
#include <linux/sys.h>
|
||||
#include <linux/linkage.h>
|
||||
#include <asm/segment.h>
|
||||
#define ASSEMBLY
|
||||
#include <asm/smp.h>
|
||||
|
||||
EBX = 0x00
|
||||
ECX = 0x04
|
||||
EDX = 0x08
|
||||
ESI = 0x0C
|
||||
EDI = 0x10
|
||||
EBP = 0x14
|
||||
EAX = 0x18
|
||||
DS = 0x1C
|
||||
ES = 0x20
|
||||
ORIG_EAX = 0x24
|
||||
EIP = 0x28
|
||||
CS = 0x2C
|
||||
EFLAGS = 0x30
|
||||
OLDESP = 0x34
|
||||
OLDSS = 0x38
|
||||
|
||||
CF_MASK = 0x00000001
|
||||
IF_MASK = 0x00000200
|
||||
NT_MASK = 0x00004000
|
||||
VM_MASK = 0x00020000
|
||||
|
||||
/*
|
||||
* these are offsets into the task-struct.
|
||||
*/
|
||||
state = 0
|
||||
flags = 4
|
||||
sigpending = 8
|
||||
addr_limit = 12
|
||||
exec_domain = 16
|
||||
need_resched = 20
|
||||
|
||||
ENOSYS = 38
|
||||
|
||||
|
||||
#define SAVE_ALL \
|
||||
cld; \
|
||||
pushl %es; \
|
||||
pushl %ds; \
|
||||
pushl %eax; \
|
||||
pushl %ebp; \
|
||||
pushl %edi; \
|
||||
pushl %esi; \
|
||||
pushl %edx; \
|
||||
pushl %ecx; \
|
||||
pushl %ebx; \
|
||||
movl $(__KERNEL_DS),%edx; \
|
||||
movl %dx,%ds; \
|
||||
movl %dx,%es;
|
||||
|
||||
#define RESTORE_ALL \
|
||||
popl %ebx; \
|
||||
popl %ecx; \
|
||||
popl %edx; \
|
||||
popl %esi; \
|
||||
popl %edi; \
|
||||
popl %ebp; \
|
||||
popl %eax; \
|
||||
1: popl %ds; \
|
||||
2: popl %es; \
|
||||
3: addl $4,%esp; \
|
||||
iret; \
|
||||
.section fixup,"ax"; \
|
||||
4: pushl $0; \
|
||||
popl %ds; \
|
||||
jmp 2b; \
|
||||
5: pushl $0; \
|
||||
popl %es; \
|
||||
jmp 3b; \
|
||||
.previous; \
|
||||
.section __ex_table,"a";\
|
||||
.align 4; \
|
||||
.long 1b,4b; \
|
||||
.long 2b,5b; \
|
||||
.previous
|
||||
|
||||
#define GET_CURRENT(reg) \
|
||||
movl %esp, reg; \
|
||||
andl $-8192, reg;
|
||||
|
||||
ENTRY(lcall7)
|
||||
pushfl # We get a different stack layout with call gates,
|
||||
pushl %eax # which has to be cleaned up later..
|
||||
SAVE_ALL
|
||||
movl EIP(%esp),%eax # due to call gates, this is eflags, not eip..
|
||||
movl CS(%esp),%edx # this is eip..
|
||||
movl EFLAGS(%esp),%ecx # and this is cs..
|
||||
movl %eax,EFLAGS(%esp) #
|
||||
movl %edx,EIP(%esp) # Now we move them to their "normal" places
|
||||
movl %ecx,CS(%esp) #
|
||||
movl %esp,%ebx
|
||||
pushl %ebx
|
||||
andl $-8192,%ebx # GET_CURRENT
|
||||
movl exec_domain(%ebx),%edx # Get the execution domain
|
||||
movl 4(%edx),%edx # Get the lcall7 handler for the domain
|
||||
call *%edx
|
||||
popl %eax
|
||||
jmp ret_from_sys_call
|
||||
|
||||
|
||||
#ifdef __SMP__
|
||||
ALIGN
|
||||
.globl ret_from_smpfork
|
||||
ret_from_smpfork:
|
||||
GET_CURRENT(%ebx)
|
||||
btrl $0, SYMBOL_NAME(scheduler_lock)
|
||||
jmp ret_from_sys_call
|
||||
#endif /* __SMP__ */
|
||||
|
||||
/*
|
||||
* Return to user mode is not as complex as all this looks,
|
||||
* but we want the default path for a system call return to
|
||||
* go as quickly as possible which is why some of this is
|
||||
* less clear than it otherwise should be.
|
||||
*/
|
||||
|
||||
ENTRY(system_call)
|
||||
pushl %eax # save orig_eax
|
||||
SAVE_ALL
|
||||
GET_CURRENT(%ebx)
|
||||
cmpl $(NR_syscalls),%eax
|
||||
jae badsys
|
||||
testb $0x20,flags(%ebx) # PF_TRACESYS
|
||||
jne tracesys
|
||||
call *SYMBOL_NAME(sys_call_table)(,%eax,4)
|
||||
movl %eax,EAX(%esp) # save the return value
|
||||
ALIGN
|
||||
.globl ret_from_sys_call
|
||||
.globl ret_from_intr
|
||||
ret_from_sys_call:
|
||||
movl SYMBOL_NAME(bh_mask),%eax
|
||||
andl SYMBOL_NAME(bh_active),%eax
|
||||
jne handle_bottom_half
|
||||
ret_with_reschedule:
|
||||
cmpl $0,need_resched(%ebx)
|
||||
jne reschedule
|
||||
cmpl $0,sigpending(%ebx)
|
||||
jne signal_return
|
||||
RESTORE_ALL
|
||||
ALIGN
|
||||
signal_return:
|
||||
testl $(VM_MASK),EFLAGS(%esp)
|
||||
pushl %esp
|
||||
jne v86_signal_return
|
||||
pushl $0
|
||||
call SYMBOL_NAME(do_signal)
|
||||
addl $8,%esp
|
||||
RESTORE_ALL
|
||||
ALIGN
|
||||
v86_signal_return:
|
||||
call SYMBOL_NAME(save_v86_state)
|
||||
movl %eax,%esp
|
||||
pushl %eax
|
||||
pushl $0
|
||||
call SYMBOL_NAME(do_signal)
|
||||
addl $8,%esp
|
||||
RESTORE_ALL
|
||||
ALIGN
|
||||
tracesys:
|
||||
movl $-ENOSYS,EAX(%esp)
|
||||
call SYMBOL_NAME(syscall_trace)
|
||||
movl ORIG_EAX(%esp),%eax
|
||||
call *SYMBOL_NAME(sys_call_table)(,%eax,4)
|
||||
movl %eax,EAX(%esp) # save the return value
|
||||
call SYMBOL_NAME(syscall_trace)
|
||||
jmp ret_from_sys_call
|
||||
badsys:
|
||||
movl $-ENOSYS,EAX(%esp)
|
||||
jmp ret_from_sys_call
|
||||
|
||||
ALIGN
|
||||
ret_from_exception:
|
||||
movl SYMBOL_NAME(bh_mask),%eax
|
||||
andl SYMBOL_NAME(bh_active),%eax
|
||||
jne handle_bottom_half
|
||||
ALIGN
|
||||
ret_from_intr:
|
||||
GET_CURRENT(%ebx)
|
||||
movl EFLAGS(%esp),%eax # mix EFLAGS and CS
|
||||
movb CS(%esp),%al
|
||||
testl $(VM_MASK | 3),%eax # return to VM86 mode or non-supervisor?
|
||||
jne ret_with_reschedule
|
||||
RESTORE_ALL
|
||||
|
||||
ALIGN
|
||||
handle_bottom_half:
|
||||
pushl $ret_from_intr
|
||||
jmp SYMBOL_NAME(do_bottom_half)
|
||||
|
||||
ALIGN
|
||||
reschedule:
|
||||
pushl $ret_from_sys_call
|
||||
jmp SYMBOL_NAME(schedule) # test
|
||||
|
||||
|
||||
ENTRY(divide_error)
|
||||
pushl $0 # no error code
|
||||
pushl $ SYMBOL_NAME(do_divide_error)
|
||||
ALIGN
|
||||
error_code:
|
||||
pushl %ds
|
||||
pushl %eax
|
||||
xorl %eax,%eax
|
||||
pushl %ebp
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
pushl %edx
|
||||
decl %eax # eax = -1
|
||||
pushl %ecx
|
||||
pushl %ebx
|
||||
#if 1
|
||||
xorl %ecx,%ecx # zero ecx
|
||||
cld
|
||||
mov %es,%cx # get the lower order bits of es
|
||||
#else
|
||||
cld
|
||||
# Some older processors leave the top 16 bits of the 32 bit destination
|
||||
# register undefined, rather than zeroed in the following instruction.
|
||||
# This won't matter when restoring or loading a segment register from the
|
||||
# stack. It may be a problem if any code reads the full 32 bit value.
|
||||
# dosemu? kernel? Would somebody like to verify that this way is really OK?
|
||||
movl %es,%cx
|
||||
#endif
|
||||
xchgl %eax, ORIG_EAX(%esp) # orig_eax (get the error code. )
|
||||
movl %esp,%edx
|
||||
xchgl %ecx, ES(%esp) # get the address and save es.
|
||||
pushl %eax # push the error code
|
||||
pushl %edx
|
||||
movl $(__KERNEL_DS),%edx
|
||||
movl %dx,%ds
|
||||
movl %dx,%es
|
||||
GET_CURRENT(%ebx)
|
||||
call *%ecx
|
||||
addl $8,%esp
|
||||
jmp ret_from_exception
|
||||
|
||||
ENTRY(coprocessor_error)
|
||||
pushl $0
|
||||
pushl $ SYMBOL_NAME(do_coprocessor_error)
|
||||
jmp error_code
|
||||
|
||||
ENTRY(device_not_available)
|
||||
pushl $-1 # mark this as an int
|
||||
SAVE_ALL
|
||||
GET_CURRENT(%ebx)
|
||||
pushl $ret_from_exception
|
||||
movl %cr0,%eax
|
||||
testl $0x4,%eax # EM (math emulation bit)
|
||||
je SYMBOL_NAME(math_state_restore)
|
||||
pushl $0 # temporary storage for ORIG_EIP
|
||||
call SYMBOL_NAME(math_emulate)
|
||||
addl $4,%esp
|
||||
ret
|
||||
|
||||
ENTRY(debug)
|
||||
pushl $0
|
||||
pushl $ SYMBOL_NAME(do_debug)
|
||||
jmp error_code
|
||||
|
||||
ENTRY(nmi)
|
||||
pushl $0
|
||||
pushl $ SYMBOL_NAME(do_nmi)
|
||||
jmp error_code
|
||||
|
||||
ENTRY(int3)
|
||||
pushl $0
|
||||
pushl $ SYMBOL_NAME(do_int3)
|
||||
jmp error_code
|
||||
|
||||
ENTRY(overflow)
|
||||
pushl $0
|
||||
pushl $ SYMBOL_NAME(do_overflow)
|
||||
jmp error_code
|
||||
|
||||
ENTRY(bounds)
|
||||
pushl $0
|
||||
pushl $ SYMBOL_NAME(do_bounds)
|
||||
jmp error_code
|
||||
|
||||
ENTRY(invalid_op)
|
||||
pushl $0
|
||||
pushl $ SYMBOL_NAME(do_invalid_op)
|
||||
jmp error_code
|
||||
|
||||
ENTRY(coprocessor_segment_overrun)
|
||||
pushl $0
|
||||
pushl $ SYMBOL_NAME(do_coprocessor_segment_overrun)
|
||||
jmp error_code
|
||||
|
||||
ENTRY(reserved)
|
||||
pushl $0
|
||||
pushl $ SYMBOL_NAME(do_reserved)
|
||||
jmp error_code
|
||||
|
||||
ENTRY(double_fault)
|
||||
pushl $ SYMBOL_NAME(do_double_fault)
|
||||
jmp error_code
|
||||
|
||||
ENTRY(invalid_TSS)
|
||||
pushl $ SYMBOL_NAME(do_invalid_TSS)
|
||||
jmp error_code
|
||||
|
||||
ENTRY(segment_not_present)
|
||||
pushl $ SYMBOL_NAME(do_segment_not_present)
|
||||
jmp error_code
|
||||
|
||||
ENTRY(stack_segment)
|
||||
pushl $ SYMBOL_NAME(do_stack_segment)
|
||||
jmp error_code
|
||||
|
||||
ENTRY(general_protection)
|
||||
pushl $ SYMBOL_NAME(do_general_protection)
|
||||
jmp error_code
|
||||
|
||||
ENTRY(alignment_check)
|
||||
pushl $ SYMBOL_NAME(do_alignment_check)
|
||||
jmp error_code
|
||||
|
||||
ENTRY(page_fault)
|
||||
pushl $ SYMBOL_NAME(do_page_fault)
|
||||
jmp error_code
|
||||
|
||||
ENTRY(spurious_interrupt_bug)
|
||||
pushl $0
|
||||
pushl $ SYMBOL_NAME(do_spurious_interrupt_bug)
|
||||
jmp error_code
|
||||
|
||||
.data
|
||||
ENTRY(sys_call_table)
|
||||
.long SYMBOL_NAME(sys_setup) /* 0 */
|
||||
.long SYMBOL_NAME(sys_exit)
|
||||
.long SYMBOL_NAME(sys_fork)
|
||||
.long SYMBOL_NAME(sys_read)
|
||||
.long SYMBOL_NAME(sys_write)
|
||||
.long SYMBOL_NAME(sys_open) /* 5 */
|
||||
.long SYMBOL_NAME(sys_close)
|
||||
.long SYMBOL_NAME(sys_waitpid)
|
||||
.long SYMBOL_NAME(sys_creat)
|
||||
.long SYMBOL_NAME(sys_link)
|
||||
.long SYMBOL_NAME(sys_unlink) /* 10 */
|
||||
.long SYMBOL_NAME(sys_execve)
|
||||
.long SYMBOL_NAME(sys_chdir)
|
||||
.long SYMBOL_NAME(sys_time)
|
||||
.long SYMBOL_NAME(sys_mknod)
|
||||
.long SYMBOL_NAME(sys_chmod) /* 15 */
|
||||
.long SYMBOL_NAME(sys_lchown)
|
||||
.long SYMBOL_NAME(sys_ni_syscall) /* old break syscall holder */
|
||||
.long SYMBOL_NAME(sys_stat)
|
||||
.long SYMBOL_NAME(sys_lseek)
|
||||
.long SYMBOL_NAME(sys_getpid) /* 20 */
|
||||
.long SYMBOL_NAME(sys_mount)
|
||||
.long SYMBOL_NAME(sys_umount)
|
||||
.long SYMBOL_NAME(sys_setuid)
|
||||
.long SYMBOL_NAME(sys_getuid)
|
||||
.long SYMBOL_NAME(sys_stime) /* 25 */
|
||||
.long SYMBOL_NAME(sys_ptrace)
|
||||
.long SYMBOL_NAME(sys_alarm)
|
||||
.long SYMBOL_NAME(sys_fstat)
|
||||
.long SYMBOL_NAME(sys_pause)
|
||||
.long SYMBOL_NAME(sys_utime) /* 30 */
|
||||
.long SYMBOL_NAME(sys_ni_syscall) /* old stty syscall holder */
|
||||
.long SYMBOL_NAME(sys_ni_syscall) /* old gtty syscall holder */
|
||||
.long SYMBOL_NAME(sys_access)
|
||||
.long SYMBOL_NAME(sys_nice)
|
||||
.long SYMBOL_NAME(sys_ni_syscall) /* 35 */ /* old ftime syscall holder */
|
||||
.long SYMBOL_NAME(sys_sync)
|
||||
.long SYMBOL_NAME(sys_kill)
|
||||
.long SYMBOL_NAME(sys_rename)
|
||||
.long SYMBOL_NAME(sys_mkdir)
|
||||
.long SYMBOL_NAME(sys_rmdir) /* 40 */
|
||||
.long SYMBOL_NAME(sys_dup)
|
||||
.long SYMBOL_NAME(sys_pipe)
|
||||
.long SYMBOL_NAME(sys_times)
|
||||
.long SYMBOL_NAME(sys_ni_syscall) /* old prof syscall holder */
|
||||
.long SYMBOL_NAME(sys_brk) /* 45 */
|
||||
.long SYMBOL_NAME(sys_setgid)
|
||||
.long SYMBOL_NAME(sys_getgid)
|
||||
.long SYMBOL_NAME(sys_signal)
|
||||
.long SYMBOL_NAME(sys_geteuid)
|
||||
.long SYMBOL_NAME(sys_getegid) /* 50 */
|
||||
.long SYMBOL_NAME(sys_acct)
|
||||
.long SYMBOL_NAME(sys_ni_syscall) /* old phys syscall holder */
|
||||
.long SYMBOL_NAME(sys_ni_syscall) /* old lock syscall holder */
|
||||
.long SYMBOL_NAME(sys_ioctl)
|
||||
.long SYMBOL_NAME(sys_fcntl) /* 55 */
|
||||
.long SYMBOL_NAME(sys_ni_syscall) /* old mpx syscall holder */
|
||||
.long SYMBOL_NAME(sys_setpgid)
|
||||
.long SYMBOL_NAME(sys_ni_syscall) /* old ulimit syscall holder */
|
||||
.long SYMBOL_NAME(sys_olduname)
|
||||
.long SYMBOL_NAME(sys_umask) /* 60 */
|
||||
.long SYMBOL_NAME(sys_chroot)
|
||||
.long SYMBOL_NAME(sys_ustat)
|
||||
.long SYMBOL_NAME(sys_dup2)
|
||||
.long SYMBOL_NAME(sys_getppid)
|
||||
.long SYMBOL_NAME(sys_getpgrp) /* 65 */
|
||||
.long SYMBOL_NAME(sys_setsid)
|
||||
.long SYMBOL_NAME(sys_sigaction)
|
||||
.long SYMBOL_NAME(sys_sgetmask)
|
||||
.long SYMBOL_NAME(sys_ssetmask)
|
||||
.long SYMBOL_NAME(sys_setreuid) /* 70 */
|
||||
.long SYMBOL_NAME(sys_setregid)
|
||||
.long SYMBOL_NAME(sys_sigsuspend)
|
||||
.long SYMBOL_NAME(sys_sigpending)
|
||||
.long SYMBOL_NAME(sys_sethostname)
|
||||
.long SYMBOL_NAME(sys_setrlimit) /* 75 */
|
||||
.long SYMBOL_NAME(sys_getrlimit)
|
||||
.long SYMBOL_NAME(sys_getrusage)
|
||||
.long SYMBOL_NAME(sys_gettimeofday)
|
||||
.long SYMBOL_NAME(sys_settimeofday)
|
||||
.long SYMBOL_NAME(sys_getgroups) /* 80 */
|
||||
.long SYMBOL_NAME(sys_setgroups)
|
||||
.long SYMBOL_NAME(old_select)
|
||||
.long SYMBOL_NAME(sys_symlink)
|
||||
.long SYMBOL_NAME(sys_lstat)
|
||||
.long SYMBOL_NAME(sys_readlink) /* 85 */
|
||||
.long SYMBOL_NAME(sys_uselib)
|
||||
.long SYMBOL_NAME(sys_swapon)
|
||||
.long SYMBOL_NAME(sys_reboot)
|
||||
.long SYMBOL_NAME(old_readdir)
|
||||
.long SYMBOL_NAME(old_mmap) /* 90 */
|
||||
.long SYMBOL_NAME(sys_munmap)
|
||||
.long SYMBOL_NAME(sys_truncate)
|
||||
.long SYMBOL_NAME(sys_ftruncate)
|
||||
.long SYMBOL_NAME(sys_fchmod)
|
||||
.long SYMBOL_NAME(sys_fchown) /* 95 */
|
||||
.long SYMBOL_NAME(sys_getpriority)
|
||||
.long SYMBOL_NAME(sys_setpriority)
|
||||
.long SYMBOL_NAME(sys_ni_syscall) /* old profil syscall holder */
|
||||
.long SYMBOL_NAME(sys_statfs)
|
||||
.long SYMBOL_NAME(sys_fstatfs) /* 100 */
|
||||
.long SYMBOL_NAME(sys_ioperm)
|
||||
.long SYMBOL_NAME(sys_socketcall)
|
||||
.long SYMBOL_NAME(sys_syslog)
|
||||
.long SYMBOL_NAME(sys_setitimer)
|
||||
.long SYMBOL_NAME(sys_getitimer) /* 105 */
|
||||
.long SYMBOL_NAME(sys_newstat)
|
||||
.long SYMBOL_NAME(sys_newlstat)
|
||||
.long SYMBOL_NAME(sys_newfstat)
|
||||
.long SYMBOL_NAME(sys_uname)
|
||||
.long SYMBOL_NAME(sys_iopl) /* 110 */
|
||||
.long SYMBOL_NAME(sys_vhangup)
|
||||
.long SYMBOL_NAME(sys_idle)
|
||||
.long SYMBOL_NAME(sys_vm86old)
|
||||
.long SYMBOL_NAME(sys_wait4)
|
||||
.long SYMBOL_NAME(sys_swapoff) /* 115 */
|
||||
.long SYMBOL_NAME(sys_sysinfo)
|
||||
.long SYMBOL_NAME(sys_ipc)
|
||||
.long SYMBOL_NAME(sys_fsync)
|
||||
.long SYMBOL_NAME(sys_sigreturn)
|
||||
.long SYMBOL_NAME(sys_clone) /* 120 */
|
||||
.long SYMBOL_NAME(sys_setdomainname)
|
||||
.long SYMBOL_NAME(sys_newuname)
|
||||
.long SYMBOL_NAME(sys_modify_ldt)
|
||||
.long SYMBOL_NAME(sys_adjtimex)
|
||||
.long SYMBOL_NAME(sys_mprotect) /* 125 */
|
||||
.long SYMBOL_NAME(sys_sigprocmask)
|
||||
.long SYMBOL_NAME(sys_create_module)
|
||||
.long SYMBOL_NAME(sys_init_module)
|
||||
.long SYMBOL_NAME(sys_delete_module)
|
||||
.long SYMBOL_NAME(sys_get_kernel_syms) /* 130 */
|
||||
.long SYMBOL_NAME(sys_quotactl)
|
||||
.long SYMBOL_NAME(sys_getpgid)
|
||||
.long SYMBOL_NAME(sys_fchdir)
|
||||
.long SYMBOL_NAME(sys_bdflush)
|
||||
.long SYMBOL_NAME(sys_sysfs) /* 135 */
|
||||
.long SYMBOL_NAME(sys_personality)
|
||||
.long SYMBOL_NAME(sys_ni_syscall) /* for afs_syscall */
|
||||
.long SYMBOL_NAME(sys_setfsuid)
|
||||
.long SYMBOL_NAME(sys_setfsgid)
|
||||
.long SYMBOL_NAME(sys_llseek) /* 140 */
|
||||
.long SYMBOL_NAME(sys_getdents)
|
||||
.long SYMBOL_NAME(sys_select)
|
||||
.long SYMBOL_NAME(sys_flock)
|
||||
.long SYMBOL_NAME(sys_msync)
|
||||
.long SYMBOL_NAME(sys_readv) /* 145 */
|
||||
.long SYMBOL_NAME(sys_writev)
|
||||
.long SYMBOL_NAME(sys_getsid)
|
||||
.long SYMBOL_NAME(sys_fdatasync)
|
||||
.long SYMBOL_NAME(sys_sysctl)
|
||||
.long SYMBOL_NAME(sys_mlock) /* 150 */
|
||||
.long SYMBOL_NAME(sys_munlock)
|
||||
.long SYMBOL_NAME(sys_mlockall)
|
||||
.long SYMBOL_NAME(sys_munlockall)
|
||||
.long SYMBOL_NAME(sys_sched_setparam)
|
||||
.long SYMBOL_NAME(sys_sched_getparam) /* 155 */
|
||||
.long SYMBOL_NAME(sys_sched_setscheduler)
|
||||
.long SYMBOL_NAME(sys_sched_getscheduler)
|
||||
.long SYMBOL_NAME(sys_sched_yield)
|
||||
.long SYMBOL_NAME(sys_sched_get_priority_max)
|
||||
.long SYMBOL_NAME(sys_sched_get_priority_min) /* 160 */
|
||||
.long SYMBOL_NAME(sys_sched_rr_get_interval)
|
||||
.long SYMBOL_NAME(sys_nanosleep)
|
||||
.long SYMBOL_NAME(sys_mremap)
|
||||
.long SYMBOL_NAME(sys_setresuid)
|
||||
.long SYMBOL_NAME(sys_getresuid) /* 165 */
|
||||
.long SYMBOL_NAME(sys_vm86)
|
||||
.long SYMBOL_NAME(sys_query_module)
|
||||
.long SYMBOL_NAME(sys_poll)
|
||||
.long SYMBOL_NAME(sys_nfsservctl)
|
||||
.long SYMBOL_NAME(sys_setresgid) /* 170 */
|
||||
.long SYMBOL_NAME(sys_getresgid)
|
||||
.long SYMBOL_NAME(sys_prctl)
|
||||
.long SYMBOL_NAME(sys_rt_sigreturn)
|
||||
.long SYMBOL_NAME(sys_rt_sigaction)
|
||||
.long SYMBOL_NAME(sys_rt_sigprocmask) /* 175 */
|
||||
.long SYMBOL_NAME(sys_rt_sigpending)
|
||||
.long SYMBOL_NAME(sys_rt_sigtimedwait)
|
||||
.long SYMBOL_NAME(sys_rt_sigqueueinfo)
|
||||
.long SYMBOL_NAME(sys_rt_sigsuspend)
|
||||
.long SYMBOL_NAME(sys_pread) /* 180 */
|
||||
.long SYMBOL_NAME(sys_pwrite)
|
||||
.long SYMBOL_NAME(sys_chown)
|
||||
.long SYMBOL_NAME(sys_getcwd)
|
||||
.long SYMBOL_NAME(sys_capget)
|
||||
.long SYMBOL_NAME(sys_capset) /* 185 */
|
||||
.long SYMBOL_NAME(sys_sigaltstack)
|
||||
.long SYMBOL_NAME(sys_sendfile)
|
||||
.long SYMBOL_NAME(sys_ni_syscall) /* streams1 */
|
||||
.long SYMBOL_NAME(sys_ni_syscall) /* streams2 */
|
||||
.long SYMBOL_NAME(sys_table) /* 190 */
|
||||
|
||||
.rept NR_syscalls-190
|
||||
.long SYMBOL_NAME(sys_ni_syscall)
|
||||
.endr
|
61
kernel/table21/main.c
Normal file
61
kernel/table21/main.c
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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 <linux/slab.h>
|
||||
#include <linux/smp.h>
|
||||
#include <linux/signal.h>
|
||||
|
||||
#include <asm/uaccess.h>
|
||||
#include <asm/pgtable.h>
|
||||
#include <asm/io.h>
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/table.h>
|
||||
|
||||
#include "version.h"
|
||||
|
||||
extern void scheduling_functions_start_here(void);
|
||||
extern void scheduling_functions_end_here(void);
|
||||
|
||||
int (*table_function_ptr) (int, union table *, const void *) = 0;
|
||||
|
||||
EXPORT_SYMBOL(table_function_ptr);
|
||||
|
||||
EXPORT_SYMBOL(nr_running);
|
||||
EXPORT_SYMBOL(pidhash);
|
||||
EXPORT_SYMBOL(task);
|
||||
EXPORT_SYMBOL(si_swapinfo);
|
||||
EXPORT_SYMBOL(scheduling_functions_start_here);
|
||||
EXPORT_SYMBOL(scheduling_functions_end_here);
|
||||
EXPORT_SYMBOL(avenrun);
|
||||
EXPORT_SYMBOL(nr_tasks);
|
||||
EXPORT_SYMBOL(last_pid);
|
||||
EXPORT_SYMBOL(page_cache_size);
|
||||
EXPORT_SYMBOL(init_mm);
|
||||
|
||||
asmlinkage int
|
||||
sys_table (int type, union table *buf, const void *param)
|
||||
{
|
||||
if (table_function_ptr == 0)
|
||||
return -ENOSYS;
|
||||
|
||||
return (*table_function_ptr) (type, buf, param);
|
||||
}
|
607
kernel/table21/module.c
Normal file
607
kernel/table21/module.c
Normal file
@@ -0,0 +1,607 @@
|
||||
/*
|
||||
* 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 <linux/slab.h>
|
||||
#include <linux/smp.h>
|
||||
#include <linux/signal.h>
|
||||
|
||||
#include <asm/uaccess.h>
|
||||
#include <asm/pgtable.h>
|
||||
#include <asm/io.h>
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/table.h>
|
||||
|
||||
#include "version.h"
|
||||
|
||||
extern int (*table_function_ptr) (int, union table *, const void *);
|
||||
|
||||
int table_fkt (int, union table *, const void *);
|
||||
|
||||
EXPORT_NO_SYMBOLS;
|
||||
|
||||
int
|
||||
init_module(void)
|
||||
{
|
||||
printk ("init_module () = %p - %d, %d\n",
|
||||
table_fkt, sizeof (union table), sizeof (sigset_t));
|
||||
table_function_ptr = table_fkt;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
cleanup_module(void)
|
||||
{
|
||||
table_function_ptr = 0;
|
||||
}
|
||||
|
||||
#define LOAD_INT(x) ((x) >> FSHIFT)
|
||||
#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
|
||||
|
||||
#ifdef CONFIG_DEBUG_MALLOC
|
||||
int get_malloc(char * buffer);
|
||||
#endif
|
||||
|
||||
static void collect_sigign_sigcatch(struct task_struct *p, sigset_t *ign,
|
||||
sigset_t *catch)
|
||||
{
|
||||
struct k_sigaction *k;
|
||||
int i;
|
||||
|
||||
sigemptyset(ign);
|
||||
sigemptyset(catch);
|
||||
|
||||
#if 0
|
||||
printk ("collect_sigign_sigcatch: %p - %p\n",
|
||||
p, p->sig);
|
||||
#endif
|
||||
|
||||
if (p->sig) {
|
||||
k = p->sig->action;
|
||||
for (i = 1; i <= _NSIG; ++i, ++k) {
|
||||
#if 0
|
||||
printk ("signal: %d - %p (%p, %p)\n",
|
||||
i, k->sa.sa_handler, SIG_IGN, SIG_DFL);
|
||||
#endif
|
||||
if (k->sa.sa_handler == SIG_IGN)
|
||||
sigaddset(ign, i);
|
||||
else if (k->sa.sa_handler != SIG_DFL)
|
||||
sigaddset(catch, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* These bracket the sleeping functions..
|
||||
*/
|
||||
extern void scheduling_functions_start_here(void);
|
||||
extern void scheduling_functions_end_here(void);
|
||||
#define first_sched ((unsigned long) scheduling_functions_start_here)
|
||||
#define last_sched ((unsigned long) scheduling_functions_end_here)
|
||||
|
||||
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 = 4096 + (unsigned long)p;
|
||||
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 < first_sched || eip >= last_sched)
|
||||
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 >= first_sched && pc < last_sched) {
|
||||
schedule_frame = ((unsigned long *)p->tss.ksp)[6];
|
||||
return ((unsigned long *)schedule_frame)[12];
|
||||
}
|
||||
return pc;
|
||||
}
|
||||
#elif defined(__mc68000__)
|
||||
{
|
||||
unsigned long fp, pc;
|
||||
unsigned long stack_page;
|
||||
int count = 0;
|
||||
extern int sys_pause (void);
|
||||
|
||||
stack_page = p->kernel_stack_page;
|
||||
if (!stack_page)
|
||||
return 0;
|
||||
fp = ((struct switch_stack *)p->tss.ksp)->a6;
|
||||
do {
|
||||
if (fp < stack_page || fp >= 4088+stack_page)
|
||||
return 0;
|
||||
pc = ((unsigned long *)fp)[1];
|
||||
/* FIXME: This depends on the order of these functions. */
|
||||
if (pc < first_sched || pc >= last_sched)
|
||||
return pc;
|
||||
fp = *(unsigned long *) fp;
|
||||
} while (count++ < 16);
|
||||
}
|
||||
#elif defined(__powerpc__)
|
||||
return (p->tss.wchan);
|
||||
#elif defined (CONFIG_ARM)
|
||||
{
|
||||
unsigned long fp, lr;
|
||||
unsigned long stack_page;
|
||||
int count = 0;
|
||||
|
||||
stack_page = 4096 + (unsigned long)p;
|
||||
fp = get_css_fp (&p->tss);
|
||||
do {
|
||||
if (fp < stack_page || fp > 4092+stack_page)
|
||||
return 0;
|
||||
lr = pc_pointer (((unsigned long *)fp)[-1]);
|
||||
if (lr < first_sched || lr > last_sched)
|
||||
return lr;
|
||||
fp = *(unsigned long *) (fp - 12);
|
||||
} while (count ++ < 16);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(__i386__)
|
||||
# define KSTK_EIP(tsk) (((unsigned long *)(4096+(unsigned long)(tsk)))[1019])
|
||||
# define KSTK_ESP(tsk) (((unsigned long *)(4096+(unsigned long)(tsk)))[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 *)(PT_REG(pc) + PAGE_SIZE + (unsigned long)(tsk)))
|
||||
# define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->tss.usp)
|
||||
#elif defined(CONFIG_ARM)
|
||||
# define KSTK_EIP(tsk) (((unsigned long *)(4096+(unsigned long)(tsk)))[1022])
|
||||
# define KSTK_ESP(tsk) (((unsigned long *)(4096+(unsigned long)(tsk)))[1020])
|
||||
#elif defined(__mc68000__)
|
||||
#define KSTK_EIP(tsk) \
|
||||
({ \
|
||||
unsigned long eip = 0; \
|
||||
if ((tsk)->tss.esp0 > PAGE_SIZE && \
|
||||
MAP_NR((tsk)->tss.esp0) < max_mapnr) \
|
||||
eip = ((struct pt_regs *) (tsk)->tss.esp0)->pc; \
|
||||
eip; })
|
||||
#define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->tss.usp)
|
||||
#elif defined(__powerpc__)
|
||||
#define KSTK_EIP(tsk) ((tsk)->tss.regs->nip)
|
||||
#define KSTK_ESP(tsk) ((tsk)->tss.regs->gpr[1])
|
||||
#elif defined (__sparc_v9__)
|
||||
# define KSTK_EIP(tsk) ((tsk)->tss.kregs->tpc)
|
||||
# define KSTK_ESP(tsk) ((tsk)->tss.kregs->u_regs[UREG_FP])
|
||||
#elif defined(__sparc__)
|
||||
# define KSTK_EIP(tsk) ((tsk)->tss.kregs->pc)
|
||||
# define KSTK_ESP(tsk) ((tsk)->tss.kregs->u_regs[UREG_FP])
|
||||
#endif
|
||||
|
||||
/* Gcc optimizes away "strlen(x)" for constant x */
|
||||
#define ADDBUF(buffer, string) \
|
||||
do { memcpy(buffer, string, strlen(string)); \
|
||||
buffer += strlen(string); } while (0)
|
||||
|
||||
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 (MAP_NR(pte_page(page)) >= max_mapnr)
|
||||
continue;
|
||||
if (atomic_read(&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++;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
table_fkt (int type, union table *buf, const void *param)
|
||||
{
|
||||
union table tbl;
|
||||
struct sysinfo i;
|
||||
struct task_struct *tsk = NULL;
|
||||
struct proclist_args plistargs;
|
||||
int index, tindex, err, tty;
|
||||
sigset_t sigign, sigcatch;
|
||||
pid_t pid;
|
||||
|
||||
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;
|
||||
copy_from_user (&pid, param, sizeof (pid_t));
|
||||
|
||||
read_lock (&tasklist_lock);
|
||||
tsk = find_task_by_pid (pid);
|
||||
/* FIXME!! This should be done after the last use */
|
||||
read_unlock(&tasklist_lock);
|
||||
|
||||
if (tsk == NULL)
|
||||
return -ESRCH;
|
||||
break;
|
||||
case TABLE_PROCLIST:
|
||||
err = verify_area (VERIFY_READ, param,
|
||||
sizeof (struct proclist_args));
|
||||
if (err)
|
||||
return err;
|
||||
copy_from_user (&plistargs, param,
|
||||
sizeof (struct proclist_args));
|
||||
break;
|
||||
}
|
||||
|
||||
/* Main function dispatcher */
|
||||
|
||||
switch (type) {
|
||||
case TABLE_PROCLIST:
|
||||
tsk = task [0];
|
||||
read_lock (&tasklist_lock);
|
||||
for (index = tindex = 0; index < nr_tasks;
|
||||
index++, tsk = tsk->next_task) {
|
||||
if (tsk->pid == 0) continue;
|
||||
switch (plistargs.which & TABLE_KERN_PROC_MASK) {
|
||||
case TABLE_KERN_PROC_PID:
|
||||
if (tsk->pid != plistargs.arg) continue;
|
||||
break;
|
||||
case TABLE_KERN_PROC_PGRP:
|
||||
if (tsk->pgrp != plistargs.arg) continue;
|
||||
break;
|
||||
case TABLE_KERN_PROC_SESSION:
|
||||
if (tsk->session != plistargs.arg) continue;
|
||||
case TABLE_KERN_PROC_TTY:
|
||||
tty = tsk->tty ?
|
||||
kdev_t_to_nr (tsk->tty->device) : 0;
|
||||
if (tty != plistargs.arg) continue;
|
||||
break;
|
||||
case TABLE_KERN_PROC_UID:
|
||||
if (tsk->uid != plistargs.arg) continue;
|
||||
break;
|
||||
case TABLE_KERN_PROC_RUID:
|
||||
if (tsk->euid != plistargs.arg) continue;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((plistargs.which & TABLE_EXCLUDE_IDLE) &&
|
||||
(tsk->state != 0))
|
||||
continue;
|
||||
|
||||
if ((plistargs.which & TABLE_EXCLUDE_NOTTY) &&
|
||||
(tsk->tty == NULL))
|
||||
continue;
|
||||
|
||||
tbl.proclist.pids [tindex++] = tsk->pid;
|
||||
}
|
||||
tbl.proclist.nr_running = nr_running;
|
||||
tbl.proclist.last_pid = last_pid;
|
||||
tbl.proclist.nr_tasks = tindex;
|
||||
read_unlock(&tasklist_lock);
|
||||
break;
|
||||
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]->times.tms_utime +
|
||||
task[0]->times.tms_stime;
|
||||
break;
|
||||
case TABLE_PROC_STATE:
|
||||
tbl.proc_state.uid = tsk->uid;
|
||||
tbl.proc_state.gid = tsk->gid;
|
||||
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:
|
||||
memcpy (&tbl.proc_signal.signal, &tsk->signal,
|
||||
sizeof (tbl.proc_signal.signal));
|
||||
|
||||
memcpy (&tbl.proc_signal.blocked, &tsk->blocked,
|
||||
sizeof (tbl.proc_signal.blocked));
|
||||
|
||||
collect_sigign_sigcatch (tsk, &sigign, &sigcatch);
|
||||
|
||||
memcpy (&tbl.proc_signal.ignored, &sigign,
|
||||
sizeof (tbl.proc_signal.ignored));
|
||||
|
||||
memcpy (&tbl.proc_signal.caught, &sigcatch,
|
||||
sizeof (tbl.proc_signal.caught));
|
||||
|
||||
#if 0
|
||||
printk ("PROC_SIGNAL: (%lu, %lu) - (%lu, %lu)\n",
|
||||
tbl.proc_signal.ignored.sig [0],
|
||||
tbl.proc_signal.ignored.sig [1],
|
||||
tbl.proc_signal.caught.sig [0],
|
||||
tbl.proc_signal.caught.sig [1]);
|
||||
#endif
|
||||
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->mmap ?
|
||||
tsk->mm->mmap->vm_start : 0;
|
||||
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 << PAGE_SHIFT;
|
||||
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, srs = 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;
|
||||
|
||||
/* Well, shared library seem to get mapped
|
||||
* above 0x40000000 and are executable,
|
||||
* so I use this hack to get their size.
|
||||
*/
|
||||
|
||||
if (vma->vm_flags & VM_GROWSDOWN)
|
||||
srs += pages; /* stack */
|
||||
else if ((vma->vm_flags & VM_EXEC) &&
|
||||
(vma->vm_start > 0x40000000))
|
||||
lrs += pages; /* library */
|
||||
else if (vma->vm_flags & VM_EXECUTABLE)
|
||||
trs += pages; /* text */
|
||||
else
|
||||
drs += pages;
|
||||
|
||||
vma = vma->vm_next;
|
||||
}
|
||||
|
||||
tbl.proc_segment.vsize = vsize;
|
||||
tbl.proc_segment.size = size << PAGE_SHIFT;
|
||||
tbl.proc_segment.resident = resident << PAGE_SHIFT;
|
||||
tbl.proc_segment.shared = share << PAGE_SHIFT;
|
||||
tbl.proc_segment.trs = trs << PAGE_SHIFT;
|
||||
tbl.proc_segment.lrs = lrs << PAGE_SHIFT;
|
||||
tbl.proc_segment.drs = drs << PAGE_SHIFT;
|
||||
tbl.proc_segment.srs = srs << PAGE_SHIFT;
|
||||
tbl.proc_segment.dt = dt << PAGE_SHIFT;
|
||||
}
|
||||
break;
|
||||
case TABLE_PROC_TIME:
|
||||
tbl.proc_time.utime = tsk->times.tms_utime;
|
||||
tbl.proc_time.stime = tsk->times.tms_stime;
|
||||
tbl.proc_time.cutime = tsk->times.tms_cutime;
|
||||
tbl.proc_time.cstime = tsk->times.tms_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 = KSTK_ESP(tsk);
|
||||
tbl.proc_kernel.keip = KSTK_EIP(tsk);
|
||||
|
||||
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;
|
||||
|
||||
copy_to_user (buf, &tbl, sizeof (union table));
|
||||
|
||||
return 0;
|
||||
}
|
344
kernel/table21/unistd-i386.h
Normal file
344
kernel/table21/unistd-i386.h
Normal file
@@ -0,0 +1,344 @@
|
||||
#ifndef _ASM_I386_UNISTD_H_
|
||||
#define _ASM_I386_UNISTD_H_
|
||||
|
||||
/*
|
||||
* This file contains the system call numbers.
|
||||
*/
|
||||
|
||||
#define __NR_setup 0 /* used only by init, to get system going */
|
||||
#define __NR_exit 1
|
||||
#define __NR_fork 2
|
||||
#define __NR_read 3
|
||||
#define __NR_write 4
|
||||
#define __NR_open 5
|
||||
#define __NR_close 6
|
||||
#define __NR_waitpid 7
|
||||
#define __NR_creat 8
|
||||
#define __NR_link 9
|
||||
#define __NR_unlink 10
|
||||
#define __NR_execve 11
|
||||
#define __NR_chdir 12
|
||||
#define __NR_time 13
|
||||
#define __NR_mknod 14
|
||||
#define __NR_chmod 15
|
||||
#define __NR_lchown 16
|
||||
#define __NR_break 17
|
||||
#define __NR_oldstat 18
|
||||
#define __NR_lseek 19
|
||||
#define __NR_getpid 20
|
||||
#define __NR_mount 21
|
||||
#define __NR_umount 22
|
||||
#define __NR_setuid 23
|
||||
#define __NR_getuid 24
|
||||
#define __NR_stime 25
|
||||
#define __NR_ptrace 26
|
||||
#define __NR_alarm 27
|
||||
#define __NR_oldfstat 28
|
||||
#define __NR_pause 29
|
||||
#define __NR_utime 30
|
||||
#define __NR_stty 31
|
||||
#define __NR_gtty 32
|
||||
#define __NR_access 33
|
||||
#define __NR_nice 34
|
||||
#define __NR_ftime 35
|
||||
#define __NR_sync 36
|
||||
#define __NR_kill 37
|
||||
#define __NR_rename 38
|
||||
#define __NR_mkdir 39
|
||||
#define __NR_rmdir 40
|
||||
#define __NR_dup 41
|
||||
#define __NR_pipe 42
|
||||
#define __NR_times 43
|
||||
#define __NR_prof 44
|
||||
#define __NR_brk 45
|
||||
#define __NR_setgid 46
|
||||
#define __NR_getgid 47
|
||||
#define __NR_signal 48
|
||||
#define __NR_geteuid 49
|
||||
#define __NR_getegid 50
|
||||
#define __NR_acct 51
|
||||
#define __NR_phys 52
|
||||
#define __NR_lock 53
|
||||
#define __NR_ioctl 54
|
||||
#define __NR_fcntl 55
|
||||
#define __NR_mpx 56
|
||||
#define __NR_setpgid 57
|
||||
#define __NR_ulimit 58
|
||||
#define __NR_oldolduname 59
|
||||
#define __NR_umask 60
|
||||
#define __NR_chroot 61
|
||||
#define __NR_ustat 62
|
||||
#define __NR_dup2 63
|
||||
#define __NR_getppid 64
|
||||
#define __NR_getpgrp 65
|
||||
#define __NR_setsid 66
|
||||
#define __NR_sigaction 67
|
||||
#define __NR_sgetmask 68
|
||||
#define __NR_ssetmask 69
|
||||
#define __NR_setreuid 70
|
||||
#define __NR_setregid 71
|
||||
#define __NR_sigsuspend 72
|
||||
#define __NR_sigpending 73
|
||||
#define __NR_sethostname 74
|
||||
#define __NR_setrlimit 75
|
||||
#define __NR_getrlimit 76
|
||||
#define __NR_getrusage 77
|
||||
#define __NR_gettimeofday 78
|
||||
#define __NR_settimeofday 79
|
||||
#define __NR_getgroups 80
|
||||
#define __NR_setgroups 81
|
||||
#define __NR_select 82
|
||||
#define __NR_symlink 83
|
||||
#define __NR_oldlstat 84
|
||||
#define __NR_readlink 85
|
||||
#define __NR_uselib 86
|
||||
#define __NR_swapon 87
|
||||
#define __NR_reboot 88
|
||||
#define __NR_readdir 89
|
||||
#define __NR_mmap 90
|
||||
#define __NR_munmap 91
|
||||
#define __NR_truncate 92
|
||||
#define __NR_ftruncate 93
|
||||
#define __NR_fchmod 94
|
||||
#define __NR_fchown 95
|
||||
#define __NR_getpriority 96
|
||||
#define __NR_setpriority 97
|
||||
#define __NR_profil 98
|
||||
#define __NR_statfs 99
|
||||
#define __NR_fstatfs 100
|
||||
#define __NR_ioperm 101
|
||||
#define __NR_socketcall 102
|
||||
#define __NR_syslog 103
|
||||
#define __NR_setitimer 104
|
||||
#define __NR_getitimer 105
|
||||
#define __NR_stat 106
|
||||
#define __NR_lstat 107
|
||||
#define __NR_fstat 108
|
||||
#define __NR_olduname 109
|
||||
#define __NR_iopl 110
|
||||
#define __NR_vhangup 111
|
||||
#define __NR_idle 112
|
||||
#define __NR_vm86old 113
|
||||
#define __NR_wait4 114
|
||||
#define __NR_swapoff 115
|
||||
#define __NR_sysinfo 116
|
||||
#define __NR_ipc 117
|
||||
#define __NR_fsync 118
|
||||
#define __NR_sigreturn 119
|
||||
#define __NR_clone 120
|
||||
#define __NR_setdomainname 121
|
||||
#define __NR_uname 122
|
||||
#define __NR_modify_ldt 123
|
||||
#define __NR_adjtimex 124
|
||||
#define __NR_mprotect 125
|
||||
#define __NR_sigprocmask 126
|
||||
#define __NR_create_module 127
|
||||
#define __NR_init_module 128
|
||||
#define __NR_delete_module 129
|
||||
#define __NR_get_kernel_syms 130
|
||||
#define __NR_quotactl 131
|
||||
#define __NR_getpgid 132
|
||||
#define __NR_fchdir 133
|
||||
#define __NR_bdflush 134
|
||||
#define __NR_sysfs 135
|
||||
#define __NR_personality 136
|
||||
#define __NR_afs_syscall 137 /* Syscall for Andrew File System */
|
||||
#define __NR_setfsuid 138
|
||||
#define __NR_setfsgid 139
|
||||
#define __NR__llseek 140
|
||||
#define __NR_getdents 141
|
||||
#define __NR__newselect 142
|
||||
#define __NR_flock 143
|
||||
#define __NR_msync 144
|
||||
#define __NR_readv 145
|
||||
#define __NR_writev 146
|
||||
#define __NR_getsid 147
|
||||
#define __NR_fdatasync 148
|
||||
#define __NR__sysctl 149
|
||||
#define __NR_mlock 150
|
||||
#define __NR_munlock 151
|
||||
#define __NR_mlockall 152
|
||||
#define __NR_munlockall 153
|
||||
#define __NR_sched_setparam 154
|
||||
#define __NR_sched_getparam 155
|
||||
#define __NR_sched_setscheduler 156
|
||||
#define __NR_sched_getscheduler 157
|
||||
#define __NR_sched_yield 158
|
||||
#define __NR_sched_get_priority_max 159
|
||||
#define __NR_sched_get_priority_min 160
|
||||
#define __NR_sched_rr_get_interval 161
|
||||
#define __NR_nanosleep 162
|
||||
#define __NR_mremap 163
|
||||
#define __NR_setresuid 164
|
||||
#define __NR_getresuid 165
|
||||
#define __NR_vm86 166
|
||||
#define __NR_query_module 167
|
||||
#define __NR_poll 168
|
||||
#define __NR_nfsservctl 169
|
||||
#define __NR_setresgid 170
|
||||
#define __NR_getresgid 171
|
||||
#define __NR_prctl 172
|
||||
#define __NR_rt_sigreturn 173
|
||||
#define __NR_rt_sigaction 174
|
||||
#define __NR_rt_sigprocmask 175
|
||||
#define __NR_rt_sigpending 176
|
||||
#define __NR_rt_sigtimedwait 177
|
||||
#define __NR_rt_sigqueueinfo 178
|
||||
#define __NR_rt_sigsuspend 179
|
||||
#define __NR_pread 180
|
||||
#define __NR_pwrite 181
|
||||
#define __NR_chown 182
|
||||
#define __NR_getcwd 183
|
||||
#define __NR_capget 184
|
||||
#define __NR_capset 185
|
||||
#define __NR_sigaltstack 186
|
||||
#define __NR_sendfile 187
|
||||
#define __NR_streams1 188 /* some people actually want it */
|
||||
#define __NR_streams2 189 /* some people actually want it */
|
||||
#define __NR_table 190
|
||||
|
||||
/* user-visible error numbers are in the range -1 - -122: see <asm-i386/errno.h> */
|
||||
|
||||
#define __syscall_return(type, res) \
|
||||
do { \
|
||||
if ((unsigned long)(res) >= (unsigned long)(-125)) { \
|
||||
errno = -(res); \
|
||||
res = -1; \
|
||||
} \
|
||||
return (type) (res); \
|
||||
} while (0)
|
||||
|
||||
/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
|
||||
#define _syscall0(type,name) \
|
||||
type name(void) \
|
||||
{ \
|
||||
long __res; \
|
||||
__asm__ volatile ("int $0x80" \
|
||||
: "=a" (__res) \
|
||||
: "0" (__NR_##name)); \
|
||||
__syscall_return(type,__res); \
|
||||
}
|
||||
|
||||
#define _syscall1(type,name,type1,arg1) \
|
||||
type name(type1 arg1) \
|
||||
{ \
|
||||
long __res; \
|
||||
__asm__ volatile ("int $0x80" \
|
||||
: "=a" (__res) \
|
||||
: "0" (__NR_##name),"b" ((long)(arg1))); \
|
||||
__syscall_return(type,__res); \
|
||||
}
|
||||
|
||||
#define _syscall2(type,name,type1,arg1,type2,arg2) \
|
||||
type name(type1 arg1,type2 arg2) \
|
||||
{ \
|
||||
long __res; \
|
||||
__asm__ volatile ("int $0x80" \
|
||||
: "=a" (__res) \
|
||||
: "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2))); \
|
||||
__syscall_return(type,__res); \
|
||||
}
|
||||
|
||||
#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
|
||||
type name(type1 arg1,type2 arg2,type3 arg3) \
|
||||
{ \
|
||||
long __res; \
|
||||
__asm__ volatile ("int $0x80" \
|
||||
: "=a" (__res) \
|
||||
: "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \
|
||||
"d" ((long)(arg3))); \
|
||||
__syscall_return(type,__res); \
|
||||
}
|
||||
|
||||
#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
|
||||
type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
|
||||
{ \
|
||||
long __res; \
|
||||
__asm__ volatile ("int $0x80" \
|
||||
: "=a" (__res) \
|
||||
: "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \
|
||||
"d" ((long)(arg3)),"S" ((long)(arg4))); \
|
||||
__syscall_return(type,__res); \
|
||||
}
|
||||
|
||||
#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
|
||||
type5,arg5) \
|
||||
type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
|
||||
{ \
|
||||
long __res; \
|
||||
__asm__ volatile ("int $0x80" \
|
||||
: "=a" (__res) \
|
||||
: "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \
|
||||
"d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5))); \
|
||||
__syscall_return(type,__res); \
|
||||
}
|
||||
|
||||
#ifdef __KERNEL_SYSCALLS__
|
||||
|
||||
/*
|
||||
* we need this inline - forking from kernel space will result
|
||||
* in NO COPY ON WRITE (!!!), until an execve is executed. This
|
||||
* is no problem, but for the stack. This is handled by not letting
|
||||
* main() use the stack at all after fork(). Thus, no function
|
||||
* calls - which means inline code for fork too, as otherwise we
|
||||
* would use the stack upon exit from 'fork()'.
|
||||
*
|
||||
* Actually only pause and fork are needed inline, so that there
|
||||
* won't be any messing with the stack from main(), but we define
|
||||
* some others too.
|
||||
*/
|
||||
#define __NR__exit __NR_exit
|
||||
static inline _syscall0(int,idle)
|
||||
static inline _syscall0(int,pause)
|
||||
static inline _syscall1(int,setup,int,magic)
|
||||
static inline _syscall0(int,sync)
|
||||
static inline _syscall0(pid_t,setsid)
|
||||
static inline _syscall3(int,write,int,fd,const char *,buf,off_t,count)
|
||||
static inline _syscall3(int,read,int,fd,char *,buf,off_t,count)
|
||||
static inline _syscall3(off_t,lseek,int,fd,off_t,offset,int,count)
|
||||
static inline _syscall1(int,dup,int,fd)
|
||||
static inline _syscall3(int,execve,const char *,file,char **,argv,char **,envp)
|
||||
static inline _syscall3(int,open,const char *,file,int,flag,int,mode)
|
||||
static inline _syscall1(int,close,int,fd)
|
||||
static inline _syscall1(int,_exit,int,exitcode)
|
||||
static inline _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
|
||||
static inline _syscall1(int,delete_module,const char *,name)
|
||||
|
||||
static inline pid_t wait(int * wait_stat)
|
||||
{
|
||||
return waitpid(-1,wait_stat,0);
|
||||
}
|
||||
|
||||
/*
|
||||
* This is the mechanism for creating a new kernel thread.
|
||||
*
|
||||
* NOTE! Only a kernel-only process(ie the swapper or direct descendants
|
||||
* who haven't done an "execve()") should use this: it will work within
|
||||
* a system call from a "real" process, but the process memory space will
|
||||
* not be free'd until both the parent and the child have exited.
|
||||
*/
|
||||
static inline pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
|
||||
{
|
||||
long retval;
|
||||
|
||||
__asm__ __volatile__(
|
||||
"movl %%esp,%%esi\n\t"
|
||||
"int $0x80\n\t" /* Linux/i386 system call */
|
||||
"cmpl %%esp,%%esi\n\t" /* child or parent? */
|
||||
"je 1f\n\t" /* parent - jump */
|
||||
"pushl %3\n\t" /* push argument */
|
||||
"call *%4\n\t" /* call fn */
|
||||
"movl %2,%0\n\t" /* exit */
|
||||
"int $0x80\n"
|
||||
"1:\t"
|
||||
:"=a" (retval)
|
||||
:"0" (__NR_clone), "i" (__NR_exit),
|
||||
"r" (arg), "r" (fn),
|
||||
"b" (flags | CLONE_VM)
|
||||
:"si");
|
||||
return retval;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _ASM_I386_UNISTD_H_ */
|
1
kernel/table21/version.h
Normal file
1
kernel/table21/version.h
Normal file
@@ -0,0 +1 @@
|
||||
#define _TABLE_VERSION 1
|
@@ -1,85 +0,0 @@
|
||||
#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,21 +1,20 @@
|
||||
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@"\"
|
||||
CFLAGS = -Wall -W @CFLAGS@
|
||||
|
||||
lib_LTLIBRARIES = libgtop.la
|
||||
|
||||
libgtop_la_SOURCES = init.c open.c close.c command.c read.c read_data.c write.c lib.c
|
||||
libgtop_la_SOURCES = init.c open.c close.c command.c read.c \
|
||||
read_data.c write.c lib.c parameter.c \
|
||||
sysdeps.c
|
||||
|
||||
BUILT_SOURCES = lib.c
|
||||
|
||||
lib.c: lib.awk $(top_builddir)/config.h $(top_builddir)/features.def
|
||||
$(AWK) -f $(srcdir)/lib.awk < $(top_builddir)/features.def > lib-t
|
||||
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
|
||||
|
||||
|
24
lib/close.c
24
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_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,49 @@
|
||||
#include <glibtop/xmalloc.h>
|
||||
|
||||
void *
|
||||
glibtop_call_l (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, 0, 0);
|
||||
|
||||
cmnd = glibtop_calloc_r (server, 1, sizeof (glibtop_command));
|
||||
memset (&cmnd, 0, sizeof (glibtop_command));
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
memcpy (&cmnd->server, server, sizeof (glibtop));
|
||||
|
||||
cmnd->command = command;
|
||||
cmnd->size = send_size;
|
||||
|
||||
glibtop_write_l (server, sizeof (glibtop_command), cmnd);
|
||||
glibtop_write_l (server, send_size, send_buf);
|
||||
glibtop_read_l (server, recv_size, recv_buf);
|
||||
|
||||
ptr = glibtop_read_data_l (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;
|
||||
}
|
||||
|
620
lib/gnuclient.c
620
lib/gnuclient.c
@@ -1,620 +0,0 @@
|
||||
/* -*-C-*-
|
||||
Client code to allow local and remote editing of files by XEmacs.
|
||||
Copyright (C) 1989 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995 Sun Microsystems, Inc.
|
||||
Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of XEmacs.
|
||||
|
||||
XEmacs 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.
|
||||
|
||||
XEmacs 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 XEmacs; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
Author: Andy Norman (ange@hplb.hpl.hp.com), based on
|
||||
'etc/emacsclient.c' from the GNU Emacs 18.52 distribution.
|
||||
|
||||
Please mail bugs and suggestions to the author at the above address.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file incorporates new features added by Bob Weiner <weiner@mot.com>,
|
||||
* Darrell Kindred <dkindred@cmu.edu> and Arup Mukherjee <arup@cmu.edu>.
|
||||
* GNUATTACH support added by Ben Wing <wing@xemacs.org>.
|
||||
* 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
|
||||
/* Hand-munged RCS header */
|
||||
static char rcsid [] = "!Header: gnuclient.c,v 2.2 95/12/12 01:39:21 wing nene !";
|
||||
#endif
|
||||
|
||||
#include "gnuserv.h"
|
||||
#include "getopt.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif /* HAVE_STRING_H */
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#if !defined(SYSV_IPC) && !defined(UNIX_DOMAIN_SOCKETS) && \
|
||||
!defined(INTERNET_DOMAIN_SOCKETS)
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
fprintf (stderr, "Sorry, the Emacs server is only "
|
||||
"supported on systems that have\n");
|
||||
fprintf (stderr, "Unix Domain sockets, Internet Domain "
|
||||
"sockets or System V IPC.\n");
|
||||
exit (1);
|
||||
} /* main */
|
||||
#else /* SYSV_IPC || UNIX_DOMAIN_SOCKETS || INTERNET_DOMAIN_SOCKETS */
|
||||
|
||||
static char cwd[MAXPATHLEN+2]; /* current working directory when calculated */
|
||||
static char *cp = NULL; /* ptr into valid bit of cwd above */
|
||||
|
||||
static pid_t emacs_pid; /* Process id for emacs process */
|
||||
|
||||
void initialize_signals (void);
|
||||
|
||||
static void
|
||||
tell_emacs_to_resume (int sig)
|
||||
{
|
||||
char buffer[GSERV_BUFSZ+1];
|
||||
int s; /* socket / msqid to server */
|
||||
int connect_type; /* CONN_UNIX, CONN_INTERNET, or
|
||||
ONN_IPC */
|
||||
|
||||
/* Why is SYSV so retarded? */
|
||||
/* We want emacs to realize that we are resuming */
|
||||
signal(SIGCONT, tell_emacs_to_resume);
|
||||
|
||||
connect_type = make_connection (NULL, (u_short) 0, &s);
|
||||
|
||||
sprintf(buffer,"(gnuserv-eval '(resume-pid-console %d))", (int)getpid());
|
||||
send_string(s, buffer);
|
||||
|
||||
#ifdef SYSV_IPC
|
||||
if (connect_type == (int) CONN_IPC)
|
||||
disconnect_from_ipc_server (s, msgp, FALSE);
|
||||
#else /* !SYSV_IPC */
|
||||
if (connect_type != (int) CONN_IPC)
|
||||
disconnect_from_server (s, FALSE);
|
||||
#endif /* !SYSV_IPC */
|
||||
}
|
||||
|
||||
static void
|
||||
pass_signal_to_emacs (int sig)
|
||||
{
|
||||
if (kill (emacs_pid, sig) == -1)
|
||||
{
|
||||
fprintf (stderr, "gnuattach: Could not pass signal to emacs process\n");
|
||||
exit (1);
|
||||
}
|
||||
initialize_signals ();
|
||||
}
|
||||
|
||||
void
|
||||
initialize_signals ()
|
||||
{
|
||||
/* Set up signal handler to pass relevant signals to emacs process.
|
||||
We used to send SIGSEGV, SIGBUS, SIGPIPE, SIGILL and others to
|
||||
Emacs, but I think it's better not to. I can see no reason why
|
||||
Emacs should SIGSEGV whenever gnuclient SIGSEGV-s, etc. */
|
||||
signal (SIGHUP, pass_signal_to_emacs);
|
||||
signal (SIGQUIT, pass_signal_to_emacs);
|
||||
signal (SIGINT, pass_signal_to_emacs);
|
||||
#ifdef SIGWINCH
|
||||
signal (SIGWINCH, pass_signal_to_emacs);
|
||||
#endif
|
||||
|
||||
/* We want emacs to realize that we are resuming */
|
||||
signal (SIGCONT, tell_emacs_to_resume);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
get_current_working_directory -- return the cwd.
|
||||
*/
|
||||
static char *
|
||||
get_current_working_directory (void)
|
||||
{
|
||||
if (cp == NULL)
|
||||
{ /* haven't calculated it yet */
|
||||
#ifdef BSD
|
||||
if (getwd (cwd) == 0)
|
||||
#else /* !BSD */
|
||||
if (getcwd (cwd,MAXPATHLEN) == NULL)
|
||||
#endif /* !BSD */
|
||||
{
|
||||
perror (progname);
|
||||
fprintf (stderr, "%s: unable to get current working directory\n",
|
||||
progname);
|
||||
exit (1);
|
||||
} /* if */
|
||||
|
||||
/* on some systems, cwd can look like '@machine/' ... */
|
||||
/* ignore everything before the first '/' */
|
||||
for (cp = cwd; *cp && *cp != '/'; ++cp)
|
||||
;
|
||||
|
||||
} /* if */
|
||||
|
||||
return cp;
|
||||
|
||||
} /* get_current_working_directory */
|
||||
|
||||
|
||||
/*
|
||||
filename_expand -- try to convert the given filename into a fully-qualified
|
||||
pathname.
|
||||
*/
|
||||
static void
|
||||
filename_expand (char *fullpath, char *filename)
|
||||
/* fullpath - returned full pathname */
|
||||
/* filename - filename to expand */
|
||||
{
|
||||
int len;
|
||||
|
||||
fullpath[0] = '\0';
|
||||
|
||||
if (filename[0] && filename[0] != '/')
|
||||
{ /* relative filename */
|
||||
strcat (fullpath, get_current_working_directory ());
|
||||
len = strlen (fullpath);
|
||||
|
||||
if (len > 0 && fullpath[len-1] == '/') /* trailing slash already? */
|
||||
; /* yep */
|
||||
else
|
||||
strcat (fullpath, "/"); /* nope, append trailing slash */
|
||||
} /* if */
|
||||
|
||||
strcat (fullpath,filename);
|
||||
|
||||
} /* filename_expand */
|
||||
|
||||
/* Encase the string in quotes, escape all the backslashes and quotes
|
||||
in string. */
|
||||
static char *
|
||||
clean_string (CONST char *s)
|
||||
{
|
||||
int i = 0;
|
||||
char *p, *res;
|
||||
|
||||
for (p = s; *p; p++, i++)
|
||||
{
|
||||
if (*p == '\\' || *p == '\"')
|
||||
++i;
|
||||
else if (*p == '\004')
|
||||
i += 3;
|
||||
}
|
||||
p = res = (char *)malloc (i + 2 + 1);
|
||||
*p++ = '\"';
|
||||
for (; *s; p++, s++)
|
||||
{
|
||||
switch (*s)
|
||||
{
|
||||
case '\\':
|
||||
*p++ = '\\';
|
||||
*p = '\\';
|
||||
break;
|
||||
case '\"':
|
||||
*p++ = '\\';
|
||||
*p = '\"';
|
||||
break;
|
||||
case '\004':
|
||||
*p++ = '\\';
|
||||
*p++ = 'C';
|
||||
*p++ = '-';
|
||||
*p = 'd';
|
||||
break;
|
||||
default:
|
||||
*p = *s;
|
||||
}
|
||||
}
|
||||
*p++ = '\"';
|
||||
*p = '\0';
|
||||
return res;
|
||||
}
|
||||
|
||||
#define GET_ARGUMENT(var, desc) do { \
|
||||
if (*(p + 1)) (var) = p + 1; \
|
||||
else \
|
||||
{ \
|
||||
if (!argv[++i]) \
|
||||
{ \
|
||||
fprintf (stderr, "%s: `%s' must be followed by an argument\n", \
|
||||
progname, desc); \
|
||||
exit (1); \
|
||||
} \
|
||||
(var) = argv[i]; \
|
||||
} \
|
||||
over = 1; \
|
||||
} while (0)
|
||||
|
||||
/* A strdup immitation. */
|
||||
static char *
|
||||
my_strdup (CONST char *s)
|
||||
{
|
||||
char *new = malloc (strlen (s) + 1);
|
||||
if (new)
|
||||
strcpy (new, s);
|
||||
return new;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
int starting_line = 1; /* line to start editing at */
|
||||
char command[MAXPATHLEN+50]; /* emacs command buffer */
|
||||
char fullpath[MAXPATHLEN+1]; /* full pathname to file */
|
||||
char *eval_form = NULL; /* form to evaluate with `-eval' */
|
||||
char *eval_function = NULL; /* function to evaluate with `-f' */
|
||||
char *load_library = NULL; /* library to load */
|
||||
int quick = 0; /* quick edit, don't wait for user to
|
||||
finish */
|
||||
int batch = 0; /* batch mode */
|
||||
int view = 0; /* view only. */
|
||||
int nofiles = 0;
|
||||
int errflg = 0; /* option error */
|
||||
int s; /* socket / msqid to server */
|
||||
int connect_type; /* CONN_UNIX, CONN_INTERNET, or
|
||||
* CONN_IPC */
|
||||
int suppress_windows_system = 0;
|
||||
char *display = NULL;
|
||||
#ifdef INTERNET_DOMAIN_SOCKETS
|
||||
char *hostarg = NULL; /* remote hostname */
|
||||
char *remotearg;
|
||||
char thishost[HOSTNAMSZ]; /* this hostname */
|
||||
char remotepath[MAXPATHLEN+1]; /* remote pathname */
|
||||
char *path;
|
||||
int rflg = 0; /* pathname given on cmdline */
|
||||
char *portarg;
|
||||
u_short port = 0; /* port to server */
|
||||
#endif /* INTERNET_DOMAIN_SOCKETS */
|
||||
#ifdef SYSV_IPC
|
||||
struct msgbuf *msgp; /* message */
|
||||
#endif /* SYSV_IPC */
|
||||
char *tty = NULL;
|
||||
char buffer[GSERV_BUFSZ + 1]; /* buffer to read pid */
|
||||
char result[GSERV_BUFSZ + 1];
|
||||
int i;
|
||||
|
||||
#ifdef INTERNET_DOMAIN_SOCKETS
|
||||
memset (remotepath, 0, sizeof (remotepath));
|
||||
#endif /* INTERNET_DOMAIN_SOCKETS */
|
||||
|
||||
progname = strrchr (argv[0], '/');
|
||||
if (progname)
|
||||
++progname;
|
||||
else
|
||||
progname = argv[0];
|
||||
|
||||
display = getenv ("DISPLAY");
|
||||
if (!display)
|
||||
suppress_windows_system = 1;
|
||||
else
|
||||
display = my_strdup (display);
|
||||
|
||||
for (i = 1; argv[i] && !errflg; i++)
|
||||
{
|
||||
if (*argv[i] != '-')
|
||||
break;
|
||||
else if (*argv[i] == '-'
|
||||
&& (*(argv[i] + 1) == '\0'
|
||||
|| (*(argv[i] + 1) == '-' && *(argv[i] + 2) == '\0')))
|
||||
{
|
||||
/* `-' or `--' */
|
||||
++i;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!strcmp (argv[i], "-batch") || !strcmp (argv[i], "--batch"))
|
||||
batch = 1;
|
||||
else if (!strcmp (argv[i], "-eval") || !strcmp (argv[i], "--eval"))
|
||||
{
|
||||
if (!argv[++i])
|
||||
{
|
||||
fprintf (stderr, "%s: `-eval' must be followed by an argument\n",
|
||||
progname);
|
||||
exit (1);
|
||||
}
|
||||
eval_form = argv[i];
|
||||
}
|
||||
else if (!strcmp (argv[i], "-display") || !strcmp (argv[i], "--display"))
|
||||
{
|
||||
suppress_windows_system = 0;
|
||||
if (!argv[++i])
|
||||
{
|
||||
fprintf (stderr,
|
||||
"%s: `-display' must be followed by an argument\n",
|
||||
progname);
|
||||
exit (1);
|
||||
}
|
||||
if (display)
|
||||
free (display);
|
||||
/* no need to strdup. */
|
||||
display = argv[i];
|
||||
}
|
||||
else if (!strcmp (argv[i], "-nw"))
|
||||
suppress_windows_system = 1;
|
||||
else
|
||||
{
|
||||
/* Iterate over one-letter options. */
|
||||
char *p;
|
||||
int over = 0;
|
||||
for (p = argv[i] + 1; *p && !over; p++)
|
||||
{
|
||||
switch (*p)
|
||||
{
|
||||
case 'q':
|
||||
quick = 1;
|
||||
break;
|
||||
case 'v':
|
||||
view = 1;
|
||||
break;
|
||||
case 'f':
|
||||
GET_ARGUMENT (eval_function, "-f");
|
||||
break;
|
||||
case 'l':
|
||||
GET_ARGUMENT (load_library, "-l");
|
||||
break;
|
||||
#ifdef INTERNET_DOMAIN_SOCKETS
|
||||
case 'h':
|
||||
GET_ARGUMENT (hostarg, "-h");
|
||||
break;
|
||||
case 'p':
|
||||
GET_ARGUMENT (portarg, "-p");
|
||||
port = atoi (portarg);
|
||||
break;
|
||||
case 'r':
|
||||
GET_ARGUMENT (remotearg, "-r");
|
||||
strcpy (remotepath, remotearg);
|
||||
rflg = 1;
|
||||
break;
|
||||
#endif /* INTERNET_DOMAIN_SOCKETS */
|
||||
default:
|
||||
errflg = 1;
|
||||
}
|
||||
} /* for */
|
||||
} /* else */
|
||||
} /* for */
|
||||
|
||||
if (errflg)
|
||||
{
|
||||
fprintf (stderr,
|
||||
#ifdef INTERNET_DOMAIN_SOCKETS
|
||||
"usage: %s [-nw] [-display display] [-q] [-v] [-l library]\n"
|
||||
" [-batch] [-f function] [-eval form]\n"
|
||||
" [-h host] [-p port] [-r remote-path] [[+line] file] ...\n",
|
||||
#else /* !INTERNET_DOMAIN_SOCKETS */
|
||||
"usage: %s [-nw] [-q] [-v] [-l library] [-f function] [-eval form] "
|
||||
"[[+line] path] ...\n",
|
||||
#endif /* !INTERNET_DOMAIN_SOCKETS */
|
||||
progname);
|
||||
exit (1);
|
||||
}
|
||||
if (batch && argv[i])
|
||||
{
|
||||
fprintf (stderr, "%s: Cannot specify `-batch' with file names\n",
|
||||
progname);
|
||||
exit (1);
|
||||
}
|
||||
if (suppress_windows_system && hostarg)
|
||||
{
|
||||
fprintf (stderr, "%s: Remote editing is available only on X\n",
|
||||
progname);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
*result = '\0';
|
||||
if (eval_function || eval_form || load_library)
|
||||
{
|
||||
#if defined(INTERNET_DOMAIN_SOCKETS)
|
||||
connect_type = make_connection (hostarg, port, &s);
|
||||
#else
|
||||
connect_type = make_connection (NULL, (u_short) 0, &s);
|
||||
#endif
|
||||
sprintf (command, "(gnuserv-eval%s '(progn ", quick ? "-quickly" : "");
|
||||
send_string (s, command);
|
||||
if (load_library)
|
||||
{
|
||||
sprintf (command, " (load-library %s)", clean_string (load_library));
|
||||
send_string (s, command);
|
||||
}
|
||||
if (eval_form)
|
||||
{
|
||||
sprintf (command, " %s", eval_form);
|
||||
send_string (s, command);
|
||||
}
|
||||
if (eval_function)
|
||||
{
|
||||
sprintf (command, " (%s)", eval_function);
|
||||
send_string (s, command);
|
||||
}
|
||||
send_string (s, "))");
|
||||
send_string (s, EOT_STR);
|
||||
if (read_line (s, result) == 0)
|
||||
{
|
||||
fprintf (stderr, "%s: Could not read\n", progname);
|
||||
exit (1);
|
||||
}
|
||||
} /* eval_function || eval_form || load_library */
|
||||
else if (batch)
|
||||
{
|
||||
fprintf (stderr, "%s: `-batch' requires an evaluation\n",
|
||||
progname);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if (!batch)
|
||||
{
|
||||
if (suppress_windows_system)
|
||||
{
|
||||
tty = ttyname (0);
|
||||
if (!tty)
|
||||
{
|
||||
fprintf (stderr, "%s: Not connected to a tty", progname);
|
||||
exit (1);
|
||||
}
|
||||
#if defined(INTERNET_DOMAIN_SOCKETS)
|
||||
connect_type = make_connection (hostarg, port, &s);
|
||||
#else
|
||||
connect_type = make_connection (NULL, (u_short) 0, &s);
|
||||
#endif
|
||||
send_string (s, "(gnuserv-eval '(emacs-pid))");
|
||||
send_string (s, EOT_STR);
|
||||
|
||||
if (read_line (s, buffer) == 0)
|
||||
{
|
||||
fprintf (stderr, "%s: Could not establish Emacs procces id\n",
|
||||
progname);
|
||||
exit (1);
|
||||
}
|
||||
/* Don't do disconnect_from_server becasue we have already read
|
||||
data, and disconnect doesn't do anything else. */
|
||||
#ifndef INTERNET_DOMAIN_SOCKETS
|
||||
if (connect_type == (int) CONN_IPC)
|
||||
disconnect_from_ipc_server (s, msgp, FALSE);
|
||||
#endif /* !SYSV_IPC */
|
||||
|
||||
emacs_pid = (pid_t)atol(buffer);
|
||||
initialize_signals();
|
||||
} /* suppress_windows_system */
|
||||
|
||||
#if defined(INTERNET_DOMAIN_SOCKETS)
|
||||
connect_type = make_connection (hostarg, port, &s);
|
||||
#else
|
||||
connect_type = make_connection (NULL, (u_short) 0, &s);
|
||||
#endif
|
||||
|
||||
#ifdef INTERNET_DOMAIN_SOCKETS
|
||||
if (connect_type == (int) CONN_INTERNET)
|
||||
{
|
||||
char *ptr;
|
||||
gethostname (thishost, HOSTNAMSZ);
|
||||
if (!rflg)
|
||||
{ /* attempt to generate a path
|
||||
* to this machine */
|
||||
if ((ptr = getenv ("GNU_NODE")) != NULL)
|
||||
/* user specified a path */
|
||||
strcpy (remotepath, ptr);
|
||||
}
|
||||
#if 0 /* This is really bogus... re-enable it if you must have it! */
|
||||
#if defined (hp9000s300) || defined (hp9000s800)
|
||||
else if (strcmp (thishost,hostarg))
|
||||
{ /* try /net/thishost */
|
||||
strcpy (remotepath, "/net/"); /* (this fails using internet
|
||||
addresses) */
|
||||
strcat (remotepath, thishost);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{ /* same machines, no need for path */
|
||||
remotepath[0] = '\0'; /* default is the empty path */
|
||||
}
|
||||
#endif /* INTERNET_DOMAIN_SOCKETS */
|
||||
|
||||
#ifdef SYSV_IPC
|
||||
if ((msgp = (struct msgbuf *)
|
||||
malloc (sizeof *msgp + GSERV_BUFSZ)) == NULL)
|
||||
{
|
||||
fprintf (stderr, "%s: not enough memory for message buffer\n", progname);
|
||||
exit (1);
|
||||
} /* if */
|
||||
|
||||
msgp->mtext[0] = '\0'; /* ready for later strcats */
|
||||
#endif /* SYSV_IPC */
|
||||
|
||||
if (suppress_windows_system)
|
||||
{
|
||||
char *term = getenv ("TERM");
|
||||
if (!term)
|
||||
{
|
||||
fprintf (stderr, "%s: unknown terminal type\n", progname);
|
||||
exit (1);
|
||||
}
|
||||
sprintf (command, "(gnuserv-edit-files '(tty %s %s %d) '(",
|
||||
clean_string (tty), clean_string (term), (int)getpid ());
|
||||
}
|
||||
else /* !suppress_windows_system */
|
||||
{
|
||||
sprintf (command, "(gnuserv-edit-files '(x %s) '(",
|
||||
clean_string (display));
|
||||
} /* !suppress_windows_system */
|
||||
send_string (s, command);
|
||||
|
||||
if (!argv[i])
|
||||
nofiles = 1;
|
||||
|
||||
for (; argv[i]; i++)
|
||||
{
|
||||
if (i < argc - 1 && *argv[i] == '+')
|
||||
starting_line = atoi (argv[i++]);
|
||||
else
|
||||
starting_line = 1;
|
||||
/* If the last argument is +something, treat it as a file. */
|
||||
if (i == argc)
|
||||
{
|
||||
starting_line = 1;
|
||||
--i;
|
||||
}
|
||||
filename_expand (fullpath, argv[i]);
|
||||
#ifdef INTERNET_DOMAIN_SOCKETS
|
||||
path = malloc (strlen (remotepath) + strlen (fullpath) + 1);
|
||||
sprintf (path, "%s%s", remotepath, fullpath);
|
||||
#else
|
||||
path = my_strdup (fullpath);
|
||||
#endif
|
||||
sprintf (command, "(%d . %s)", starting_line, clean_string (path));
|
||||
send_string (s, command);
|
||||
free (path);
|
||||
} /* for */
|
||||
|
||||
sprintf (command, ")%s%s",
|
||||
(quick || (nofiles && !suppress_windows_system)) ? " 'quick" : "",
|
||||
view ? " 'view" : "");
|
||||
send_string (s, command);
|
||||
send_string (s, ")");
|
||||
|
||||
#ifdef SYSV_IPC
|
||||
if (connect_type == (int) CONN_IPC)
|
||||
disconnect_from_ipc_server (s, msgp, FALSE);
|
||||
#else /* !SYSV_IPC */
|
||||
if (connect_type != (int) CONN_IPC)
|
||||
disconnect_from_server (s, FALSE);
|
||||
#endif /* !SYSV_IPC */
|
||||
} /* not batch */
|
||||
|
||||
if (batch && !quick)
|
||||
printf ("%s\n", result);
|
||||
|
||||
return 0;
|
||||
|
||||
} /* main */
|
||||
|
||||
#endif /* SYSV_IPC || UNIX_DOMAIN_SOCKETS || INTERNET_DOMAIN_SOCKETS */
|
231
lib/init.c
231
lib/init.c
@@ -20,23 +20,230 @@
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/open.h>
|
||||
#include <glibtop/xmalloc.h>
|
||||
#include <glibtop/sysdeps.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;
|
||||
|
||||
static 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") : LIBGTOP_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 if (!strcmp (command, "pipe")) {
|
||||
|
||||
/* Open pipe to server. */
|
||||
server->method = GLIBTOP_METHOD_PIPE;
|
||||
|
||||
} else {
|
||||
|
||||
glibtop_error_r (server, "Unknown server method '%s'",
|
||||
server->server_command+1);
|
||||
|
||||
}
|
||||
|
||||
glibtop_free_r (server, command);
|
||||
}
|
||||
|
||||
glibtop *
|
||||
glibtop_init_r (glibtop **server, const unsigned long features,
|
||||
const unsigned flags)
|
||||
glibtop_init_r (glibtop **server_ptr, unsigned long features, unsigned flags)
|
||||
{
|
||||
if (*server != NULL)
|
||||
return *server;
|
||||
glibtop *server;
|
||||
|
||||
if (glibtop_global_server == NULL) {
|
||||
glibtop_global_server = &_glibtop_global_server;
|
||||
glibtop_open_l (glibtop_global_server, "glibtop",
|
||||
features, flags);
|
||||
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) {
|
||||
if (flags & GLIBTOP_FEATURES_EXCEPT)
|
||||
features = ~features & GLIBTOP_SYSDEPS_ALL;
|
||||
|
||||
if (features == 0)
|
||||
features = GLIBTOP_SYSDEPS_ALL;
|
||||
|
||||
if (flags & GLIBTOP_FEATURES_NO_SERVER) {
|
||||
server->method = GLIBTOP_METHOD_DIRECT;
|
||||
features = 0;
|
||||
}
|
||||
|
||||
server->features = features;
|
||||
|
||||
_init_server (server, features);
|
||||
|
||||
server->flags |= _GLIBTOP_INIT_STATE_INIT;
|
||||
|
||||
switch (server->method) {
|
||||
case GLIBTOP_METHOD_PIPE:
|
||||
case GLIBTOP_METHOD_UNIX:
|
||||
if (glibtop_server_features & features)
|
||||
break;
|
||||
|
||||
server->method = GLIBTOP_METHOD_DIRECT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
glibtop *
|
||||
glibtop_init_s (glibtop **server_ptr, unsigned long features, unsigned flags)
|
||||
{
|
||||
glibtop *server;
|
||||
glibtop_init_func_t *init_fkt;
|
||||
|
||||
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_SYSDEPS) == 0) {
|
||||
glibtop_open_s (server, "glibtop", features, flags);
|
||||
|
||||
for (init_fkt = _glibtop_init_hook_s; *init_fkt; init_fkt++)
|
||||
(*init_fkt) (server);
|
||||
|
||||
server->flags |= _GLIBTOP_INIT_STATE_SYSDEPS;
|
||||
}
|
||||
|
||||
return server;
|
||||
}
|
||||
|
114
lib/inodedb.c
Normal file
114
lib/inodedb.c
Normal file
@@ -0,0 +1,114 @@
|
||||
/* $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/error.h>
|
||||
#include <glibtop/xmalloc.h>
|
||||
#include <glibtop/inodedb.h>
|
||||
|
||||
#include <pwd.h>
|
||||
#include <gdbm.h>
|
||||
|
||||
#ifndef SYSTEM_INODEDB
|
||||
#define SYSTEM_INODEDB "/usr/var/libgtop/inodedb.db"
|
||||
#endif
|
||||
|
||||
glibtop_inodedb *
|
||||
glibtop_inodedb_open_s (glibtop *server, unsigned databases,
|
||||
unsigned long cachesize)
|
||||
{
|
||||
glibtop_inodedb *inodedb;
|
||||
char filename [BUFSIZ];
|
||||
struct passwd *pwd;
|
||||
struct stat statb;
|
||||
|
||||
if (!databases)
|
||||
databases = GLIBTOP_INODEDB_ALL;
|
||||
|
||||
inodedb = glibtop_calloc_r (server, 1, sizeof (glibtop_inodedb));
|
||||
|
||||
if (stat (SYSTEM_INODEDB, &statb))
|
||||
databases &= ~GLIBTOP_INODEDB_SYSTEM;
|
||||
|
||||
if (databases & GLIBTOP_INODEDB_SYSTEM) {
|
||||
inodedb->system_dbf = gdbm_open
|
||||
(SYSTEM_INODEDB, 0, GDBM_READER, 0, 0);
|
||||
if (!inodedb->system_dbf)
|
||||
glibtop_error_io_r
|
||||
(server, "gdbm_open (%s)", SYSTEM_INODEDB);
|
||||
}
|
||||
|
||||
pwd = getpwuid (getuid ());
|
||||
if (!pwd) glibtop_error_io_r (server, "getpwuid");
|
||||
|
||||
sprintf (filename, "%s/var/libgtop/inodedb.db", pwd->pw_dir);
|
||||
|
||||
if (stat (filename, &statb))
|
||||
databases &= ~GLIBTOP_INODEDB_USER;
|
||||
|
||||
if (databases & GLIBTOP_INODEDB_USER) {
|
||||
inodedb->user_dbf = gdbm_open
|
||||
(filename, 0, GDBM_READER, 0, 0);
|
||||
if (!inodedb->user_dbf)
|
||||
glibtop_error_io_r
|
||||
(server, "gdbm_open (%s)", filename);
|
||||
}
|
||||
|
||||
return inodedb;
|
||||
}
|
||||
|
||||
const char *
|
||||
glibtop_inodedb_lookup_s (glibtop *server, glibtop_inodedb *inodedb,
|
||||
u_int64_t device, u_int64_t inode)
|
||||
{
|
||||
glibtop_inodedb_key key;
|
||||
datum d_key, d_content;
|
||||
|
||||
d_key.dptr = (void *) &key;
|
||||
d_key.dsize = sizeof (key);
|
||||
|
||||
key.device = device;
|
||||
key.inode = inode;
|
||||
|
||||
if (inodedb->system_dbf) {
|
||||
d_content = gdbm_fetch (inodedb->system_dbf, d_key);
|
||||
if (d_content.dptr) return d_content.dptr;
|
||||
}
|
||||
|
||||
if (inodedb->user_dbf) {
|
||||
d_content = gdbm_fetch (inodedb->user_dbf, d_key);
|
||||
if (d_content.dptr) return d_content.dptr;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
glibtop_inodedb_close_s (glibtop *server, glibtop_inodedb *inodedb)
|
||||
{
|
||||
if (inodedb->system_dbf)
|
||||
gdbm_close (inodedb->system_dbf);
|
||||
|
||||
if (inodedb->user_dbf)
|
||||
gdbm_close (inodedb->user_dbf);
|
||||
|
||||
glibtop_free_r (server, inodedb);
|
||||
}
|
171
lib/lib.awk
171
lib/lib.awk
@@ -2,51 +2,164 @@ 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 "";
|
||||
print "#include <glibtop/sysdeps.h>";
|
||||
print "#include <glibtop/union.h>";
|
||||
print "";
|
||||
print "#include <glibtop/command.h>";
|
||||
|
||||
|
||||
print "";
|
||||
print "/* Some required fields are missing. */";
|
||||
print "";
|
||||
|
||||
print "static void";
|
||||
print "_glibtop_missing_feature (glibtop *server, const char *feature,";
|
||||
print "\t\t\t const u_int64_t present, u_int64_t *required)";
|
||||
print "{";
|
||||
print "\tswitch (server->error_method) {";
|
||||
print "\tcase GLIBTOP_ERROR_METHOD_WARN_ONCE:";
|
||||
print "\t\t*required &= present;";
|
||||
print "\tcase GLIBTOP_ERROR_METHOD_WARN:";
|
||||
print "\t\tglibtop_warn_r (server,";
|
||||
print "\t\t\t\t_(\"glibtop_get_%s (): Client requested \"";
|
||||
print "\t\t\t\t \"field mask %05Lx, but only have %05Lx.\"),";
|
||||
print "\t\t\t\t feature, required, present);";
|
||||
print "\t\tbreak;";
|
||||
print "\tcase GLIBTOP_ERROR_METHOD_ABORT:";
|
||||
print "\t\tglibtop_error_r (server,";
|
||||
print "\t\t\t\t _(\"glibtop_get_%s (): Client requested \"";
|
||||
print "\t\t\t\t \"field mask %05x, but only have %05x.\"),";
|
||||
print "\t\t\t\t feature, required, present);";
|
||||
print "\t\tbreak;";
|
||||
print "\t}";
|
||||
print "}";
|
||||
|
||||
print "";
|
||||
print "/* Library functions. */";
|
||||
print "";
|
||||
|
||||
convert["long"] = "int64_t";
|
||||
convert["ulong"] = "u_int64_t";
|
||||
convert["pid_t"] = "pid_t";
|
||||
convert["int"] = "int";
|
||||
}
|
||||
|
||||
function output(feature) {
|
||||
if (feature ~ /^proclist$/) {
|
||||
print "unsigned *";
|
||||
prefix = "return ";
|
||||
function output(line) {
|
||||
split (line, line_fields, /\|/);
|
||||
retval = line_fields[1];
|
||||
feature = line_fields[2];
|
||||
param_def = line_fields[4];
|
||||
|
||||
orig = feature; sub(/^@/,"",feature);
|
||||
space = feature; gsub(/./," ",space);
|
||||
|
||||
print retval;
|
||||
if (retval !~ /^void$/) {
|
||||
prefix = "retval = ";
|
||||
prefix_space = " ";
|
||||
} else {
|
||||
prefix = "";
|
||||
print "void";
|
||||
}
|
||||
if (feature ~ /^proc_/) {
|
||||
param = ", pid_t pid";
|
||||
} else {
|
||||
param = "";
|
||||
prefix_space = "";
|
||||
}
|
||||
|
||||
print "glibtop_get_"feature"_l (glibtop *server, glibtop_"feature" *buf"param")";
|
||||
print "{";
|
||||
print "\tglibtop_init_r (&server, GLIBTOP_SYSDEPS_"toupper(feature)", 0);";
|
||||
if (param_def == "string") {
|
||||
call_param = ", "line_fields[5];
|
||||
param_decl = ",\n "space" const char *"line_fields[5];
|
||||
send_ptr = "\n\tvoid *send_ptr = "line_fields[5]";";
|
||||
send_size = "\n\tconst size_t send_size =\n\t\tstrlen ("line_fields[5]") + 1;";
|
||||
} else {
|
||||
call_param = "";
|
||||
param_decl = "";
|
||||
send_size = "";
|
||||
send_ptr = "";
|
||||
nr_params = split (param_def, params, /:/);
|
||||
for (param = 1; param <= nr_params; param++) {
|
||||
list = params[param];
|
||||
type = params[param];
|
||||
sub(/\(.*/, "", type);
|
||||
sub(/^\w+\(/, "", list); sub(/\)$/, "", list);
|
||||
count = split (list, fields, /,/);
|
||||
for (field = 1; field <= count; field++) {
|
||||
if (param_decl == "")
|
||||
param_decl = ",\n "space" ";
|
||||
else
|
||||
param_decl = param_decl", ";
|
||||
param_decl = param_decl""convert[type]" "fields[field];
|
||||
call_param = call_param", "fields[field];
|
||||
if (send_ptr == "")
|
||||
send_ptr = "\n\tvoid *send_ptr = &"fields[field]";";
|
||||
if (send_size == "")
|
||||
send_size = "\n\tconst size_t send_size =\n\t\t";
|
||||
else
|
||||
send_size = send_size" + ";
|
||||
send_size = send_size"sizeof ("fields[field]")";
|
||||
}
|
||||
}
|
||||
if (send_size != "")
|
||||
send_size = send_size";";
|
||||
else
|
||||
send_size = "\n\tconst size_t send_size = 0;";
|
||||
if (send_ptr == "")
|
||||
send_ptr = "\n\tvoid *send_ptr = NULL;";
|
||||
}
|
||||
|
||||
print "glibtop_get_"feature"_l (glibtop *server, glibtop_"feature" *buf"param_decl")";
|
||||
|
||||
print "{"send_ptr""send_size;
|
||||
if (retval !~ /^void$/)
|
||||
print "\t"retval" retval;";
|
||||
print "";
|
||||
print "\tif (server->features & GLIBTOP_SYSDEPS_"toupper(feature)") {";
|
||||
|
||||
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 "\tglibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_"toupper(feature)"), 0);";
|
||||
|
||||
print "";
|
||||
print "\t/* If neccessary, we ask the server for the requested";
|
||||
print "\t * feature. If not, we call the sysdeps function. */";
|
||||
print "";
|
||||
|
||||
print "\tif ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&";
|
||||
print "\t (server->features & (1 << GLIBTOP_SYSDEPS_"toupper(feature)")))";
|
||||
print "\t{";
|
||||
|
||||
print "\t\t"prefix"glibtop_call_l (server, GLIBTOP_CMND_"toupper(feature)",";
|
||||
print "\t\t\t\t"prefix_space"send_size, send_ptr,";
|
||||
print "\t\t\t\t"prefix_space"sizeof (glibtop_"feature"), buf);";
|
||||
|
||||
print "\t} else {";
|
||||
|
||||
if (orig !~ /^@/)
|
||||
print "#if (!GLIBTOP_SUID_"toupper(feature)")";
|
||||
|
||||
print "\t\t"prefix"glibtop_get_"feature"_s (server, buf"call_param");";
|
||||
|
||||
if (orig !~ /^@/) {
|
||||
print "#else";
|
||||
print "\t\terrno = ENOSYS;";
|
||||
print "\t\tglibtop_error_io_r (server, \"glibtop_get_"feature"\");";
|
||||
print "#endif";
|
||||
}
|
||||
|
||||
print "\t}";
|
||||
|
||||
print "";
|
||||
print "\t/* Make sure that all required fields are present. */";
|
||||
print "";
|
||||
|
||||
print "\tif (buf->flags & server->required."feature")";
|
||||
print "\t\t_glibtop_missing_feature (server, \""feature"\", buf->flags,";
|
||||
print "\t\t\t\t\t &server->required."feature");";
|
||||
|
||||
if (retval !~ /^void$/) {
|
||||
print "\n\t/* Now we can return. */";
|
||||
print "\n\treturn retval;";
|
||||
}
|
||||
|
||||
print "}";
|
||||
print "";
|
||||
}
|
||||
|
||||
/^(\w+)/ { output($1) }
|
||||
|
||||
|
||||
/^[^#]/ { output($0) }
|
||||
|
||||
|
212
lib/open.c
212
lib/open.c
@@ -21,136 +21,146 @@
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/open.h>
|
||||
#include <glibtop/version.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_l (glibtop *server, const char *program_name,
|
||||
const unsigned long features, const unsigned flags)
|
||||
const unsigned long features, const unsigned flags)
|
||||
{
|
||||
char version [BUFSIZ], buffer [BUFSIZ];
|
||||
char *server_command, *server_rsh, *temp;
|
||||
char *server_host, *server_user;
|
||||
glibtop_sysdeps sysdeps;
|
||||
|
||||
memset (server, 0, sizeof (glibtop));
|
||||
int connect_type;
|
||||
|
||||
server->name = program_name;
|
||||
|
||||
/* Is the user allowed to override the server ? */
|
||||
/* It is important to set _GLIBTOP_INIT_STATE_OPEN here when we
|
||||
* do recursive calls to glibtop_init_r (). */
|
||||
|
||||
if ((flags & GLIBTOP_OPEN_NO_OVERRIDE) == 0) {
|
||||
server->flags |= _GLIBTOP_INIT_STATE_OPEN;
|
||||
|
||||
/* Try to get data from environment. */
|
||||
|
||||
temp = getenv ("LIBGTOP_SERVER") ?
|
||||
getenv ("LIBGTOP_SERVER") : GTOP_SERVER;
|
||||
|
||||
server_command = glibtop_malloc_r (server, strlen (temp) + 1);
|
||||
|
||||
strcpy (server_command, temp);
|
||||
|
||||
temp = getenv ("LIBGTOP_RSH") ?
|
||||
getenv ("LIBGTOP_RSH") : "rsh";
|
||||
|
||||
server_rsh = glibtop_malloc_r (server, strlen (temp) + 1);
|
||||
|
||||
strcpy (server_rsh, temp);
|
||||
|
||||
/* Extract host and user information. */
|
||||
|
||||
temp = strstr (server_command, ":");
|
||||
|
||||
if (temp) {
|
||||
*temp = 0;
|
||||
server_host = server_command;
|
||||
server_command = temp+1;
|
||||
|
||||
temp = strstr (server_host, "@");
|
||||
|
||||
if (temp) {
|
||||
*temp = 0;
|
||||
server_user = server_host;
|
||||
server_host = temp+1;
|
||||
} else {
|
||||
server_user = NULL;
|
||||
}
|
||||
} else {
|
||||
server_host = NULL;
|
||||
server_user = NULL;
|
||||
}
|
||||
|
||||
/* Store everything in `server'. */
|
||||
|
||||
server->server_command = server_command;
|
||||
server->server_host = server_host;
|
||||
server->server_user = server_user;
|
||||
server->server_rsh = server_rsh;
|
||||
}
|
||||
|
||||
/* Get server features. */
|
||||
|
||||
if (server->server_host == NULL) {
|
||||
server->features = glibtop_server_features;
|
||||
|
||||
if (server->features == 0)
|
||||
return;
|
||||
}
|
||||
server->error_method = GLIBTOP_ERROR_METHOD_DEFAULT;
|
||||
|
||||
/* Fork and exec server. */
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "SIZEOF: %u - %u - %u - %u - %u - %u\n",
|
||||
sizeof (glibtop_command), sizeof (glibtop_response),
|
||||
sizeof (glibtop_mountentry), sizeof (glibtop_union),
|
||||
sizeof (glibtop_sysdeps), sizeof (glibtop_response_union));
|
||||
#endif
|
||||
|
||||
if (pipe (server->input) || pipe (server->output))
|
||||
glibtop_error_r (server, _("cannot make a pipe: %s\n"),
|
||||
strerror (errno));
|
||||
switch (server->method) {
|
||||
case GLIBTOP_METHOD_DIRECT:
|
||||
server->features = 0;
|
||||
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");
|
||||
|
||||
server->pid = fork ();
|
||||
connect_type = glibtop_make_connection
|
||||
("unix", 0, &server->socket);
|
||||
|
||||
fprintf (stderr, "Connect Type is %d.\n", connect_type);
|
||||
|
||||
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);
|
||||
server->flags |= _GLIBTOP_INIT_STATE_SERVER;
|
||||
|
||||
if (server_host) {
|
||||
if (server_user) {
|
||||
execl (server->server_rsh, "-l",
|
||||
server->server_user, server->server_host,
|
||||
server->server_command, NULL);
|
||||
} else {
|
||||
execl (server->server_rsh,
|
||||
server->server_host, server_command, NULL);
|
||||
}
|
||||
} else {
|
||||
execl (server->server_command, NULL);
|
||||
server->features = -1;
|
||||
break;
|
||||
case GLIBTOP_METHOD_PIPE:
|
||||
fprintf (stderr, "Opening pipe to server (%s).\n",
|
||||
LIBGTOP_SERVER);
|
||||
|
||||
if (pipe (server->input) || pipe (server->output))
|
||||
glibtop_error_io_r (server, "cannot make a pipe");
|
||||
|
||||
server->pid = fork ();
|
||||
|
||||
if (server->pid < 0) {
|
||||
glibtop_error_io_r (server, "fork failed");
|
||||
} else if (server->pid == 0) {
|
||||
close (0); close (1);
|
||||
close (server->input [0]); close (server->output [1]);
|
||||
dup2 (server->input [1], 1);
|
||||
dup2 (server->output [0], 0);
|
||||
execl (LIBGTOP_SERVER, NULL);
|
||||
glibtop_error_io_r (server, "execl (%s)",
|
||||
LIBGTOP_SERVER);
|
||||
_exit (2);
|
||||
}
|
||||
|
||||
_exit (2);
|
||||
close (server->input [1]);
|
||||
close (server->output [0]);
|
||||
|
||||
server->flags |= _GLIBTOP_INIT_STATE_SERVER;
|
||||
|
||||
server->features = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
fprintf (stderr, "PID: %d\n", server->pid);
|
||||
/* If the server has been started, ask it for its features. */
|
||||
|
||||
close (server->input [1]);
|
||||
close (server->output [0]);
|
||||
if (server->flags & _GLIBTOP_INIT_STATE_SERVER) {
|
||||
char version [BUFSIZ], buffer [BUFSIZ];
|
||||
glibtop_sysdeps sysdeps;
|
||||
unsigned size, nbytes;
|
||||
|
||||
sprintf (version, "%s server %s ready.\n", PACKAGE, VERSION);
|
||||
/* First check whether the server version is correct. */
|
||||
|
||||
glibtop_read_l (server, strlen (version), buffer);
|
||||
sprintf (version, LIBGTOP_VERSION_STRING,
|
||||
LIBGTOP_VERSION, LIBGTOP_SERVER_VERSION,
|
||||
sizeof (glibtop_command),
|
||||
sizeof (glibtop_response),
|
||||
sizeof (glibtop_union),
|
||||
sizeof (glibtop_sysdeps));
|
||||
|
||||
if (memcmp (version, buffer, strlen (version)))
|
||||
glibtop_error_r (server, _("server version is not %s"), VERSION);
|
||||
size = strlen (version) + 1;
|
||||
|
||||
glibtop_read_l (server, sizeof (nbytes), &nbytes);
|
||||
|
||||
fprintf (stderr, "Calling GLITOP_CMND_SYSDEPS ...\n");
|
||||
if (nbytes != size)
|
||||
glibtop_error_r (server,
|
||||
"Requested %u bytes but got %u.",
|
||||
size, nbytes);
|
||||
|
||||
glibtop_read_l (server, nbytes, buffer);
|
||||
|
||||
if (memcmp (version, buffer, size))
|
||||
glibtop_error_r (server, "server version is not %s",
|
||||
LIBGTOP_VERSION);
|
||||
|
||||
glibtop_call_l (server, GLIBTOP_CMND_SYSDEPS, 0, NULL,
|
||||
sizeof (glibtop_sysdeps), &sysdeps);
|
||||
/* Now ask it for its features. */
|
||||
|
||||
glibtop_call_l (server, GLIBTOP_CMND_SYSDEPS, 0, NULL,
|
||||
sizeof (glibtop_sysdeps), &sysdeps);
|
||||
|
||||
server->features = sysdeps.features;
|
||||
|
||||
server->features = sysdeps.features;
|
||||
memcpy (&server->sysdeps, &sysdeps, sizeof (glibtop_sysdeps));
|
||||
|
||||
fprintf (stderr, "Features: %lu\n", server->features);
|
||||
fprintf (stderr, "Server features are %lu.\n",
|
||||
server->features);
|
||||
}
|
||||
|
||||
/* In any case, we call the open functions of our own sysdeps
|
||||
* directory. */
|
||||
|
||||
fprintf (stderr, "Calling sysdeps open function.\n");
|
||||
|
||||
glibtop_init_s (&server, features, flags);
|
||||
}
|
||||
|
87
lib/parameter.c
Normal file
87
lib/parameter.c
Normal file
@@ -0,0 +1,87 @@
|
||||
/* $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));
|
||||
case GLIBTOP_PARAM_ERROR_METHOD:
|
||||
_write_data (&server->error_method,
|
||||
sizeof (server->error_method));
|
||||
}
|
||||
|
||||
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;
|
||||
case GLIBTOP_PARAM_ERROR_METHOD:
|
||||
_check_data (sizeof (server->error_method));
|
||||
memcpy (&server->error_method, data_ptr, data_size);
|
||||
break;
|
||||
}
|
||||
}
|
49
lib/read.c
49
lib/read.c
@@ -23,19 +23,48 @@
|
||||
|
||||
/* Reads some data from server. */
|
||||
|
||||
static void
|
||||
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) {
|
||||
nread = recv (s, ptr, remaining, 0);
|
||||
|
||||
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)
|
||||
{
|
||||
size_t ssize;
|
||||
int ret = 0;
|
||||
|
||||
glibtop_init_r (&server, 0, 0);
|
||||
|
||||
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));
|
||||
|
||||
#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);
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user