Compare commits
26 Commits
sysctl_mar
...
LIBGTOP_1_
Author | SHA1 | Date | |
---|---|---|---|
|
41062d0262 | ||
|
58c882a860 | ||
|
789d156972 | ||
|
19c24da036 | ||
|
929a025f53 | ||
|
6a7c289305 | ||
|
b65a4a7dcb | ||
|
39b2fffe83 | ||
|
efb913acff | ||
|
79e756a2f7 | ||
|
b08968e644 | ||
|
dff497d2fa | ||
|
38de742ca4 | ||
|
e0d3401bc4 | ||
|
aae2b5a94d | ||
|
a5bd38fc19 | ||
|
931b8f065e | ||
|
f7885e488f | ||
|
8122db69ee | ||
|
ab13d4919d | ||
|
1d955fbf1f | ||
|
8af25a2003 | ||
|
12eb6a25ec | ||
|
77ced087a1 | ||
|
983475d0c1 | ||
|
70b65c05e5 |
@@ -32,8 +32,3 @@ ABOUT-NLS
|
||||
libgtop.spec
|
||||
libgtop-0.99.*.tar.gz
|
||||
libgtop-0.99.*
|
||||
install-sh
|
||||
mkinstalldirs
|
||||
missing
|
||||
INSTALL
|
||||
COPYING
|
||||
|
40
ChangeLog
40
ChangeLog
@@ -1,41 +1,19 @@
|
||||
1999-03-21 Martin Baulig <martin@home-of-linux.org>
|
||||
1999-05-31 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
Added a new sysctl () interface to the Linux Kernel.
|
||||
|
||||
* kernel/sysctl: Imported.
|
||||
|
||||
* libgtop-sysdeps.m4: If `--enable-hacker-mode' is given, check
|
||||
for my new sysctl () interface.
|
||||
Released LibGTop 1.0.2.
|
||||
|
||||
1999-03-20 Martin Baulig <martin@home-of-linux.org>
|
||||
1999-05-26 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
Removed all traces of my old table () Linux kernel hack.
|
||||
* configure.in (INCLUDES): Define `LIBGTOP_VERSION_CODE' here so we
|
||||
can use version conditionals in the sysdeps code.
|
||||
|
||||
* kernel: Removed.
|
||||
* sysdeps/kernel: Removed.
|
||||
* libgtop-sysdeps.m4: Don't check for table (); it does not
|
||||
exist any longer.
|
||||
1999-05-25 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
1999-03-19 Martin Baulig <martin@home-of-linux.org>
|
||||
* libgtop-sysdeps.m4: Make the I4B check work for NetBSD.
|
||||
|
||||
This is *untested* - please read "sysdeps/freebsd/ChangeLog" !
|
||||
1999-05-16 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* libgtop-sysdeps.m4: Use the `freebsd' sysdeps directory for
|
||||
BSDI as well if the `--enable-hacker-mode' parameter was given.
|
||||
|
||||
1999-03-18 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* LIBGTOP-VERSION: Set version number to 1.0.2 binary age 1,
|
||||
intergace age 1.
|
||||
|
||||
1999-03-17 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
Imported first version of my Solaris port.
|
||||
|
||||
* configure.in: Check for `kstat_open' in `-lkstat'.
|
||||
|
||||
* libgtop-sysdeps.m4: Recognize the `solaris' sysdeps directory
|
||||
when the `--enable-hacker-mode' parameter was given.
|
||||
* doc: Merged the LibGTop Manual from the HEAD.
|
||||
|
||||
1999-03-01 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
|
@@ -11,7 +11,7 @@ support = support
|
||||
endif
|
||||
|
||||
SUBDIRS = po intl $(support) macros misc include sysdeps lib src \
|
||||
$(examples_SUBDIRS)
|
||||
$(examples_SUBDIRS) doc
|
||||
|
||||
include_HEADERS = glibtop.h
|
||||
|
||||
|
@@ -138,7 +138,7 @@
|
||||
|
||||
#undef NEED_LIBGTOP
|
||||
|
||||
#undef HAVE_LINUX_SYSCTL
|
||||
#undef HAVE_LINUX_TABLE
|
||||
#undef HAVE_LIBGTOP_SMP
|
||||
|
||||
#undef HAVE_XAUTH
|
||||
|
16
configure.in
16
configure.in
@@ -13,6 +13,12 @@ AC_MSG_ERROR([
|
||||
*** The "dc" utility was not found on your system.
|
||||
***
|
||||
*** When using RedHat Linux, you need to install the "bc" package.
|
||||
***
|
||||
*** It is now part of the "bc" package, so you should look at
|
||||
*** ftp://ftp.gnu.org/pub/gnu/bc/ if you want to compile it yourself.
|
||||
***
|
||||
*** Other systems and distributions may also have it in their "bc" package,
|
||||
*** so if there's no "dc" one, please look for "bc".
|
||||
***])
|
||||
fi
|
||||
|
||||
@@ -147,7 +153,7 @@ else
|
||||
fi
|
||||
|
||||
if test "x$enable_static" != xno; then
|
||||
static_targets="first_static second_static mountlist_static procmap_static netload_static sysdeps_static $guile_static_examples $smp_static_examples"
|
||||
static_targets="first_static second_static mountlist_static procmap_static netload_static sysdeps_static timings_static $guile_static_examples $smp_static_examples"
|
||||
else
|
||||
static_targets=""
|
||||
fi
|
||||
@@ -183,9 +189,6 @@ AC_CHECK_HEADERS(string.h strings.h, break)
|
||||
AC_REPLACE_FUNCS(strerror)
|
||||
AC_CHECK_LIB(kvm, kvm_open)
|
||||
|
||||
dnl Solaris 7
|
||||
AC_CHECK_LIB(kstat, kstat_open)
|
||||
|
||||
dnl For DEC OSF1
|
||||
AC_CHECK_LIB(mach, vm_statistics)
|
||||
|
||||
@@ -357,7 +360,7 @@ 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 $GLIB_CFLAGS $CFLAGS $X_CFLAGS $guile_def "'-DGTOPLOCALEDIR=\"$(datadir)/locale\" -DLIBGTOP_VERSION=\"'"$LIBGTOP_VERSION"'\" -DLIBGTOP_SERVER_VERSION=\"'"$LIBGTOP_SERVER_VERSION"'\" -DLIBGTOP_SERVER=\"'"$LIBGTOP_SERVER"'\"'
|
||||
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 $GLIB_CFLAGS $CFLAGS $X_CFLAGS $guile_def "'-DGTOPLOCALEDIR=\"$(datadir)/locale\" -DLIBGTOP_VERSION=\"'"$LIBGTOP_VERSION"'\" -DLIBGTOP_SERVER_VERSION=\"'"$LIBGTOP_SERVER_VERSION"'\" -DLIBGTOP_VERSION_CODE='$LIBGTOP_VERSION_CODE' -DLIBGTOP_SERVER=\"'"$LIBGTOP_SERVER"'\"'
|
||||
|
||||
AC_SUBST(INCLUDES)
|
||||
|
||||
@@ -402,12 +405,13 @@ sysdeps/stub_suid/Makefile
|
||||
sysdeps/sun4/Makefile
|
||||
sysdeps/osf1/Makefile
|
||||
sysdeps/linux/Makefile
|
||||
sysdeps/kernel/Makefile
|
||||
sysdeps/freebsd/Makefile
|
||||
sysdeps/solaris/Makefile
|
||||
src/Makefile
|
||||
src/daemon/Makefile
|
||||
src/inodedb/Makefile
|
||||
lib/Makefile
|
||||
examples/Makefile
|
||||
doc/Makefile
|
||||
support/Makefile
|
||||
macros/Makefile])
|
||||
|
@@ -13,3 +13,4 @@ second_static
|
||||
second_linux
|
||||
smp_static sysdeps_static netload_static procmap_static mountlist_static
|
||||
smp sysdeps netload procmap mountlist
|
||||
timings timings_static
|
||||
|
@@ -1,3 +1,22 @@
|
||||
1999-05-28 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* first.c, second.c, sysdeps.c: Use LibGTop version conditionals
|
||||
so we can more easily merge the code into LIBGTOP_STABLE_1_0.
|
||||
|
||||
1999-05-07 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* timings.c (timersub): Renamed this to `libgtop_timersub' and define
|
||||
it on all systems.
|
||||
|
||||
Fri Apr 9 00:14:52 1999 Timur Bakeyev <timur@gnu.org>
|
||||
|
||||
* timings.c: Added timersub defenition, to make code compilable on
|
||||
BSDI.
|
||||
|
||||
1999-03-24 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* timings.c: New example.
|
||||
|
||||
1999-03-17 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* first.c, second.c: Fixed a bug that caused a core dump when
|
||||
|
@@ -12,13 +12,14 @@ DEFS = @DEFS@
|
||||
libgtopdir = $(libexecdir)/libgtop
|
||||
|
||||
libgtop_PROGRAMS = first second\
|
||||
mountlist procmap netload sysdeps\
|
||||
mountlist procmap netload sysdeps timings \
|
||||
@static_targets@ @guile_examples@ @smp_examples@
|
||||
|
||||
EXTRA_PROGRAMS = first_static second_static \
|
||||
mountlist_static procmap_static \
|
||||
third third_static smp smp_static \
|
||||
netload_static sysdeps_static
|
||||
netload_static sysdeps_static \
|
||||
timings_static
|
||||
|
||||
first_SOURCES = first.c
|
||||
first_LDADD = $(top_builddir)/lib/libgtop.la \
|
||||
@@ -108,3 +109,13 @@ smp_static_SOURCES = $(smp_SOURCES)
|
||||
smp_static_LDADD = $(smp_LDADD)
|
||||
smp_static_LDFLAGS = -static
|
||||
|
||||
timings_SOURCES = timings.c
|
||||
timings_LDADD = $(top_builddir)/lib/libgtop.la \
|
||||
$(top_builddir)/sysdeps/common/libgtop_common.la \
|
||||
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \
|
||||
@LIBSUPPORT@ @INTLLIBS@
|
||||
|
||||
timings_static_SOURCES = $(timings_SOURCES)
|
||||
timings_static_LDADD = $(timings_LDADD)
|
||||
timings_static_LDFLAGS = -static
|
||||
|
||||
|
244
examples/first.c
244
examples/first.c
@@ -116,9 +116,16 @@ main (int argc, char *argv [])
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_uptime (&data.uptime);
|
||||
|
||||
#if LIBGTOP_VERSION_CODE > 1001000
|
||||
printf ("Uptime (0x%08lx): %f, %f, %lu\n",
|
||||
(unsigned long) data.uptime.flags,
|
||||
data.uptime.uptime, data.uptime.idletime,
|
||||
(unsigned long) data.uptime.boot_time);
|
||||
#else
|
||||
printf ("Uptime (0x%08lx): %f, %f\n",
|
||||
(unsigned long) data.uptime.flags,
|
||||
data.uptime.uptime, data.uptime.idletime);
|
||||
#endif
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_loadavg (&data.loadavg);
|
||||
@@ -242,15 +249,52 @@ main (int argc, char *argv [])
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_state (&data.proc_state, pid);
|
||||
|
||||
#if LIBGTOP_VERSION_CODE > 1001000
|
||||
printf ("Proc_State PID %5d (0x%08lx): '%s', %u - "
|
||||
"%u, %u, %u, %u - %u, %u, %u\n", (int) pid,
|
||||
(unsigned long) data.proc_state.flags,
|
||||
data.proc_state.cmd, data.proc_state.state,
|
||||
data.proc_state.uid, data.proc_state.gid,
|
||||
data.proc_state.ruid, data.proc_state.rgid,
|
||||
data.proc_state.has_cpu, data.proc_state.processor,
|
||||
data.proc_state.last_processor);
|
||||
#else
|
||||
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);
|
||||
#endif
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_uid (&data.proc_uid, pid);
|
||||
|
||||
#if LIBGTOP_VERSION_CODE > 1001000
|
||||
printf ("Proc_Uid PID %5d (0x%08lx): "
|
||||
"%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d - %d",
|
||||
(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.suid, data.proc_uid.sgid,
|
||||
data.proc_uid.fsuid, data.proc_uid.fsgid,
|
||||
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,
|
||||
data.proc_uid.ngroups);
|
||||
|
||||
if (data.proc_uid.ngroups) {
|
||||
for (i = 0; i < data.proc_uid.ngroups; i++) {
|
||||
if (i)
|
||||
printf (" %d", data.proc_uid.groups [i]);
|
||||
else
|
||||
printf (" (%d", data.proc_uid.groups [i]);
|
||||
}
|
||||
printf (")");
|
||||
}
|
||||
|
||||
printf ("\n");
|
||||
#else
|
||||
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,
|
||||
@@ -260,6 +304,7 @@ main (int argc, char *argv [])
|
||||
data.proc_uid.pgrp, data.proc_uid.session,
|
||||
data.proc_uid.tty, data.proc_uid.tpgid,
|
||||
data.proc_uid.priority, data.proc_uid.nice);
|
||||
#endif
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_mem (&data.proc_mem, pid);
|
||||
@@ -277,6 +322,30 @@ main (int argc, char *argv [])
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_segment (&data.proc_segment, pid);
|
||||
|
||||
#if LIBGTOP_VERSION_CODE > 1001000
|
||||
printf ("Proc_Segment PID %5d (0x%08lx): "
|
||||
"%lu %lu %lu %lu %lu 0x%lx 0x%lx 0x%lx "
|
||||
"0x%lx 0x%lx 0x%lx 0x%lx 0x%lx "
|
||||
"0x%lx 0x%lx 0x%lx 0x%lx\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_data,
|
||||
(unsigned long) data.proc_segment.end_data,
|
||||
(unsigned long) data.proc_segment.start_brk,
|
||||
(unsigned long) data.proc_segment.end_brk,
|
||||
(unsigned long) data.proc_segment.start_stack,
|
||||
(unsigned long) data.proc_segment.start_mmap,
|
||||
(unsigned long) data.proc_segment.arg_start,
|
||||
(unsigned long) data.proc_segment.arg_end,
|
||||
(unsigned long) data.proc_segment.env_start,
|
||||
(unsigned long) data.proc_segment.env_end);
|
||||
#else
|
||||
printf ("Proc_Segment PID %5d (0x%08lx): "
|
||||
"%lu %lu %lu %lu %lu %lu %lu %lu\n", (int) pid,
|
||||
(unsigned long) data.proc_segment.flags,
|
||||
@@ -288,6 +357,7 @@ main (int argc, char *argv [])
|
||||
(unsigned long) data.proc_segment.start_code,
|
||||
(unsigned long) data.proc_segment.end_code,
|
||||
(unsigned long) data.proc_segment.start_stack);
|
||||
#endif
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_time (&data.proc_time, pid);
|
||||
@@ -308,6 +378,19 @@ main (int argc, char *argv [])
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_signal (&data.proc_signal, pid);
|
||||
|
||||
#if LIBGTOP_VERSION_CODE > 1001000
|
||||
printf ("Proc_Signal PID %5d (0x%08lx): "
|
||||
"%lx %lx %lx %lx %lx %lx %lx %lx\n", (int) pid,
|
||||
(unsigned long) data.proc_signal.flags,
|
||||
(unsigned long) data.proc_signal.signal [0],
|
||||
(unsigned long) data.proc_signal.signal [1],
|
||||
(unsigned long) data.proc_signal.blocked [0],
|
||||
(unsigned long) data.proc_signal.blocked [1],
|
||||
(unsigned long) data.proc_signal.sigignore [0],
|
||||
(unsigned long) data.proc_signal.sigignore [1],
|
||||
(unsigned long) data.proc_signal.sigcatch [0],
|
||||
(unsigned long) data.proc_signal.sigcatch [1]);
|
||||
#else
|
||||
printf ("Proc_Signal PID %5d (0x%08lx): "
|
||||
"%lu %lu %lu %lu\n", (int) pid,
|
||||
(unsigned long) data.proc_signal.flags,
|
||||
@@ -315,12 +398,13 @@ main (int argc, char *argv [])
|
||||
(unsigned long) data.proc_signal.blocked,
|
||||
(unsigned long) data.proc_signal.sigignore,
|
||||
(unsigned long) data.proc_signal.sigcatch);
|
||||
#endif
|
||||
|
||||
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,
|
||||
"%lu %lu %lu %lu %lu 0x%lx 0x%lx 0x%lx (%s)\n", (int) pid,
|
||||
(unsigned long) data.proc_kernel.flags,
|
||||
(unsigned long) data.proc_kernel.k_flags,
|
||||
(unsigned long) data.proc_kernel.min_flt,
|
||||
@@ -353,15 +437,52 @@ main (int argc, char *argv [])
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_state (&data.proc_state, ppid);
|
||||
|
||||
#if LIBGTOP_VERSION_CODE > 1001000
|
||||
printf ("Proc_State PPID %5d (0x%08lx): '%s', %u - "
|
||||
"%u, %u, %u, %u - %u, %u, %u\n", (int) ppid,
|
||||
(unsigned long) data.proc_state.flags,
|
||||
data.proc_state.cmd, data.proc_state.state,
|
||||
data.proc_state.uid, data.proc_state.gid,
|
||||
data.proc_state.ruid, data.proc_state.rgid,
|
||||
data.proc_state.has_cpu, data.proc_state.processor,
|
||||
data.proc_state.last_processor);
|
||||
#else
|
||||
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);
|
||||
#endif
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_uid (&data.proc_uid, ppid);
|
||||
|
||||
#if LIBGTOP_VERSION_CODE > 1001000
|
||||
printf ("Proc_Uid PPID %5d (0x%08lx): "
|
||||
"%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d - %d",
|
||||
(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.suid, data.proc_uid.sgid,
|
||||
data.proc_uid.fsuid, data.proc_uid.fsgid,
|
||||
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,
|
||||
data.proc_uid.ngroups);
|
||||
|
||||
if (data.proc_uid.ngroups) {
|
||||
for (i = 0; i < data.proc_uid.ngroups; i++) {
|
||||
if (i)
|
||||
printf (" %d", data.proc_uid.groups [i]);
|
||||
else
|
||||
printf (" (%d", data.proc_uid.groups [i]);
|
||||
}
|
||||
printf (")");
|
||||
}
|
||||
|
||||
printf ("\n");
|
||||
#else
|
||||
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,
|
||||
@@ -371,6 +492,7 @@ main (int argc, char *argv [])
|
||||
data.proc_uid.pgrp, data.proc_uid.session,
|
||||
data.proc_uid.tty, data.proc_uid.tpgid,
|
||||
data.proc_uid.priority, data.proc_uid.nice);
|
||||
#endif
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_mem (&data.proc_mem, ppid);
|
||||
@@ -388,6 +510,30 @@ main (int argc, char *argv [])
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_segment (&data.proc_segment, ppid);
|
||||
|
||||
#if LIBGTOP_VERSION_CODE > 1001000
|
||||
printf ("Proc_Segment PPID %5d (0x%08lx): "
|
||||
"%lu %lu %lu %lu %lu 0x%lx 0x%lx 0x%lx "
|
||||
"0x%lx 0x%lx 0x%lx 0x%lx 0x%lx "
|
||||
"0x%lx 0x%lx 0x%lx 0x%lx\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_data,
|
||||
(unsigned long) data.proc_segment.end_data,
|
||||
(unsigned long) data.proc_segment.start_brk,
|
||||
(unsigned long) data.proc_segment.end_brk,
|
||||
(unsigned long) data.proc_segment.start_stack,
|
||||
(unsigned long) data.proc_segment.start_mmap,
|
||||
(unsigned long) data.proc_segment.arg_start,
|
||||
(unsigned long) data.proc_segment.arg_end,
|
||||
(unsigned long) data.proc_segment.env_start,
|
||||
(unsigned long) data.proc_segment.env_end);
|
||||
#else
|
||||
printf ("Proc_Segment PPID %5d (0x%08lx): "
|
||||
"%lu %lu %lu %lu %lu %lu %lu %lu\n", (int) ppid,
|
||||
(unsigned long) data.proc_segment.flags,
|
||||
@@ -399,6 +545,7 @@ main (int argc, char *argv [])
|
||||
(unsigned long) data.proc_segment.start_code,
|
||||
(unsigned long) data.proc_segment.end_code,
|
||||
(unsigned long) data.proc_segment.start_stack);
|
||||
#endif
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_time (&data.proc_time, ppid);
|
||||
@@ -419,18 +566,32 @@ main (int argc, char *argv [])
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_signal (&data.proc_signal, ppid);
|
||||
|
||||
#if LIBGTOP_VERSION_CODE > 1001000
|
||||
printf ("Proc_Signal PPID %5d (0x%08lx): "
|
||||
"%lx %lx %lx %lx %lx %lx %lx %lx\n",
|
||||
(int) ppid, (unsigned long) data.proc_signal.flags,
|
||||
(unsigned long) data.proc_signal.signal [0],
|
||||
(unsigned long) data.proc_signal.signal [1],
|
||||
(unsigned long) data.proc_signal.blocked [0],
|
||||
(unsigned long) data.proc_signal.blocked [1],
|
||||
(unsigned long) data.proc_signal.sigignore [0],
|
||||
(unsigned long) data.proc_signal.sigignore [1],
|
||||
(unsigned long) data.proc_signal.sigcatch [0],
|
||||
(unsigned long) data.proc_signal.sigcatch [1]);
|
||||
#else
|
||||
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);
|
||||
#endif
|
||||
|
||||
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,
|
||||
"%lu %lu %lu %lu %lu 0x%lx 0x%lx 0x%lx (%s)\n", (int) ppid,
|
||||
(unsigned long) data.proc_kernel.flags,
|
||||
(unsigned long) data.proc_kernel.k_flags,
|
||||
(unsigned long) data.proc_kernel.min_flt,
|
||||
@@ -463,15 +624,52 @@ main (int argc, char *argv [])
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_state (&data.proc_state, 1);
|
||||
|
||||
#if LIBGTOP_VERSION_CODE > 1001000
|
||||
printf ("Proc_State INIT %5d (0x%08lx): '%s', %u - "
|
||||
"%u, %u, %u, %u - %u, %u, %u\n", 1,
|
||||
(unsigned long) data.proc_state.flags,
|
||||
data.proc_state.cmd, data.proc_state.state,
|
||||
data.proc_state.uid, data.proc_state.gid,
|
||||
data.proc_state.ruid, data.proc_state.rgid,
|
||||
data.proc_state.has_cpu, data.proc_state.processor,
|
||||
data.proc_state.last_processor);
|
||||
#else
|
||||
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);
|
||||
#endif
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_uid (&data.proc_uid, 1);
|
||||
|
||||
#if LIBGTOP_VERSION_CODE > 1001000
|
||||
printf ("Proc_Uid INIT %5d (0x%08lx): "
|
||||
"%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d - %d", 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.suid, data.proc_uid.sgid,
|
||||
data.proc_uid.fsuid, data.proc_uid.fsgid,
|
||||
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,
|
||||
data.proc_uid.ngroups);
|
||||
|
||||
if (data.proc_uid.ngroups) {
|
||||
for (i = 0; i < data.proc_uid.ngroups; i++) {
|
||||
if (i)
|
||||
printf (" %d", data.proc_uid.groups [i]);
|
||||
else
|
||||
printf (" (%d", data.proc_uid.groups [i]);
|
||||
}
|
||||
printf (")");
|
||||
}
|
||||
|
||||
printf ("\n");
|
||||
#else
|
||||
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,
|
||||
@@ -481,6 +679,7 @@ main (int argc, char *argv [])
|
||||
data.proc_uid.pgrp, data.proc_uid.session,
|
||||
data.proc_uid.tty, data.proc_uid.tpgid,
|
||||
data.proc_uid.priority, data.proc_uid.nice);
|
||||
#endif
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_mem (&data.proc_mem, 1);
|
||||
@@ -498,6 +697,30 @@ main (int argc, char *argv [])
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_segment (&data.proc_segment, 1);
|
||||
|
||||
#if LIBGTOP_VERSION_CODE > 1001000
|
||||
printf ("Proc_Segment INIT %5d (0x%08lx): "
|
||||
"%lu %lu %lu %lu %lu 0x%lx 0x%lx 0x%lx "
|
||||
"0x%lx 0x%lx 0x%lx 0x%lx 0x%lx "
|
||||
"0x%lx 0x%lx 0x%lx 0x%lx\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_data,
|
||||
(unsigned long) data.proc_segment.end_data,
|
||||
(unsigned long) data.proc_segment.start_brk,
|
||||
(unsigned long) data.proc_segment.end_brk,
|
||||
(unsigned long) data.proc_segment.start_stack,
|
||||
(unsigned long) data.proc_segment.start_mmap,
|
||||
(unsigned long) data.proc_segment.arg_start,
|
||||
(unsigned long) data.proc_segment.arg_end,
|
||||
(unsigned long) data.proc_segment.env_start,
|
||||
(unsigned long) data.proc_segment.env_end);
|
||||
#else
|
||||
printf ("Proc_Segment INIT %5d (0x%08lx): "
|
||||
"%lu %lu %lu %lu %lu %lu %lu %lu\n", 1,
|
||||
(unsigned long) data.proc_segment.flags,
|
||||
@@ -509,6 +732,7 @@ main (int argc, char *argv [])
|
||||
(unsigned long) data.proc_segment.start_code,
|
||||
(unsigned long) data.proc_segment.end_code,
|
||||
(unsigned long) data.proc_segment.start_stack);
|
||||
#endif
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_time (&data.proc_time, 1);
|
||||
@@ -529,6 +753,19 @@ main (int argc, char *argv [])
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_signal (&data.proc_signal, 1);
|
||||
|
||||
#if LIBGTOP_VERSION_CODE > 1001000
|
||||
printf ("Proc_Signal INIT %5d (0x%08lx): "
|
||||
"%lx %lx %lx %lx %lx %lx %lx %lx\n", 1,
|
||||
(unsigned long) data.proc_signal.flags,
|
||||
(unsigned long) data.proc_signal.signal [0],
|
||||
(unsigned long) data.proc_signal.signal [1],
|
||||
(unsigned long) data.proc_signal.blocked [0],
|
||||
(unsigned long) data.proc_signal.blocked [1],
|
||||
(unsigned long) data.proc_signal.sigignore [0],
|
||||
(unsigned long) data.proc_signal.sigignore [1],
|
||||
(unsigned long) data.proc_signal.sigcatch [0],
|
||||
(unsigned long) data.proc_signal.sigcatch [1]);
|
||||
#else
|
||||
printf ("Proc_Signal INIT %5d (0x%08lx): "
|
||||
"%lu %lu %lu %lu\n", 1,
|
||||
(unsigned long) data.proc_signal.flags,
|
||||
@@ -536,12 +773,13 @@ main (int argc, char *argv [])
|
||||
(unsigned long) data.proc_signal.blocked,
|
||||
(unsigned long) data.proc_signal.sigignore,
|
||||
(unsigned long) data.proc_signal.sigcatch);
|
||||
#endif
|
||||
|
||||
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,
|
||||
"%lu %lu %lu %lu %lu 0x%lx 0x%lx 0x%lx (%s)\n", 1,
|
||||
(unsigned long) data.proc_kernel.flags,
|
||||
(unsigned long) data.proc_kernel.k_flags,
|
||||
(unsigned long) data.proc_kernel.min_flt,
|
||||
|
@@ -97,7 +97,7 @@ main (int argc, char *argv [])
|
||||
unsigned device, device_major, device_minor;
|
||||
char perm [5];
|
||||
|
||||
if (maps [i].flags & (1 << GLIBTOP_MAP_ENTRY_FILENAME))
|
||||
if (maps [i].flags & (1L << GLIBTOP_MAP_ENTRY_FILENAME))
|
||||
filename = maps [i].filename;
|
||||
|
||||
#ifdef GLIBTOP_INODEDB
|
||||
@@ -116,24 +116,41 @@ main (int argc, char *argv [])
|
||||
device_minor = (device & 255);
|
||||
device_major = ((device >> 8) & 255);
|
||||
|
||||
if (filename)
|
||||
fprintf (stderr, "%08lx-%08lx %08lx - "
|
||||
"%02x:%02x %08lu - %4s - %s\n",
|
||||
if (filename) {
|
||||
char *format;
|
||||
|
||||
if (sizeof (void*) == 8)
|
||||
format = "%016lx-%016lx %016lx - "
|
||||
"%02x:%02x %08lu - %4s - %s\n";
|
||||
else
|
||||
format = "%08lx-%08lx %08lx - "
|
||||
"%02x:%02x %08lu - %4s - %s\n";
|
||||
|
||||
fprintf (stderr, format,
|
||||
(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",
|
||||
} else {
|
||||
char * format;
|
||||
|
||||
if (sizeof (void*) == 8)
|
||||
format = "%016lx-%016lx %016lx - "
|
||||
"%02x:%02x %08lu - %4s\n";
|
||||
else
|
||||
format = "%08lx-%08lx %08lx - "
|
||||
"%02x:%02x %08lu - %4s\n";
|
||||
|
||||
fprintf (stderr, format,
|
||||
(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);
|
||||
|
@@ -52,16 +52,53 @@ output (pid_t pid)
|
||||
printf ("\n");
|
||||
|
||||
glibtop_get_proc_state (&data.proc_state, pid);
|
||||
|
||||
|
||||
#if LIBGTOP_VERSION_CODE > 1001000
|
||||
printf ("Proc_State PID %5d (0x%08lx): '%s', %u - "
|
||||
"%u, %u, %u, %u - %u, %u, %u\n", (int) pid,
|
||||
(unsigned long) data.proc_state.flags,
|
||||
data.proc_state.cmd, data.proc_state.state,
|
||||
data.proc_state.uid, data.proc_state.gid,
|
||||
data.proc_state.ruid, data.proc_state.rgid,
|
||||
data.proc_state.has_cpu, data.proc_state.processor,
|
||||
data.proc_state.last_processor);
|
||||
#else
|
||||
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);
|
||||
#endif
|
||||
|
||||
glibtop_get_proc_uid (&data.proc_uid, pid);
|
||||
|
||||
#if LIBGTOP_VERSION_CODE > 1001000
|
||||
printf ("Proc_Uid PID %5d (0x%08lx): "
|
||||
"%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d - %d",
|
||||
(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.suid, data.proc_uid.sgid,
|
||||
data.proc_uid.fsuid, data.proc_uid.fsgid,
|
||||
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,
|
||||
data.proc_uid.ngroups);
|
||||
|
||||
if (data.proc_uid.ngroups) {
|
||||
for (i = 0; i < data.proc_uid.ngroups; i++) {
|
||||
if (i)
|
||||
printf (" %d", data.proc_uid.groups [i]);
|
||||
else
|
||||
printf (" (%d", data.proc_uid.groups [i]);
|
||||
}
|
||||
printf (")");
|
||||
}
|
||||
|
||||
printf ("\n");
|
||||
#else
|
||||
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,
|
||||
@@ -71,7 +108,8 @@ output (pid_t pid)
|
||||
data.proc_uid.pgrp, data.proc_uid.session,
|
||||
data.proc_uid.tty, data.proc_uid.tpgid,
|
||||
data.proc_uid.priority, data.proc_uid.nice);
|
||||
|
||||
#endif
|
||||
|
||||
glibtop_get_proc_mem (&data.proc_mem, pid);
|
||||
|
||||
printf ("Proc_Mem PID %5d (0x%08lx): "
|
||||
@@ -86,6 +124,30 @@ output (pid_t pid)
|
||||
|
||||
glibtop_get_proc_segment (&data.proc_segment, pid);
|
||||
|
||||
#if LIBGTOP_VERSION_CODE > 1001000
|
||||
printf ("Proc_Segment PID %5d (0x%08lx): "
|
||||
"%lu %lu %lu %lu %lu 0x%lx 0x%lx 0x%lx "
|
||||
"0x%lx 0x%lx 0x%lx 0x%lx 0x%lx "
|
||||
"0x%lx 0x%lx 0x%lx 0x%lx\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_data,
|
||||
(unsigned long) data.proc_segment.end_data,
|
||||
(unsigned long) data.proc_segment.start_brk,
|
||||
(unsigned long) data.proc_segment.end_brk,
|
||||
(unsigned long) data.proc_segment.start_stack,
|
||||
(unsigned long) data.proc_segment.start_mmap,
|
||||
(unsigned long) data.proc_segment.arg_start,
|
||||
(unsigned long) data.proc_segment.arg_end,
|
||||
(unsigned long) data.proc_segment.env_start,
|
||||
(unsigned long) data.proc_segment.env_end);
|
||||
#else
|
||||
printf ("Proc_Segment PID %5d (0x%08lx): "
|
||||
"%lu %lu %lu %lu %lu %lu %lu %lu\n", (int) pid,
|
||||
(unsigned long) data.proc_segment.flags,
|
||||
@@ -97,6 +159,7 @@ output (pid_t pid)
|
||||
(unsigned long) data.proc_segment.start_code,
|
||||
(unsigned long) data.proc_segment.end_code,
|
||||
(unsigned long) data.proc_segment.start_stack);
|
||||
#endif
|
||||
|
||||
glibtop_get_proc_time (&data.proc_time, pid);
|
||||
|
||||
@@ -115,6 +178,19 @@ output (pid_t pid)
|
||||
|
||||
glibtop_get_proc_signal (&data.proc_signal, pid);
|
||||
|
||||
#if LIBGTOP_VERSION_CODE > 1001000
|
||||
printf ("Proc_Signal PID %5d (0x%08lx): "
|
||||
"%lx %lx %lx %lx %lx %lx %lx %lx\n", (int) pid,
|
||||
(unsigned long) data.proc_signal.flags,
|
||||
(unsigned long) data.proc_signal.signal [0],
|
||||
(unsigned long) data.proc_signal.signal [1],
|
||||
(unsigned long) data.proc_signal.blocked [0],
|
||||
(unsigned long) data.proc_signal.blocked [1],
|
||||
(unsigned long) data.proc_signal.sigignore [0],
|
||||
(unsigned long) data.proc_signal.sigignore [1],
|
||||
(unsigned long) data.proc_signal.sigcatch [0],
|
||||
(unsigned long) data.proc_signal.sigcatch [1]);
|
||||
#else
|
||||
printf ("Proc_Signal PID %5d (0x%08lx): "
|
||||
"%lu %lu %lu %lu\n", (int) pid,
|
||||
(unsigned long) data.proc_signal.flags,
|
||||
@@ -122,11 +198,12 @@ output (pid_t pid)
|
||||
(unsigned long) data.proc_signal.blocked,
|
||||
(unsigned long) data.proc_signal.sigignore,
|
||||
(unsigned long) data.proc_signal.sigcatch);
|
||||
#endif
|
||||
|
||||
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,
|
||||
"%lu %lu %lu %lu %lu 0x%lx 0x%lx 0x%lx (%s)\n", (int) pid,
|
||||
(unsigned long) data.proc_kernel.flags,
|
||||
(unsigned long) data.proc_kernel.k_flags,
|
||||
(unsigned long) data.proc_kernel.min_flt,
|
||||
|
@@ -69,10 +69,13 @@ main (int argc, char *argv [])
|
||||
|
||||
glibtop_get_sysdeps (&sysdeps);
|
||||
|
||||
#define FEATURE_CHECK(f) ((sysdeps.features & (1 << GLIBTOP_SYSDEPS_##f##)) ? 1 : 0)
|
||||
#define FEATURE_CHECK(f) ((sysdeps.features & (1L << GLIBTOP_SYSDEPS_##f##)) ? 1 : 0)
|
||||
|
||||
printf ("Sysdeps (0x%08lx):\n\n"
|
||||
"\tfeatures:\t\t0x%08lx\n\n"
|
||||
#if LIBGTOP_VERSION_CODE > 1001000
|
||||
"\tpointer_size:\t\t0x%08lx\n\n"
|
||||
#endif
|
||||
"\tcpu:\t\t%d\t0x%08lx\n"
|
||||
"\tmem:\t\t%d\t0x%08lx\n"
|
||||
"\tswap:\t\t%d\t0x%08lx\n\n"
|
||||
@@ -97,6 +100,9 @@ main (int argc, char *argv [])
|
||||
"\tppp:\t\t%d\t0x%08lx\n\n",
|
||||
(unsigned long) sysdeps.flags,
|
||||
(unsigned long) sysdeps.features,
|
||||
#if LIBGTOP_VERSION_CODE > 1001000
|
||||
(unsigned long) sysdeps.pointer_size,
|
||||
#endif
|
||||
FEATURE_CHECK(CPU),
|
||||
(unsigned long) sysdeps.cpu,
|
||||
FEATURE_CHECK(MEM),
|
||||
|
360
examples/timings.c
Normal file
360
examples/timings.c
Normal file
@@ -0,0 +1,360 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
LibGTop 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.
|
||||
|
||||
LibGTop 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 LibGTop; see the file COPYING. 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/union.h>
|
||||
#include <glibtop/sysdeps.h>
|
||||
|
||||
#include <sys/times.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
#ifndef PROFILE_COUNT
|
||||
#define PROFILE_COUNT 100000L
|
||||
#endif
|
||||
|
||||
#ifndef PROFILE_COUNT_EXPENSIVE
|
||||
#define PROFILE_COUNT_EXPENSIVE 10000L
|
||||
#endif
|
||||
|
||||
#define ELAPSED_UTIME ((unsigned long) elapsed_utime.tv_sec * 1000000 + (unsigned long) elapsed_utime.tv_usec)
|
||||
#define ELAPSED_STIME ((unsigned long) elapsed_stime.tv_sec * 1000000 + (unsigned long) elapsed_stime.tv_usec)
|
||||
|
||||
#define libgtop_timeradd(tvp, uvp, vvp) \
|
||||
do { \
|
||||
(vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
|
||||
(vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
|
||||
if ((vvp)->tv_usec >= 1000000) { \
|
||||
(vvp)->tv_sec++; \
|
||||
(vvp)->tv_usec -= 1000000; \
|
||||
} \
|
||||
} while (0)
|
||||
#define libgtop_timersub(tvp, uvp, vvp) \
|
||||
do { \
|
||||
(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
|
||||
(vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
|
||||
if ((vvp)->tv_usec < 0) { \
|
||||
(vvp)->tv_sec--; \
|
||||
(vvp)->tv_usec += 1000000; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
int
|
||||
main (int argc, char *argv [])
|
||||
{
|
||||
glibtop_union data;
|
||||
glibtop_sysdeps sysdeps;
|
||||
unsigned c, count, port, i, *ptr;
|
||||
struct rusage total_start, total_end;
|
||||
struct rusage rusage_start, rusage_end;
|
||||
struct timeval elapsed_utime, elapsed_stime;
|
||||
char buffer [BUFSIZ];
|
||||
pid_t pid, ppid;
|
||||
char *args;
|
||||
|
||||
count = PROFILE_COUNT;
|
||||
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, GTOPLOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
printf ("%-12s (%-10s): %7s - %9s - %9s\n",
|
||||
"Feature", "Flags", "Count", "utime", "stime");
|
||||
printf ("-------------------------------------------"
|
||||
"---------------\n");
|
||||
|
||||
glibtop_init_r (&glibtop_global_server, 0, 0);
|
||||
|
||||
getrusage (RUSAGE_SELF, &total_start);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_start);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_cpu (&data.cpu);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_end);
|
||||
|
||||
libgtop_timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
|
||||
&elapsed_utime);
|
||||
|
||||
libgtop_timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
|
||||
&elapsed_stime);
|
||||
|
||||
printf ("CPU (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
|
||||
(unsigned long) data.cpu.flags, PROFILE_COUNT,
|
||||
(long double) ELAPSED_UTIME / PROFILE_COUNT,
|
||||
(long double) ELAPSED_STIME / PROFILE_COUNT);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_start);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT_EXPENSIVE; c++)
|
||||
glibtop_get_mem (&data.mem);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_end);
|
||||
|
||||
libgtop_timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
|
||||
&elapsed_utime);
|
||||
|
||||
libgtop_timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
|
||||
&elapsed_stime);
|
||||
|
||||
printf ("Memory (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
|
||||
(unsigned long) data.mem.flags, PROFILE_COUNT_EXPENSIVE,
|
||||
(long double) ELAPSED_UTIME / PROFILE_COUNT_EXPENSIVE,
|
||||
(long double) ELAPSED_STIME / PROFILE_COUNT_EXPENSIVE);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_start);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT_EXPENSIVE; c++)
|
||||
glibtop_get_swap (&data.swap);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_end);
|
||||
|
||||
libgtop_timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
|
||||
&elapsed_utime);
|
||||
|
||||
libgtop_timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
|
||||
&elapsed_stime);
|
||||
|
||||
printf ("Swap (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
|
||||
(unsigned long) data.swap.flags, PROFILE_COUNT_EXPENSIVE,
|
||||
(long double) ELAPSED_UTIME / PROFILE_COUNT_EXPENSIVE,
|
||||
(long double) ELAPSED_STIME / PROFILE_COUNT_EXPENSIVE);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_start);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_uptime (&data.uptime);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_end);
|
||||
|
||||
libgtop_timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
|
||||
&elapsed_utime);
|
||||
|
||||
libgtop_timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
|
||||
&elapsed_stime);
|
||||
|
||||
printf ("Uptime (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
|
||||
(unsigned long) data.uptime.flags, PROFILE_COUNT,
|
||||
(long double) ELAPSED_UTIME / PROFILE_COUNT,
|
||||
(long double) ELAPSED_STIME / PROFILE_COUNT);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_start);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_loadavg (&data.loadavg);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_end);
|
||||
|
||||
libgtop_timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
|
||||
&elapsed_utime);
|
||||
|
||||
libgtop_timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
|
||||
&elapsed_stime);
|
||||
|
||||
printf ("Loadavg (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
|
||||
(unsigned long) data.loadavg.flags, PROFILE_COUNT,
|
||||
(long double) ELAPSED_UTIME / PROFILE_COUNT,
|
||||
(long double) ELAPSED_STIME / PROFILE_COUNT);
|
||||
|
||||
printf ("\n");
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_start);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT_EXPENSIVE; c++) {
|
||||
ptr = glibtop_get_proclist (&data.proclist, 0, 0);
|
||||
glibtop_free (ptr);
|
||||
}
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_end);
|
||||
|
||||
libgtop_timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
|
||||
&elapsed_utime);
|
||||
|
||||
libgtop_timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
|
||||
&elapsed_stime);
|
||||
|
||||
printf ("Proclist (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
|
||||
(unsigned long) data.proclist.flags,
|
||||
PROFILE_COUNT_EXPENSIVE,
|
||||
(long double) ELAPSED_UTIME / PROFILE_COUNT_EXPENSIVE,
|
||||
(long double) ELAPSED_STIME / PROFILE_COUNT_EXPENSIVE);
|
||||
|
||||
pid = getpid ();
|
||||
|
||||
printf ("\n");
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_start);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_state (&data.proc_state, pid);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_end);
|
||||
|
||||
libgtop_timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
|
||||
&elapsed_utime);
|
||||
|
||||
libgtop_timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
|
||||
&elapsed_stime);
|
||||
|
||||
printf ("Proc_State (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
|
||||
(unsigned long) data.proc_state.flags, PROFILE_COUNT,
|
||||
(long double) ELAPSED_UTIME / PROFILE_COUNT,
|
||||
(long double) ELAPSED_STIME / PROFILE_COUNT);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_start);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_uid (&data.proc_uid, pid);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_end);
|
||||
|
||||
libgtop_timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
|
||||
&elapsed_utime);
|
||||
|
||||
libgtop_timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
|
||||
&elapsed_stime);
|
||||
|
||||
printf ("Proc_Uid (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
|
||||
(unsigned long) data.proc_uid.flags, PROFILE_COUNT,
|
||||
(long double) ELAPSED_UTIME / PROFILE_COUNT,
|
||||
(long double) ELAPSED_STIME / PROFILE_COUNT);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_start);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_mem (&data.proc_mem, pid);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_end);
|
||||
|
||||
libgtop_timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
|
||||
&elapsed_utime);
|
||||
|
||||
libgtop_timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
|
||||
&elapsed_stime);
|
||||
|
||||
printf ("Proc_Mem (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
|
||||
(unsigned long) data.proc_mem.flags, PROFILE_COUNT,
|
||||
(long double) ELAPSED_UTIME / PROFILE_COUNT,
|
||||
(long double) ELAPSED_STIME / PROFILE_COUNT);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_start);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_segment (&data.proc_segment, pid);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_end);
|
||||
|
||||
libgtop_timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
|
||||
&elapsed_utime);
|
||||
|
||||
libgtop_timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
|
||||
&elapsed_stime);
|
||||
|
||||
printf ("Proc_Segment (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
|
||||
(unsigned long) data.proc_segment.flags, PROFILE_COUNT,
|
||||
(long double) ELAPSED_UTIME / PROFILE_COUNT,
|
||||
(long double) ELAPSED_STIME / PROFILE_COUNT);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_start);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_time (&data.proc_time, pid);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_end);
|
||||
|
||||
libgtop_timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
|
||||
&elapsed_utime);
|
||||
|
||||
libgtop_timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
|
||||
&elapsed_stime);
|
||||
|
||||
printf ("Proc_Time (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
|
||||
(unsigned long) data.proc_time.flags, PROFILE_COUNT,
|
||||
(long double) ELAPSED_UTIME / PROFILE_COUNT,
|
||||
(long double) ELAPSED_STIME / PROFILE_COUNT);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_start);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_signal (&data.proc_signal, pid);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_end);
|
||||
|
||||
libgtop_timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
|
||||
&elapsed_utime);
|
||||
|
||||
libgtop_timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
|
||||
&elapsed_stime);
|
||||
|
||||
printf ("Proc_Signal (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
|
||||
(unsigned long) data.proc_signal.flags, PROFILE_COUNT,
|
||||
(long double) ELAPSED_UTIME / PROFILE_COUNT,
|
||||
(long double) ELAPSED_STIME / PROFILE_COUNT);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_start);
|
||||
|
||||
for (c = 0; c < PROFILE_COUNT; c++)
|
||||
glibtop_get_proc_kernel (&data.proc_kernel, pid);
|
||||
|
||||
getrusage (RUSAGE_SELF, &rusage_end);
|
||||
|
||||
libgtop_timersub (&rusage_end.ru_utime, &rusage_start.ru_utime,
|
||||
&elapsed_utime);
|
||||
|
||||
libgtop_timersub (&rusage_end.ru_stime, &rusage_start.ru_stime,
|
||||
&elapsed_stime);
|
||||
|
||||
printf ("Proc_Kernel (0x%08lx): %7lu - %9.2Lf - %9.2Lf\n",
|
||||
(unsigned long) data.proc_kernel.flags, PROFILE_COUNT,
|
||||
(long double) ELAPSED_UTIME / PROFILE_COUNT,
|
||||
(long double) ELAPSED_STIME / PROFILE_COUNT);
|
||||
|
||||
getrusage (RUSAGE_SELF, &total_end);
|
||||
|
||||
libgtop_timersub (&total_end.ru_utime, &total_start.ru_utime,
|
||||
&elapsed_utime);
|
||||
|
||||
libgtop_timersub (&total_end.ru_stime, &total_start.ru_stime,
|
||||
&elapsed_stime);
|
||||
|
||||
printf ("-------------------------------------------"
|
||||
"---------------\n");
|
||||
|
||||
printf ("%-36s %9lu - %9lu\n\n", "TOTAL",
|
||||
ELAPSED_UTIME, ELAPSED_STIME);
|
||||
|
||||
printf ("All timings are in clock ticks "
|
||||
"(1000000 ticks per second).\n\n");
|
||||
|
||||
glibtop_close ();
|
||||
|
||||
exit (0);
|
||||
}
|
38
include/glibtop/limits.h
Normal file
38
include/glibtop/limits.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
LibGTop 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.
|
||||
|
||||
LibGTop 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 LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GLIBTOP_LIMITS_H__
|
||||
#define __GLIBTOP_LIMITS_H__
|
||||
|
||||
#include <glibtop/global.h>
|
||||
|
||||
BEGIN_LIBGTOP_DECLS
|
||||
|
||||
/* Nobody should really be using more than 64 processors. */
|
||||
#define GLIBTOP_NCPU 64
|
||||
|
||||
END_LIBGTOP_DECLS
|
||||
|
||||
#endif
|
14
kernel/ChangeLog
Normal file
14
kernel/ChangeLog
Normal file
@@ -0,0 +1,14 @@
|
||||
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.
|
||||
|
||||
* kernel.patch: Patch for the Linux kernel to add the
|
||||
new system call.
|
1
kernel/sysctl/.cvsignore
Normal file
1
kernel/sysctl/.cvsignore
Normal file
@@ -0,0 +1 @@
|
||||
*.flags
|
File diff suppressed because it is too large
Load Diff
@@ -5,12 +5,19 @@
|
||||
|
||||
enum {
|
||||
LIBGTOP_VERSION = 1,
|
||||
LIBGTOP_PROC,
|
||||
LIBGTOP_UPDATE_EXPENSIVE,
|
||||
LIBGTOP_STAT,
|
||||
LIBGTOP_STAT = 101,
|
||||
LIBGTOP_MEM,
|
||||
LIBGTOP_SWAP,
|
||||
LIBGTOP_PROCLIST
|
||||
LIBGTOP_PROCLIST = 201,
|
||||
LIBGTOP_PROC_STATE = 211,
|
||||
LIBGTOP_PROC_KERNEL,
|
||||
LIBGTOP_PROC_SEGMENT,
|
||||
LIBGTOP_PROC_MEM,
|
||||
LIBGTOP_PROC_SIGNAL,
|
||||
LIBGTOP_PROC_ARGS = 251,
|
||||
LIBGTOP_PROC_MAPS,
|
||||
LIBGTOP_NETLOAD = 301
|
||||
};
|
||||
|
||||
enum {
|
||||
@@ -23,12 +30,47 @@ enum {
|
||||
LIBGTOP_PROCLIST_RUID
|
||||
};
|
||||
|
||||
#define LIBGTOP_PROCLIST_MASK 15
|
||||
#define LIBGTOP_NSIG 4
|
||||
|
||||
#define LIBGTOP_PROCLIST_MASK 15
|
||||
#define LIBGTOP_MAX_GROUPS 32
|
||||
|
||||
#define LIBGTOP_EXCLUDE_IDLE 0x1000
|
||||
#define LIBGTOP_EXCLUDE_SYSTEM 0x2000
|
||||
#define LIBGTOP_EXCLUDE_NOTTY 0x4000
|
||||
|
||||
#define LIBGTOP_TASK_RUNNING 1
|
||||
#define LIBGTOP_TASK_INTERRUPTIBLE 2
|
||||
#define LIBGTOP_TASK_UNINTERRUPTIBLE 4
|
||||
#define LIBGTOP_TASK_ZOMBIE 8
|
||||
#define LIBGTOP_TASK_STOPPED 16
|
||||
#define LIBGTOP_TASK_SWAPPING 32
|
||||
|
||||
#define LIBGTOP_VM_READ 0x0001 /* currently active flags */
|
||||
#define LIBGTOP_VM_WRITE 0x0002
|
||||
#define LIBGTOP_VM_EXEC 0x0004
|
||||
#define LIBGTOP_VM_SHARED 0x0008
|
||||
|
||||
#define LIBGTOP_VM_MAYREAD 0x0010 /* limits for mprotect() etc */
|
||||
#define LIBGTOP_VM_MAYWRITE 0x0020
|
||||
#define LIBGTOP_VM_MAYEXEC 0x0040
|
||||
#define LIBGTOP_VM_MAYSHARE 0x0080
|
||||
|
||||
#define LIBGTOP_VM_GROWSDOWN 0x0100 /* general info on the segment */
|
||||
#define LIBGTOP_VM_GROWSUP 0x0200
|
||||
#define LIBGTOP_VM_SHM 0x0400 /* shared memory area, don't swap out */
|
||||
#define LIBGTOP_VM_DENYWRITE 0x0800 /* ETXTBSY on write attempts.. */
|
||||
|
||||
#define LIBGTOP_VM_EXECUTABLE 0x1000
|
||||
#define LIBGTOP_VM_LOCKED 0x2000
|
||||
#define LIBGTOP_VM_IO 0x4000 /* Memory mapped I/O or similar */
|
||||
|
||||
#define LIBGTOP_MAP_PATH_LEN (PAGE_SIZE - sizeof (libgtop_proc_maps_header_t))
|
||||
|
||||
#ifndef min
|
||||
#define min(a,b) ((a < b) ? a : b)
|
||||
#endif
|
||||
|
||||
typedef struct libgtop_stat libgtop_stat_t;
|
||||
|
||||
typedef struct libgtop_cpu libgtop_cpu_t;
|
||||
@@ -36,6 +78,17 @@ typedef struct libgtop_mem libgtop_mem_t;
|
||||
typedef struct libgtop_swap libgtop_swap_t;
|
||||
typedef struct libgtop_proclist libgtop_proclist_t;
|
||||
|
||||
typedef struct libgtop_proc_state libgtop_proc_state_t;
|
||||
typedef struct libgtop_proc_kernel libgtop_proc_kernel_t;
|
||||
typedef struct libgtop_proc_segment libgtop_proc_segment_t;
|
||||
typedef struct libgtop_proc_mem libgtop_proc_mem_t;
|
||||
typedef struct libgtop_proc_signal libgtop_proc_signal_t;
|
||||
|
||||
typedef struct libgtop_proc_maps_header libgtop_proc_maps_header_t;
|
||||
typedef struct libgtop_proc_maps libgtop_proc_maps_t;
|
||||
|
||||
typedef struct libgtop_netload libgtop_netload_t;
|
||||
|
||||
struct libgtop_cpu
|
||||
{
|
||||
unsigned long total; /* Total CPU Time */
|
||||
@@ -51,6 +104,7 @@ struct libgtop_mem
|
||||
unsigned long freeram; /* Available memory size */
|
||||
unsigned long sharedram; /* Amount of shared memory */
|
||||
unsigned long bufferram; /* Memory used by buffers */
|
||||
unsigned long cachedram;
|
||||
};
|
||||
|
||||
struct libgtop_swap
|
||||
@@ -61,6 +115,7 @@ struct libgtop_swap
|
||||
|
||||
struct libgtop_proclist
|
||||
{
|
||||
int count;
|
||||
int nr_running, nr_tasks, last_pid;
|
||||
unsigned pids [NR_TASKS];
|
||||
};
|
||||
@@ -79,4 +134,109 @@ struct libgtop_stat
|
||||
unsigned int pswpin, pswpout; /* # of swap pgs brought in/out */
|
||||
};
|
||||
|
||||
struct libgtop_proc_state
|
||||
{
|
||||
long state;
|
||||
unsigned long flags;
|
||||
char comm [16];
|
||||
int uid, euid, suid, fsuid;
|
||||
int gid, egid, sgid, fsgid;
|
||||
int pid, pgrp, ppid;
|
||||
int session;
|
||||
unsigned int tty;
|
||||
int tpgid;
|
||||
long priority, counter, def_priority;
|
||||
long utime, stime, cutime, cstime, start_time;
|
||||
long per_cpu_utime [NR_CPUS], per_cpu_stime [NR_CPUS];
|
||||
int has_cpu, processor, last_processor;
|
||||
|
||||
unsigned long context;
|
||||
unsigned long start_code, end_code, start_data, end_data;
|
||||
unsigned long start_brk, brk, start_stack, start_mmap;
|
||||
unsigned long arg_start, arg_end, env_start, env_end;
|
||||
unsigned long rss, rlim, total_vm, locked_vm;
|
||||
|
||||
unsigned long policy, rt_priority;
|
||||
unsigned long it_real_value, it_prof_value, it_virt_value;
|
||||
unsigned long it_real_incr, it_prof_incr, it_virt_incr;
|
||||
|
||||
unsigned long keip, kesp;
|
||||
unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt;
|
||||
unsigned long nswap, cnswap;
|
||||
|
||||
int ngroups, groups [LIBGTOP_MAX_GROUPS];
|
||||
};
|
||||
|
||||
struct libgtop_proc_kernel
|
||||
{
|
||||
unsigned long wchan;
|
||||
};
|
||||
|
||||
struct libgtop_proc_segment
|
||||
{
|
||||
unsigned long vsize, data, exec, stack, lib;
|
||||
};
|
||||
|
||||
struct libgtop_proc_mem
|
||||
{
|
||||
libgtop_proc_segment_t segment;
|
||||
int size, resident, share, trs, lrs, drs, dt;
|
||||
unsigned long rss, rlim;
|
||||
};
|
||||
|
||||
struct libgtop_proc_signal
|
||||
{
|
||||
unsigned long signal [LIBGTOP_NSIG];
|
||||
unsigned long blocked [LIBGTOP_NSIG];
|
||||
unsigned long ignore [LIBGTOP_NSIG];
|
||||
unsigned long catch [LIBGTOP_NSIG];
|
||||
};
|
||||
|
||||
struct libgtop_proc_maps_header
|
||||
{
|
||||
unsigned long start, end, offset, perm;
|
||||
off_t filename_offset;
|
||||
ino_t inode;
|
||||
dev_t device;
|
||||
} __attribute__ ((aligned (64)));
|
||||
|
||||
struct libgtop_proc_maps
|
||||
{
|
||||
libgtop_proc_maps_header_t header;
|
||||
char filename [LIBGTOP_MAP_PATH_LEN];
|
||||
};
|
||||
|
||||
struct libgtop_netload
|
||||
{
|
||||
unsigned long rx_packets; /* total packets received */
|
||||
unsigned long tx_packets; /* total packets transmitted */
|
||||
unsigned long rx_bytes; /* total bytes received */
|
||||
unsigned long tx_bytes; /* total bytes transmitted */
|
||||
unsigned long rx_errors; /* bad packets received */
|
||||
unsigned long tx_errors; /* packet transmit problems */
|
||||
unsigned long rx_dropped; /* no space in linux buffers */
|
||||
unsigned long tx_dropped; /* no space available in linux */
|
||||
unsigned long multicast; /* multicast packets received */
|
||||
unsigned long collisions;
|
||||
|
||||
/* detailed rx_errors: */
|
||||
unsigned long rx_length_errors;
|
||||
unsigned long rx_over_errors; /* receiver ring buff overflow */
|
||||
unsigned long rx_crc_errors; /* recved pkt with crc error */
|
||||
unsigned long rx_frame_errors; /* recv'd frame alignment error */
|
||||
unsigned long rx_fifo_errors; /* recv'r fifo overrun */
|
||||
unsigned long rx_missed_errors; /* receiver missed packet */
|
||||
|
||||
/* detailed tx_errors */
|
||||
unsigned long tx_aborted_errors;
|
||||
unsigned long tx_carrier_errors;
|
||||
unsigned long tx_fifo_errors;
|
||||
unsigned long tx_heartbeat_errors;
|
||||
unsigned long tx_window_errors;
|
||||
|
||||
/* for cslip etc */
|
||||
unsigned long rx_compressed;
|
||||
unsigned long tx_compressed;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -15,6 +15,8 @@
|
||||
extern unsigned long total_forks;
|
||||
|
||||
EXPORT_SYMBOL(task);
|
||||
EXPORT_SYMBOL(init_mm);
|
||||
EXPORT_SYMBOL(pidhash);
|
||||
EXPORT_SYMBOL(avenrun);
|
||||
EXPORT_SYMBOL(nr_running);
|
||||
EXPORT_SYMBOL(nr_tasks);
|
||||
@@ -22,3 +24,7 @@ EXPORT_SYMBOL(last_pid);
|
||||
EXPORT_SYMBOL(total_forks);
|
||||
EXPORT_SYMBOL(si_swapinfo);
|
||||
|
||||
extern void scheduling_functions_start_here(void);
|
||||
extern void scheduling_functions_end_here(void);
|
||||
EXPORT_SYMBOL(scheduling_functions_start_here);
|
||||
EXPORT_SYMBOL(scheduling_functions_end_here);
|
||||
|
188
kernel/table.h
Normal file
188
kernel/table.h
Normal file
@@ -0,0 +1,188 @@
|
||||
#ifndef _LINUX_TABLE_H
|
||||
#define _LINUX_TABLE_H
|
||||
|
||||
#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_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) */
|
||||
|
||||
struct table_cpu
|
||||
{
|
||||
unsigned long total; /* Total CPU Time */
|
||||
unsigned long user; /* CPU Time in User Mode */
|
||||
unsigned long nice; /* CPU Time in User Mode (nice) */
|
||||
unsigned long sys; /* CPU Time in System Mode */
|
||||
unsigned long idle; /* CPU Time in the Idle Task */
|
||||
unsigned long frequency; /* Tick frequency */
|
||||
};
|
||||
|
||||
/* Memory Usage (in bytes) */
|
||||
|
||||
struct table_mem
|
||||
{
|
||||
unsigned long total; /* Total physical memory */
|
||||
unsigned long used; /* Used memory size */
|
||||
unsigned long free; /* Free memory size */
|
||||
unsigned long shared; /* Shared memory size */
|
||||
unsigned long buffer; /* Size of buffers */
|
||||
unsigned long cached; /* Size of cached memory */
|
||||
};
|
||||
|
||||
/* Swap Space (in bytes) */
|
||||
|
||||
struct table_swap
|
||||
{
|
||||
unsigned long total; /* Total swap space */
|
||||
unsigned long used; /* Used swap space */
|
||||
unsigned long free; /* Free swap space */
|
||||
unsigned long pagein; /* Total # of pages swapped in */
|
||||
unsigned long pageout; /* Total # of pages swapped out */
|
||||
};
|
||||
|
||||
/* Load average */
|
||||
|
||||
struct table_loadavg
|
||||
{
|
||||
double loadavg [3];
|
||||
unsigned nr_running;
|
||||
unsigned nr_tasks;
|
||||
unsigned last_pid;
|
||||
};
|
||||
|
||||
/* Uptime */
|
||||
|
||||
struct table_uptime
|
||||
{
|
||||
unsigned long uptime;
|
||||
unsigned long idle;
|
||||
};
|
||||
|
||||
/* 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
|
||||
{
|
||||
long state;
|
||||
unsigned long flags;
|
||||
char comm[16];
|
||||
int uid, gid;
|
||||
};
|
||||
|
||||
struct table_proc_uid
|
||||
{
|
||||
int uid, euid, suid, fsuid;
|
||||
int gid, egid, sgid, fsgid;
|
||||
int pid, pgrp, ppid;
|
||||
int session;
|
||||
unsigned int tty;
|
||||
int tpgid;
|
||||
long priority;
|
||||
long counter;
|
||||
long def_priority;
|
||||
};
|
||||
|
||||
struct table_proc_mem
|
||||
{
|
||||
unsigned long context;
|
||||
unsigned long start_code, end_code, start_data, end_data;
|
||||
unsigned long start_brk, brk, start_stack, start_mmap;
|
||||
unsigned long arg_start, arg_end, env_start, env_end;
|
||||
unsigned long rss, rlim, total_vm, locked_vm;
|
||||
};
|
||||
|
||||
struct table_proc_segment
|
||||
{
|
||||
unsigned long vsize;
|
||||
unsigned long size, resident, shared;
|
||||
unsigned long trs, lrs, drs, srs, dt;
|
||||
};
|
||||
|
||||
struct table_proc_time
|
||||
{
|
||||
long utime, stime, cutime, cstime, start_time;
|
||||
unsigned long timeout, policy, rt_priority;
|
||||
unsigned long it_real_value, it_prof_value, it_virt_value;
|
||||
unsigned long it_real_incr, it_prof_incr, it_virt_incr;
|
||||
};
|
||||
|
||||
struct table_proc_signal
|
||||
{
|
||||
unsigned long long signal,
|
||||
blocked, /* bitmap of masked signals */
|
||||
ignored, /* mask of ignored signals */
|
||||
caught; /* mask of caught signals */
|
||||
};
|
||||
|
||||
struct table_proc_kernel
|
||||
{
|
||||
unsigned long keip, kesp, wchan;
|
||||
unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt;
|
||||
unsigned long nswap, cnswap;
|
||||
};
|
||||
|
||||
/* Union */
|
||||
|
||||
union table
|
||||
{
|
||||
struct table_cpu cpu;
|
||||
struct table_mem mem;
|
||||
struct table_swap swap;
|
||||
struct table_loadavg loadavg;
|
||||
struct table_uptime uptime;
|
||||
struct table_proclist proclist;
|
||||
struct table_proc_uid proc_uid;
|
||||
struct table_proc_mem proc_mem;
|
||||
struct table_proc_segment proc_segment;
|
||||
struct table_proc_time proc_time;
|
||||
struct table_proc_state proc_state;
|
||||
struct table_proc_signal proc_signal;
|
||||
struct table_proc_kernel proc_kernel;
|
||||
};
|
||||
|
||||
#endif /* _LINUX_IPC_H */
|
||||
|
||||
|
13
kernel/table20/Makefile
Normal file
13
kernel/table20/Makefile
Normal file
@@ -0,0 +1,13 @@
|
||||
#
|
||||
# Makefile for the linux system information tables.
|
||||
#
|
||||
# Note! Dependencies are done automagically by 'make dep', which also
|
||||
# removes any old dependencies. DON'T put your own dependencies here
|
||||
# unless it's something special (ie not a .c file).
|
||||
#
|
||||
# Note 2! The CFLAGS definition is now in the main makefile...
|
||||
|
||||
O_TARGET := table.o
|
||||
O_OBJS := main.o
|
||||
|
||||
include $(TOPDIR)/Rules.make
|
21
kernel/table20/README
Normal file
21
kernel/table20/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
|
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
|
51
kernel/table20/kernel.patch
Normal file
51
kernel/table20/kernel.patch
Normal file
@@ -0,0 +1,51 @@
|
||||
diff -ur linux-2.0.32/Makefile linux-hacked/Makefile
|
||||
--- linux-2.0.32/Makefile Fri Nov 7 19:51:05 1997
|
||||
+++ linux-hacked/Makefile Thu Jun 11 20:41:12 1998
|
||||
@@ -87,7 +87,7 @@
|
||||
# standard CFLAGS
|
||||
#
|
||||
|
||||
-CFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -fno-strength-reduce
|
||||
+CFLAGS = -Wall -Wstrict-prototypes -g -O2 -fomit-frame-pointer -fno-strength-reduce
|
||||
|
||||
ifdef CONFIG_CPP
|
||||
CFLAGS := $(CFLAGS) -x c++
|
||||
@@ -113,12 +113,12 @@
|
||||
# Include the make variables (CC, etc...)
|
||||
#
|
||||
|
||||
-ARCHIVES =kernel/kernel.o mm/mm.o fs/fs.o ipc/ipc.o net/network.a
|
||||
+ARCHIVES =kernel/kernel.o mm/mm.o fs/fs.o ipc/ipc.o net/network.a table/table.o
|
||||
FILESYSTEMS =fs/filesystems.a
|
||||
DRIVERS =drivers/block/block.a \
|
||||
drivers/char/char.a
|
||||
LIBS =$(TOPDIR)/lib/lib.a
|
||||
-SUBDIRS =kernel drivers mm fs net ipc lib
|
||||
+SUBDIRS =kernel drivers mm fs net ipc lib table
|
||||
|
||||
ifeq ($(CONFIG_ISDN),y)
|
||||
DRIVERS := $(DRIVERS) drivers/isdn/isdn.a
|
||||
diff -ur linux-2.0.32/arch/i386/kernel/entry.S linux-hacked/arch/i386/kernel/entry.S
|
||||
--- linux-2.0.32/arch/i386/kernel/entry.S Tue Sep 16 23:42:45 1997
|
||||
+++ linux-hacked/arch/i386/kernel/entry.S Thu Jun 11 21:37:20 1998
|
||||
@@ -699,4 +699,8 @@
|
||||
.long SYMBOL_NAME(sys_mremap)
|
||||
.long 0,0
|
||||
.long SYMBOL_NAME(sys_vm86)
|
||||
- .space (NR_syscalls-166)*4
|
||||
+ .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
|
||||
diff -ur linux-2.0.32/include/asm-i386/unistd.h linux-hacked/include/asm-i386/unistd.h
|
||||
--- linux-2.0.32/include/asm-i386/unistd.h Fri Mar 22 07:34:02 1996
|
||||
+++ linux-hacked/include/asm-i386/unistd.h Thu Jun 11 21:37:03 1998
|
||||
@@ -169,6 +169,7 @@
|
||||
#define __NR_sched_rr_get_interval 161
|
||||
#define __NR_nanosleep 162
|
||||
#define __NR_mremap 163
|
||||
+#define __NR_table 188
|
||||
|
||||
/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
|
||||
#define _syscall0(type,name) \
|
468
kernel/table20/main.c
Normal file
468
kernel/table20/main.c
Normal file
@@ -0,0 +1,468 @@
|
||||
/*
|
||||
* linux/table/table_impl.c
|
||||
* Copyright (C) 1998 Martin Baulig
|
||||
*/
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/kernel_stat.h>
|
||||
#include <linux/tty.h>
|
||||
#include <linux/user.h>
|
||||
#include <linux/a.out.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/mman.h>
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/ioport.h>
|
||||
#include <linux/config.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/pagemap.h>
|
||||
#include <linux/swap.h>
|
||||
|
||||
#include <asm/segment.h>
|
||||
#include <asm/pgtable.h>
|
||||
#include <asm/io.h>
|
||||
|
||||
#include <linux/table.h>
|
||||
|
||||
#include "version.h"
|
||||
|
||||
#if defined(__i386__)
|
||||
# define KSTK_EIP(tsk) (((unsigned long *)tsk->kernel_stack_page)[1019])
|
||||
# define KSTK_ESP(tsk) (((unsigned long *)tsk->kernel_stack_page)[1022])
|
||||
#elif defined(__alpha__)
|
||||
/*
|
||||
* See arch/alpha/kernel/ptrace.c for details.
|
||||
*/
|
||||
# define PT_REG(reg) (PAGE_SIZE - sizeof(struct pt_regs) \
|
||||
+ (long)&((struct pt_regs *)0)->reg)
|
||||
# define KSTK_EIP(tsk) (*(unsigned long *)(tsk->kernel_stack_page + PT_REG(pc)))
|
||||
# define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->tss.usp)
|
||||
#elif defined(__sparc__)
|
||||
# define PT_REG(reg) (PAGE_SIZE - sizeof(struct pt_regs) \
|
||||
+ (long)&((struct pt_regs *)0)->reg)
|
||||
# define KSTK_EIP(tsk) (*(unsigned long *)(tsk->kernel_stack_page + PT_REG(pc)))
|
||||
# define KSTK_ESP(tsk) (*(unsigned long *)(tsk->kernel_stack_page + PT_REG(u_regs[UREG_FP])))
|
||||
#endif
|
||||
|
||||
static struct task_struct *
|
||||
get_task (pid_t pid)
|
||||
{
|
||||
struct task_struct ** p;
|
||||
|
||||
p = task;
|
||||
while (++p < task+NR_TASKS) {
|
||||
if (*p && (*p)->pid == pid)
|
||||
return *p;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline void statm_pte_range(pmd_t * pmd, unsigned long address, unsigned long size,
|
||||
int * pages, int * shared, int * dirty, int * total)
|
||||
{
|
||||
pte_t * pte;
|
||||
unsigned long end;
|
||||
|
||||
if (pmd_none(*pmd))
|
||||
return;
|
||||
if (pmd_bad(*pmd)) {
|
||||
printk("statm_pte_range: bad pmd (%08lx)\n", pmd_val(*pmd));
|
||||
pmd_clear(pmd);
|
||||
return;
|
||||
}
|
||||
pte = pte_offset(pmd, address);
|
||||
address &= ~PMD_MASK;
|
||||
end = address + size;
|
||||
if (end > PMD_SIZE)
|
||||
end = PMD_SIZE;
|
||||
do {
|
||||
pte_t page = *pte;
|
||||
|
||||
address += PAGE_SIZE;
|
||||
pte++;
|
||||
if (pte_none(page))
|
||||
continue;
|
||||
++*total;
|
||||
if (!pte_present(page))
|
||||
continue;
|
||||
++*pages;
|
||||
if (pte_dirty(page))
|
||||
++*dirty;
|
||||
if (pte_page(page) >= high_memory)
|
||||
continue;
|
||||
if (mem_map[MAP_NR(pte_page(page))].count > 1)
|
||||
++*shared;
|
||||
} while (address < end);
|
||||
}
|
||||
|
||||
static inline void statm_pmd_range(pgd_t * pgd, unsigned long address, unsigned long size,
|
||||
int * pages, int * shared, int * dirty, int * total)
|
||||
{
|
||||
pmd_t * pmd;
|
||||
unsigned long end;
|
||||
|
||||
if (pgd_none(*pgd))
|
||||
return;
|
||||
if (pgd_bad(*pgd)) {
|
||||
printk("statm_pmd_range: bad pgd (%08lx)\n", pgd_val(*pgd));
|
||||
pgd_clear(pgd);
|
||||
return;
|
||||
}
|
||||
pmd = pmd_offset(pgd, address);
|
||||
address &= ~PGDIR_MASK;
|
||||
end = address + size;
|
||||
if (end > PGDIR_SIZE)
|
||||
end = PGDIR_SIZE;
|
||||
do {
|
||||
statm_pte_range(pmd, address, end - address, pages, shared, dirty, total);
|
||||
address = (address + PMD_SIZE) & PMD_MASK;
|
||||
pmd++;
|
||||
} while (address < end);
|
||||
}
|
||||
|
||||
static void statm_pgd_range(pgd_t * pgd, unsigned long address, unsigned long end,
|
||||
int * pages, int * shared, int * dirty, int * total)
|
||||
{
|
||||
while (address < end) {
|
||||
statm_pmd_range(pgd, address, end - address, pages, shared, dirty, total);
|
||||
address = (address + PGDIR_SIZE) & PGDIR_MASK;
|
||||
pgd++;
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
get_wchan (struct task_struct *p)
|
||||
{
|
||||
if (!p || p == current || p->state == TASK_RUNNING)
|
||||
return 0;
|
||||
#if defined(__i386__)
|
||||
{
|
||||
unsigned long ebp, eip;
|
||||
unsigned long stack_page;
|
||||
int count = 0;
|
||||
|
||||
stack_page = p->kernel_stack_page;
|
||||
if (!stack_page)
|
||||
return 0;
|
||||
ebp = p->tss.ebp;
|
||||
do {
|
||||
if (ebp < stack_page || ebp >= 4092+stack_page)
|
||||
return 0;
|
||||
eip = *(unsigned long *) (ebp+4);
|
||||
if (eip < (unsigned long) interruptible_sleep_on
|
||||
|| eip >= (unsigned long) add_timer)
|
||||
return eip;
|
||||
ebp = *(unsigned long *) ebp;
|
||||
} while (count++ < 16);
|
||||
}
|
||||
#elif defined(__alpha__)
|
||||
/*
|
||||
* This one depends on the frame size of schedule(). Do a
|
||||
* "disass schedule" in gdb to find the frame size. Also, the
|
||||
* code assumes that sleep_on() follows immediately after
|
||||
* interruptible_sleep_on() and that add_timer() follows
|
||||
* immediately after interruptible_sleep(). Ugly, isn't it?
|
||||
* Maybe adding a wchan field to task_struct would be better,
|
||||
* after all...
|
||||
*/
|
||||
{
|
||||
unsigned long schedule_frame;
|
||||
unsigned long pc;
|
||||
|
||||
pc = thread_saved_pc(&p->tss);
|
||||
if (pc >= (unsigned long) interruptible_sleep_on && pc < (unsigned long) add_timer) {
|
||||
schedule_frame = ((unsigned long *)p->tss.ksp)[6];
|
||||
return ((unsigned long *)schedule_frame)[12];
|
||||
}
|
||||
return pc;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
asmlinkage int
|
||||
sys_table (int type, union table *buf, const void *param)
|
||||
{
|
||||
union table tbl;
|
||||
struct sysinfo i;
|
||||
struct task_struct *tsk = NULL;
|
||||
struct ip_chain *chain;
|
||||
struct ip_fwkernel *rule;
|
||||
char devname [9];
|
||||
int index, err;
|
||||
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;
|
||||
memcpy_fromfs (&pid, param, sizeof (pid_t));
|
||||
|
||||
tsk = get_task (pid);
|
||||
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.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;
|
||||
tbl.swap.pagein = kstat.pswpin;
|
||||
tbl.swap.pageout = kstat.pswpout;
|
||||
break;
|
||||
case TABLE_LOADAVG:
|
||||
tbl.loadavg.loadavg [0] = (double) avenrun [0] / (1 << FSHIFT);
|
||||
tbl.loadavg.loadavg [1] = (double) avenrun [1] / (1 << FSHIFT);
|
||||
tbl.loadavg.loadavg [2] = (double) avenrun [2] / (1 << FSHIFT);
|
||||
tbl.loadavg.nr_running = nr_running;
|
||||
tbl.loadavg.nr_tasks = nr_tasks;
|
||||
tbl.loadavg.last_pid = last_pid;
|
||||
break;
|
||||
case TABLE_UPTIME:
|
||||
tbl.uptime.uptime = jiffies;
|
||||
tbl.uptime.idle = task[0]->utime + task[0]->stime;
|
||||
break;
|
||||
case TABLE_PROC_STATE:
|
||||
tbl.proc_state.state = tsk->state;
|
||||
tbl.proc_state.flags = tsk->flags;
|
||||
memcpy (tbl.proc_state.comm, tsk->comm,
|
||||
sizeof (tbl.proc_state.comm));
|
||||
break;
|
||||
case TABLE_PROC_UID:
|
||||
tbl.proc_uid.uid = tsk->uid;
|
||||
tbl.proc_uid.euid = tsk->euid;
|
||||
tbl.proc_uid.suid = tsk->suid;
|
||||
tbl.proc_uid.fsuid = tsk->fsuid;
|
||||
|
||||
tbl.proc_uid.gid = tsk->gid;
|
||||
tbl.proc_uid.egid = tsk->egid;
|
||||
tbl.proc_uid.sgid = tsk->sgid;
|
||||
tbl.proc_uid.fsgid = tsk->fsgid;
|
||||
|
||||
tbl.proc_uid.pid = tsk->pid;
|
||||
tbl.proc_uid.pgrp = tsk->pgrp;
|
||||
tbl.proc_uid.ppid = tsk->p_pptr->pid;
|
||||
|
||||
tbl.proc_uid.session = tsk->session;
|
||||
tbl.proc_uid.tty = tsk->tty ?
|
||||
kdev_t_to_nr (tsk->tty->device) : 0;
|
||||
tbl.proc_uid.tpgid = tsk->tty ? tsk->tty->pgrp : -1;
|
||||
|
||||
tbl.proc_uid.priority = tsk->priority;
|
||||
tbl.proc_uid.counter = tsk->counter;
|
||||
tbl.proc_uid.def_priority = DEF_PRIORITY;
|
||||
break;
|
||||
case TABLE_PROC_SIGNAL:
|
||||
tbl.proc_signal.signal = tsk->signal;
|
||||
tbl.proc_signal.blocked = tsk->blocked;
|
||||
|
||||
if (tsk->sig) {
|
||||
struct sigaction * action = tsk->sig->action;
|
||||
unsigned long sig_ign = 0, sig_caught = 0;
|
||||
unsigned long bit = 1;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 32; i++) {
|
||||
switch((unsigned long) action->sa_handler) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
sig_ign |= bit;
|
||||
break;
|
||||
default:
|
||||
sig_caught |= bit;
|
||||
}
|
||||
bit <<= 1;
|
||||
action++;
|
||||
}
|
||||
|
||||
tbl.proc_signal.ignored = sig_ign;
|
||||
tbl.proc_signal.caught = sig_caught;
|
||||
} else {
|
||||
tbl.proc_signal.ignored = 0;
|
||||
tbl.proc_signal.caught = 0;
|
||||
}
|
||||
break;
|
||||
case TABLE_PROC_MEM:
|
||||
if (tsk->mm && tsk->mm != &init_mm) {
|
||||
tbl.proc_mem.context = tsk->mm->context;
|
||||
tbl.proc_mem.start_code = tsk->mm->start_code;
|
||||
tbl.proc_mem.end_code = tsk->mm->end_code;
|
||||
tbl.proc_mem.start_data = tsk->mm-> start_data;
|
||||
tbl.proc_mem.end_data = tsk->mm->end_data;
|
||||
tbl.proc_mem.start_brk = tsk->mm->start_brk;
|
||||
tbl.proc_mem.brk = tsk->mm->brk;
|
||||
tbl.proc_mem.start_stack = tsk->mm->start_stack;
|
||||
tbl.proc_mem.start_mmap = tsk->mm->start_mmap;
|
||||
tbl.proc_mem.arg_start = tsk->mm->arg_start;
|
||||
tbl.proc_mem.arg_end = tsk->mm->arg_end;
|
||||
tbl.proc_mem.env_start = tsk->mm->env_start;
|
||||
tbl.proc_mem.env_end = tsk->mm->env_end;
|
||||
tbl.proc_mem.rss = tsk->mm->rss;
|
||||
tbl.proc_mem.total_vm = tsk->mm->total_vm;
|
||||
tbl.proc_mem.locked_vm = tsk->mm->locked_vm;
|
||||
}
|
||||
tbl.proc_mem.rlim = tsk->rlim ?
|
||||
tsk->rlim[RLIMIT_RSS].rlim_cur : 0;
|
||||
break;
|
||||
case TABLE_PROC_SEGMENT:
|
||||
if (tsk->mm && tsk->mm != &init_mm) {
|
||||
unsigned long vsize = 0;
|
||||
int size = 0, resident = 0, share = 0;
|
||||
int trs = 0, lrs = 0, drs = 0, dt = 0;
|
||||
struct vm_area_struct * vma = tsk->mm->mmap;
|
||||
|
||||
while (vma) {
|
||||
pgd_t *pgd = pgd_offset(tsk->mm, vma->vm_start);
|
||||
int pages = 0, shared = 0, dirty = 0, total = 0;
|
||||
|
||||
vsize += vma->vm_end - vma->vm_start;
|
||||
|
||||
statm_pgd_range (pgd, vma->vm_start, vma->vm_end,
|
||||
&pages, &shared, &dirty, &total);
|
||||
resident += pages;
|
||||
share += shared;
|
||||
dt += dirty;
|
||||
size += total;
|
||||
if (vma->vm_flags & VM_EXECUTABLE)
|
||||
trs += pages; /* text */
|
||||
else if (vma->vm_flags & VM_GROWSDOWN)
|
||||
drs += pages; /* stack */
|
||||
else if (vma->vm_end > 0x60000000)
|
||||
lrs += pages; /* library */
|
||||
else
|
||||
drs += pages;
|
||||
vma = vma->vm_next;
|
||||
}
|
||||
|
||||
tbl.proc_segment.vsize = vsize;
|
||||
tbl.proc_segment.size = size;
|
||||
tbl.proc_segment.resident = resident;
|
||||
tbl.proc_segment.shared = share;
|
||||
tbl.proc_segment.trs = trs;
|
||||
tbl.proc_segment.lrs = lrs;
|
||||
tbl.proc_segment.dt = dt;
|
||||
}
|
||||
break;
|
||||
case TABLE_PROC_TIME:
|
||||
tbl.proc_time.utime = tsk->utime;
|
||||
tbl.proc_time.stime = tsk->stime;
|
||||
tbl.proc_time.cutime = tsk->cutime;
|
||||
tbl.proc_time.cstime = tsk->cstime;
|
||||
|
||||
tbl.proc_time.start_time = tsk->start_time;
|
||||
tbl.proc_time.timeout = tsk->timeout;
|
||||
tbl.proc_time.policy = tsk->policy;
|
||||
tbl.proc_time.rt_priority = tsk->rt_priority;
|
||||
|
||||
tbl.proc_time.it_real_value = tsk->it_real_value;
|
||||
tbl.proc_time.it_prof_value = tsk->it_prof_value;
|
||||
tbl.proc_time.it_virt_value = tsk->it_virt_value;
|
||||
tbl.proc_time.it_real_incr = tsk->it_real_incr;
|
||||
tbl.proc_time.it_prof_incr = tsk->it_prof_incr;
|
||||
tbl.proc_time.it_virt_incr = tsk->it_virt_incr;
|
||||
break;
|
||||
case TABLE_PROC_KERNEL:
|
||||
tbl.proc_kernel.min_flt = tsk->min_flt;
|
||||
tbl.proc_kernel.cmin_flt = tsk->cmin_flt;
|
||||
tbl.proc_kernel.maj_flt = tsk->maj_flt;
|
||||
tbl.proc_kernel.cmaj_flt = tsk->cmaj_flt;
|
||||
|
||||
tbl.proc_kernel.kesp = tsk->kernel_stack_page ? KSTK_EIP(tsk) : 0;
|
||||
tbl.proc_kernel.keip = tsk->kernel_stack_page ? KSTK_ESP(tsk) : 0;
|
||||
|
||||
tbl.proc_kernel.nswap = tsk->nswap;
|
||||
tbl.proc_kernel.cnswap = tsk->cnswap;
|
||||
|
||||
tbl.proc_kernel.wchan = get_wchan (tsk);
|
||||
break;
|
||||
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;
|
||||
}
|
||||
|
||||
err = verify_area (VERIFY_WRITE, buf, sizeof (struct table));
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
memcpy_tofs (buf, &tbl, sizeof (union table));
|
||||
return 0;
|
||||
}
|
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
kernel/version.h
Normal file
1
kernel/version.h
Normal file
@@ -0,0 +1 @@
|
||||
#define _TABLE_VERSION 1
|
10
lib/lib.pl
10
lib/lib.pl
@@ -46,14 +46,16 @@ 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, old_required, present);";
|
||||
print "\t\t\t\t \"field mask %05lx, but only have %05lx.\"),";
|
||||
print "\t\t\t\t feature, (unsigned long) old_required,";
|
||||
print "\t\t\t\t (unsigned long) 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, old_required, present);";
|
||||
print "\t\t\t\t \"field mask %05lx, but only have %05lx.\"),";
|
||||
print "\t\t\t\t feature, (unsigned long) old_required,";
|
||||
print "\t\t\t\t (unsigned long) present);";
|
||||
print "\t\tbreak;";
|
||||
print "\t}";
|
||||
print '}';
|
||||
|
@@ -30,6 +30,7 @@ do_read (int s, void *ptr, size_t total_size)
|
||||
{
|
||||
int nread;
|
||||
size_t already_read = 0, remaining = total_size;
|
||||
char *tmp_ptr;
|
||||
|
||||
while (already_read < total_size) {
|
||||
nread = recv (s, ptr, remaining, 0);
|
||||
@@ -46,7 +47,10 @@ do_read (int s, void *ptr, size_t total_size)
|
||||
|
||||
already_read += nread;
|
||||
remaining -= nread;
|
||||
(char *) ptr += nread;
|
||||
/* (char *) ptr += nread; */
|
||||
tmp_ptr = ptr;
|
||||
tmp_ptr += nread;
|
||||
ptr = tmp_ptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -40,6 +40,7 @@ GLIBTOP_SUID_PROC_TIME +
|
||||
GLIBTOP_SUID_PROC_SIGNAL +
|
||||
GLIBTOP_SUID_PROC_KERNEL +
|
||||
GLIBTOP_SUID_PROC_SEGMENT +
|
||||
GLIBTOP_SUID_PROC_ARGS +
|
||||
GLIBTOP_SUID_PROC_MAP +
|
||||
GLIBTOP_SUID_NETLOAD +
|
||||
GLIBTOP_SUID_PPP;
|
||||
|
@@ -15,44 +15,45 @@ AC_DEFUN([LIBGTOP_HACKER_TESTS],[
|
||||
|
||||
case "$host_os" in
|
||||
linux*)
|
||||
AC_ARG_WITH(linux-sysctl,
|
||||
[ --with-linux-sysctl Use the sysctl () interface from Martin Baulig],[
|
||||
linux_sysctl="$withval"],[linux_sysctl=auto])
|
||||
if test $linux_sysctl = yes ; then
|
||||
AC_CHECK_HEADER(linux/libgtop.h, linux_sysctl=yes, linux_sysctl=no)
|
||||
elif test $linux_sysctl = auto ; then
|
||||
AC_MSG_CHECKING(for LibGTop sysctl support in Linux Kernel)
|
||||
AC_ARG_WITH(linux-table,
|
||||
[ --with-linux-table Use the table () function from Martin Baulig],[
|
||||
linux_table="$withval"],[linux_table=auto])
|
||||
if test $linux_table = yes ; then
|
||||
AC_CHECK_HEADER(linux/table.h, linux_table=yes, linux_table=no)
|
||||
elif test $linux_table = auto ; then
|
||||
AC_MSG_CHECKING(for table function in Linux Kernel)
|
||||
AC_TRY_RUN([
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <sys/sysctl.h>
|
||||
#include <linux/libgtop.h>
|
||||
#include <unistd.h>
|
||||
#include <linux/unistd.h>
|
||||
#include <linux/table.h>
|
||||
|
||||
#define SIZE(x) sizeof(x)/sizeof(x[0])
|
||||
#include <syscall.h>
|
||||
|
||||
int name[2] = { CTL_LIBGTOP, LIBGTOP_VERSION };
|
||||
static inline _syscall3 (int, table, int, type, union table *, tbl, const void *, param);
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
unsigned version;
|
||||
size_t size = sizeof (version);
|
||||
union table tbl;
|
||||
int ret;
|
||||
|
||||
if (sysctl (name, SIZE (name), &version, &size, NULL, 0))
|
||||
exit (1);
|
||||
else if (version < 1)
|
||||
exit (2);
|
||||
else
|
||||
exit (0);
|
||||
ret = table (TABLE_VERSION, NULL, NULL);
|
||||
|
||||
if (ret == -1)
|
||||
exit (-errno);
|
||||
|
||||
exit (ret < 1 ? ret : 0);
|
||||
}
|
||||
], linux_sysctl=yes, linux_sysctl=no, linux_sysctl=no)
|
||||
AC_MSG_RESULT($linux_sysctl)
|
||||
], linux_table=yes, linux_table=no, linux_table=no)
|
||||
AC_MSG_RESULT($linux_table)
|
||||
fi
|
||||
if test $linux_sysctl = yes ; then
|
||||
AC_DEFINE(HAVE_LINUX_SYSCTL)
|
||||
if test $linux_table = yes ; then
|
||||
AC_DEFINE(HAVE_LINUX_TABLE)
|
||||
fi
|
||||
AM_CONDITIONAL(LINUX_SYSCTL, test $linux_sysctl = yes)
|
||||
AM_CONDITIONAL(LINUX_TABLE, test $linux_table = yes)
|
||||
;;
|
||||
esac
|
||||
])
|
||||
@@ -107,17 +108,17 @@ AC_DEFUN([GNOME_LIBGTOP_SYSDEPS],[
|
||||
|
||||
case "$host_os" in
|
||||
linux*)
|
||||
if test x$linux_sysctl = xyes ; then
|
||||
if test x$linux_table = xyes ; then
|
||||
libgtop_sysdeps_dir=kernel
|
||||
libgtop_use_machine_h=no
|
||||
else
|
||||
libgtop_sysdeps_dir=linux
|
||||
libgtop_use_machine_h=no
|
||||
libgtop_have_sysinfo=yes
|
||||
fi
|
||||
libgtop_have_sysinfo=yes
|
||||
libgtop_need_server=no
|
||||
;;
|
||||
freebsd*|netbsd*|openbsd*)
|
||||
freebsd*|netbsd*|openbsd*|bsdi*)
|
||||
libgtop_sysdeps_dir=freebsd
|
||||
libgtop_use_machine_h=yes
|
||||
libgtop_need_server=yes
|
||||
@@ -126,20 +127,9 @@ AC_DEFUN([GNOME_LIBGTOP_SYSDEPS],[
|
||||
*)
|
||||
if test x$hacker_mode = xyes ; then
|
||||
case "$host_os" in
|
||||
bsdi*)
|
||||
libgtop_sysdeps_dir=freebsd
|
||||
libgtop_use_machine_h=yes
|
||||
libgtop_need_server=yes
|
||||
libgtop_postinstall='chgrp kmem $(bindir)/libgtop_server && chmod 2755 $(bindir)/libgtop_server'
|
||||
;;
|
||||
solaris*)
|
||||
libgtop_sysdeps_dir=solaris
|
||||
libgtop_use_machine_h=yes
|
||||
libgtop_need_server=no
|
||||
;;
|
||||
sunos4*)
|
||||
libgtop_sysdeps_dir=sun4
|
||||
libgtop_use_machine_h=yes
|
||||
libgtop_use_machine_h=yes
|
||||
libgtop_need_server=yes
|
||||
;;
|
||||
osf*)
|
||||
@@ -187,7 +177,7 @@ AC_DEFUN([GNOME_LIBGTOP_SYSDEPS],[
|
||||
#include <net/netisr.h>
|
||||
#include <net/route.h>
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if (defined __FreeBSD__) || (defined __NetBSD__)
|
||||
#include <net/if_sppp.h>
|
||||
#else
|
||||
#include <i4b/sppp/if_sppp.h>
|
||||
@@ -213,7 +203,7 @@ AC_DEFUN([GNOME_LIBGTOP_SYSDEPS],[
|
||||
#include <net/netisr.h>
|
||||
#include <net/route.h>
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
#include <net/if_sppp.h>
|
||||
#else
|
||||
#include <i4b/sppp/if_sppp.h>
|
||||
|
26
misc/timings/timings.linux-proc
Normal file
26
misc/timings/timings.linux-proc
Normal file
@@ -0,0 +1,26 @@
|
||||
This statistics were made on a PPRO 200 running Linux 2.2.1
|
||||
reading everything from /proc while the system was idle.
|
||||
|
||||
|
||||
Feature (Flags ): Count - utime - stime
|
||||
----------------------------------------------------------
|
||||
CPU (0x000007ff): 100000 - 13.90 - 181.80
|
||||
Memory (0x0000007f): 10000 - 32.00 - 8061.00
|
||||
Swap (0x0000001f): 10000 - 46.00 - 8130.00
|
||||
Uptime (0x00000003): 100000 - 19.60 - 72.20
|
||||
Loadavg (0x0000000f): 100000 - 32.40 - 77.10
|
||||
|
||||
Proclist (0x00000007): 10000 - 2250.00 - 4419.00
|
||||
|
||||
Proc_State (0x0000000f): 100000 - 40.70 - 221.00
|
||||
Proc_Uid (0x00000fff): 100000 - 72.40 - 327.30
|
||||
Proc_Mem (0x0000003f): 100000 - 65.70 - 283.90
|
||||
Proc_Segment (0x000000f5): 100000 - 76.50 - 281.10
|
||||
Proc_Time (0x000001ff): 100000 - 37.00 - 160.90
|
||||
Proc_Signal (0x0000000f): 100000 - 52.50 - 148.50
|
||||
Proc_Kernel (0x0000017f): 100000 - 56.70 - 153.50
|
||||
----------------------------------------------------------
|
||||
TOTAL 70030000 - 396830000
|
||||
|
||||
All timings are in clock ticks (1000000 ticks per second).
|
||||
|
27
misc/timings/timings.linux-sysctl
Normal file
27
misc/timings/timings.linux-sysctl
Normal file
@@ -0,0 +1,27 @@
|
||||
This statistics were made on a PPRO 200 running Linux 2.2.1
|
||||
(the same machine I made the timings.linux-proc on) with my
|
||||
new sysctl () based kernel module.
|
||||
|
||||
|
||||
Feature (Flags ): Count - utime - stime
|
||||
----------------------------------------------------------
|
||||
CPU (0x0000003f): 100000 - 3.50 - 5.40
|
||||
Memory (0x0000003f): 10000 - 3.00 - 6.00
|
||||
Swap (0x0000001f): 10000 - 10.00 - 7.00
|
||||
Uptime (0x00000003): 100000 - 2.30 - 7.00
|
||||
Loadavg (0x00000001): 100000 - 3.00 - 5.60
|
||||
|
||||
Proclist (0x00000007): 10000 - 13.00 - 46.00
|
||||
|
||||
Proc_State (0x0000000d): 100000 - 3.20 - 7.70
|
||||
Proc_Uid (0x00000fff): 100000 - 3.60 - 7.40
|
||||
Proc_Mem (0x0000003f): 100000 - 4.10 - 34.30
|
||||
Proc_Segment (0x000000ff): 100000 - 5.90 - 41.50
|
||||
Proc_Time (0x0000013d): 100000 - 3.50 - 7.50
|
||||
Proc_Signal (0x0000000f): 100000 - 2.70 - 8.80
|
||||
Proc_Kernel (0x000000fe): 100000 - 4.00 - 13.30
|
||||
----------------------------------------------------------
|
||||
TOTAL 3840000 - 14440000
|
||||
|
||||
All timings are in clock ticks (1000000 ticks per second).
|
||||
|
@@ -2,6 +2,6 @@ Makefile
|
||||
Makefile.in
|
||||
POTFILES
|
||||
cat-id-tbl.c
|
||||
*.gmo *.mo
|
||||
*.gmo
|
||||
libgtop.pot
|
||||
Makefile.in.in
|
||||
|
4
po/de.po
4
po/de.po
@@ -5,7 +5,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: libgtop VERSION\n"
|
||||
"POT-Creation-Date: 1999-03-01 22:58+0100\n"
|
||||
"POT-Creation-Date: 1999-05-28 01:39+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: Martin Baulig <martin@home-of-linux.org>\n"
|
||||
"Language-Team: Martin Baulig <martin@home-of-linux.org>\n"
|
||||
@@ -1015,7 +1015,7 @@ msgstr ""
|
||||
msgid "%s: option `-W %s' doesn't allow an argument\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/read.c:71
|
||||
#: lib/read.c:75
|
||||
#, c-format
|
||||
msgid "read %d bytes"
|
||||
msgstr ""
|
||||
|
4
po/es.po
4
po/es.po
@@ -1,7 +1,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: glibtop 1.0.0\n"
|
||||
"POT-Creation-Date: 1999-03-01 22:58+0100\n"
|
||||
"POT-Creation-Date: 1999-05-28 01:39+0200\n"
|
||||
"PO-Revision-Date: 1998-12-13 04:38+0100\n"
|
||||
"Last-Translator: Pablo Saratxaga <srtxg@chanae.alphanet.ch>\n"
|
||||
"Language-Team: Pablo Saratxaga <srtxg@chanae.alphanet.ch>\n"
|
||||
@@ -1057,7 +1057,7 @@ msgstr "%s: la opci
|
||||
msgid "%s: option `-W %s' doesn't allow an argument\n"
|
||||
msgstr "%s: la opci<63>n `-W %s' no admite argumentos\n"
|
||||
|
||||
#: lib/read.c:71
|
||||
#: lib/read.c:75
|
||||
#, c-format
|
||||
msgid "read %d bytes"
|
||||
msgstr "le<6C>dos %d bytes"
|
||||
|
@@ -6,7 +6,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 1999-03-01 22:58+0100\n"
|
||||
"POT-Creation-Date: 1999-05-28 01:39+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@@ -992,7 +992,7 @@ msgstr ""
|
||||
msgid "%s: option `-W %s' doesn't allow an argument\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/read.c:71
|
||||
#: lib/read.c:75
|
||||
#, c-format
|
||||
msgid "read %d bytes"
|
||||
msgstr ""
|
||||
|
@@ -6,7 +6,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 1999-03-01 22:58+0100\n"
|
||||
"POT-Creation-Date: 1999-05-28 01:39+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@@ -992,7 +992,7 @@ msgstr ""
|
||||
msgid "%s: option `-W %s' doesn't allow an argument\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/read.c:71
|
||||
#: lib/read.c:75
|
||||
#, c-format
|
||||
msgid "read %d bytes"
|
||||
msgstr ""
|
||||
|
@@ -6,7 +6,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 1999-03-01 22:58+0100\n"
|
||||
"POT-Creation-Date: 1999-05-28 01:39+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@@ -992,7 +992,7 @@ msgstr ""
|
||||
msgid "%s: option `-W %s' doesn't allow an argument\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/read.c:71
|
||||
#: lib/read.c:75
|
||||
#, c-format
|
||||
msgid "read %d bytes"
|
||||
msgstr ""
|
||||
|
@@ -6,7 +6,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 1999-03-01 22:58+0100\n"
|
||||
"POT-Creation-Date: 1999-05-28 01:39+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@@ -992,7 +992,7 @@ msgstr ""
|
||||
msgid "%s: option `-W %s' doesn't allow an argument\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/read.c:71
|
||||
#: lib/read.c:75
|
||||
#, c-format
|
||||
msgid "read %d bytes"
|
||||
msgstr ""
|
||||
|
@@ -6,7 +6,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 1999-03-01 22:58+0100\n"
|
||||
"POT-Creation-Date: 1999-05-28 01:39+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@@ -992,7 +992,7 @@ msgstr ""
|
||||
msgid "%s: option `-W %s' doesn't allow an argument\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/read.c:71
|
||||
#: lib/read.c:75
|
||||
#, c-format
|
||||
msgid "read %d bytes"
|
||||
msgstr ""
|
||||
|
@@ -6,7 +6,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 1999-03-01 22:58+0100\n"
|
||||
"POT-Creation-Date: 1999-05-28 01:39+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@@ -992,7 +992,7 @@ msgstr ""
|
||||
msgid "%s: option `-W %s' doesn't allow an argument\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/read.c:71
|
||||
#: lib/read.c:75
|
||||
#, c-format
|
||||
msgid "read %d bytes"
|
||||
msgstr ""
|
||||
|
@@ -6,7 +6,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 1999-03-01 22:58+0100\n"
|
||||
"POT-Creation-Date: 1999-05-28 01:39+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@@ -992,7 +992,7 @@ msgstr ""
|
||||
msgid "%s: option `-W %s' doesn't allow an argument\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/read.c:71
|
||||
#: lib/read.c:75
|
||||
#, c-format
|
||||
msgid "read %d bytes"
|
||||
msgstr ""
|
||||
|
4
po/fr.po
4
po/fr.po
@@ -5,7 +5,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: libgtop VERSION\n"
|
||||
"POT-Creation-Date: 1999-03-01 22:58+0100\n"
|
||||
"POT-Creation-Date: 1999-05-28 01:39+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: Vincent Renardias <vincent@waw.com>\n"
|
||||
"Language-Team: Vincent Renardias <vincent@waw.com>\n"
|
||||
@@ -983,7 +983,7 @@ msgstr ""
|
||||
msgid "%s: option `-W %s' doesn't allow an argument\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/read.c:71
|
||||
#: lib/read.c:75
|
||||
#, c-format
|
||||
msgid "read %d bytes"
|
||||
msgstr ""
|
||||
|
4
po/ja.po
4
po/ja.po
@@ -4,7 +4,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: libgtop VERSION\n"
|
||||
"POT-Creation-Date: 1999-03-01 22:58+0100\n"
|
||||
"POT-Creation-Date: 1999-05-28 01:39+0200\n"
|
||||
"PO-Revision-Date: 1998-12-11 06:53+09:00\n"
|
||||
"Last-Translator: Eiichiro ITANI <emu@ceres.dti.ne.jp>\n"
|
||||
"Language-Team: <gnome@lists.hypercore.co.jp>\n"
|
||||
@@ -1004,7 +1004,7 @@ msgstr ""
|
||||
msgid "%s: option `-W %s' doesn't allow an argument\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/read.c:71
|
||||
#: lib/read.c:75
|
||||
#, c-format
|
||||
msgid "read %d bytes"
|
||||
msgstr ""
|
||||
|
4
po/ko.po
4
po/ko.po
@@ -5,7 +5,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: libgtop VERSION\n"
|
||||
"POT-Creation-Date: 1999-03-01 22:58+0100\n"
|
||||
"POT-Creation-Date: 1999-05-28 01:39+0200\n"
|
||||
"PO-Revision-Date: 1999-02-04 14:31:38+0900\n"
|
||||
"Last-Translator: Sung-Hyun Nam <namsh@lgic.co.kr>\n"
|
||||
"Language-Team: Korean <ko@li.org>\n"
|
||||
@@ -980,7 +980,7 @@ msgstr "%s: `-W %s'
|
||||
msgid "%s: option `-W %s' doesn't allow an argument\n"
|
||||
msgstr "%s: `-W %s' <20>ɼ<EFBFBD><C9BC><EFBFBD> <20><><EFBFBD>ڰ<EFBFBD> <20>ʿ<EFBFBD><CABF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>\n"
|
||||
|
||||
#: lib/read.c:71
|
||||
#: lib/read.c:75
|
||||
#, c-format
|
||||
msgid "read %d bytes"
|
||||
msgstr ""
|
||||
|
4
po/no.po
4
po/no.po
@@ -5,7 +5,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: libgtop 0.99.3\n"
|
||||
"POT-Creation-Date: 1999-03-01 22:58+0100\n"
|
||||
"POT-Creation-Date: 1999-05-28 01:39+0200\n"
|
||||
"PO-Revision-Date: 1999-01-27 23:22+0100\n"
|
||||
"Last-Translator: Kjartan Maraas <kmaraas@fib.hl.no>\n"
|
||||
"Language-Team: Norwegian <no@li.org>\n"
|
||||
@@ -1004,7 +1004,7 @@ msgstr "%s: flagget `-W %s' er flertydig\n"
|
||||
msgid "%s: option `-W %s' doesn't allow an argument\n"
|
||||
msgstr "%s: flagget `-W %s' tar ikke argumenter\n"
|
||||
|
||||
#: lib/read.c:71
|
||||
#: lib/read.c:75
|
||||
#, c-format
|
||||
msgid "read %d bytes"
|
||||
msgstr "les %d bytes"
|
||||
|
@@ -1,6 +1,7 @@
|
||||
Makefile.in
|
||||
Makefile
|
||||
libgtop_daemon
|
||||
libgtop_server
|
||||
server.conf
|
||||
.libs
|
||||
.deps
|
||||
|
@@ -1,3 +1,11 @@
|
||||
1999-05-07 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* server.c (main): There's some problem with uname () - some systems
|
||||
like Solaris or Digital Unix return a nonnegative value on success,
|
||||
some others like Linux return 0. Since all known systems seem to return
|
||||
a negative value on failure, we simply check whether the return value is
|
||||
not negative here.
|
||||
|
||||
1999-02-19 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* Makefile.am (LIBGTOP_COMPILE_SYSTEM): Hardcoded system name.
|
||||
|
@@ -62,6 +62,7 @@ int
|
||||
do_read (int s, void *ptr, size_t total_size)
|
||||
{
|
||||
int nread;
|
||||
char *tmp_ptr;
|
||||
size_t already_read = 0, remaining = total_size;
|
||||
|
||||
while (already_read < total_size) {
|
||||
@@ -82,7 +83,10 @@ do_read (int s, void *ptr, size_t total_size)
|
||||
|
||||
already_read += nread;
|
||||
remaining -= nread;
|
||||
(char *) ptr += nread;
|
||||
/* (char *) ptr += nread; */
|
||||
tmp_ptr = ptr;
|
||||
tmp_ptr += nread;
|
||||
ptr = tmp_ptr;
|
||||
|
||||
#ifdef REAL_DEBUG
|
||||
fprintf (stderr, "READ (%d): %d - %d - %d\n",
|
||||
|
@@ -68,7 +68,7 @@ main(int argc, char *argv[])
|
||||
uid = getuid (); euid = geteuid ();
|
||||
gid = getgid (); egid = getegid ();
|
||||
|
||||
if (uname (&uts)) _exit (1);
|
||||
if (uname (&uts) < 0) _exit (1);
|
||||
|
||||
if (strcmp (uts.sysname, LIBGTOP_COMPILE_SYSTEM) ||
|
||||
strcmp (uts.release, LIBGTOP_COMPILE_RELEASE) ||
|
||||
|
@@ -128,7 +128,7 @@ handle_slave_command (glibtop_command *cmnd, glibtop_response *resp,
|
||||
sizeof (glibtop_sysdeps));
|
||||
resp->u.sysdeps.features = glibtop_server_features;
|
||||
resp->u.sysdeps.flags = glibtop_server_features |
|
||||
(1 << GLIBTOP_SYSDEPS_FEATURES);
|
||||
(1L << GLIBTOP_SYSDEPS_FEATURES);
|
||||
resp->offset = _offset_union (sysdeps);
|
||||
break;
|
||||
#if GLIBTOP_SUID_CPU
|
||||
|
@@ -6,5 +6,5 @@ endif
|
||||
|
||||
SUBDIRS = @sysdeps_dir@ common names $(guile_SUBDIRS)
|
||||
|
||||
DIST_SUBDIRS = common guile linux names osf1 \
|
||||
stub stub_suid sun4 freebsd solaris
|
||||
DIST_SUBDIRS = common guile linux kernel names osf1 \
|
||||
stub stub_suid sun4 freebsd
|
||||
|
@@ -2,24 +2,5 @@
|
||||
.libs
|
||||
Makefile
|
||||
Makefile.in
|
||||
close.lo
|
||||
cpu.lo
|
||||
init.lo
|
||||
libgtop_sysdeps.la
|
||||
loadavg.lo
|
||||
mem.lo
|
||||
msg_limits.lo
|
||||
open.lo
|
||||
prockernel.lo
|
||||
proclist.lo
|
||||
procmem.lo
|
||||
procsegment.lo
|
||||
procsignal.lo
|
||||
procstate.lo
|
||||
proctime.lo
|
||||
procuid.lo
|
||||
sem_limits.lo
|
||||
shm_limits.lo
|
||||
swap.lo
|
||||
sysdeps.lo
|
||||
uptime.lo
|
||||
*.lo
|
||||
*.la
|
||||
|
@@ -1,3 +1,29 @@
|
||||
1999-05-26 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
More NetBSD 1.4 fixes.
|
||||
|
||||
* mem.c, procmap.c, procmem.c: Make this work with the new UVM code.
|
||||
|
||||
[FIXME: This following most likely works on all BSD systems, but
|
||||
this needs to be tested; I made it conditional to NetBSD 1.4 at
|
||||
the moment. Please extend the conditionals to any other systems
|
||||
where this works ...]
|
||||
|
||||
* procstate.c: Added `ruid' and `rgid' for LibGTop >= 1.1.0.
|
||||
* procuid.c: Added `ngroups' and `groups' for LibGTop >= 1.1.0.
|
||||
|
||||
1999-05-25 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* ppp.c: Make this work on NetBSD.
|
||||
|
||||
Thu Apr 8 23:47:29 1999 Timur Bakeyev <timur@gnu.org>
|
||||
|
||||
* cpu.c, mem.c, netload.c, procargs.c, procstate.c, proctime.c,
|
||||
sem_limits.c, shm_limits.c, swap.c: Added initial port for BSD/OS
|
||||
(aka BSDI) 2.x and 3.x. 4.x should also(?) work.
|
||||
|
||||
Still, this port require more close look and extended check.
|
||||
|
||||
1999-03-19 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
Added basic support for BSDI. It compiles without problems on
|
||||
|
@@ -28,13 +28,17 @@
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_cpu =
|
||||
(1 << GLIBTOP_CPU_TOTAL) + (1 << GLIBTOP_CPU_USER) +
|
||||
(1 << GLIBTOP_CPU_NICE) + (1 << GLIBTOP_CPU_SYS) +
|
||||
(1 << GLIBTOP_CPU_IDLE) + (1 << GLIBTOP_CPU_FREQUENCY);
|
||||
(1L << GLIBTOP_CPU_TOTAL) + (1L << GLIBTOP_CPU_USER) +
|
||||
(1L << GLIBTOP_CPU_NICE) + (1L << GLIBTOP_CPU_SYS) +
|
||||
(1L << GLIBTOP_CPU_IDLE) + (1L << GLIBTOP_CPU_FREQUENCY);
|
||||
|
||||
/* nlist structure for kernel access */
|
||||
static struct nlist nlst [] = {
|
||||
#ifdef __bsdi__
|
||||
{ "_cpustats" },
|
||||
#else
|
||||
{ "_cp_time" },
|
||||
#endif
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
@@ -66,7 +70,7 @@ glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf)
|
||||
struct clockinfo ci;
|
||||
size_t length;
|
||||
|
||||
glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_CPU), 0);
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_CPU), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_cpu));
|
||||
|
||||
|
@@ -26,6 +26,10 @@
|
||||
|
||||
BEGIN_LIBGTOP_DECLS
|
||||
|
||||
#if _IN_LIBGTOP
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#define KI_PROC(ki) (&(ki))->kp_proc)
|
||||
#define KI_EPROC(ki) (&(ki))->kp_eproc)
|
||||
|
||||
|
@@ -28,7 +28,7 @@
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_loadavg =
|
||||
(1 << GLIBTOP_LOADAVG_LOADAVG);
|
||||
(1L << GLIBTOP_LOADAVG_LOADAVG);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
@@ -46,7 +46,7 @@ glibtop_get_loadavg_p (glibtop *server, glibtop_loadavg *buf)
|
||||
double ldavg[3];
|
||||
int i;
|
||||
|
||||
glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_LOADAVG), 0);
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_LOADAVG), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_loadavg));
|
||||
|
||||
|
@@ -28,22 +28,22 @@
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
#include <sys/sysctl.h>
|
||||
#ifndef __bsdi__
|
||||
#include <sys/vmmeter.h>
|
||||
#endif
|
||||
#include <vm/vm_param.h>
|
||||
|
||||
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
|
||||
#include <uvm/uvm_extern.h>
|
||||
#endif
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_mem =
|
||||
(1 << GLIBTOP_MEM_TOTAL) + (1 << GLIBTOP_MEM_USED) +
|
||||
(1 << GLIBTOP_MEM_FREE) +
|
||||
#ifndef __bsdi__
|
||||
(1 << GLIBTOP_MEM_SHARED) +
|
||||
#endif
|
||||
(1 << GLIBTOP_MEM_BUFFER) +
|
||||
(1L << GLIBTOP_MEM_TOTAL) + (1L << GLIBTOP_MEM_USED) +
|
||||
(1L << GLIBTOP_MEM_FREE) +
|
||||
(1L << GLIBTOP_MEM_SHARED) +
|
||||
(1L << GLIBTOP_MEM_BUFFER) +
|
||||
#ifdef __FreeBSD__
|
||||
(1 << GLIBTOP_MEM_CACHED) +
|
||||
(1L << GLIBTOP_MEM_CACHED) +
|
||||
#endif
|
||||
(1 << GLIBTOP_MEM_USER) + (1 << GLIBTOP_MEM_LOCKED);
|
||||
(1L << GLIBTOP_MEM_USER) + (1L << GLIBTOP_MEM_LOCKED);
|
||||
|
||||
#ifndef LOG1024
|
||||
#define LOG1024 10
|
||||
@@ -57,20 +57,33 @@ static int pageshift; /* log base 2 of the pagesize */
|
||||
|
||||
/* nlist structure for kernel access */
|
||||
static struct nlist nlst [] = {
|
||||
{ "_cnt" },
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
|
||||
{ "_bufpages" },
|
||||
{ 0 }
|
||||
#else
|
||||
#if defined(__bsdi__)
|
||||
{ "_bufcachemem" },
|
||||
#elif defined(__FreeBSD__)
|
||||
{ "_bufspace" },
|
||||
#else
|
||||
{ "_bufpages" },
|
||||
#endif
|
||||
{ "_cnt" },
|
||||
{ 0 }
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifndef __bsdi__
|
||||
/* MIB array for sysctl */
|
||||
/* static int mib_length=2; */
|
||||
static int mib_length=2;
|
||||
#ifdef __bsdi__
|
||||
static int mib [] = { CTL_VM, VM_TOTAL };
|
||||
#else
|
||||
static int mib [] = { CTL_VM, VM_METER };
|
||||
#endif /* __bsdi__ */
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
|
||||
static int mib_uvmexp [] = { CTL_VM, VM_UVMEXP };
|
||||
#endif
|
||||
|
||||
/* Init function. */
|
||||
|
||||
@@ -102,23 +115,26 @@ glibtop_init_mem_p (glibtop *server)
|
||||
void
|
||||
glibtop_get_mem_p (glibtop *server, glibtop_mem *buf)
|
||||
{
|
||||
#ifndef __bsdi__
|
||||
struct vmtotal vmt;
|
||||
size_t length_vmt;
|
||||
#endif
|
||||
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
|
||||
struct uvmexp uvmexp;
|
||||
size_t length_uvmexp;
|
||||
#else
|
||||
struct vmmeter vmm;
|
||||
#endif
|
||||
u_int v_used_count;
|
||||
u_int v_total_count;
|
||||
u_int v_free_count;
|
||||
int bufspace;
|
||||
|
||||
glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_MEM), 0);
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_MEM), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_mem));
|
||||
|
||||
if (server->sysdeps.mem == 0)
|
||||
return;
|
||||
|
||||
#ifndef __bsdi__
|
||||
/* [FIXME: On FreeBSD 2.2.6, sysctl () returns an incorrect
|
||||
* value for `vmt.vm'. We use some code from Unix top
|
||||
* here.] */
|
||||
@@ -126,19 +142,26 @@ glibtop_get_mem_p (glibtop *server, glibtop_mem *buf)
|
||||
/* Get the data from sysctl */
|
||||
length_vmt = sizeof (vmt);
|
||||
if (sysctl (mib, 2, &vmt, &length_vmt, NULL, 0)) {
|
||||
glibtop_warn_io_r (server, "sysctl");
|
||||
glibtop_warn_io_r (server, "sysctl (vmt)");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
|
||||
length_uvmexp = sizeof (uvmexp);
|
||||
if (sysctl (mib_uvmexp, 2, &uvmexp, &length_uvmexp, NULL, 0)) {
|
||||
glibtop_warn_io_r (server, "sysctl (uvmexp)");
|
||||
return;
|
||||
}
|
||||
#else
|
||||
/* Get the data from kvm_* */
|
||||
if (kvm_read (server->machine.kd, nlst[0].n_value,
|
||||
if (kvm_read (server->machine.kd, nlst[1].n_value,
|
||||
&vmm, sizeof (vmm)) != sizeof (vmm)) {
|
||||
glibtop_warn_io_r (server, "kvm_read (cnt)");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (kvm_read (server->machine.kd, nlst[1].n_value,
|
||||
if (kvm_read (server->machine.kd, nlst[0].n_value,
|
||||
&bufspace, sizeof (bufspace)) != sizeof (bufspace)) {
|
||||
glibtop_warn_io_r (server, "kvm_read (bufspace)");
|
||||
return;
|
||||
@@ -146,29 +169,45 @@ glibtop_get_mem_p (glibtop *server, glibtop_mem *buf)
|
||||
|
||||
/* convert memory stats to Kbytes */
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__)
|
||||
v_total_count = vmm.v_page_count;
|
||||
#else
|
||||
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
|
||||
v_total_count = uvmexp.reserve_kernel +
|
||||
uvmexp.reserve_pagedaemon +
|
||||
uvmexp.free + uvmexp.wired + uvmexp.active +
|
||||
uvmexp.inactive;
|
||||
#else
|
||||
v_total_count = vmm.v_kernel_pages +
|
||||
vmm.v_free_count + vmm.v_wire_count +
|
||||
vmm.v_active_count + vmm.v_inactive_count;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
|
||||
v_used_count = uvmexp.active + uvmexp.inactive;
|
||||
v_free_count = uvmexp.free;
|
||||
#else
|
||||
v_used_count = vmm.v_active_count + vmm.v_inactive_count;
|
||||
v_free_count = vmm.v_free_count;
|
||||
#endif
|
||||
|
||||
buf->total = (u_int64_t) pagetok (v_total_count) << LOG1024;
|
||||
buf->used = (u_int64_t) pagetok (v_used_count) << LOG1024;
|
||||
buf->free = (u_int64_t) pagetok (vmm.v_free_count) << LOG1024;
|
||||
buf->free = (u_int64_t) pagetok (v_free_count) << LOG1024;
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
buf->cached = (u_int64_t) pagetok (vmm.v_cache_count) << LOG1024;
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
|
||||
buf->locked = (u_int64_t) pagetok (uvmexp.wired) << LOG1024;
|
||||
#else
|
||||
buf->locked = (u_int64_t) pagetok (vmm.v_wire_count) << LOG1024;
|
||||
#ifndef __bsdi__
|
||||
buf->shared = (u_int64_t) pagetok (vmt.t_rmshr) << LOG1024;
|
||||
#endif
|
||||
|
||||
buf->shared = (u_int64_t) pagetok (vmt.t_rmshr) << LOG1024;
|
||||
|
||||
#if __FreeBSD__
|
||||
buf->buffer = (u_int64_t) bufspace;
|
||||
#else
|
||||
|
@@ -37,7 +37,7 @@ glibtop_init_msg_limits_p (glibtop *server)
|
||||
void
|
||||
glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf)
|
||||
{
|
||||
glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_MSG_LIMITS), 0);
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_MSG_LIMITS), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_msg_limits));
|
||||
}
|
||||
@@ -56,9 +56,9 @@ glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf)
|
||||
#include <sys/msg.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_msg_limits =
|
||||
(1 << GLIBTOP_IPC_MSGMAX) + (1 << GLIBTOP_IPC_MSGMNI) +
|
||||
(1 << GLIBTOP_IPC_MSGMNB) + (1 << GLIBTOP_IPC_MSGTQL) +
|
||||
(1 << GLIBTOP_IPC_MSGSSZ);
|
||||
(1L << GLIBTOP_IPC_MSGMAX) + (1L << GLIBTOP_IPC_MSGMNI) +
|
||||
(1L << GLIBTOP_IPC_MSGMNB) + (1L << GLIBTOP_IPC_MSGTQL) +
|
||||
(1L << GLIBTOP_IPC_MSGSSZ);
|
||||
|
||||
/* The values in this structure never change at runtime, so we only
|
||||
* read it once during initialization. We have to use the name `_msginfo'
|
||||
@@ -95,7 +95,7 @@ glibtop_init_msg_limits_p (glibtop *server)
|
||||
void
|
||||
glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf)
|
||||
{
|
||||
glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_MSG_LIMITS), 0);
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_MSG_LIMITS), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_msg_limits));
|
||||
|
||||
|
@@ -39,20 +39,20 @@
|
||||
#include <netinet/in_var.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_netload =
|
||||
(1 << GLIBTOP_NETLOAD_IF_FLAGS) +
|
||||
(1 << GLIBTOP_NETLOAD_MTU) +
|
||||
(1 << GLIBTOP_NETLOAD_SUBNET) +
|
||||
(1 << GLIBTOP_NETLOAD_ADDRESS) +
|
||||
(1 << GLIBTOP_NETLOAD_PACKETS_IN) +
|
||||
(1 << GLIBTOP_NETLOAD_PACKETS_OUT) +
|
||||
(1 << GLIBTOP_NETLOAD_PACKETS_TOTAL) +
|
||||
(1 << GLIBTOP_NETLOAD_BYTES_IN) +
|
||||
(1 << GLIBTOP_NETLOAD_BYTES_OUT) +
|
||||
(1 << GLIBTOP_NETLOAD_BYTES_TOTAL) +
|
||||
(1 << GLIBTOP_NETLOAD_ERRORS_IN) +
|
||||
(1 << GLIBTOP_NETLOAD_ERRORS_OUT) +
|
||||
(1 << GLIBTOP_NETLOAD_ERRORS_TOTAL) +
|
||||
(1 << GLIBTOP_NETLOAD_COLLISIONS);
|
||||
(1L << GLIBTOP_NETLOAD_IF_FLAGS) +
|
||||
(1L << GLIBTOP_NETLOAD_MTU) +
|
||||
(1L << GLIBTOP_NETLOAD_SUBNET) +
|
||||
(1L << GLIBTOP_NETLOAD_ADDRESS) +
|
||||
(1L << GLIBTOP_NETLOAD_PACKETS_IN) +
|
||||
(1L << GLIBTOP_NETLOAD_PACKETS_OUT) +
|
||||
(1L << GLIBTOP_NETLOAD_PACKETS_TOTAL) +
|
||||
(1L << GLIBTOP_NETLOAD_BYTES_IN) +
|
||||
(1L << GLIBTOP_NETLOAD_BYTES_OUT) +
|
||||
(1L << GLIBTOP_NETLOAD_BYTES_TOTAL) +
|
||||
(1L << GLIBTOP_NETLOAD_ERRORS_IN) +
|
||||
(1L << GLIBTOP_NETLOAD_ERRORS_OUT) +
|
||||
(1L << GLIBTOP_NETLOAD_ERRORS_TOTAL) +
|
||||
(1L << GLIBTOP_NETLOAD_COLLISIONS);
|
||||
|
||||
/* nlist structure for kernel access */
|
||||
static struct nlist nlst [] = {
|
||||
@@ -87,7 +87,7 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
|
||||
struct in_ifaddr in;
|
||||
} ifaddr;
|
||||
|
||||
glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_NETLOAD), 0);
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_NETLOAD), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_netload));
|
||||
|
||||
@@ -107,7 +107,7 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
|
||||
sizeof (ifnet)) != sizeof (ifnet))
|
||||
glibtop_error_io_r (server, "kvm_read (ifnetaddr)");
|
||||
|
||||
#if (defined __FreeBSD__) || (defined __bsdi__)
|
||||
#if defined(__FreeBSD__) || defined(__bsdi__)
|
||||
if (kvm_read (server->machine.kd, (u_long) ifnet.if_name,
|
||||
tname, 16) != 16)
|
||||
glibtop_error_io_r (server, "kvm_read (if_name)");
|
||||
@@ -116,9 +116,9 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
|
||||
tname [15] = 0;
|
||||
#endif
|
||||
|
||||
#if (defined __FreeBSD__) && (__FreeBSD_version >= 300000)
|
||||
#if defined(__FreeBSD__) && (__FreeBSD_version >= 300000)
|
||||
ifaddraddr = (u_long) ifnet.if_addrhead.tqh_first;
|
||||
#elif (defined __FreeBSD__) || (defined __bsdi__)
|
||||
#elif defined(__FreeBSD__) || defined(__bsdi__)
|
||||
ifaddraddr = (u_long) ifnet.if_addrlist;
|
||||
#else
|
||||
ifaddraddr = (u_long) ifnet.if_addrlist.tqh_first;
|
||||
@@ -194,18 +194,18 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
|
||||
return;
|
||||
}
|
||||
|
||||
#if (defined __FreeBSD__) && (__FreeBSD_version >= 300000)
|
||||
#if defined(__FreeBSD__) && (__FreeBSD_version >= 300000)
|
||||
ifaddraddr = (u_long)ifaddr.ifa.ifa_link.tqe_next;
|
||||
#elif (defined __FreeBSD__) || (defined __bsdi__)
|
||||
#elif defined(__FreeBSD__) || defined(__bsdi__)
|
||||
ifaddraddr = (u_long)ifaddr.ifa.ifa_next;
|
||||
#else
|
||||
ifaddraddr = (u_long)ifaddr.ifa.ifa_list.tqe_next;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if (defined __FreeBSD__) && (__FreeBSD_version >= 300000)
|
||||
#if defined(__FreeBSD__) && (__FreeBSD_version >= 300000)
|
||||
ifnetaddr = (u_long) ifnet.if_link.tqe_next;
|
||||
#elif (defined __FreeBSD__) || (defined __bsdi__)
|
||||
#elif defined(__FreeBSD__) || defined(__bsdi__)
|
||||
ifnetaddr = (u_long) ifnet.if_next;
|
||||
#else
|
||||
ifnetaddr = (u_long) ifnet.if_list.tqe_next;
|
||||
|
@@ -39,7 +39,7 @@
|
||||
#include <net/netisr.h>
|
||||
#include <net/route.h>
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
#include <net/if_sppp.h>
|
||||
#else
|
||||
#include <i4b/sppp/if_sppp.h>
|
||||
@@ -51,11 +51,11 @@
|
||||
#endif
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_ppp =
|
||||
(1 << GLIBTOP_PPP_STATE);
|
||||
(1L << GLIBTOP_PPP_STATE);
|
||||
|
||||
#ifdef HAVE_I4B_ACCT
|
||||
static const unsigned long _glibtop_sysdeps_ppp_acct =
|
||||
(1 << GLIBTOP_PPP_BYTES_IN) + (1 << GLIBTOP_PPP_BYTES_OUT);
|
||||
(1L << GLIBTOP_PPP_BYTES_IN) + (1L << GLIBTOP_PPP_BYTES_OUT);
|
||||
#endif
|
||||
|
||||
#endif /* HAVE_I4B */
|
||||
@@ -99,7 +99,7 @@ glibtop_get_ppp_p (glibtop *server, glibtop_ppp *buf, unsigned short device)
|
||||
#endif
|
||||
int phase;
|
||||
|
||||
glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_PPP), 0);
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PPP), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_ppp));
|
||||
|
||||
|
@@ -33,7 +33,7 @@
|
||||
#include <sys/proc.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_args =
|
||||
(1 << GLIBTOP_PROC_ARGS_SIZE);
|
||||
(1L << GLIBTOP_PROC_ARGS_SIZE);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
@@ -54,18 +54,22 @@ glibtop_get_proc_args_p (glibtop *server, glibtop_proc_args *buf,
|
||||
unsigned size = 0, pos = 0;
|
||||
int count;
|
||||
|
||||
#ifndef __bsdi__
|
||||
char filename [BUFSIZ];
|
||||
struct stat statb;
|
||||
#endif
|
||||
|
||||
glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_PROC_ARGS), 0);
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_ARGS), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_args));
|
||||
|
||||
/* swapper, init, pagedaemon, vmdaemon, update - this doen't work. */
|
||||
if (pid < 5) return NULL;
|
||||
|
||||
#ifndef __bsdi__
|
||||
sprintf (filename, "/proc/%d/mem", pid);
|
||||
if (stat (filename, &statb)) return NULL;
|
||||
#endif
|
||||
|
||||
glibtop_suid_enter (server);
|
||||
|
||||
|
@@ -28,7 +28,7 @@
|
||||
|
||||
#define LINUX_VERSION(x,y,z) (0x10000*(x) + 0x100*(y) + z)
|
||||
|
||||
#define BIT_SHIFT(x) (1 << (x % 32))
|
||||
#define BIT_SHIFT(x) (1L << (x % 64))
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_procdata_0 =
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_CMD) +
|
||||
|
@@ -49,18 +49,18 @@
|
||||
#endif
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_kernel_pstats =
|
||||
(1 << GLIBTOP_PROC_KERNEL_MIN_FLT) +
|
||||
(1 << GLIBTOP_PROC_KERNEL_MAJ_FLT) +
|
||||
(1 << GLIBTOP_PROC_KERNEL_CMIN_FLT) +
|
||||
(1 << GLIBTOP_PROC_KERNEL_CMAJ_FLT);
|
||||
(1L << GLIBTOP_PROC_KERNEL_MIN_FLT) +
|
||||
(1L << GLIBTOP_PROC_KERNEL_MAJ_FLT) +
|
||||
(1L << GLIBTOP_PROC_KERNEL_CMIN_FLT) +
|
||||
(1L << GLIBTOP_PROC_KERNEL_CMAJ_FLT);
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_kernel_pcb =
|
||||
(1 << GLIBTOP_PROC_KERNEL_KSTK_EIP) +
|
||||
(1 << GLIBTOP_PROC_KERNEL_KSTK_ESP);
|
||||
(1L << GLIBTOP_PROC_KERNEL_KSTK_EIP) +
|
||||
(1L << GLIBTOP_PROC_KERNEL_KSTK_ESP);
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_kernel_wchan =
|
||||
(1 << GLIBTOP_PROC_KERNEL_NWCHAN) +
|
||||
(1 << GLIBTOP_PROC_KERNEL_WCHAN);
|
||||
(1L << GLIBTOP_PROC_KERNEL_NWCHAN) +
|
||||
(1L << GLIBTOP_PROC_KERNEL_WCHAN);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
@@ -86,7 +86,7 @@ glibtop_get_proc_kernel_p (glibtop *server,
|
||||
char filename [BUFSIZ];
|
||||
struct stat statb;
|
||||
|
||||
glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_PROC_KERNEL), 0);
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_KERNEL), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_kernel));
|
||||
|
||||
@@ -102,13 +102,13 @@ glibtop_get_proc_kernel_p (glibtop *server,
|
||||
glibtop_error_io_r (server, "kvm_getprocs (%d)", pid);
|
||||
|
||||
buf->nwchan = (unsigned long) pinfo [0].kp_proc.p_wchan &~ KERNBASE;
|
||||
buf->flags |= (1 << GLIBTOP_PROC_KERNEL_NWCHAN);
|
||||
buf->flags |= (1L << GLIBTOP_PROC_KERNEL_NWCHAN);
|
||||
|
||||
if (pinfo [0].kp_proc.p_wchan && pinfo [0].kp_proc.p_wmesg) {
|
||||
strncpy (buf->wchan, pinfo [0].kp_eproc.e_wmesg,
|
||||
sizeof (buf->wchan) - 1);
|
||||
buf->wchan [sizeof (buf->wchan) - 1] = 0;
|
||||
buf->flags |= (1 << GLIBTOP_PROC_KERNEL_WCHAN);
|
||||
buf->flags |= (1L << GLIBTOP_PROC_KERNEL_WCHAN);
|
||||
} else {
|
||||
buf->wchan [0] = 0;
|
||||
}
|
||||
|
@@ -29,8 +29,8 @@
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proclist =
|
||||
(1 << GLIBTOP_PROCLIST_TOTAL) + (1 << GLIBTOP_PROCLIST_NUMBER) +
|
||||
(1 << GLIBTOP_PROCLIST_SIZE);
|
||||
(1L << GLIBTOP_PROCLIST_TOTAL) + (1L << GLIBTOP_PROCLIST_NUMBER) +
|
||||
(1L << GLIBTOP_PROCLIST_SIZE);
|
||||
|
||||
/* Fetch list of currently running processes.
|
||||
* The interface of this function is a little bit different from the others:
|
||||
@@ -67,7 +67,7 @@ glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf,
|
||||
int which, count;
|
||||
int i,j;
|
||||
|
||||
glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_PROCLIST), 0);
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROCLIST), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proclist));
|
||||
|
||||
|
@@ -48,14 +48,22 @@
|
||||
#include <sys/sysctl.h>
|
||||
#include <vm/vm.h>
|
||||
|
||||
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
|
||||
/* Fixme ... */
|
||||
#undef _KERNEL
|
||||
#define _UVM_UVM_AMAP_I_H_ 1
|
||||
#define _UVM_UVM_MAP_I_H_ 1
|
||||
#include <uvm/uvm.h>
|
||||
#endif
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_map =
|
||||
(1 << GLIBTOP_PROC_MAP_TOTAL) + (1 << GLIBTOP_PROC_MAP_NUMBER) +
|
||||
(1 << GLIBTOP_PROC_MAP_SIZE);
|
||||
(1L << GLIBTOP_PROC_MAP_TOTAL) + (1L << GLIBTOP_PROC_MAP_NUMBER) +
|
||||
(1L << GLIBTOP_PROC_MAP_SIZE);
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_map_entry =
|
||||
(1 << GLIBTOP_MAP_ENTRY_START) + (1 << GLIBTOP_MAP_ENTRY_END) +
|
||||
(1 << GLIBTOP_MAP_ENTRY_OFFSET) + (1 << GLIBTOP_MAP_ENTRY_PERM) +
|
||||
(1 << GLIBTOP_MAP_ENTRY_INODE) + (1 << GLIBTOP_MAP_ENTRY_DEVICE);
|
||||
(1L << GLIBTOP_MAP_ENTRY_START) + (1L << GLIBTOP_MAP_ENTRY_END) +
|
||||
(1L << GLIBTOP_MAP_ENTRY_OFFSET) + (1L << GLIBTOP_MAP_ENTRY_PERM) +
|
||||
(1L << GLIBTOP_MAP_ENTRY_INODE) + (1L << GLIBTOP_MAP_ENTRY_DEVICE);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
@@ -74,15 +82,22 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
|
||||
struct kinfo_proc *pinfo;
|
||||
struct vm_map_entry entry, *first;
|
||||
struct vmspace vmspace;
|
||||
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
|
||||
struct vnode vnode;
|
||||
struct inode inode;
|
||||
#else
|
||||
struct vm_object object;
|
||||
#endif
|
||||
glibtop_map_entry *maps;
|
||||
#if defined __FreeBSD__
|
||||
struct vnode vnode;
|
||||
struct inode inode;
|
||||
struct mount mount;
|
||||
#endif
|
||||
int count, i = 0;
|
||||
int update = 0;
|
||||
|
||||
glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_PROC_MAP), 0);
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_MAP), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_map));
|
||||
|
||||
@@ -147,9 +162,14 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
|
||||
if (entry.eflags & (MAP_ENTRY_IS_A_MAP|MAP_ENTRY_IS_SUB_MAP))
|
||||
continue;
|
||||
#endif
|
||||
#else
|
||||
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
|
||||
if (UVM_ET_ISSUBMAP (&entry))
|
||||
continue;
|
||||
#else
|
||||
if (entry.is_a_map || entry.is_sub_map)
|
||||
continue;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
maps [i].flags = _glibtop_sysdeps_map_entry;
|
||||
@@ -169,6 +189,19 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
|
||||
|
||||
i++;
|
||||
|
||||
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
|
||||
if (!entry.object.uvm_obj)
|
||||
continue;
|
||||
|
||||
/* We're only interested in vnodes */
|
||||
|
||||
if (kvm_read (server->machine.kd,
|
||||
(unsigned long) entry.object.uvm_obj,
|
||||
&vnode, sizeof (vnode)) != sizeof (vnode)) {
|
||||
glibtop_warn_io_r (server, "kvm_read (vnode)");
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
if (!entry.object.vm_object)
|
||||
continue;
|
||||
|
||||
@@ -178,6 +211,24 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
|
||||
(unsigned long) entry.object.vm_object,
|
||||
&object, sizeof (object)) != sizeof (object))
|
||||
glibtop_error_io_r (server, "kvm_read (object)");
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
|
||||
if (!vnode.v_uvm.u_flags & UVM_VNODE_VALID)
|
||||
continue;
|
||||
|
||||
if ((vnode.v_type != VREG) || (vnode.v_tag != VT_UFS) ||
|
||||
!vnode.v_data) continue;
|
||||
|
||||
if (kvm_read (server->machine.kd,
|
||||
(unsigned long) vnode.v_data,
|
||||
&inode, sizeof (inode)) != sizeof (inode))
|
||||
glibtop_error_io_r (server, "kvm_read (inode)");
|
||||
|
||||
maps [i-1].inode = inode.i_number;
|
||||
maps [i-1].device = inode.i_dev;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
/* If the object is of type vnode, add its size */
|
||||
|
@@ -45,13 +45,29 @@
|
||||
#include <sys/sysctl.h>
|
||||
#include <vm/vm.h>
|
||||
|
||||
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
|
||||
/* Fixme ... */
|
||||
#undef _KERNEL
|
||||
#define _UVM_UVM_AMAP_I_H_ 1
|
||||
#define _UVM_UVM_MAP_I_H_ 1
|
||||
#include <uvm/uvm.h>
|
||||
#endif
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_mem =
|
||||
(1 << GLIBTOP_PROC_MEM_SIZE) +
|
||||
(1 << GLIBTOP_PROC_MEM_VSIZE) +
|
||||
(1 << GLIBTOP_PROC_MEM_SHARE) +
|
||||
(1 << GLIBTOP_PROC_MEM_RESIDENT) +
|
||||
(1 << GLIBTOP_PROC_MEM_RSS) +
|
||||
(1 << GLIBTOP_PROC_MEM_RSS_RLIM);
|
||||
(1L << GLIBTOP_PROC_MEM_SIZE) +
|
||||
(1L << GLIBTOP_PROC_MEM_VSIZE) +
|
||||
(1L << GLIBTOP_PROC_MEM_RESIDENT) +
|
||||
(1L << GLIBTOP_PROC_MEM_RSS) +
|
||||
(1L << GLIBTOP_PROC_MEM_RSS_RLIM);
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_mem_share =
|
||||
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
|
||||
(1L << GLIBTOP_PROC_MEM_SHARE);
|
||||
#elif defined(__FreeBSD__)
|
||||
(1L << GLIBTOP_PROC_MEM_SHARE);
|
||||
#else
|
||||
0;
|
||||
#endif
|
||||
|
||||
#ifndef LOG1024
|
||||
#define LOG1024 10
|
||||
@@ -82,7 +98,8 @@ glibtop_init_proc_mem_p (glibtop *server)
|
||||
/* we only need the amount of log(2)1024 for our conversion */
|
||||
pageshift -= LOG1024;
|
||||
|
||||
server->sysdeps.proc_mem = _glibtop_sysdeps_proc_mem;
|
||||
server->sysdeps.proc_mem = _glibtop_sysdeps_proc_mem |
|
||||
_glibtop_sysdeps_proc_mem_share;
|
||||
}
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
@@ -94,11 +111,16 @@ glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
|
||||
struct kinfo_proc *pinfo;
|
||||
struct vm_map_entry entry, *first;
|
||||
struct vmspace *vms, vmspace;
|
||||
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
|
||||
struct vnode vnode;
|
||||
struct inode inode;
|
||||
#else
|
||||
struct vm_object object;
|
||||
#endif
|
||||
struct plimit plimit;
|
||||
int count;
|
||||
|
||||
glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_PROC_MEM), 0);
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_MEM), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_mem));
|
||||
|
||||
@@ -173,11 +195,29 @@ glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
|
||||
if (entry.eflags & (MAP_ENTRY_IS_A_MAP|MAP_ENTRY_IS_SUB_MAP))
|
||||
continue;
|
||||
#endif
|
||||
#else
|
||||
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
|
||||
if (UVM_ET_ISSUBMAP (&entry))
|
||||
continue;
|
||||
#else
|
||||
if (entry.is_a_map || entry.is_sub_map)
|
||||
continue;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
|
||||
if (!entry.object.uvm_obj)
|
||||
continue;
|
||||
|
||||
/* We're only interested in vnodes */
|
||||
|
||||
if (kvm_read (server->machine.kd,
|
||||
(unsigned long) entry.object.uvm_obj,
|
||||
&vnode, sizeof (vnode)) != sizeof (vnode)) {
|
||||
glibtop_warn_io_r (server, "kvm_read (vnode)");
|
||||
return;
|
||||
}
|
||||
#else
|
||||
if (!entry.object.vm_object)
|
||||
continue;
|
||||
|
||||
@@ -189,18 +229,31 @@ glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
|
||||
glibtop_warn_io_r (server, "kvm_read (object)");
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
/* If the object is of type vnode, add its size */
|
||||
|
||||
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
|
||||
if (!vnode.v_uvm.u_flags & UVM_VNODE_VALID)
|
||||
continue;
|
||||
|
||||
if ((vnode.v_type != VREG) || (vnode.v_tag != VT_UFS) ||
|
||||
!vnode.v_data) continue;
|
||||
|
||||
/* Reference count must be at least two. */
|
||||
if (vnode.v_uvm.u_obj.uo_refs <= 1)
|
||||
continue;
|
||||
|
||||
buf->share += pagetok (vnode.v_uvm.u_obj.uo_npages) << LOG1024;
|
||||
#endif
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
if (object.type != OBJT_VNODE)
|
||||
continue;
|
||||
|
||||
buf->share += object.un_pager.vnp.vnp_size;
|
||||
#else
|
||||
buf->share += object.size;
|
||||
#endif
|
||||
}
|
||||
|
||||
buf->flags = _glibtop_sysdeps_proc_mem;
|
||||
buf->flags = _glibtop_sysdeps_proc_mem |
|
||||
_glibtop_sysdeps_proc_mem_share;
|
||||
}
|
||||
|
@@ -48,7 +48,7 @@ glibtop_get_proc_segment_p (glibtop *server,
|
||||
glibtop_proc_segment *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_PROC_SEGMENT), 0);
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_SEGMENT), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_segment));
|
||||
|
||||
|
@@ -28,10 +28,10 @@
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_signal =
|
||||
(1 << GLIBTOP_PROC_SIGNAL_SIGNAL) +
|
||||
(1 << GLIBTOP_PROC_SIGNAL_BLOCKED) +
|
||||
(1 << GLIBTOP_PROC_SIGNAL_SIGIGNORE) +
|
||||
(1 << GLIBTOP_PROC_SIGNAL_SIGCATCH);
|
||||
(1L << GLIBTOP_PROC_SIGNAL_SIGNAL) +
|
||||
(1L << GLIBTOP_PROC_SIGNAL_BLOCKED) +
|
||||
(1L << GLIBTOP_PROC_SIGNAL_SIGIGNORE) +
|
||||
(1L << GLIBTOP_PROC_SIGNAL_SIGCATCH);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
@@ -49,7 +49,7 @@ glibtop_get_proc_signal_p (glibtop *server,
|
||||
struct kinfo_proc *pinfo;
|
||||
int count = 0;
|
||||
|
||||
glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_PROC_SIGNAL), 0);
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_SIGNAL), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_signal));
|
||||
|
||||
|
@@ -27,20 +27,29 @@
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
#if (!defined __OpenBSD__) && (!defined __bsdi__)
|
||||
#if !defined(__OpenBSD__)
|
||||
//&& (!defined __bsdi__)
|
||||
#include <sys/user.h>
|
||||
#endif
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_state =
|
||||
(1 << GLIBTOP_PROC_STATE_CMD) + (1 << GLIBTOP_PROC_STATE_STATE) +
|
||||
(1 << GLIBTOP_PROC_STATE_UID) + (1 << GLIBTOP_PROC_STATE_GID);
|
||||
(1L << GLIBTOP_PROC_STATE_CMD) + (1L << GLIBTOP_PROC_STATE_UID) +
|
||||
(1L << GLIBTOP_PROC_STATE_GID);
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_state_new =
|
||||
#if LIBGTOP_VERSION_CODE >= 1001000
|
||||
(1L << GLIBTOP_PROC_STATE_RUID) + (1L << GLIBTOP_PROC_STATE_RGID);
|
||||
#else
|
||||
0;
|
||||
#endif
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_proc_state_p (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_state = _glibtop_sysdeps_proc_state;
|
||||
server->sysdeps.proc_state = _glibtop_sysdeps_proc_state |
|
||||
_glibtop_sysdeps_proc_state_new;
|
||||
}
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
@@ -53,7 +62,7 @@ glibtop_get_proc_state_p (glibtop *server,
|
||||
struct kinfo_proc *pinfo;
|
||||
int count = 0;
|
||||
|
||||
glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_PROC_STATE), 0);
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_STATE), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_state));
|
||||
|
||||
@@ -73,27 +82,34 @@ glibtop_get_proc_state_p (glibtop *server,
|
||||
buf->uid = pinfo [0].kp_eproc.e_pcred.p_svuid;
|
||||
buf->gid = pinfo [0].kp_eproc.e_pcred.p_svgid;
|
||||
|
||||
switch (pinfo [0].kp_proc.p_stat) {
|
||||
case SIDL:
|
||||
buf->state = 'I';
|
||||
break;
|
||||
case SRUN:
|
||||
buf->state = 'R';
|
||||
break;
|
||||
case SSLEEP:
|
||||
buf->state = 'S';
|
||||
break;
|
||||
case SSTOP:
|
||||
buf->state = 'T';
|
||||
break;
|
||||
case SZOMB:
|
||||
buf->state = 'Z';
|
||||
break;
|
||||
default:
|
||||
buf->state = '?';
|
||||
break;
|
||||
}
|
||||
#if LIBGTOP_VERSION_CODE >= 1001000
|
||||
buf->ruid = pinfo [0].kp_eproc.e_pcred.p_ruid;
|
||||
buf->rgid = pinfo [0].kp_eproc.e_pcred.p_rgid;
|
||||
#endif
|
||||
|
||||
/* Set the flags for the data we're about to return*/
|
||||
buf->flags = _glibtop_sysdeps_proc_state;
|
||||
buf->flags = _glibtop_sysdeps_proc_state |
|
||||
_glibtop_sysdeps_proc_state_new;
|
||||
|
||||
switch (pinfo [0].kp_proc.p_stat) {
|
||||
case SIDL:
|
||||
buf->state = 0;
|
||||
break;
|
||||
case SRUN:
|
||||
buf->state = GLIBTOP_PROCESS_RUNNING;
|
||||
break;
|
||||
case SSLEEP:
|
||||
buf->state = GLIBTOP_PROCESS_INTERRUPTIBLE;
|
||||
break;
|
||||
case SSTOP:
|
||||
buf->state = GLIBTOP_PROCESS_STOPPED;
|
||||
break;
|
||||
case SZOMB:
|
||||
buf->state = GLIBTOP_PROCESS_ZOMBIE;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
buf->flags |= (1L << GLIBTOP_PROC_STATE_STATE);
|
||||
}
|
||||
|
@@ -32,11 +32,12 @@
|
||||
#endif
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_time =
|
||||
(1 << GLIBTOP_PROC_TIME_RTIME) + (1 << GLIBTOP_PROC_TIME_FREQUENCY);
|
||||
(1L << GLIBTOP_PROC_TIME_RTIME) + (1L << GLIBTOP_PROC_TIME_FREQUENCY);
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_time_user =
|
||||
(1 << GLIBTOP_PROC_TIME_UTIME) + (1 << GLIBTOP_PROC_TIME_STIME) +
|
||||
(1 << GLIBTOP_PROC_TIME_CUTIME) + (1 << GLIBTOP_PROC_TIME_CSTIME);
|
||||
(1L << GLIBTOP_PROC_TIME_UTIME) + (1L << GLIBTOP_PROC_TIME_STIME) +
|
||||
(1L << GLIBTOP_PROC_TIME_CUTIME) + (1L << GLIBTOP_PROC_TIME_CSTIME) +
|
||||
(1L << GLIBTOP_PROC_TIME_START_TIME);
|
||||
|
||||
#define tv2sec(tv) (((u_int64_t) tv.tv_sec * 1000000) + (u_int64_t) tv.tv_usec)
|
||||
|
||||
@@ -123,31 +124,74 @@ glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
struct kinfo_proc *pinfo;
|
||||
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
|
||||
register struct rusage *rup;
|
||||
#else
|
||||
struct user *u_addr = (struct user *)USRSTACK;
|
||||
#endif
|
||||
struct pstats pstats;
|
||||
int count;
|
||||
|
||||
char filename [BUFSIZ];
|
||||
struct stat statb;
|
||||
|
||||
glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_PROC_TIME), 0);
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_TIME), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_time));
|
||||
|
||||
if (server->sysdeps.proc_time == 0)
|
||||
return;
|
||||
|
||||
/* It does not work for the swapper task. */
|
||||
if (pid == 0) return;
|
||||
|
||||
#if !(defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000))
|
||||
if (server->sysdeps.proc_time == 0)
|
||||
return;
|
||||
|
||||
#ifndef __bsdi__
|
||||
sprintf (filename, "/proc/%d/mem", (int) pid);
|
||||
if (stat (filename, &statb)) return;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Get the process information */
|
||||
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
|
||||
if ((pinfo == NULL) || (count != 1))
|
||||
glibtop_error_io_r (server, "kvm_getprocs (%d)", pid);
|
||||
|
||||
#if (defined __FreeBSD__) && (__FreeBSD_version >= 300003)
|
||||
buf->rtime = pinfo [0].kp_proc.p_runtime;
|
||||
#else
|
||||
buf->rtime = tv2sec (pinfo [0].kp_proc.p_rtime);
|
||||
#endif
|
||||
|
||||
buf->frequency = 1000000;
|
||||
buf->flags = _glibtop_sysdeps_proc_time;
|
||||
|
||||
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
|
||||
glibtop_suid_enter (server);
|
||||
|
||||
if (kvm_read (server->machine.kd,
|
||||
(unsigned long) pinfo [0].kp_proc.p_stats,
|
||||
&pstats, sizeof (pstats)) != sizeof (pstats)) {
|
||||
glibtop_warn_io_r (server, "kvm_read (pstats)");
|
||||
return;
|
||||
}
|
||||
|
||||
glibtop_suid_leave (server);
|
||||
|
||||
rup = &pstats.p_ru;
|
||||
calcru(&(pinfo [0]).kp_proc,
|
||||
&rup->ru_utime, &rup->ru_stime, NULL);
|
||||
|
||||
buf->utime = tv2sec (pstats.p_ru.ru_utime);
|
||||
buf->stime = tv2sec (pstats.p_ru.ru_stime);
|
||||
|
||||
buf->cutime = tv2sec (pstats.p_cru.ru_utime);
|
||||
buf->cstime = tv2sec (pstats.p_cru.ru_stime);
|
||||
|
||||
buf->start_time = tv2sec (pstats.p_start);
|
||||
|
||||
buf->flags |= _glibtop_sysdeps_proc_time_user;
|
||||
#else
|
||||
glibtop_suid_enter (server);
|
||||
|
||||
if ((pinfo [0].kp_proc.p_flag & P_INMEM) &&
|
||||
@@ -180,15 +224,6 @@ glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf,
|
||||
}
|
||||
|
||||
glibtop_suid_leave (server);
|
||||
|
||||
#if (defined __FreeBSD__) && (__FreeBSD_version >= 300003)
|
||||
buf->rtime = pinfo [0].kp_proc.p_runtime;
|
||||
#else
|
||||
buf->rtime = tv2sec (pinfo [0].kp_proc.p_rtime);
|
||||
#endif
|
||||
|
||||
buf->frequency = 1000000;
|
||||
|
||||
buf->flags |= _glibtop_sysdeps_proc_time;
|
||||
}
|
||||
|
||||
|
@@ -28,18 +28,28 @@
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_uid =
|
||||
(1 << GLIBTOP_PROC_UID_UID) + (1 << GLIBTOP_PROC_UID_EUID) +
|
||||
(1 << GLIBTOP_PROC_UID_EGID) + (1 << GLIBTOP_PROC_UID_PID) +
|
||||
(1 << GLIBTOP_PROC_UID_PPID) + (1 << GLIBTOP_PROC_UID_PGRP) +
|
||||
(1 << GLIBTOP_PROC_UID_TPGID) + (1 << GLIBTOP_PROC_UID_PRIORITY) +
|
||||
(1 << GLIBTOP_PROC_UID_NICE);
|
||||
(1L << GLIBTOP_PROC_UID_UID) + (1L << GLIBTOP_PROC_UID_EUID) +
|
||||
(1L << GLIBTOP_PROC_UID_EGID) + (1L << GLIBTOP_PROC_UID_PID) +
|
||||
(1L << GLIBTOP_PROC_UID_PPID) + (1L << GLIBTOP_PROC_UID_PGRP) +
|
||||
(1L << GLIBTOP_PROC_UID_TPGID) + (1L << GLIBTOP_PROC_UID_PRIORITY) +
|
||||
(1L << GLIBTOP_PROC_UID_NICE);
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_uid_groups =
|
||||
#if LIBGTOP_VERSION_CODE >= 1001000
|
||||
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
|
||||
(1L << GLIBTOP_PROC_UID_NGROUPS) + (1L << GLIBTOP_PROC_UID_GROUPS);
|
||||
#endif
|
||||
#else
|
||||
0;
|
||||
#endif
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_proc_uid_p (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_uid = _glibtop_sysdeps_proc_uid;
|
||||
server->sysdeps.proc_uid = _glibtop_sysdeps_proc_uid |
|
||||
_glibtop_sysdeps_proc_uid_groups;
|
||||
}
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
@@ -51,7 +61,14 @@ glibtop_get_proc_uid_p (glibtop *server, glibtop_proc_uid *buf,
|
||||
struct kinfo_proc *pinfo;
|
||||
int count = 0;
|
||||
|
||||
glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_PROC_UID), 0);
|
||||
#if LIBGTOP_VERSION_CODE >= 1001000
|
||||
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
|
||||
struct ucred ucred;
|
||||
void *ucred_ptr;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_UID), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_uid));
|
||||
|
||||
@@ -80,4 +97,30 @@ glibtop_get_proc_uid_p (glibtop *server, glibtop_proc_uid *buf,
|
||||
/* Set the flags for the data we're about to return*/
|
||||
buf->flags = _glibtop_sysdeps_proc_uid;
|
||||
|
||||
/* Use LibGTop conditionals here so we can more easily merge this
|
||||
* code into the LIBGTOP_STABLE_1_0 branch. */
|
||||
#if LIBGTOP_VERSION_CODE >= 1001000
|
||||
/* This probably also works with other versions, but not yet
|
||||
* tested. Please remove the conditional if this is true. */
|
||||
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
|
||||
ucred_ptr = (void *) pinfo [0].kp_eproc.e_pcred.pc_ucred;
|
||||
|
||||
if (ucred_ptr) {
|
||||
if (kvm_read (server->machine.kd, (unsigned long) ucred_ptr,
|
||||
&ucred, sizeof (ucred)) != sizeof (ucred)) {
|
||||
glibtop_warn_io_r (server, "kvm_read (ucred)");
|
||||
} else {
|
||||
int count = (ucred.cr_ngroups < GLIBTOP_MAX_GROUPS) ?
|
||||
ucred.cr_ngroups : GLIBTOP_MAX_GROUPS;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
buf->groups [i] = ucred.cr_groups [i];
|
||||
buf->ngroups = count;
|
||||
|
||||
buf->flags |= _glibtop_sysdeps_proc_uid_groups;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
#if (defined __bsdi__) && (_BSDI_VERSION < 199700)
|
||||
#if defined(__bsdi__) && (_BSDI_VERSION < 199700)
|
||||
/* Older versions of BSDI don't seem to have this. */
|
||||
|
||||
void
|
||||
@@ -37,7 +37,7 @@ glibtop_init_sem_limits_p (glibtop *server)
|
||||
void
|
||||
glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf)
|
||||
{
|
||||
glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_SEM_LIMITS), 0);
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SEM_LIMITS), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_sem_limits));
|
||||
}
|
||||
@@ -46,7 +46,7 @@ glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf)
|
||||
|
||||
/* #define KERNEL to get declaration of `struct seminfo'. */
|
||||
|
||||
#if (defined __FreeBSD__) || (defined __bsdi__)
|
||||
#if defined(__FreeBSD__) || defined(__bsdi__)
|
||||
#define KERNEL 1
|
||||
#else
|
||||
#define _KERNEL 1
|
||||
@@ -56,11 +56,11 @@ glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf)
|
||||
#include <sys/sem.h>
|
||||
|
||||
static unsigned long _glibtop_sysdeps_sem_limits =
|
||||
(1 << GLIBTOP_IPC_SEMMAP) + (1 << GLIBTOP_IPC_SEMMNI) +
|
||||
(1 << GLIBTOP_IPC_SEMMNS) + (1 << GLIBTOP_IPC_SEMMNU) +
|
||||
(1 << GLIBTOP_IPC_SEMMSL) + (1 << GLIBTOP_IPC_SEMOPM) +
|
||||
(1 << GLIBTOP_IPC_SEMUME) + (1 << GLIBTOP_IPC_SEMUSZ) +
|
||||
(1 << GLIBTOP_IPC_SEMVMX) + (1 << GLIBTOP_IPC_SEMAEM);
|
||||
(1L << GLIBTOP_IPC_SEMMAP) + (1L << GLIBTOP_IPC_SEMMNI) +
|
||||
(1L << GLIBTOP_IPC_SEMMNS) + (1L << GLIBTOP_IPC_SEMMNU) +
|
||||
(1L << GLIBTOP_IPC_SEMMSL) + (1L << GLIBTOP_IPC_SEMOPM) +
|
||||
(1L << GLIBTOP_IPC_SEMUME) + (1L << GLIBTOP_IPC_SEMUSZ) +
|
||||
(1L << GLIBTOP_IPC_SEMVMX) + (1L << GLIBTOP_IPC_SEMAEM);
|
||||
|
||||
/* The values in this structure never change at runtime, so we only
|
||||
* read it once during initialization. We have to use the name `_seminfo'
|
||||
@@ -97,7 +97,7 @@ glibtop_init_sem_limits_p (glibtop *server)
|
||||
void
|
||||
glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf)
|
||||
{
|
||||
glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_SEM_LIMITS), 0);
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SEM_LIMITS), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_sem_limits));
|
||||
|
||||
|
@@ -27,7 +27,7 @@
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
#if (defined __bsdi__) && (_BSDI_VERSION < 199700)
|
||||
#if defined(__bsdi__) && (_BSDI_VERSION < 199700)
|
||||
/* Older versions of BSDI don't seem to have this. */
|
||||
|
||||
void
|
||||
@@ -37,7 +37,7 @@ glibtop_init_shm_limits_p (glibtop *server)
|
||||
void
|
||||
glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf)
|
||||
{
|
||||
glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_SHM_LIMITS), 0);
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SHM_LIMITS), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_shm_limits));
|
||||
}
|
||||
@@ -46,7 +46,7 @@ glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf)
|
||||
|
||||
/* #define KERNEL to get declaration of `struct shminfo'. */
|
||||
|
||||
#if (defined __FreeBSD__) || (defined __bsdi__)
|
||||
#if defined(__FreeBSD__) || defined(__bsdi__)
|
||||
#define KERNEL 1
|
||||
#else
|
||||
#define _KERNEL 1
|
||||
@@ -56,9 +56,9 @@ glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf)
|
||||
#include <sys/shm.h>
|
||||
|
||||
static unsigned long _glibtop_sysdeps_shm_limits =
|
||||
(1 << GLIBTOP_IPC_SHMMAX) + (1 << GLIBTOP_IPC_SHMMIN) +
|
||||
(1 << GLIBTOP_IPC_SHMMNI) + (1 << GLIBTOP_IPC_SHMSEG) +
|
||||
(1 << GLIBTOP_IPC_SHMALL);
|
||||
(1L << GLIBTOP_IPC_SHMMAX) + (1L << GLIBTOP_IPC_SHMMIN) +
|
||||
(1L << GLIBTOP_IPC_SHMMNI) + (1L << GLIBTOP_IPC_SHMSEG) +
|
||||
(1L << GLIBTOP_IPC_SHMALL);
|
||||
|
||||
/* The values in this structure never change at runtime, so we only
|
||||
* read it once during initialization. We have to use the name `_shminfo'
|
||||
@@ -95,7 +95,7 @@ glibtop_init_shm_limits_p (glibtop *server)
|
||||
void
|
||||
glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf)
|
||||
{
|
||||
glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_SHM_LIMITS), 0);
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SHM_LIMITS), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_shm_limits));
|
||||
|
||||
|
@@ -30,19 +30,28 @@
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_swap =
|
||||
(1 << GLIBTOP_SWAP_TOTAL) + (1 << GLIBTOP_SWAP_USED) +
|
||||
(1 << GLIBTOP_SWAP_FREE) + (1 << GLIBTOP_SWAP_PAGEIN) +
|
||||
(1 << GLIBTOP_SWAP_PAGEOUT);
|
||||
(1L << GLIBTOP_SWAP_TOTAL) + (1L << GLIBTOP_SWAP_USED) +
|
||||
(1L << GLIBTOP_SWAP_FREE) + (1L << GLIBTOP_SWAP_PAGEIN) +
|
||||
(1L << GLIBTOP_SWAP_PAGEOUT);
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) || defined(__bsdi__)
|
||||
|
||||
#include <sys/conf.h>
|
||||
#ifdef __bsdi__
|
||||
#include <vm/swap_pager.h>
|
||||
#else
|
||||
#include <sys/rlist.h>
|
||||
#endif
|
||||
#include <sys/vmmeter.h>
|
||||
|
||||
#if __FreeBSD__ < 4
|
||||
|
||||
/* nlist structure for kernel access */
|
||||
|
||||
#if defined(__bsdi__)
|
||||
static struct nlist nlst [] = {
|
||||
{ "_swapstats" }, /* general swap info */
|
||||
{ 0 }
|
||||
};
|
||||
#elif __FreeBSD__ < 4
|
||||
static struct nlist nlst [] = {
|
||||
#define VM_SWAPLIST 0
|
||||
{ "_swaplist" },/* list of free swap areas */
|
||||
@@ -56,28 +65,36 @@ static struct nlist nlst [] = {
|
||||
{ "_dmmax" }, /* maximum size of a swap block */
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#elif (defined __NetBSD__)
|
||||
#elif defined(__NetBSD__)
|
||||
|
||||
#if (__NetBSD_Version__ >= 104000000)
|
||||
#include <uvm/uvm_extern.h>
|
||||
#include <sys/swap.h>
|
||||
#else
|
||||
#include <vm/vm_swap.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
|
||||
static int mib_uvmexp [] = { CTL_VM, VM_UVMEXP };
|
||||
#else
|
||||
/* nlist structure for kernel access */
|
||||
static struct nlist nlst2 [] = {
|
||||
{ "_cnt" },
|
||||
{ 0 }
|
||||
};
|
||||
#endif
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_swap_p (glibtop *server)
|
||||
{
|
||||
#ifdef __FreeBSD__
|
||||
#if __FreeBSD__ < 4
|
||||
#if defined(__FreeBSD__) || defined(__bsdi__)
|
||||
#if __FreeBSD__ < 4 || defined(__bsdi__)
|
||||
if (kvm_nlist (server->machine.kd, nlst) != 0) {
|
||||
glibtop_warn_io_r (server, "kvm_nlist (swap)");
|
||||
return;
|
||||
@@ -86,16 +103,18 @@ glibtop_init_swap_p (glibtop *server)
|
||||
struct kvm_swap dummy;
|
||||
|
||||
if (kvm_getswapinfo (server->machine.kd, &dummy, 1, 0) != 0) {
|
||||
glibtop_warn_io_r (server, "kvm_nlist (swap)");
|
||||
glibtop_warn_io_r (server, "kvm_swap (swap)");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !(defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000))
|
||||
if (kvm_nlist (server->machine.kd, nlst2) != 0) {
|
||||
glibtop_warn_io_r (server, "kvm_nlist (swap)");
|
||||
glibtop_warn_io_r (server, "kvm_nlist (cnt)");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
server->sysdeps.swap = _glibtop_sysdeps_swap;
|
||||
}
|
||||
@@ -110,8 +129,9 @@ glibtop_init_swap_p (glibtop *server)
|
||||
void
|
||||
glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
|
||||
{
|
||||
#ifdef __FreeBSD__
|
||||
#if __FreeBSD__ < 4
|
||||
#if defined(__FreeBSD__)
|
||||
|
||||
# if __FreeBSD__ < 4
|
||||
char *header;
|
||||
int hlen, nswdev, dmmax;
|
||||
int div, nfree, npfree;
|
||||
@@ -122,29 +142,44 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
|
||||
struct rlist *swapptr;
|
||||
size_t sw_size;
|
||||
u_long ptr;
|
||||
#else
|
||||
# else
|
||||
int nswdev;
|
||||
struct kvm_swap kvmsw[16];
|
||||
#endif
|
||||
#elif (defined __NetBSD__)
|
||||
# endif
|
||||
|
||||
#elif defined(__bsdi__)
|
||||
struct swapstats swap;
|
||||
#elif defined(__NetBSD__)
|
||||
struct swapent *swaplist;
|
||||
#endif
|
||||
|
||||
int nswap, i;
|
||||
int avail = 0, inuse = 0;
|
||||
|
||||
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
|
||||
struct uvmexp uvmexp;
|
||||
size_t length_uvmexp;
|
||||
#else
|
||||
/* To get `pagein' and `pageout'. */
|
||||
struct vmmeter vmm;
|
||||
#endif
|
||||
static int swappgsin = -1;
|
||||
static int swappgsout = -1;
|
||||
|
||||
glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_SWAP), 0);
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SWAP), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_swap));
|
||||
|
||||
if (server->sysdeps.swap == 0)
|
||||
return;
|
||||
|
||||
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
|
||||
length_uvmexp = sizeof (uvmexp);
|
||||
if (sysctl (mib_uvmexp, 2, &uvmexp, &length_uvmexp, NULL, 0)) {
|
||||
glibtop_warn_io_r (server, "sysctl (uvmexp)");
|
||||
return;
|
||||
}
|
||||
#else
|
||||
/* This is used to get the `pagein' and `pageout' members. */
|
||||
|
||||
if (kvm_read (server->machine.kd, nlst2[0].n_value,
|
||||
@@ -152,6 +187,7 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
|
||||
glibtop_warn_io_r (server, "kvm_read (cnt)");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (swappgsin < 0) {
|
||||
buf->pagein = 0;
|
||||
@@ -160,21 +196,31 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
|
||||
#ifdef __FreeBSD__
|
||||
buf->pagein = vmm.v_swappgsin - swappgsin;
|
||||
buf->pageout = vmm.v_swappgsout - swappgsout;
|
||||
#else
|
||||
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
|
||||
buf->pagein = uvmexp.swapins - swappgsin;
|
||||
buf->pageout = uvmexp.swapouts - swappgsout;
|
||||
#else
|
||||
buf->pagein = vmm.v_swpin - swappgsin;
|
||||
buf->pageout = vmm.v_swpout - swappgsout;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
swappgsin = vmm.v_swappgsin;
|
||||
swappgsout = vmm.v_swappgsout;
|
||||
#else
|
||||
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
|
||||
swappgsin = uvmexp.swapins;
|
||||
swappgsout = uvmexp.swapouts;
|
||||
#else
|
||||
swappgsin = vmm.v_swpin;
|
||||
swappgsout = vmm.v_swpout;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__)
|
||||
|
||||
#if __FreeBSD__ < 4
|
||||
|
||||
@@ -214,7 +260,7 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
|
||||
|
||||
if (kvm_read (server->machine.kd, nlst[VM_SWDEVT].n_value,
|
||||
&ptr, sizeof (ptr)) != sizeof (ptr)) {
|
||||
glibtop_warn_io_r (server, "kvm_read (swaplist)");
|
||||
glibtop_warn_io_r (server, "kvm_read (swdevt)");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -328,7 +374,24 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
|
||||
|
||||
#endif
|
||||
|
||||
#elif (defined __NetBSD__)
|
||||
#elif defined(__bsdi__)
|
||||
|
||||
/* General info about swap devices. */
|
||||
|
||||
if (kvm_read (server->machine.kd, nlst[0].n_value,
|
||||
&swap, sizeof (swap)) != sizeof (swap)) {
|
||||
glibtop_warn_io_r (server, "kvm_read (swap)");
|
||||
return;
|
||||
}
|
||||
|
||||
buf->flags = _glibtop_sysdeps_swap;
|
||||
|
||||
buf->used = swap.swap_total - swap.swap_free;
|
||||
buf->free = swap.swap_free;
|
||||
|
||||
buf->total = swap.swap_total;
|
||||
|
||||
#elif defined(__NetBSD__)
|
||||
|
||||
nswap = swapctl (SWAP_NSWAP, NULL, 0);
|
||||
if (nswap < 0) {
|
||||
|
@@ -30,11 +30,11 @@
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_uptime =
|
||||
(1 << GLIBTOP_UPTIME_UPTIME) + (1 << GLIBTOP_UPTIME_IDLETIME);
|
||||
(1L << GLIBTOP_UPTIME_UPTIME) + (1L << GLIBTOP_UPTIME_IDLETIME);
|
||||
|
||||
static const unsigned long _required_cpu_flags =
|
||||
(1 << GLIBTOP_CPU_TOTAL) + (1 << GLIBTOP_CPU_IDLE) +
|
||||
(1 << GLIBTOP_CPU_FREQUENCY);
|
||||
(1L << GLIBTOP_CPU_TOTAL) + (1L << GLIBTOP_CPU_IDLE) +
|
||||
(1L << GLIBTOP_CPU_FREQUENCY);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
@@ -51,7 +51,7 @@ glibtop_get_uptime_p (glibtop *server, glibtop_uptime *buf)
|
||||
{
|
||||
glibtop_cpu cpu;
|
||||
|
||||
glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_UPTIME), 0);
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_UPTIME), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_uptime));
|
||||
|
||||
|
28
sysdeps/kernel/.cvsignore
Normal file
28
sysdeps/kernel/.cvsignore
Normal file
@@ -0,0 +1,28 @@
|
||||
.deps
|
||||
.libs
|
||||
Makefile
|
||||
Makefile.in
|
||||
close.lo
|
||||
cpu.lo
|
||||
init.lo
|
||||
ipc_limits.lo
|
||||
libgtop_sysdeps.la
|
||||
loadavg.lo
|
||||
mem.lo
|
||||
msg_limits.lo
|
||||
open.lo
|
||||
procdata.lo
|
||||
prockernel.lo
|
||||
proclist.lo
|
||||
procmem.lo
|
||||
procsegment.lo
|
||||
procsignal.lo
|
||||
procstate.lo
|
||||
proctime.lo
|
||||
procuid.lo
|
||||
sem_limits.lo
|
||||
shm_limits.lo
|
||||
swap.lo
|
||||
sysdeps.lo
|
||||
sysinfo.lo
|
||||
uptime.lo
|
23
sysdeps/kernel/ChangeLog
Normal file
23
sysdeps/kernel/ChangeLog
Normal file
@@ -0,0 +1,23 @@
|
||||
1998-10-26 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* netload.c: New file. Currently empty.
|
||||
|
||||
1998-10-26 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* procargs.c: New file. Currently empty.
|
||||
|
||||
1998-10-25 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* ppp.c: New file. Currently empty.
|
||||
|
||||
1998-06-14 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* kernel.s: New file - declaration of the table () function
|
||||
via _syscall3 (); due to a bug in egcs, we cannot put this
|
||||
into a C file.
|
||||
|
||||
1998-06-13 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
The code in this directory fetches all information
|
||||
directly from the kernel. It uses the new table ()
|
||||
system call from the `kernel' directory.
|
@@ -4,14 +4,21 @@ INCLUDES = @INCLUDES@
|
||||
|
||||
lib_LTLIBRARIES = libgtop_sysdeps.la
|
||||
|
||||
libgtop_sysdeps_la_SOURCES = open.c close.c siglist.c cpu.c mem.c swap.c \
|
||||
libgtop_sysdeps_la_SOURCES = open.c close.c kernel.s cpu.c mem.c swap.c \
|
||||
uptime.c loadavg.c shm_limits.c msg_limits.c \
|
||||
sem_limits.c proclist.c procstate.c procuid.c \
|
||||
proctime.c procmem.c procsignal.c prockernel.c \
|
||||
procsegment.c procargs.c procmap.c netload.c \
|
||||
ppp.c
|
||||
procsegment.c siglist.c procargs.c procmap.c \
|
||||
netload.c ppp.c
|
||||
|
||||
libgtop_sysdeps_la_LDFLAGS = $(LT_VERSION_INFO)
|
||||
|
||||
include_HEADERS = glibtop_server.h
|
||||
|
||||
noinst_HEADERS = kernel.h
|
||||
|
||||
kernel.o kernel.lo: $(srcdir)/kernel.s
|
||||
rm -f kernel.o kernel.lo
|
||||
$(AS) -o kernel.o $(srcdir)/kernel.s
|
||||
cp kernel.o kernel.lo
|
||||
|
||||
|
@@ -21,10 +21,16 @@
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <config.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/cpu.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_cpu = 0;
|
||||
#include "kernel.h"
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_cpu =
|
||||
(1 << GLIBTOP_CPU_TOTAL) + (1 << GLIBTOP_CPU_USER) +
|
||||
(1 << GLIBTOP_CPU_NICE) + (1 << GLIBTOP_CPU_SYS) +
|
||||
(1 << GLIBTOP_CPU_IDLE) + (1 << GLIBTOP_CPU_FREQUENCY);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
@@ -39,5 +45,21 @@ glibtop_init_cpu_s (glibtop *server)
|
||||
void
|
||||
glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf)
|
||||
{
|
||||
union table tbl;
|
||||
|
||||
glibtop_init_s (&server, GLIBTOP_SYSDEPS_CPU, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_cpu));
|
||||
|
||||
if (table (TABLE_CPU, &tbl, NULL))
|
||||
glibtop_error_io_r (server, "table(TABLE_CPU)");
|
||||
|
||||
buf->flags = _glibtop_sysdeps_cpu;
|
||||
|
||||
buf->total = tbl.cpu.total;
|
||||
buf->user = tbl.cpu.user;
|
||||
buf->nice = tbl.cpu.nice;
|
||||
buf->sys = tbl.cpu.sys;
|
||||
buf->idle = tbl.cpu.idle;
|
||||
buf->frequency = tbl.cpu.frequency;
|
||||
}
|
||||
|
89
sysdeps/kernel/glibtop_private.h
Normal file
89
sysdeps/kernel/glibtop_private.h
Normal file
@@ -0,0 +1,89 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, March 1999.
|
||||
|
||||
LibGTop 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.
|
||||
|
||||
LibGTop 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 LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GLIBTOP_PRIVATE_H__
|
||||
#define __GLIBTOP_PRIVATE_H__
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/user.h>
|
||||
|
||||
#undef LIBGTOP_VERSION
|
||||
#include <linux/libgtop.h>
|
||||
|
||||
BEGIN_LIBGTOP_DECLS
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_stat_s (glibtop *server, libgtop_stat_t *stat);
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_mem_s (glibtop *server, libgtop_mem_t *mem);
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_swap_s (glibtop *server, libgtop_swap_t *swap);
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_proclist_s (glibtop *server,
|
||||
libgtop_proclist_t *proclist,
|
||||
u_int64_t which, u_int64_t arg);
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_proc_state_s (glibtop *server,
|
||||
libgtop_proc_state_t *proc_state,
|
||||
pid_t pid);
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_proc_mem_s (glibtop *server,
|
||||
libgtop_proc_mem_t *proc_mem,
|
||||
pid_t pid);
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_proc_signal_s (glibtop *server,
|
||||
libgtop_proc_signal_t *proc_signal,
|
||||
pid_t pid);
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_proc_kernel_s (glibtop *server,
|
||||
libgtop_proc_kernel_t *proc_kernel,
|
||||
pid_t pid);
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_proc_args_s (glibtop *server, pid_t pid,
|
||||
char *result, size_t max_len);
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_proc_maps_s (glibtop *server, pid_t pid,
|
||||
libgtop_proc_maps_t *result,
|
||||
size_t max_len);
|
||||
|
||||
int
|
||||
glibtop_get_proc_data_netload_s (glibtop *server,
|
||||
libgtop_netload_t *netload,
|
||||
const char *device);
|
||||
|
||||
END_LIBGTOP_DECLS
|
||||
|
||||
#endif __GLIBTOP_PRIVATE_H__
|
40
sysdeps/kernel/kernel.h
Normal file
40
sysdeps/kernel/kernel.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
LibGTop 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.
|
||||
|
||||
LibGTop 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 LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GLIBTOP_KERNEL_KERNEL_H__
|
||||
#define __GLIBTOP_KERNEL_KERNEL_H__
|
||||
|
||||
#include <linux/unistd.h>
|
||||
#include <linux/table.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <syscall.h>
|
||||
|
||||
BEGIN_LIBGTOP_DECLS
|
||||
|
||||
extern int table (int, union table *, const void *);
|
||||
|
||||
END_LIBGTOP_DECLS
|
||||
|
||||
#endif
|
42
sysdeps/kernel/kernel.s
Normal file
42
sysdeps/kernel/kernel.s
Normal file
@@ -0,0 +1,42 @@
|
||||
.file "test.c"
|
||||
.version "01.01"
|
||||
/ GNU C version egcs-2.90.29 980515 (egcs-1.0.3 release) (i686-pc-linux-gnu) compiled by GNU C version egcs-2.90.29 980515 (egcs-1.0.3 release).
|
||||
/ options passed: -O2 -Wall -W
|
||||
/ options enabled: -fdefer-pop -fcse-follow-jumps -fcse-skip-blocks
|
||||
/ -fexpensive-optimizations -fthread-jumps -fstrength-reduce -fpeephole
|
||||
/ -fforce-mem -ffunction-cse -finline -fkeep-static-consts -fcaller-saves
|
||||
/ -fpcc-struct-return -frerun-cse-after-loop -frerun-loop-opt
|
||||
/ -fschedule-insns2 -fcommon -fverbose-asm -fgnu-linker -fregmove
|
||||
/ -falias-check -fargument-alias -m80387 -mhard-float -mno-soft-float
|
||||
/ -mieee-fp -mfp-ret-in-387 -mschedule-prologue -mcpu=pentiumpro
|
||||
/ -march=pentium
|
||||
|
||||
gcc2_compiled.:
|
||||
.text
|
||||
.align 4
|
||||
.globl table
|
||||
.type table,@function
|
||||
table:
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
movl $190,%eax
|
||||
pushl %ebx
|
||||
movl 8(%ebp),%ebx
|
||||
movl 12(%ebp),%ecx
|
||||
movl 16(%ebp),%edx
|
||||
#APP
|
||||
int $0x80
|
||||
#NO_APP
|
||||
testl %eax,%eax
|
||||
jge .L3
|
||||
negl %eax
|
||||
movl %eax,errno
|
||||
movl $-1,%eax
|
||||
.L3:
|
||||
movl -4(%ebp),%ebx
|
||||
movl %ebp,%esp
|
||||
popl %ebp
|
||||
ret
|
||||
.Lfe1:
|
||||
.size table,.Lfe1-table
|
||||
.ident "GCC: (GNU) egcs-2.90.29 980515 (egcs-1.0.3 release)"
|
@@ -21,10 +21,15 @@
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <config.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/loadavg.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_loadavg = 0;
|
||||
#include "kernel.h"
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_loadavg =
|
||||
(1 << GLIBTOP_LOADAVG_LOADAVG) + (1 << GLIBTOP_LOADAVG_NR_RUNNING) +
|
||||
(1 << GLIBTOP_LOADAVG_NR_TASKS) + (1 << GLIBTOP_LOADAVG_LAST_PID);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
@@ -34,10 +39,27 @@ glibtop_init_loadavg_s (glibtop *server)
|
||||
server->sysdeps.loadavg = _glibtop_sysdeps_loadavg;
|
||||
}
|
||||
|
||||
/* Provides load averange. */
|
||||
/* Provides load load averange. */
|
||||
|
||||
void
|
||||
glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf)
|
||||
{
|
||||
union table tbl;
|
||||
|
||||
glibtop_init_s (&server, GLIBTOP_SYSDEPS_LOADAVG, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_loadavg));
|
||||
|
||||
if (table (TABLE_LOADAVG, &tbl, NULL))
|
||||
glibtop_error_io_r (server, "table(TABLE_LOADAVG)");
|
||||
|
||||
buf->flags = _glibtop_sysdeps_loadavg;
|
||||
|
||||
buf->loadavg [0] = tbl.loadavg.loadavg [0];
|
||||
buf->loadavg [1] = tbl.loadavg.loadavg [1];
|
||||
buf->loadavg [2] = tbl.loadavg.loadavg [2];
|
||||
|
||||
buf->nr_running = tbl.loadavg.nr_running;
|
||||
buf->nr_tasks = tbl.loadavg.nr_tasks;
|
||||
buf->last_pid = tbl.loadavg.last_pid;
|
||||
}
|
||||
|
@@ -21,10 +21,17 @@
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <config.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/mem.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_mem = 0;
|
||||
#include "kernel.h"
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_mem =
|
||||
(1 << GLIBTOP_MEM_TOTAL) + (1 << GLIBTOP_MEM_USED) +
|
||||
(1 << GLIBTOP_MEM_FREE) + (1 << GLIBTOP_MEM_SHARED) +
|
||||
(1 << GLIBTOP_MEM_BUFFER) + (1 << GLIBTOP_MEM_CACHED) +
|
||||
(1 << GLIBTOP_MEM_USER);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
@@ -39,5 +46,23 @@ glibtop_init_mem_s (glibtop *server)
|
||||
void
|
||||
glibtop_get_mem_s (glibtop *server, glibtop_mem *buf)
|
||||
{
|
||||
union table tbl;
|
||||
|
||||
glibtop_init_s (&server, GLIBTOP_SYSDEPS_MEM, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_mem));
|
||||
|
||||
if (table (TABLE_MEM, &tbl, NULL))
|
||||
glibtop_error_io_r (server, "table(TABLE_MEM)");
|
||||
|
||||
buf->flags = _glibtop_sysdeps_mem;
|
||||
|
||||
buf->total = tbl.mem.total;
|
||||
buf->used = tbl.mem.used;
|
||||
buf->free = tbl.mem.free;
|
||||
buf->shared = tbl.mem.shared;
|
||||
buf->buffer = tbl.mem.buffer;
|
||||
buf->cached = tbl.mem.cached;
|
||||
|
||||
buf->user = buf->total - buf->free - buf->shared - buf->buffer;
|
||||
}
|
||||
|
@@ -21,10 +21,16 @@
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/msg_limits.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_msg_limits = 0;
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/msg.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_msg_limits =
|
||||
(1 << GLIBTOP_IPC_MSGPOOL) + (1 << GLIBTOP_IPC_MSGMAP) +
|
||||
(1 << GLIBTOP_IPC_MSGMAX) + (1 << GLIBTOP_IPC_MSGMNB) +
|
||||
(1 << GLIBTOP_IPC_MSGMNI) + (1 << GLIBTOP_IPC_MSGSSZ) +
|
||||
(1 << GLIBTOP_IPC_MSGTQL);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
@@ -39,5 +45,21 @@ glibtop_init_msg_limits_s (glibtop *server)
|
||||
void
|
||||
glibtop_get_msg_limits_s (glibtop *server, glibtop_msg_limits *buf)
|
||||
{
|
||||
struct msginfo msginfo;
|
||||
|
||||
glibtop_init_s (&server, GLIBTOP_SYSDEPS_MSG_LIMITS, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_msg_limits));
|
||||
|
||||
buf->flags = _glibtop_sysdeps_msg_limits;
|
||||
|
||||
msgctl (0, IPC_INFO, (struct msqid_ds *) &msginfo);
|
||||
|
||||
buf->msgpool = msginfo.msgpool;
|
||||
buf->msgmap = msginfo.msgmap;
|
||||
buf->msgmax = msginfo.msgmax;
|
||||
buf->msgmnb = msginfo.msgmnb;
|
||||
buf->msgmni = msginfo.msgmni;
|
||||
buf->msgssz = msginfo.msgssz;
|
||||
buf->msgtql = msginfo.msgtql;
|
||||
}
|
||||
|
@@ -23,6 +23,33 @@
|
||||
|
||||
#include <glibtop/open.h>
|
||||
|
||||
/* =====================================================
|
||||
* Linux kernel version information for procps utilities
|
||||
* Copyright (c) 1996 Charles Blake <cblake@bbn.com>
|
||||
*/
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#define LINUX_VERSION(x,y,z) (0x10000*(x) + 0x100*(y) + z)
|
||||
|
||||
static int linux_version_code = 0;
|
||||
|
||||
static void set_linux_version(void) {
|
||||
static struct utsname uts;
|
||||
int x = 0, y = 0, z = 0; /* cleared in case sscanf() < 3 */
|
||||
|
||||
if (linux_version_code) return;
|
||||
if (uname(&uts) == -1) /* failure most likely implies impending death */
|
||||
exit(1);
|
||||
if (sscanf(uts.release, "%d.%d.%d", &x, &y, &z) < 3)
|
||||
fprintf(stderr, /* *very* unlikely to happen by accident */
|
||||
"Non-standard uts for running kernel:\n"
|
||||
"release %s=%d.%d.%d gives version code %d\n",
|
||||
uts.release, x, y, z, LINUX_VERSION(x,y,z));
|
||||
linux_version_code = LINUX_VERSION(x, y, z);
|
||||
}
|
||||
|
||||
/* ======================================================= */
|
||||
|
||||
/* Opens pipe to gtop server. Returns 0 on success and -1 on error. */
|
||||
|
||||
void
|
||||
@@ -30,4 +57,7 @@ glibtop_open_s (glibtop *server, const char *program_name,
|
||||
const unsigned long features, const unsigned flags)
|
||||
{
|
||||
server->name = program_name;
|
||||
|
||||
set_linux_version ();
|
||||
server->os_version_code = (unsigned long) linux_version_code;
|
||||
}
|
||||
|
@@ -38,7 +38,7 @@ glibtop_init_proc_args_s (glibtop *server)
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
char *
|
||||
const char *
|
||||
glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf,
|
||||
pid_t pid, unsigned max_len)
|
||||
{
|
||||
|
180
sysdeps/kernel/procdata.c
Normal file
180
sysdeps/kernel/procdata.c
Normal file
@@ -0,0 +1,180 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
LibGTop 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.
|
||||
|
||||
LibGTop 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 LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop/procdata.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define LINUX_VERSION(x,y,z) (0x10000*(x) + 0x100*(y) + z)
|
||||
|
||||
#define BIT_SHIFT(x) (1 << (x % 32))
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_procdata_0 =
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_CMD) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_STATE) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_UID) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_PID) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_PPID) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_PGRP) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_SESSION) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_TTY) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_TPGID) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_PRIORITY) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_NICE) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_SIGNAL) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_BLOCKED) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_SIGIGNORE) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_SIGCATCH) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_START_TIME) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_UTIME) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_STIME) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_CUTIME) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_CSTIME) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_SIZE) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_RESIDENT) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_SHARE) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_TRS) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_LRS) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_DRS) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_DT) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_VSIZE) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_RSS) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_RSS_RLIM) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_TIMEOUT) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_IT_REAL_VALUE);
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_procdata_1 =
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_K_FLAGS) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_MIN_FLT) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_MAJ_FLT) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_CMIN_FLT) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_CMAJ_FLT) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_START_CODE) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_END_CODE) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_START_STACK) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_KSTK_ESP) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_KSTK_EIP) +
|
||||
BIT_SHIFT(GLIBTOP_PROCDATA_WCHAN);
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
void
|
||||
glibtop_get_procdata_s (glibtop *server, glibtop_procdata *buf, pid_t pid)
|
||||
{
|
||||
char input [BUFSIZ], *tmp;
|
||||
struct stat statb;
|
||||
int nread;
|
||||
FILE *f;
|
||||
|
||||
glibtop_init_s (&server, 0, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_procdata));
|
||||
|
||||
if (pid == 0) {
|
||||
/* Client is only interested in the flags. */
|
||||
buf->flags [0] = _glibtop_sysdeps_procdata_0;
|
||||
buf->flags [1] = _glibtop_sysdeps_procdata_1;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
sprintf (input, "/proc/%d/stat", pid);
|
||||
|
||||
if (stat (input, &statb)) return;
|
||||
|
||||
buf->uid = statb.st_uid;
|
||||
|
||||
f = fopen (input, "r");
|
||||
if (!f) return;
|
||||
|
||||
nread = fread (input, 1, BUFSIZ, f);
|
||||
|
||||
if (nread < 0) {
|
||||
fclose (f);
|
||||
return;
|
||||
}
|
||||
|
||||
input [nread] = 0;
|
||||
|
||||
/* This is from guile-utils/gtop/proc/readproc.c */
|
||||
|
||||
/* split into "PID (cmd" and "<rest>" */
|
||||
tmp = strrchr (input, ')');
|
||||
*tmp = '\0'; /* replace trailing ')' with NUL */
|
||||
/* parse these two strings separately, skipping the leading "(". */
|
||||
memset (buf->cmd, 0, sizeof (buf->cmd));
|
||||
sscanf (input, "%d (%39c", &buf->pid, buf->cmd);
|
||||
sscanf(tmp + 2, /* skip space after ')' too */
|
||||
"%c %d %d %d %d %d %lu %lu %lu %lu %lu "
|
||||
"%ld %ld %ld %ld %d %d %lu %lu %ld %lu "
|
||||
"%lu %lu %lu %lu %lu %lu %lu %d %d %d %d %lu",
|
||||
&buf->state, &buf->ppid, &buf->pgrp, &buf->session,
|
||||
&buf->tty, &buf->tpgid, &buf->k_flags, &buf->min_flt,
|
||||
&buf->cmin_flt, &buf->maj_flt, &buf->cmaj_flt,
|
||||
&buf->utime, &buf->stime, &buf->cutime, &buf->cstime,
|
||||
&buf->priority, &buf->nice, &buf->timeout,
|
||||
&buf->it_real_value, &buf->start_time, &buf->vsize,
|
||||
&buf->rss, &buf->rss_rlim, &buf->start_code,
|
||||
&buf->end_code, &buf->start_stack, &buf->kstk_esp,
|
||||
&buf->kstk_eip, &buf->signal, &buf->blocked,
|
||||
&buf->sigignore, &buf->sigcatch, &buf->wchan);
|
||||
|
||||
if (buf->tty == 0)
|
||||
/* the old notty val, update elsewhere bef. moving to 0 */
|
||||
buf->tty = -1;
|
||||
|
||||
if (server->os_version_code < LINUX_VERSION(1,3,39)) {
|
||||
/* map old meanings to new */
|
||||
buf->priority = 2*15 - buf->priority;
|
||||
buf->nice = 15 - buf->nice;
|
||||
}
|
||||
if (server->os_version_code < LINUX_VERSION(1,1,30) && buf->tty != -1)
|
||||
/* when tty wasn't full devno */
|
||||
buf->tty = 4*0x100 + buf->tty;
|
||||
|
||||
fclose (f);
|
||||
|
||||
sprintf (input, "/proc/%d/statm", pid);
|
||||
|
||||
f = fopen (input, "r");
|
||||
if (!f) return;
|
||||
|
||||
nread = fread (input, 1, BUFSIZ, f);
|
||||
|
||||
if (nread < 0) {
|
||||
fclose (f);
|
||||
return;
|
||||
}
|
||||
|
||||
input [nread] = 0;
|
||||
|
||||
sscanf (input, "%ld %ld %ld %ld %ld %ld %ld",
|
||||
&buf->size, &buf->resident, &buf->share,
|
||||
&buf->trs, &buf->lrs, &buf->drs, &buf->dt);
|
||||
|
||||
fclose (f);
|
||||
|
||||
buf->flags [0] = _glibtop_sysdeps_procdata_0;
|
||||
buf->flags [1] = _glibtop_sysdeps_procdata_1;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user