Compare commits

...

38 Commits

Author SHA1 Message Date
Steven Chamberlain
d9c01aac4a Don't include sys/pipe.h on kFreeBSD
Defining _KERNEL to include sys/pipe.h subsequently breaks sys/conf.h;
 since sys/pipe.h is not meant to be used in userland, and libgtop2 builds
 anyway on kFreeBSD without it, don't include it.
https://bugzilla.gnome.org/show_bug.cgi?id=674067
2014-04-29 00:30:07 +03:00
Ting-Wei Lan
82c28b2ad2 src/daemon: remove LINK variable
https://bugzilla.gnome.org/show_bug.cgi?id=724904
2014-04-29 00:14:49 +03:00
Benoît Dejean
05345dc032 ABI breakage by efaaf6eb77. Fixing libtool version to 10.0.0.
https://bugzilla.gnome.org/show_bug.cgi?id=323354
2014-04-29 00:11:30 +03:00
Jasper Lievisse Adriaanse
63ba7b2c12 switch from VM_METER to VM_UVMEXP 2014-04-10 16:32:47 +02:00
Antoine Jacoutot
5371e8ec88 openbsd: drop empty EXTRA_SYSDEPS_LIBS.
https://bugzilla.gnome.org/show_bug.cgi?id=727375
2014-03-31 12:50:44 +02:00
Ryan Lortie
e682094418 examples: don't override LINK and other variables
Defining our own LINK causes us to run into some trouble with LDFLAGS,
which commit 16bb5c8075 already
demonstrated.

LDFLAGS does need to be included here, but it's probably even easier to
just use the default value.

https://bugzilla.gnome.org/show_bug.cgi?id=724195
2014-02-20 20:58:16 -05:00
Ryan Lortie
2e861977a6 freebsd: don't link to libgeom
libgeom declares several symbols in GLib's namespace, including
g_close() and it therefore cannot be used from any program that also
uses GLib.

For now, disable the parts of the FreeBSD sysdep that use libgeom.
Hopefully the libgeom API will be changed soon.

https://bugzilla.gnome.org/show_bug.cgi?id=723685
2014-02-20 20:56:57 -05:00
Ting-Wei Lan
a39f290683 Fix build issues on FreeBSD 2014-02-20 20:55:39 -05:00
Antoine Jacoutot
02b55313f3 openbsd: bring glibtop_get_proc_segment from FreeBSD 2014-02-08 11:54:07 +01:00
Antoine Jacoutot
596c42d7f1 openbsd: drop unecessary check 2014-02-08 11:53:26 +01:00
Shankar Prasad
d4d4f7735a updated kn.po 2014-02-05 16:38:05 +05:30
Antoine Jacoutot
4cd3e4fed6 openbsd: merge patches from ports tree
Bring OpenBSD closer to FreeBSD to help checking what is missing/different.
Also we make sure to use and build mountlist and fsusage from the
sysdeps/openbsd directory instead of the common one.

https://bugzilla.gnome.org/show_bug.cgi?id=723521
2014-02-03 10:59:05 +01:00
Antoine Jacoutot
c99ceeaa65 openbsd: better handling of p_wchan 2014-02-01 19:09:21 +01:00
Antoine Jacoutot
ecbfade528 openbsd: really drop all lsof related code 2014-01-23 15:03:36 +01:00
Jasper Lievisse Adriaanse
73d4679ad8 Remove OpenBSD RCS ID which bears no meaning here. 2014-01-23 11:24:33 +01:00
Robert Nagy
df1db43032 Fix several issues related to process information on OpenBSD and drop lsof usage. 2014-01-23 10:39:39 +01:00
Jasper Lievisse Adriaanse
ff07ba102f Some fields have moved in struct proc from timeval to timespec. 2014-01-23 10:34:52 +01:00
Jasper Lievisse Adriaanse
07d2816d5b Adjust header inclusion on OpenBSD
- fixup header inclusion after netinet/in_var.h was made private
- configure fails to define HAVE_NET_IF_VAR_H
2014-01-23 10:30:53 +01:00
Victor Ibragimov
2caff8bf5c Tajik translation updated 2013-12-20 13:36:26 +05:00
Victor Ibragimov
78e257e958 Tajik translation updated 2013-12-20 13:32:00 +05:00
Jason Xing
efaaf6eb77 Extending the cpu number from 32 to 1024 (bgo #323354, bgo #681632)
From: Jason Xing <xinggang861@gmail.com>

In 'Bug 323354 - Support a dynamic number of CPUs', there will be a
solution which can dynamically allocate memory for large number of
CPUs. As libgtop supports multiple operating systems, this work
may take some time.

This patch is a temporary patch, which worked before the whole
solution comes out. It only supports linux platform with CPU number
up to 1024.

There are two Macroes which limit the statistics of CPU. One is
GLIBTOP_NCPU. The other is a buffer size. This buffer used to read
/proc/stat contents into.

https://bugzilla.gnome.org/show_bug.cgi?id=323354
https://bugzilla.gnome.org/show_bug.cgi?id=681632
2013-12-12 22:36:10 +02:00
Robert Roth
47bcd423b5 Linux cpuinfo count fixed for SMP PPC processors (bgo #621831)
libgtop processor count has been simply determined by the number
of sections in /proc/cpuinfo split by \n\n. On PPC processors
supporting SMP after the per-cpu description for each core a
new section is listed (after \n\n) with the common attributes
of the cores [1]. Work around this by only counting a section
as describing a CPU if it contains "processor" to fix bug #621831 [0]
[0] https://bugzilla.gnome.org/show_bug.cgi?id=621831
[1] https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/arch/powerpc/kernel/setup-common.c?id=9fc2105aeaaf56b0cf75296a84702d0f9e64437b#n319
2013-12-09 04:02:38 +02:00
Robert Roth
38bfee6739 pprint example extended to print cpu info 2013-12-09 04:02:21 +02:00
Robert Roth
3147bf2e34 Log error on statvfs failure.
When doing stat on a FS and failing, log the error message based
on the errno set to help the user find the reason.
https://bugzilla.gnome.org/show_bug.cgi?id=685172
2013-12-09 01:57:01 +02:00
Antoine Jacoutot
2506662196 OpenBSD: add missing header
netinet6/in6_var.h is not included automatically  anymore from netinet/in_var.h
on OpenBSD, so explicitely #include <netinet6/in6_var.h>.
2013-10-16 17:09:16 +02:00
Robert Roth
b6eb0873e7 Revert "Increased major version"
This reverts commit f9e8ae8dfc.
2013-08-31 01:11:56 +03:00
Robert Roth
2c08229f04 Merge remote-tracking branch 'origin' into wip/libgtop-ng 2013-08-30 07:34:15 +03:00
Tristan Hill
753d9abb13 proclist, procarg and proctime gtkdoc updates
Added gtkdoc for proclist, procarg and proctime.

Author:    Tristan Hill <stan@saticed.me.uk>

https://bugzilla.gnome.org/show_bug.cgi?id=616082
2013-08-30 07:31:31 +03:00
Robert Roth
af7e9cd1b6 Increased buffersize to be able to hold larger cpuinfo files (bgo #681632) 2013-08-22 01:48:12 +03:00
Robert Roth
552ea7ec3a Fixed automake warning 2013-08-22 01:37:02 +03:00
Robert Roth
43f19912e3 Fixed automake warning 2013-08-22 01:34:34 +03:00
Robert Roth
16bb5c8075 Fixed automake warning 2013-08-22 01:30:29 +03:00
Robert Roth
bebcb377af Revert "Fixed missing cache-id warning" as it breaks jhbuild.
This reverts commit 4cffb2f094.
2013-08-22 01:11:06 +03:00
Robert Roth
4cffb2f094 Fixed missing cache-id warning 2013-08-21 15:43:10 +03:00
Robert Roth
5adaa90de3 Added files created by make to .gitignore 2013-08-20 23:26:29 +03:00
Robert Roth
f9e8ae8dfc Increased major version 2013-08-20 23:26:00 +03:00
Robert Roth
efeb24a96c Added gitignore 2013-08-20 22:49:02 +03:00
Robert Roth
3c4ddb5572 release: post-release bump to 2.28.6 2013-08-19 23:49:15 +03:00
59 changed files with 982 additions and 785 deletions

100
.gitignore vendored Normal file
View File

@@ -0,0 +1,100 @@
sysdeps/Makefile
sysdeps/Makefile.in
sysdeps/*/Makefile
sysdeps/*/Makefile.in
sysdeps/*/.deps
sysdeps/*/.libs
sysdeps/*/*.o
sysdeps/*/*.lo
sysdeps/*/*.la
src/*/Makefile
src/*/Makefile.in
src/*/.deps
src/Makefile
src/Makefile.in
stamp-h1
po/*.gmo
po/stamp-it
po/POTFILES
po/Makefile.in.in
po/Makefile.in
po/Makefile
missing
misc/Makefile
misc/Makefile.in
m4/
ltmain.sh
libtool
libgtopconfig.h
libgtop.spec
libgtop-2.0.pc
lib/Makefile
lib/Makefile.in
lib/.deps
lib/.libs
lib/*.o
lib/*.lo
lib/*.la
lib/lib.c
lib/GTop-2.0.gir
lib/GTop-2.0.typelib
INSTALL
Makefile
Makefile.in
aclocal.m4
autom4te.cache/
config.guess
config.h
config.h.in
config.log
config.status
config.sub
configure
depcomp
doc/Makefile
doc/Makefile.in
doc/libgtop2.info
doc/mdate-sh
doc/reference/Makefile
doc/reference/Makefile.in
doc/reference/html/
doc/reference/libgtop-decl-list.txt
doc/reference/libgtop-decl.txt
doc/reference/tmpl/
doc/reference/version.xml
doc/reference/xml/
doc/stamp-vti
doc/texinfo.tex
doc/version.texi
examples/.deps/
examples/.libs/
examples/*.o
examples/Makefile
examples/Makefile.in
examples/affinity
examples/df
examples/first
examples/mem
examples/mountlist
examples/netlist
examples/netload
examples/openfiles
examples/pprint
examples/procargs
examples/proclist
examples/procmap
examples/second
examples/smp
examples/sysdeps
examples/timings
examples/wd
gtk-doc.make
include/Makefile
include/Makefile.in
include/glibtop/Makefile
include/glibtop/Makefile.in
install-sh
intltool-extract.in
intltool-merge.in
intltool-update.in

View File

@@ -4,11 +4,11 @@ dnl
m4_define([libgtop_major_version], [2])
m4_define([libgtop_minor_version], [28])
m4_define([libgtop_micro_version], [5])
m4_define([libgtop_micro_version], [6])
m4_define([libgtop_version], [libgtop_major_version.libgtop_minor_version.libgtop_micro_version])
dnl increment if the interface has additions, changes, removals.
m4_define([libgtop_current], [9])
m4_define([libgtop_current], [10])
dnl increment any time the source changes; set to
dnl 0 if you increment CURRENT
@@ -17,7 +17,7 @@ m4_define([libgtop_revision], [0])
dnl increment if any interfaces have been added; set to 0
dnl if any interfaces have been removed. removal has
dnl precedence over adding, so set to 0 if both happened.
m4_define([libgtop_age], [2])
m4_define([libgtop_age], [0])
# Increase each time you change the client/server protocol.
m4_define([libgtop_server_version], [5])

View File

@@ -219,17 +219,8 @@ glibtop_set_parameter_l
<INCLUDE>glibtop/procargs.h</INCLUDE>
<SECTION>
<FILE>procargs</FILE>
GLIBTOP_PROC_ARGS_SIZE
GLIBTOP_MAX_PROC_ARGS
glibtop_proc_args
glibtop_get_proc_args_l
glibtop_get_proc_args
glibtop_get_proc_args_r
glibtop_init_proc_args_p
glibtop_get_proc_args_p
glibtop_init_proc_args_s
glibtop_get_proc_args_s
glibtop_get_proc_argv_l
glibtop_get_proc_argv
</SECTION>
@@ -420,26 +411,8 @@ glibtop_get_proc_uid_s
<INCLUDE>glibtop/proctime.h</INCLUDE>
<SECTION>
<FILE>proctime</FILE>
GLIBTOP_PROC_TIME_START_TIME
GLIBTOP_PROC_TIME_RTIME
GLIBTOP_PROC_TIME_UTIME
GLIBTOP_PROC_TIME_STIME
GLIBTOP_PROC_TIME_CUTIME
GLIBTOP_PROC_TIME_CSTIME
GLIBTOP_PROC_TIME_TIMEOUT
GLIBTOP_PROC_TIME_IT_REAL_VALUE
GLIBTOP_PROC_TIME_FREQUENCY
GLIBTOP_PROC_TIME_XCPU_UTIME
GLIBTOP_PROC_TIME_XCPU_STIME
GLIBTOP_MAX_PROC_TIME
glibtop_proc_time
glibtop_get_proc_time
glibtop_get_proc_time_r
glibtop_get_proc_time_l
glibtop_init_proc_time_p
glibtop_get_proc_time_p
glibtop_init_proc_time_s
glibtop_get_proc_time_s
</SECTION>
<INCLUDE>glibtop/signal.h</INCLUDE>
@@ -515,10 +488,6 @@ glibtop_send_version
<INCLUDE>glibtop/proclist.h</INCLUDE>
<SECTION>
<FILE>proclist</FILE>
GLIBTOP_PROCLIST_NUMBER
GLIBTOP_PROCLIST_TOTAL
GLIBTOP_PROCLIST_SIZE
GLIBTOP_MAX_PROCLIST
GLIBTOP_KERN_PROC_ALL
GLIBTOP_KERN_PROC_PID
GLIBTOP_KERN_PROC_PGRP
@@ -532,12 +501,6 @@ GLIBTOP_EXCLUDE_SYSTEM
GLIBTOP_EXCLUDE_NOTTY
glibtop_proclist
glibtop_get_proclist
glibtop_get_proclist_r
glibtop_get_proclist_l
glibtop_init_proclist_p
glibtop_get_proclist_p
glibtop_init_proclist_s
glibtop_get_proclist_s
</SECTION>
<INCLUDE>glibtop/sem_limits.h</INCLUDE>

View File

@@ -1,12 +1,6 @@
## Process this file with automake to produce Makefile.in
LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@
INCLUDES = @INCLUDES@
DEFS = @DEFS@
LDFLAGS = $(LIBGTOP_EXTRA_LIBS)
AM_LDFLAGS = $(LIBGTOP_EXTRA_LIBS)
noinst_PROGRAMS = first second pprint procargs df netlist \
mountlist procmap netload sysdeps timings \

View File

@@ -3,6 +3,7 @@
#endif
#include <glibtop.h>
#include <glibtop/sysinfo.h>
#include <glibtop/union.h>
@@ -29,9 +30,41 @@ for(i = 0; i < (SIZE - 1); ++i) printf(".%u = " FORMAT ", ", i, buf.ARRAY[i]); \
printf(".%u = " FORMAT " }\n", SIZE - 1 , buf.ARRAY[SIZE - 1]); \
} while(0)
#define PPRINT_ENTRY_ARRAY(ARRAY, SIZE) do { \
size_t i; \
printf("\t%4lu B %3lu " #ARRAY "[%lu] = { ", \
(unsigned long) sizeof buf->ARRAY, 0,\
(unsigned long) G_N_ELEMENTS(buf->ARRAY)); \
for(i = 0; i < SIZE; ++i) { \
printf ("[ ");\
PPRINT_HASHTABLE(buf->ARRAY[i].values); \
printf ("]\n");\
} \
printf("} "); \
} while(0)
#define PPRINT_HASHTABLE(HASHTABLE) do { \
g_hash_table_foreach (HASHTABLE, (GHFunc)pprint_hashtable_item, NULL); \
} while(0)
#define FOOTER_PPRINT() putchar('\n');
static void pprint_hashtable_item(gchar* key, gchar* value, gpointer user_data)
{
printf ("'%s': '%s', ", key, value);
}
static void pprint_get_sysinfo(void)
{
const glibtop_sysinfo *buf;
buf = glibtop_get_sysinfo();
HEADER_PPRINT(glibtop_get_sysinfo);
//PPRINT(flags, "%#llx");
//PPRINT(ncpu, "%llu");
PPRINT_ENTRY_ARRAY(cpuinfo, 4);
FOOTER_PPRINT();
}
static void pprint_get_cpu(void)
{
@@ -291,6 +324,7 @@ int main()
{
glibtop_init();
pprint_get_sysinfo();
pprint_get_cpu();
pprint_get_fsusage("/");

View File

@@ -54,7 +54,7 @@ G_BEGIN_DECLS
Yes we are :)
Nobody should really be using more than 32 processors.
*/
#define GLIBTOP_NCPU 32
#define GLIBTOP_NCPU 1024
typedef struct _glibtop_cpu glibtop_cpu;

View File

@@ -36,22 +36,89 @@ G_BEGIN_DECLS
/* You can use the folowing constants as the `which' member of
* glibtop_get_proclist () to specify which processes to fetch. */
#define GLIBTOP_KERN_PROC_ALL 0 /* all processes */
/**
* GLIBTOP_KERN_PROC_ALL:
*
* Return information about all processes
**/
#define GLIBTOP_KERN_PROC_ALL 0
/**
* GLIBTOP_KERN_PROC_PID:
*
* Return all processes with the pid which is passed in @arg. You can use this to find out whether some process still exists.
**/
#define GLIBTOP_KERN_PROC_PID 1
/**
* GLIBTOP_KERN_PROC_PGRP:
*
* Return all processes in the process group passed in @arg.
**/
#define GLIBTOP_KERN_PROC_PGRP 2
/**
* GLIBTOP_KERN_PROC_SESSION:
*
* Return all processes in the session passed in @arg.
**/
#define GLIBTOP_KERN_PROC_SESSION 3
/**
* GLIBTOP_KERN_PROC_TTY:
*
* Return all processes which have the controlling tty passed in @arg
* (which is interpreted as the device number).
**/
#define GLIBTOP_KERN_PROC_TTY 4
/**
* GLIBTOP_KERN_PROC_UID:
*
* Return all processes with the effective uid passed in @arg.
**/
#define GLIBTOP_KERN_PROC_UID 5
/**
* GLIBTOP_KERN_PROC_RUID:
*
* Return all processes with the real uid passed in @arg.
**/
#define GLIBTOP_KERN_PROC_RUID 6
#define GLIBTOP_KERN_PROC_MASK 15
/**
* GLIBTOP_EXCLUDE_IDLE:
*
* Exclude idle processes.
**/
#define GLIBTOP_EXCLUDE_IDLE 0x1000
/**
* GLIBTOP_EXCLUDE_SYSTEM:
*
* Exclude system (on most UNIXes root's) processes.
**/
#define GLIBTOP_EXCLUDE_SYSTEM 0x2000
/**
* GLIBTOP_EXCLUDE_NOTTY:
*
* Exclude processes without a controlling terminal.
**/
#define GLIBTOP_EXCLUDE_NOTTY 0x4000
typedef struct _glibtop_proclist glibtop_proclist;
/**
* glibtop_proclist:
* @number: Number of entries in the returned list.
* @total: Total size of the returned list (this equals @number * @size).
* @size: Size of a single entry in the returned list
* (this equals <type>sizeof(unsigned)</type>).
*/
struct _glibtop_proclist
{
guint64 flags;

View File

@@ -46,26 +46,50 @@ typedef struct _glibtop_proc_time glibtop_proc_time;
/* Time section */
/**
* glibtop_proc_time:
* @start_time: Start time of process in seconds since the epoch.
* @rtime: Real time accumulated by process (should be @utime + @stime).
* @utime: User-mode CPU time accumulated by process.
* @stime: Kernel-mode CPU time accumulated by process.
* @cutime: Cumulative utime of process and reaped children.
* @cstime: Cumulative stime of process and reaped children.
* @timeout: The time (in jiffies) of the processs next timeout.
* @it_real_value: The time (in jiffies) before the next <type>SIGALRM</type>
* is sent to the process due to an interval timer.
* @frequency: Tick frequency.
* @xcpu_utime: SMP user-mode CPU time accumulated by process.
* @xcpu_stime: SMP kernel-mode CPU time accumulated by process
*
* Process time data filled by glibtop_get_proc_time().
*
* Under Linux the @start_time value may be wrong due to the information
* available from the kernel.
*
* The Linux kernel defines <type>INITIAL_JIFFIES</type> which implies a time
* shift. Because <type>INITIAL_JIFFIES</type> is not user-space defined,
* we cannot use it to compute an accurate @start_time. On Linux 2.6,
* <type>INITIAL_JIFFIES</type> is 300 so @start_time is
* always 3s different from the real start time of the given process. You
* may also get shift results if your system clock is not synchronised
* with your hardware clock. See <command>man hwclock</command>.
*/
struct _glibtop_proc_time
{
/*< private >*/
guint64 flags;
guint64 start_time; /* start time of process --
* seconds since 1-1-70 */
guint64 rtime; /* real time accumulated by process */
guint64 utime; /* user-mode CPU time accumulated by process */
guint64 stime; /* kernel-mode CPU time accumulated by process */
guint64 cutime; /* cumulative utime of process and
* reaped children */
guint64 cstime; /* cumulative stime of process and
* reaped children */
guint64 timeout; /* The time (in jiffies) of the process's
* next timeout */
guint64 it_real_value; /* The time (in jiffies) before the
* next SIGALRM is sent to the process
* due to an interval timer. */
guint64 frequency; /* Tick frequency. */
guint64 xcpu_utime [GLIBTOP_NCPU]; /* utime and stime for all CPUs on */
guint64 xcpu_stime [GLIBTOP_NCPU]; /* SMP machines. */
/*< public >*/
guint64 start_time;
guint64 rtime;
guint64 utime;
guint64 stime;
guint64 cutime;
guint64 cstime;
guint64 timeout;
guint64 it_real_value;
guint64 frequency;
guint64 xcpu_utime [GLIBTOP_NCPU];
guint64 xcpu_stime [GLIBTOP_NCPU];
};

View File

@@ -79,6 +79,8 @@ AC_DEFUN([GNOME_LIBGTOP_SYSDEPS],[
libgtop_sysdeps_dir=openbsd
libgtop_use_machine_h=yes
libgtop_need_server=yes
libgtop_sysdeps_private_mountlist=yes
libgtop_sysdeps_private_fsusage=yes
libgtop_postinstall='chgrp kmem $(bindir)/libgtop_server2 && chmod 2555 $(bindir)/libgtop_server2'
;;
freebsd*|kfreebsd*)
@@ -158,21 +160,10 @@ AC_DEFUN([GNOME_LIBGTOP_SYSDEPS],[
AC_CHECK_LIB(kvm, kvm_open, KVM_LIBS=-lkvm, KVM_LIBS=)
AC_SUBST(KVM_LIBS)
case "$host_os" in
kfreebsd*)
EXTRA_SYSDEPS_LIBS="-lgeom -ldevstat"
;;
freebsd*)
osreldate=`sysctl -n kern.osreldate 2>/dev/null`
if test -n "${osreldate}" && test ${osreldate} -ge 600000 ; then
EXTRA_SYSDEPS_LIBS="-lgeom -ldevstat"
fi
;;
esac
AC_SUBST(EXTRA_SYSDEPS_LIBS)
AC_CHECK_HEADERS(net/if_var.h)
AC_CHECK_HEADERS(net/if_var.h,,, [
#include <net/if.h>
#include <sys/types.h>
#include <sys/socket.h>])
AC_MSG_CHECKING([for I4B])
AC_TRY_COMPILE([
#include <sys/types.h>
@@ -237,10 +228,10 @@ AC_DEFUN([GNOME_LIBGTOP_SYSDEPS],[
fi
AC_MSG_CHECKING(what we need to define to get struct msginfo)
AC_CACHE_VAL(msginfo_needs,
msginfo_needs=
AC_CACHE_VAL(msginfo_cv_needs,
msginfo_cv_needs=
for def in nothing KERNEL _KERNEL; do
AC_COMPILE_IFELSE([#define $def
AC_COMPILE_IFELSE([AC_LANG_SOURCE([#define $def
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
@@ -252,23 +243,23 @@ main (void)
struct msginfo mi;
mi.msgmax = 0;
return 0;
}],
}])],
[
msginfo_needs=$def
if test ${msginfo_needs} = KERNEL; then
msginfo_cv_needs=$def
if test ${msginfo_cv_needs} = KERNEL; then
AC_DEFINE(STRUCT_MSGINFO_NEEDS_KERNEL, 1,
[Define to 1 if we need to define KERNEL to get 'struct msginfo'])
elif test ${msginfo_needs} = _KERNEL; then
elif test ${msginfo_cv_needs} = _KERNEL; then
AC_DEFINE(STRUCT_MSGINFO_NEEDS__KERNEL, 1,
[Define to 1 if we need to define _KERNEL to get 'struct msginfo'])
fi
]
)
test -n "${msginfo_needs}" && break
test -n "${msginfo_cv_needs}" && break
done
)
AC_MSG_RESULT($msginfo_needs)
if test -z "${msginfo_needs}"; then
AC_MSG_RESULT($msginfo_cv_needs)
if test -z "${msginfo_cv_needs}"; then
AC_MSG_ERROR([Could not find the definition of 'struct msginfo'])
fi
;;

109
po/kn.po
View File

@@ -1,21 +1,23 @@
# translation of libgtop.HEAD.po to Kannada
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
#
#
# Shankar Prasad <svenkate@redhat.com>, 2009.
msgid ""
msgstr ""
"Project-Id-Version: libgtop.HEAD\n"
"Report-Msgid-Bugs-To: http://bugzilla.gnome.org/enter_bug.cgi?product=libgtop&component=general\n"
"Report-Msgid-Bugs-To: http://bugzilla.gnome.org/enter_bug.cgi?product="
"libgtop&component=general\n"
"POT-Creation-Date: 2009-03-01 23:08+0000\n"
"PO-Revision-Date: 2009-03-14 20:01+0530\n"
"PO-Revision-Date: 2009-03-14 10:31-0400\n"
"Last-Translator: Shankar Prasad <svenkate@redhat.com>\n"
"Language-Team: Kannada <en@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: KBabel 1.11.4\n"
"Language: kn\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Zanata 3.2.3\n"
#: ../lib/read.c:51
#, c-format
@@ -61,129 +63,160 @@ msgstr "inetd ಇಂದ ರದ್ದು ಮಾಡಲಾದ"
#: ../src/daemon/gnuserv.c:495
#, c-format
msgid "Run '%s --help' to see a full list of available command line options.\n"
msgstr "ಲಭ್ಯವಿರುವ ಆಜ್ಞೆಯ ಒಂದು ಸಂಪೂರ್ಣ ಪಟ್ಟಿಯನ್ನು ನೋಡಲು '%s --help' ಅನ್ನು ಚಲಾಯಿಸಿ.\n"
msgstr ""
"ಲಭ್ಯವಿರುವ ಆಜ್ಞೆಯ ಒಂದು ಸಂಪೂರ್ಣ ಪಟ್ಟಿಯನ್ನು ನೋಡಲು '%s --help' ಅನ್ನು ಚಲಾಯಿಸಿ.\n"
#: ../sysdeps/osf1/siglist.c:27 ../sysdeps/sun4/siglist.c:27
#: ../sysdeps/osf1/siglist.c:27
#: ../sysdeps/sun4/siglist.c:27
msgid "Hangup"
msgstr "ನೇತಾಡು"
#: ../sysdeps/osf1/siglist.c:28 ../sysdeps/sun4/siglist.c:28
#: ../sysdeps/osf1/siglist.c:28
#: ../sysdeps/sun4/siglist.c:28
msgid "Interrupt"
msgstr "ತಡೆ"
#: ../sysdeps/osf1/siglist.c:29 ../sysdeps/sun4/siglist.c:29
#: ../sysdeps/osf1/siglist.c:29
#: ../sysdeps/sun4/siglist.c:29
msgid "Quit"
msgstr "ತ್ಯಜಿಸು"
#: ../sysdeps/osf1/siglist.c:30 ../sysdeps/sun4/siglist.c:30
#: ../sysdeps/osf1/siglist.c:30
#: ../sysdeps/sun4/siglist.c:30
msgid "Illegal instruction"
msgstr "ಅನಧೀಕೃತ ಸೂಚನೆ"
#: ../sysdeps/osf1/siglist.c:31 ../sysdeps/sun4/siglist.c:31
#: ../sysdeps/osf1/siglist.c:31
#: ../sysdeps/sun4/siglist.c:31
msgid "Trace trap"
msgstr "ಜಾಡಿನ ಟ್ರಾಪ್"
#: ../sysdeps/osf1/siglist.c:32 ../sysdeps/sun4/siglist.c:32
#: ../sysdeps/osf1/siglist.c:32
#: ../sysdeps/sun4/siglist.c:32
msgid "Abort"
msgstr "ಸ್ಥಗಿತಗೊಳಿಸು"
#: ../sysdeps/osf1/siglist.c:33 ../sysdeps/sun4/siglist.c:33
#: ../sysdeps/osf1/siglist.c:33
#: ../sysdeps/sun4/siglist.c:33
msgid "EMT error"
msgstr "EMT ದೋಷ"
#: ../sysdeps/osf1/siglist.c:34 ../sysdeps/sun4/siglist.c:34
#: ../sysdeps/osf1/siglist.c:34
#: ../sysdeps/sun4/siglist.c:34
msgid "Floating-point exception"
msgstr "ತೇಲುವ-ಬಿಂದುವಿನ ವಿನಾಯಿತಿ"
#: ../sysdeps/osf1/siglist.c:35 ../sysdeps/sun4/siglist.c:35
#: ../sysdeps/osf1/siglist.c:35
#: ../sysdeps/sun4/siglist.c:35
msgid "Kill"
msgstr "ಕೊಲ್ಲು"
#: ../sysdeps/osf1/siglist.c:36 ../sysdeps/sun4/siglist.c:36
#: ../sysdeps/osf1/siglist.c:36
#: ../sysdeps/sun4/siglist.c:36
msgid "Bus error"
msgstr "ಬಸ್ ದೋಷ"
#: ../sysdeps/osf1/siglist.c:37 ../sysdeps/sun4/siglist.c:37
#: ../sysdeps/osf1/siglist.c:37
#: ../sysdeps/sun4/siglist.c:37
msgid "Segmentation violation"
msgstr "ಸೆಗ್ಮೆಂಟೇಶನ್ ಉಲ್ಲಂಘನೆ"
#: ../sysdeps/osf1/siglist.c:38 ../sysdeps/sun4/siglist.c:38
#: ../sysdeps/osf1/siglist.c:38
#: ../sysdeps/sun4/siglist.c:38
msgid "Bad argument to system call"
msgstr "ವ್ಯವಸ್ಥೆಯ ಕೋಶಕ್ಕೆ ಸರಿಯಲ್ಲದ ಆರ್ಗ್ಯುಮೆಂಟ್"
#: ../sysdeps/osf1/siglist.c:39 ../sysdeps/sun4/siglist.c:39
#: ../sysdeps/osf1/siglist.c:39
#: ../sysdeps/sun4/siglist.c:39
msgid "Broken pipe"
msgstr "ತುಂಡಾದ ಪೈಪ್"
#: ../sysdeps/osf1/siglist.c:40 ../sysdeps/sun4/siglist.c:40
#: ../sysdeps/osf1/siglist.c:40
#: ../sysdeps/sun4/siglist.c:40
msgid "Alarm clock"
msgstr "ಅಲಾರಮ್ ಗಡಿಯಾರ"
#: ../sysdeps/osf1/siglist.c:41 ../sysdeps/sun4/siglist.c:41
#: ../sysdeps/osf1/siglist.c:41
#: ../sysdeps/sun4/siglist.c:41
msgid "Termination"
msgstr "ಅಂತ್ಯಗೊಳಿಕೆ"
#: ../sysdeps/osf1/siglist.c:42 ../sysdeps/sun4/siglist.c:42
#: ../sysdeps/osf1/siglist.c:42
#: ../sysdeps/sun4/siglist.c:42
msgid "Urgent condition on socket"
msgstr "ಸಾಕೆಟ್‌ನಲ್ಲಿ ತುರ್ತು ಪರಿಸ್ಥಿತಿ"
#: ../sysdeps/osf1/siglist.c:43 ../sysdeps/sun4/siglist.c:43
#: ../sysdeps/osf1/siglist.c:43
#: ../sysdeps/sun4/siglist.c:43
msgid "Stop"
msgstr "ನಿಲ್ಲಿಸು"
#: ../sysdeps/osf1/siglist.c:44 ../sysdeps/sun4/siglist.c:44
#: ../sysdeps/osf1/siglist.c:44
#: ../sysdeps/sun4/siglist.c:44
msgid "Keyboard stop"
msgstr "ಕೀಲಿಮಣೆ ನಿಲುಗಡೆ"
#: ../sysdeps/osf1/siglist.c:45 ../sysdeps/sun4/siglist.c:45
#: ../sysdeps/osf1/siglist.c:45
#: ../sysdeps/sun4/siglist.c:45
msgid "Continue"
msgstr "ಮುಂದುವರೆ"
#: ../sysdeps/osf1/siglist.c:46 ../sysdeps/sun4/siglist.c:46
#: ../sysdeps/osf1/siglist.c:46
#: ../sysdeps/sun4/siglist.c:46
msgid "Child status has changed"
msgstr "ಚೈಲ್ಡಿನ ಸ್ಥಿತಿ ಬದಲಾಗಿದೆ"
#: ../sysdeps/osf1/siglist.c:47 ../sysdeps/sun4/siglist.c:47
#: ../sysdeps/osf1/siglist.c:47
#: ../sysdeps/sun4/siglist.c:47
msgid "Background read from tty"
msgstr "tty ಇಂದ ಓದಲಾದ ಹಿನ್ನಲೆ"
#: ../sysdeps/osf1/siglist.c:48 ../sysdeps/sun4/siglist.c:48
#: ../sysdeps/osf1/siglist.c:48
#: ../sysdeps/sun4/siglist.c:48
msgid "Background write to tty"
msgstr "tty ಗೆ ಹಿನ್ನಲೆ ಬರೆಯುವಿಕೆ"
#: ../sysdeps/osf1/siglist.c:49 ../sysdeps/sun4/siglist.c:49
#: ../sysdeps/osf1/siglist.c:49
#: ../sysdeps/sun4/siglist.c:49
msgid "I/O now possible"
msgstr "I/O ಈಗ ಸಾಧ್ಯವಿದೆ"
#: ../sysdeps/osf1/siglist.c:50 ../sysdeps/sun4/siglist.c:50
#: ../sysdeps/osf1/siglist.c:50
#: ../sysdeps/sun4/siglist.c:50
msgid "CPU limit exceeded"
msgstr "CPU ಮಿತಿಯನ್ನು ಮೀರಲಾಗಿದೆ"
#: ../sysdeps/osf1/siglist.c:51 ../sysdeps/sun4/siglist.c:51
#: ../sysdeps/osf1/siglist.c:51
#: ../sysdeps/sun4/siglist.c:51
msgid "File size limit exceeded"
msgstr "ಕಡತದ ಗಾತ್ರದ ಮಿತಿಯನ್ನು ಮೀರಲಾಗಿದೆ"
#: ../sysdeps/osf1/siglist.c:52 ../sysdeps/sun4/siglist.c:52
#: ../sysdeps/osf1/siglist.c:52
#: ../sysdeps/sun4/siglist.c:52
msgid "Virtual alarm clock"
msgstr "ವರ್ಚುವಲ್ ಅಲಾರಮ್ ಗಡಿಯಾರ"
#: ../sysdeps/osf1/siglist.c:53 ../sysdeps/sun4/siglist.c:53
#: ../sysdeps/osf1/siglist.c:53
#: ../sysdeps/sun4/siglist.c:53
msgid "Profiling alarm clock"
msgstr "ಪ್ರೊಫೈಲಿಂಗ್ ಅಲಾರಮ್ ಗಡಿಯಾರ"
#: ../sysdeps/osf1/siglist.c:54 ../sysdeps/sun4/siglist.c:54
#: ../sysdeps/osf1/siglist.c:54
#: ../sysdeps/sun4/siglist.c:54
msgid "Window size change"
msgstr "ವಿಂಡೋ ಗಾತ್ರದ ಬದಲಾವಣೆ"
#: ../sysdeps/osf1/siglist.c:55 ../sysdeps/sun4/siglist.c:55
#: ../sysdeps/osf1/siglist.c:55
#: ../sysdeps/sun4/siglist.c:55
msgid "Information request"
msgstr "ಮಾಹಿತಿಯ ಮನವಿ"
#: ../sysdeps/osf1/siglist.c:56 ../sysdeps/sun4/siglist.c:56
#: ../sysdeps/osf1/siglist.c:56
#: ../sysdeps/sun4/siglist.c:56
msgid "User defined signal 1"
msgstr "ಬಳಕೆದಾರ ಸೂಚಿತ ಸಂಕೇತ ೧"
#: ../sysdeps/osf1/siglist.c:57 ../sysdeps/sun4/siglist.c:57
#: ../sysdeps/osf1/siglist.c:57
#: ../sysdeps/sun4/siglist.c:57
msgid "User defined signal 2"
msgstr "ಬಳಕೆದಾರ ಸೂಚಿತ ಸಂಕೇತ ೨"

View File

@@ -8,70 +8,72 @@ msgstr ""
"Project-Id-Version: Tajik Gnome\n"
"Report-Msgid-Bugs-To: http://bugzilla.gnome.org/enter_bug.cgi?"
"product=libgtop&keywords=I18N+L10N&component=general\n"
"POT-Creation-Date: 2012-12-29 00:29+0000\n"
"PO-Revision-Date: 2013-01-21 15:11+0500\n"
"POT-Creation-Date: 2013-12-19 14:39+0000\n"
"PO-Revision-Date: 2013-12-20 13:36+0500\n"
"Last-Translator: Victor Ibragimov <victor.ibragimov@gmail.com>\n"
"Language-Team: \n"
"Language: Tajik\n"
"Language: tg\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"X-Generator: Poedit 1.5.4\n"
"Plural-Forms: nplurals=2; plural=1;\n"
"X-Generator: Poedit 1.6.3\n"
#: ../lib/read.c:51
#, c-format
msgid "read %d byte"
msgid_plural "read %d bytes"
msgstr[0] ""
msgstr[1] ""
msgstr[0] "%d байти хондашуда"
msgstr[1] "%d байти хондашуда"
#: ../lib/read_data.c:51
msgid "read data size"
msgstr ""
msgstr "андозаи иттилооти хондашуда"
#: ../lib/read_data.c:70
#, c-format
msgid "read %lu byte of data"
msgid_plural "read %lu bytes of data"
msgstr[0] ""
msgstr[1] ""
msgstr[0] "%lu байти иттилооти хондашуда"
msgstr[1] "%lu байти иттилооти хондашуда"
#: ../lib/write.c:51
#, c-format
msgid "wrote %d byte"
msgid_plural "wrote %d bytes"
msgstr[0] ""
msgstr[1] ""
msgstr[0] "%d байти сабтшуда"
msgstr[1] "%d байти сабтшуда"
#: ../src/daemon/gnuserv.c:455
msgid "Enable debugging"
msgstr ""
msgstr "Фаъол кардани ислоҳи хатоҳо"
#: ../src/daemon/gnuserv.c:457
msgid "Enable verbose output"
msgstr ""
msgstr "Фаъол кардани барориши ботафсил"
#: ../src/daemon/gnuserv.c:459
msgid "Don't fork into background"
msgstr ""
msgstr "Нагузаштан ба пасзамина"
#: ../src/daemon/gnuserv.c:461
msgid "Invoked from inetd"
msgstr ""
msgstr "Дархостшуда аз inetd"
#: ../src/daemon/gnuserv.c:495
#, c-format
msgid "Run '%s --help' to see a full list of available command line options.\n"
msgstr ""
"Барои намоиш додани рӯйхати ҳамаи фармонҳои имконпазир '%s --help'-ро иҷро "
"намоед.\n"
#: ../sysdeps/osf1/siglist.c:27 ../sysdeps/sun4/siglist.c:27
msgid "Hangup"
msgstr ""
msgstr "Боздоштан"
#: ../sysdeps/osf1/siglist.c:28 ../sysdeps/sun4/siglist.c:28
msgid "Interrupt"
msgstr ""
msgstr "Қатъ"
#: ../sysdeps/osf1/siglist.c:29 ../sysdeps/sun4/siglist.c:29
msgid "Quit"
@@ -79,11 +81,11 @@ msgstr "Баромад"
#: ../sysdeps/osf1/siglist.c:30 ../sysdeps/sun4/siglist.c:30
msgid "Illegal instruction"
msgstr ""
msgstr "Дастури нодуруст"
#: ../sysdeps/osf1/siglist.c:31 ../sysdeps/sun4/siglist.c:31
msgid "Trace trap"
msgstr ""
msgstr "Таҳлил"
#: ../sysdeps/osf1/siglist.c:32 ../sysdeps/sun4/siglist.c:32
msgid "Abort"
@@ -91,35 +93,35 @@ msgstr "Қатъ кардан"
#: ../sysdeps/osf1/siglist.c:33 ../sysdeps/sun4/siglist.c:33
msgid "EMT error"
msgstr ""
msgstr "Хатои EMT"
#: ../sysdeps/osf1/siglist.c:34 ../sysdeps/sun4/siglist.c:34
msgid "Floating-point exception"
msgstr ""
msgstr "Истиснои нуқтаи тағйирёбанда"
#: ../sysdeps/osf1/siglist.c:35 ../sysdeps/sun4/siglist.c:35
msgid "Kill"
msgstr ""
msgstr "Қатъ кардан"
#: ../sysdeps/osf1/siglist.c:36 ../sysdeps/sun4/siglist.c:36
msgid "Bus error"
msgstr ""
msgstr "Хатои гузаргоҳ"
#: ../sysdeps/osf1/siglist.c:37 ../sysdeps/sun4/siglist.c:37
msgid "Segmentation violation"
msgstr ""
msgstr "Вайронии қисматбандӣ"
#: ../sysdeps/osf1/siglist.c:38 ../sysdeps/sun4/siglist.c:38
msgid "Bad argument to system call"
msgstr ""
msgstr "Аргументи нокифоя барои дархости системавӣ"
#: ../sysdeps/osf1/siglist.c:39 ../sysdeps/sun4/siglist.c:39
msgid "Broken pipe"
msgstr ""
msgstr "Вуруди вайроншуда"
#: ../sysdeps/osf1/siglist.c:40 ../sysdeps/sun4/siglist.c:40
msgid "Alarm clock"
msgstr "Соати зангдор\t"
msgstr "Соати зангдор"
#: ../sysdeps/osf1/siglist.c:41 ../sysdeps/sun4/siglist.c:41
msgid "Termination"
@@ -127,7 +129,7 @@ msgstr "Анҷоми кор"
#: ../sysdeps/osf1/siglist.c:42 ../sysdeps/sun4/siglist.c:42
msgid "Urgent condition on socket"
msgstr ""
msgstr "Шарти таъҷилӣ дар бастагоҳ"
#: ../sysdeps/osf1/siglist.c:43 ../sysdeps/sun4/siglist.c:43
msgid "Stop"
@@ -135,7 +137,7 @@ msgstr "Истодан"
#: ../sysdeps/osf1/siglist.c:44 ../sysdeps/sun4/siglist.c:44
msgid "Keyboard stop"
msgstr ""
msgstr "Қатъи клавиатура"
#: ../sysdeps/osf1/siglist.c:45 ../sysdeps/sun4/siglist.c:45
msgid "Continue"
@@ -143,48 +145,48 @@ msgstr "Идома додан"
#: ../sysdeps/osf1/siglist.c:46 ../sysdeps/sun4/siglist.c:46
msgid "Child status has changed"
msgstr ""
msgstr "Вазъияти иловагӣ тағйир ёфт"
#: ../sysdeps/osf1/siglist.c:47 ../sysdeps/sun4/siglist.c:47
msgid "Background read from tty"
msgstr ""
msgstr "Пасзаминаи хониш аз tty"
#: ../sysdeps/osf1/siglist.c:48 ../sysdeps/sun4/siglist.c:48
msgid "Background write to tty"
msgstr ""
msgstr "Пасзаминаи сабт ба tty"
#: ../sysdeps/osf1/siglist.c:49 ../sysdeps/sun4/siglist.c:49
msgid "I/O now possible"
msgstr ""
msgstr "I/O ҳоло имконпазир аст"
#: ../sysdeps/osf1/siglist.c:50 ../sysdeps/sun4/siglist.c:50
msgid "CPU limit exceeded"
msgstr ""
msgstr "Аз ҳудуди CPU афзуд"
#: ../sysdeps/osf1/siglist.c:51 ../sysdeps/sun4/siglist.c:51
msgid "File size limit exceeded"
msgstr ""
msgstr "Аз ҳудуди андозаи файл афзуд"
#: ../sysdeps/osf1/siglist.c:52 ../sysdeps/sun4/siglist.c:52
msgid "Virtual alarm clock"
msgstr ""
msgstr "Соати зангдори виртуалӣ"
#: ../sysdeps/osf1/siglist.c:53 ../sysdeps/sun4/siglist.c:53
msgid "Profiling alarm clock"
msgstr ""
msgstr "Соати зангдори профил"
#: ../sysdeps/osf1/siglist.c:54 ../sysdeps/sun4/siglist.c:54
msgid "Window size change"
msgstr ""
msgstr "Тағйири андозаи равзана"
#: ../sysdeps/osf1/siglist.c:55 ../sysdeps/sun4/siglist.c:55
msgid "Information request"
msgstr ""
msgstr "Дархости иттилоот"
#: ../sysdeps/osf1/siglist.c:56 ../sysdeps/sun4/siglist.c:56
msgid "User defined signal 1"
msgstr ""
msgstr "Сигнали интихобшудаи 1"
#: ../sysdeps/osf1/siglist.c:57 ../sysdeps/sun4/siglist.c:57
msgid "User defined signal 2"
msgstr ""
msgstr "Сигнали интихобшудаи 2"

View File

@@ -12,8 +12,6 @@
## Martin <martin@home-of-linux.org>
##
LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@
INCLUDES = $(LIBGTOP_CFLAGS) @INCLUDES@ -D_BSD \
-DLIBGTOP_COMPILE_SYSTEM="\"`uname -s`\"" \
-DLIBGTOP_COMPILE_RELEASE="\"`uname -r`\"" \

View File

@@ -134,19 +134,19 @@ glibtop_get_proc_uid(glibtop_proc_uid *buf, pid_t pid)
}
/**
* SECTION:proctime
* @title: Process Time
* @short_description: Get process time information
* @stability: Stable
*/
/**
* glibtop_get_proc_time:
* @buf:
* @pid: Process id to get the user and tty information
* @buf: Returned process time information - see #glibtop_proc_time.
* @pid: Process id
*
* Please note that under Linux, #start_time value may be strange.
* Linux kernel defines <type>INITIAL_JIFFIES</type> which implies a time
* shift. Because <type>INITIAL_JIFFIES</type> is not user-space defined,
* we cannot use it to compute accurate @code{start_time}. On Linux2.6,
* <type>INITIAL_JIFFIES</type> is 300 so <type>start_time</type> is
* always 3s different from real start time of the given process. You
* may also get shift results if your system clock is not synchronised
* with your hardware clock. See <command>man hwclock</command>.
* Get process time information.
*/
void
glibtop_get_proc_time(glibtop_proc_time *buf, pid_t pid)
@@ -197,6 +197,26 @@ glibtop_get_proc_map(glibtop_proc_map *buf, pid_t pid)
}
/**
* SECTION:procargs
* @title: Process Arguments
* @short_description: Get process command line arguments
* @see_also: #libgtop-Process-List
* @stability: Stable
*/
/**
* glibtop_get_proc_args:
* @buf: Struct with @size of returned string.
* @pid: Process id
* @max_len: Maximum length of string to return (use zero to get all arguments).
*
* Get process command line arguments.
*
* Returns: @pid's command line arguments separated by null bytes; the length of
* this string is returned in the @buf size field. You are required to free
* the string when done.
*/
char *
glibtop_get_proc_args(glibtop_proc_args *buf, pid_t pid, unsigned max_len)
{
@@ -204,6 +224,18 @@ glibtop_get_proc_args(glibtop_proc_args *buf, pid_t pid, unsigned max_len)
}
/**
* glibtop_get_proc_argv
* @buf: Struct with @size of combined returned arguments.
* @pid: Process id
* @max_len: Maximum length of all arguments combined (use zero to get all arguments).
*
* Get process command line arguments.
*
* Returns: A NULL-terminated array of strings with all arguments of process pid
* (up to @max_len characters). Remember to <function>g_strfreev</function>
* the returned array to avoid a memory leak.
*/
char **
glibtop_get_proc_argv(glibtop_proc_args *buf, pid_t pid, unsigned max_len)
{
@@ -211,6 +243,23 @@ glibtop_get_proc_argv(glibtop_proc_args *buf, pid_t pid, unsigned max_len)
}
/**
* SECTION:proclist
* @title: Process List
* @short_description: List running processes
* @stability: Stable
*/
/**
* glibtop_get_proclist
* @buf: Extra return information, see #glibtop_proclist.
* @which: Criteria for processes in returned list. See the <type>GLIBTOP_KERN_PROC_*</type> and <type>GLIBTOP_EXCLUDE_*</type> constants.
* @arg: Extra arguments applied to @which. Only <type>GLIBTOP_KERN_PROC_*</type> constants take arguments, see each constant definition for particular @arg description.
*
* Returns: A list of running processes or <type>NULL</type> on error. The
* returned list is allocated using <function>g_malloc</function> and must be
* freed using <function>g_free</function> to avoid a memory leak.
*/
pid_t*
glibtop_get_proclist(glibtop_proclist *buf, gint64 which, gint64 arg)
{

View File

@@ -11,7 +11,7 @@ libgtop_sysdeps_2_0_la_SOURCES = nosuid.c siglist.c sysinfo.c shm_limits.c \
libgtop_sysdeps_2_0_la_LDFLAGS = $(LT_VERSION_INFO)
libgtop_sysdeps_suid_2_0_la_LIBADD = $(KVM_LIBS) $(EXTRA_SYSDEPS_LIBS)
libgtop_sysdeps_suid_2_0_la_LIBADD = $(KVM_LIBS)
libgtop_sysdeps_suid_2_0_la_SOURCES = suid_open.c close.c swap.c \
proclist.c procstate.c procuid.c \
proctime.c procmem.c procsignal.c \

View File

@@ -11,7 +11,7 @@
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/statvfs.h>
#if __FreeBSD_version >= 600000 || defined(__FreeBSD_kernel__)
#if 0
#include <libgeom.h>
#include <sys/resource.h>
#include <devstat.h>
@@ -32,7 +32,7 @@ _glibtop_get_fsusage_read_write (glibtop *server, glibtop_fsusage *buf, const ch
{
int result;
struct statfs sfs;
#if __FreeBSD_version >= 600000 || defined(__FreeBSD_kernel__)
#if 0
struct devstat *ds;
void *sc;
struct timespec ts;
@@ -49,7 +49,7 @@ _glibtop_get_fsusage_read_write (glibtop *server, glibtop_fsusage *buf, const ch
glibtop_warn_io_r (server, "statfs");
return;
}
#if __FreeBSD_version >= 600000 || defined(__FreeBSD_kernel__)
#if 0
ld[0] = 0;
ld[1] = 0;
result = geom_gettree (&gmp);

View File

@@ -43,10 +43,6 @@ glibtop_open_s (glibtop *server, const char *program_name,
server->real_ncpu = ncpus - 1;
server->ncpu = MIN(GLIBTOP_NCPU - 1, server->real_ncpu);
#if defined(__FreeBSD_kernel__)
server->os_version_code = __FreeBSD_kernel_version;
#else
server->os_version_code = __FreeBSD_version;
#endif
}

View File

@@ -38,10 +38,7 @@
#include <sys/vnode.h>
#undef _KVM_VNODE
#define _KERNEL
#include <sys/pipe.h>
#include <sys/conf.h>
#undef _KERNEL
#if (__FreeBSD_version >= 800038) || (__FreeBSD_kernel_version >= 800038)
#define _WANT_FILE
#include <sys/file.h>

View File

@@ -66,11 +66,12 @@ _glibtop_init_cpu_s (glibtop *server)
/* Provides information about cpu usage. */
#define FILENAME "/proc/stat"
#define STAT_BUFSIZ 81920
void
glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf)
{
char buffer [BUFSIZ], *p;
char buffer [STAT_BUFSIZ], *p;
int i;
memset (buf, 0, sizeof (glibtop_cpu));

View File

@@ -15,6 +15,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <mntent.h>
@@ -197,7 +198,7 @@ glibtop_get_fsusage_s(glibtop *server, glibtop_fsusage *buf, const char *path)
memset(buf, 0, sizeof(glibtop_fsusage));
if (statvfs(path, &fsd) < 0) {
glibtop_warn_r(server, "statvfs '%s' failed", path);
glibtop_warn_r(server, "statvfs '%s' failed: %s", path, strerror (errno));
return;
}

View File

@@ -61,13 +61,14 @@ static void set_linux_version(glibtop *server)
/* Opens pipe to gtop server. Returns 0 on success and -1 on error. */
#define FILENAME "/proc/stat"
#define STAT_BUFSIZ 81920
void
glibtop_open_s (glibtop *server, const char *program_name,
const unsigned long features,
const unsigned flags)
{
char buffer [BUFSIZ], *p = buffer;
char buffer [STAT_BUFSIZ], *p = buffer;
server->name = program_name;

View File

@@ -36,7 +36,7 @@ static glibtop_sysinfo sysinfo = { .flags = 0 };
static void
init_sysinfo (glibtop *server)
{
char buffer [16384];
char buffer [65536];
gchar ** processors;
if(G_LIKELY(sysinfo.flags)) return;
@@ -51,7 +51,8 @@ init_sysinfo (glibtop *server)
sysinfo.ncpu++) {
gchar **parts, **p;
if (g_strrstr (processors[sysinfo.ncpu], "processor" ) == NULL)
continue;
glibtop_entry * const cpuinfo = &sysinfo.cpuinfo[sysinfo.ncpu];
cpuinfo->labels = g_ptr_array_new ();

View File

@@ -1,21 +1,24 @@
# $OpenBSD: Makefile.am,v 1.2 2011/05/23 19:35:52 jasper Exp $
INCLUDES = @INCLUDES@
noinst_LTLIBRARIES = libgtop_sysdeps-2.0.la libgtop_sysdeps_suid-2.0.la
libgtop_sysdeps_2_0_la_SOURCES = nosuid.c siglist.c sysinfo.c
libgtop_sysdeps_2_0_la_SOURCES = nosuid.c siglist.c sysinfo.c \
cpu.c loadavg.c \
uptime.c netlist.c fsusage.c mem.c \
mountlist.c procopenfiles.c procwd.c \
procaffinity.c glibtop_private.c open.c
libgtop_sysdeps_2_0_la_LDFLAGS = $(LT_VERSION_INFO)
libgtop_sysdeps_suid_2_0_la_LIBADD = $(KVM_LIBS)
libgtop_sysdeps_suid_2_0_la_SOURCES = open.c close.c cpu.c mem.c swap.c \
uptime.c loadavg.c shm_limits.c msg_limits.c \
sem_limits.c proclist.c procstate.c procuid.c \
proctime.c procmem.c procsignal.c prockernel.c \
procsegment.c procargs.c procmap.c netlist.c \
netload.c ppp.c procopenfiles.c fsusage.c \
procwd.c procaffinity.c glibtop_private.c
libgtop_sysdeps_suid_2_0_la_SOURCES = suid_open.c close.c swap.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
# TODO should be made nosuid like FreeBSD
libgtop_sysdeps_suid_2_0_la_SOURCES += shm_limits.c msg_limits.c sem_limits.c
libgtop_sysdeps_suid_2_0_la_LDFLAGS = $(LT_VERSION_INFO)

View File

@@ -1,5 +1,3 @@
/* $OpenBSD: close.c,v 1.2 2011/05/23 19:35:53 jasper Exp $ */
/* Copyright (C) 1998 Joshua Sled
This file is part of LibGTop 1.0.

View File

@@ -1,5 +1,3 @@
/* $OpenBSD: cpu.c,v 1.7 2011/07/10 15:23:01 jasper Exp $ */
/* Copyright (C) 1998 Joshua Sled
This file is part of LibGTop 1.0.
@@ -44,7 +42,7 @@ static int mib2 [] = { CTL_KERN, KERN_CPTIME };
/* Init function. */
void
_glibtop_init_cpu_p (glibtop *server)
_glibtop_init_cpu_s (glibtop *server)
{
server->sysdeps.cpu = _glibtop_sysdeps_cpu;
}
@@ -52,7 +50,7 @@ _glibtop_init_cpu_p (glibtop *server)
/* Provides information about cpu usage. */
void
glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf)
glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf)
{
gulong cpts [CPUSTATES];

View File

@@ -1,15 +1,4 @@
/* $OpenBSD: fsusage.c,v 1.4 2011/05/31 19:25:31 jasper Exp $ */
#include <config.h>
/*
* statvfs is lacking various members which are present in statfs,
* like f_(a)syncreads and f_(a)syncwrites. So eventhough we have
* statvfs, undef it here untill those members are added.
*/
#undef HAVE_SYS_STATVFS_H
#undef STAT_STATVFS
#include <glibtop.h>
#include <glibtop/error.h>
#include <glibtop/fsusage.h>
@@ -20,44 +9,57 @@
#include <unistd.h>
#include <sys/param.h>
#if defined (HAVE_SYS_STATVFS_H)
#include <sys/statvfs.h>
#else
#include <sys/mount.h>
#endif
#include <sys/statvfs.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void
_glibtop_openbsd_get_fsusage_read_write(glibtop *server,
glibtop_fsusage *buf,
const char *path);
static const unsigned long _glibtop_sysdeps_fsusage =
(1L << GLIBTOP_FSUSAGE_BLOCKS) + (1L << GLIBTOP_FSUSAGE_BFREE)
+ (1L << GLIBTOP_FSUSAGE_BAVAIL) + (1L << GLIBTOP_FSUSAGE_FILES)
+ (1L << GLIBTOP_FSUSAGE_FFREE) + (1L << GLIBTOP_FSUSAGE_BLOCK_SIZE);
void
_glibtop_openbsd_get_fsusage_read_write(glibtop *server,
glibtop_fsusage *buf,
const char *path)
static void
_glibtop_get_fsusage_read_write (glibtop *server, glibtop_fsusage *buf, const char *path)
{
int result;
#if defined (STAT_STATVFS)
struct statvfs sfs;
#else
struct statfs sfs;
#endif
int result;
struct statfs sfs;
#if defined (STAT_STATVFS)
result = statvfs (path, &sfs);
#else
result = statfs (path, &sfs);
#endif
result = statfs (path, &sfs);
if (result == -1) {
return;
}
if (result == -1) {
glibtop_warn_io_r (server, "statfs");
return;
}
buf->read = sfs.f_syncreads + sfs.f_asyncreads;
buf->write = sfs.f_syncwrites + sfs.f_asyncwrites;
buf->flags |= (1 << GLIBTOP_FSUSAGE_READ) | (1 << GLIBTOP_FSUSAGE_WRITE);
buf->read = sfs.f_syncreads + sfs.f_asyncreads;
buf->write = sfs.f_syncwrites + sfs.f_asyncwrites;
buf->flags |= (1 << GLIBTOP_FSUSAGE_READ) | (1 << GLIBTOP_FSUSAGE_WRITE);
}
void
glibtop_get_fsusage_s(glibtop *server, glibtop_fsusage *buf, const char *path)
{
struct statvfs fsd;
glibtop_init_r (&server, 0, 0);
memset (buf, 0, sizeof (glibtop_fsusage));
if (statvfs (path, &fsd) < 0)
return;
buf->block_size = fsd.f_frsize;
buf->blocks = fsd.f_blocks;
buf->bfree = fsd.f_bfree;
buf->bavail = (fsd.f_bavail > fsd.f_bfree) ? 0 : fsd.f_bavail;
buf->files = fsd.f_files;
buf->ffree = fsd.f_ffree;
buf->flags = _glibtop_sysdeps_fsusage;
_glibtop_get_fsusage_read_write(server, buf, path);
}

View File

@@ -1,5 +1,3 @@
/* $OpenBSD: glibtop_machine.h,v 1.3 2011/05/23 19:35:53 jasper Exp $ */
/* Copyright (C) 1998-99 Martin Baulig
This file is part of LibGTop 1.0.

View File

@@ -1,5 +1,3 @@
/* $OpenBSD: glibtop_private.c,v 1.2 2011/05/23 19:35:53 jasper Exp $ */
#include <config.h>
#include <glibtop.h>
#include <glibtop/error.h>
@@ -12,32 +10,6 @@
#include <glib.h>
#include <errno.h>
char *
execute_lsof(pid_t pid) {
char *output = NULL;
char *lsof;
char *command;
int exit_status;
lsof = g_find_program_in_path("lsof");
if (lsof == NULL)
return NULL;
command = g_strdup_printf("%s -n -P -Fftn -p %d", lsof, pid);
g_free(lsof);
if (g_spawn_command_line_sync (command, &output, NULL, &exit_status, NULL)) {
if (exit_status != 0) {
g_warning("Could not execute \"%s\" (%i)\nMake sure lsof(8) is installed sgid kmem.",
command, exit_status);
output = NULL;
}
}
g_free(command);
return output;
}
/* Ported from linux/glibtop_private.c */
gboolean
safe_readlink(const char *path, char *buf, int bufsiz)

View File

@@ -1,5 +1,3 @@
/* $OpenBSD: glibtop_private.h,v 1.2 2011/05/23 19:35:53 jasper Exp $ */
/* Copyright (C) 2007 Joe Marcus Clarke
This file is part of LibGTop 2.0.
@@ -34,7 +32,6 @@
G_BEGIN_DECLS
char *execute_lsof(pid_t pid);
gboolean safe_readlink(const char *path, char *buf, int bufsiz);
G_END_DECLS

View File

@@ -1,5 +1,3 @@
/* $OpenBSD: glibtop_server.h,v 1.2 2011/05/23 19:35:53 jasper Exp $ */
/* Copyright (C) 1998-99 Martin Baulig
This file is part of LibGTop 1.0.
@@ -26,11 +24,7 @@
G_BEGIN_DECLS
#define GLIBTOP_SUID_CPU (1 << GLIBTOP_SYSDEPS_CPU)
#define GLIBTOP_SUID_MEM (1 << GLIBTOP_SYSDEPS_MEM)
#define GLIBTOP_SUID_SWAP (1 << GLIBTOP_SYSDEPS_SWAP)
#define GLIBTOP_SUID_UPTIME (1 << GLIBTOP_SYSDEPS_UPTIME)
#define GLIBTOP_SUID_LOADAVG (1 << GLIBTOP_SYSDEPS_LOADAVG)
#define GLIBTOP_SUID_SHM_LIMITS (1 << GLIBTOP_SYSDEPS_SHM_LIMITS)
#define GLIBTOP_SUID_MSG_LIMITS (1 << GLIBTOP_SYSDEPS_MSG_LIMITS)
#define GLIBTOP_SUID_SEM_LIMITS (1 << GLIBTOP_SYSDEPS_SEM_LIMITS)
@@ -45,8 +39,12 @@ G_BEGIN_DECLS
#define GLIBTOP_SUID_PROC_ARGS (1 << GLIBTOP_SYSDEPS_PROC_ARGS)
#define GLIBTOP_SUID_PROC_MAP (1 << GLIBTOP_SYSDEPS_PROC_MAP)
#define GLIBTOP_SUID_NETLOAD (1 << GLIBTOP_SYSDEPS_NETLOAD)
#define GLIBTOP_SUID_NETLIST 0
#define GLIBTOP_SUID_PPP (1 << GLIBTOP_SYSDEPS_PPP)
#define GLIBTOP_SUID_CPU 0
#define GLIBTOP_SUID_MEM 0
#define GLIBTOP_SUID_UPTIME 0
#define GLIBTOP_SUID_LOADAVG 0
#define GLIBTOP_SUID_NETLIST 0
#define GLIBTOP_SUID_PROC_WD 0
#define GLIBTOP_SUID_PROC_AFFINITY 0

View File

@@ -1,5 +1,3 @@
/* $OpenBSD: glibtop_suid.h,v 1.2 2011/05/23 19:35:53 jasper Exp $ */
/* Copyright (C) 1998-99 Martin Baulig
This file is part of LibGTop 1.0.

View File

@@ -1,5 +1,3 @@
/* $OpenBSD: loadavg.c,v 1.2 2011/05/23 19:35:53 jasper Exp $ */
/* Copyright (C) 1998 Joshua Sled
This file is part of LibGTop 1.0.
@@ -34,7 +32,7 @@ static const unsigned long _glibtop_sysdeps_loadavg =
/* Init function. */
void
_glibtop_init_loadavg_p (glibtop *server)
_glibtop_init_loadavg_s (glibtop *server)
{
server->sysdeps.loadavg = _glibtop_sysdeps_loadavg;
}
@@ -42,7 +40,7 @@ _glibtop_init_loadavg_p (glibtop *server)
/* Provides load averange. */
void
glibtop_get_loadavg_p (glibtop *server, glibtop_loadavg *buf)
glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf)
{
double ldavg[3];
int i;

View File

@@ -1,5 +1,3 @@
/* $OpenBSD: mem.c,v 1.11 2011/07/10 15:23:01 jasper Exp $ */
/* Copyright (C) 1998 Joshua Sled
This file is part of LibGTop 1.0.
@@ -30,9 +28,7 @@
#include <sys/mount.h>
#include <sys/sysctl.h>
#include <sys/vmmeter.h>
#include <uvm/uvm_extern.h>
#include <uvm/uvm_param.h>
static const unsigned long _glibtop_sysdeps_mem =
(1L << GLIBTOP_MEM_TOTAL) + (1L << GLIBTOP_MEM_USED) +
@@ -50,29 +46,17 @@ static int pageshift; /* log base 2 of the pagesize */
/* define pagetok in terms of pageshift */
#define pagetok(size) ((size) << pageshift)
/* nlist structure for kernel access */
static struct nlist nlst [] = {
{ "_bufpages" },
{ 0 }
};
/* MIB array for sysctl */
static int vmmeter_mib [] = { CTL_VM, VM_METER };
static int uvmexp_mib [] = { CTL_VM, VM_UVMEXP };
static int bcstats_mib [] = { CTL_VFS, VFS_GENERIC, VFS_BCACHESTAT };
/* Init function. */
void
_glibtop_init_mem_p (glibtop *server)
_glibtop_init_mem_s (glibtop *server)
{
register int pagesize;
if (kvm_nlist (server->machine.kd, nlst) < 0) {
glibtop_warn_io_r (server, "kvm_nlist (mem)");
return;
}
/* get the page size and calculate pageshift from it */
pagesize = sysconf(_SC_PAGESIZE);
pageshift = 0;
@@ -88,14 +72,10 @@ _glibtop_init_mem_p (glibtop *server)
}
void
glibtop_get_mem_p (glibtop *server, glibtop_mem *buf)
glibtop_get_mem_s (glibtop *server, glibtop_mem *buf)
{
struct vmtotal vmt;
struct uvmexp uvmexp;
struct bcachestats bcstats;
u_int v_used_count;
u_int v_total_count;
u_int v_free_count;
size_t length;
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_MEM), 0);
@@ -106,13 +86,6 @@ glibtop_get_mem_p (glibtop *server, glibtop_mem *buf)
return;
/* Get the data from sysctl */
length = sizeof (vmt);
if (sysctl (vmmeter_mib, 2, &vmt, &length, NULL, 0)) {
glibtop_warn_io_r (server, "sysctl (vm.vmmeter)");
bzero(&vmt, sizeof(length));
return;
}
length = sizeof (uvmexp);
if (sysctl (uvmexp_mib, 2, &uvmexp, &length, NULL, 0)) {
glibtop_warn_io_r (server, "sysctl (vm.uvmexp)");
@@ -127,21 +100,12 @@ glibtop_get_mem_p (glibtop *server, glibtop_mem *buf)
return;
}
/*
* t_arm = active real memory
* t_rm = total real memory in use
* t_free = free memory pages
*/
v_total_count = vmt.t_rm + vmt.t_free;
v_used_count = vmt.t_rm;
v_free_count = vmt.t_free;
/* convert memory stats to Kbytes */
buf->total = (guint64) pagetok (v_total_count) << LOG1024;
buf->used = (guint64) pagetok (v_used_count) << LOG1024;
buf->free = (guint64) pagetok (v_free_count) << LOG1024;
buf->total = (guint64) pagetok (uvmexp.npages) << LOG1024;
buf->used = (guint64) pagetok (uvmexp.npages - uvmexp.free) << LOG1024;
buf->free = (guint64) pagetok (uvmexp.free) << LOG1024;
buf->locked = (guint64) pagetok (uvmexp.wired) << LOG1024;
buf->shared = (guint64) pagetok (vmt.t_rmshr) << LOG1024;
buf->shared = (guint64) pagetok (0 /* XXX */) << LOG1024;
buf->cached = (guint64) pagetok (bcstats.numbufpages) << LOG1024;
buf->buffer = 0;

168
sysdeps/openbsd/mountlist.c Normal file
View File

@@ -0,0 +1,168 @@
/* mountlist.c -- return a list of mounted filesystems
Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <config.h>
#include <glib.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/mount.h>
#include <string.h>
#include <glibtop.h>
#include <glibtop/mountlist.h>
/* A mount table entry. */
struct mount_entry
{
char *me_devname; /* Device node pathname, including "/dev/". */
char *me_mountdir; /* Mount point directory pathname. */
char *me_type; /* "nfs", "4.2", etc. */
dev_t me_dev; /* Device number of me_mountdir. */
struct mount_entry *me_next;
};
static struct mount_entry *read_filesystem_list (void);
/* Return a list of the currently mounted filesystems, or NULL on error.
Add each entry to the tail of the list so that they stay in order.
*/
static struct mount_entry *
read_filesystem_list (void)
{
struct mount_entry *mount_list;
struct mount_entry *me;
struct mount_entry *mtail;
/* Start the list off with a dummy entry. */
me = g_new (struct mount_entry, 1);
me->me_next = NULL;
mount_list = mtail = me;
{
struct statfs *fsp;
int entries;
entries = getmntinfo (&fsp, MNT_NOWAIT);
if (entries < 0)
return NULL;
while (entries-- > 0)
{
me = (struct mount_entry *) g_malloc (sizeof (struct mount_entry));
me->me_devname = g_strdup (fsp->f_mntfromname);
me->me_mountdir = g_strdup (fsp->f_mntonname);
me->me_type = g_strdup (fsp->f_fstypename);
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
me->me_next = NULL;
/* Add to the linked list. */
mtail->me_next = me;
mtail = me;
fsp++;
}
}
/* Free the dummy head. */
me = mount_list;
mount_list = mount_list->me_next;
g_free (me);
return mount_list;
}
static gboolean ignore_mount_entry(const struct mount_entry *me)
{
/* keep sorted */
static const char ignored[][17] = {
"autofs",
"devfs",
"fusectl",
"linprocfs",
"linsysfs",
"mfs",
"none",
"nfs",
"nullfs",
"nwfs",
"portalfs",
"proc",
"procfs",
"smbfs",
"tmpfs",
"unionfs",
"unknown"
};
typedef int (*Comparator)(const void*, const void*);
return bsearch(me->me_type,
ignored, G_N_ELEMENTS(ignored), sizeof ignored[0],
(Comparator) strcmp) != NULL;
}
glibtop_mountentry *
glibtop_get_mountlist_s (glibtop *server, glibtop_mountlist *buf, int all_fs)
{
struct mount_entry *entries, *cur, *next;
GArray *mount_array = g_array_new(FALSE, FALSE,
sizeof(glibtop_mountentry));
glibtop_init_r (&server, 0, 0);
memset (buf, 0, sizeof (glibtop_mountlist));
/* Read filesystem list. */
if((entries = read_filesystem_list ()) == NULL)
return NULL;
for (cur = &entries[0]; cur != NULL; cur = next) {
if(all_fs || !ignore_mount_entry(cur)) {
/* add a new glibtop_mountentry */
glibtop_mountentry e;
g_strlcpy(e.devname, cur->me_devname, sizeof e.devname);
g_strlcpy(e.mountdir, cur->me_mountdir, sizeof e.mountdir);
g_strlcpy(e.type, cur->me_type, sizeof e.type);
e.dev = cur->me_dev;
g_array_append_val(mount_array, e);
}
/* free current mount_entry and move to the next */
next = cur->me_next;
g_free(cur->me_devname);
g_free(cur->me_mountdir);
g_free(cur->me_type);
g_free(cur);
}
buf->size = sizeof (glibtop_mountentry);
buf->number = mount_array->len;
buf->total = buf->number * buf->size;
buf->flags = (1 << GLIBTOP_MOUNTLIST_SIZE)
| (1 << GLIBTOP_MOUNTLIST_NUMBER)
| (1 << GLIBTOP_MOUNTLIST_TOTAL);
return (glibtop_mountentry*) g_array_free(mount_array, FALSE);
}

View File

@@ -1,5 +1,3 @@
/* $OpenBSD: msg_limits.c,v 1.3 2011/05/23 19:35:54 jasper Exp $ */
/* Copyright (C) 1998-99 Martin Baulig
This file is part of LibGTop 1.0.

View File

@@ -1,5 +1,3 @@
/* $OpenBSD: netlist.c,v 1.2 2011/05/23 19:35:54 jasper Exp $ */
/*
This file is part of LibGTop 2.0.

View File

@@ -1,5 +1,3 @@
/* $OpenBSD: netload.c,v 1.4 2011/06/20 09:50:04 jasper Exp $ */
/* Copyright (C) 1998-99 Martin Baulig
This file is part of LibGTop 1.0.
@@ -36,12 +34,13 @@
#include <sys/ioctl.h>
#ifdef HAVE_NET_IF_VAR_H
#include <net/if_var.h>
#endif
#include <netinet/in.h>
#define _KERNEL
#include <netinet/in_var.h>
#undef _KERNEL
#include <netinet6/in6_var.h>
static const unsigned long _glibtop_sysdeps_netload =
(1L << GLIBTOP_NETLOAD_IF_FLAGS) +

View File

@@ -1,5 +1,3 @@
/* $OpenBSD: nosuid.c,v 1.2 2011/05/23 19:35:54 jasper Exp $ */
/* Copyright (C) 1998-99 Martin Baulig
This file is part of LibGTop 1.0.
@@ -23,16 +21,8 @@
#include <config.h>
#include <glibtop.h>
#include <glibtop/open.h>
#include <glibtop/close.h>
void
glibtop_open_s (glibtop *server,
const char *program_name,
const unsigned long features,
const unsigned flags)
{ }
void
glibtop_close_s (glibtop *server)
{ }

View File

@@ -1,5 +1,3 @@
/* $OpenBSD: open.c,v 1.4 2011/05/23 19:35:54 jasper Exp $ */
/* Copyright (C) 1998 Joshua Sled
This file is part of LibGTop 1.0.
@@ -22,74 +20,17 @@
*/
#include <config.h>
#include <sys/types.h>
#include <glibtop.h>
#include <glibtop/error.h>
#include <glibtop/open.h>
#include <glibtop/init_hooks.h>
/* !!! THIS FUNCTION RUNS SUID ROOT - CHANGE WITH CAUTION !!! */
#include <glibtop_private.h>
void
glibtop_init_p (glibtop *server, const unsigned long features,
const unsigned flags)
{
const _glibtop_init_func_t *init_fkt;
if (server == NULL)
glibtop_error_r (NULL, "glibtop_init_p (server == NULL)");
/* Do the initialization, but only if not already initialized. */
if ((server->flags & _GLIBTOP_INIT_STATE_SYSDEPS) == 0) {
glibtop_open_p (server, "glibtop", features, flags);
for (init_fkt = _glibtop_init_hook_p; *init_fkt; init_fkt++)
(*init_fkt) (server);
server->flags |= _GLIBTOP_INIT_STATE_SYSDEPS;
}
}
void
glibtop_open_p (glibtop *server, const char *program_name,
glibtop_open_s (glibtop *server, const char *program_name,
const unsigned long features,
const unsigned flags)
{
#ifdef DEBUG
fprintf (stderr, "DEBUG (%d): glibtop_open_p ()\n", getpid ());
#endif
/* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */
server->machine.uid = getuid ();
server->machine.euid = geteuid ();
server->machine.gid = getgid ();
server->machine.egid = getegid ();
server->os_version_code = OpenBSD;
/* Setup machine-specific data */
server->machine.kd = kvm_open (NULL, NULL, NULL, O_RDONLY, "kvm_open");
if (server->machine.kd == NULL)
glibtop_error_io_r (server, "kvm_open");
/* Drop priviledges. */
if (setreuid (server->machine.euid, server->machine.uid))
_exit (1);
if (setregid (server->machine.egid, server->machine.gid))
_exit (1);
/* !!! END OF SUID ROOT PART !!! */
/* Our effective uid is now those of the user invoking the server,
* so we do no longer have any priviledges. */
/* NOTE: On FreeBSD, we do not need to be suid root, we just need to
* be sgid kmem.
*
* The server will only use setegid() to get back it's priviledges,
* so it will fail if it is suid root and not sgid kmem. */
}

View File

@@ -1,5 +1,3 @@
/* $OpenBSD: ppp.c,v 1.3 2011/05/23 19:35:54 jasper Exp $ */
/* Copyright (C) 1998-99 Martin Baulig
This file is part of LibGTop 1.0.

View File

@@ -1,6 +1,5 @@
/*
* $OpenBSD: procaffinity.c,v 1.1 2009/10/16 10:56:04 jasper Exp $
* procaffinity stub.
* TODO (procaffinity stub)
*/
#include <config.h>

View File

@@ -1,5 +1,3 @@
/* $OpenBSD: procargs.c,v 1.3 2011/05/23 19:35:54 jasper Exp $ */
/* Copyright (C) 1998 Joshua Sled
This file is part of LibGTop 1.0.
@@ -69,7 +67,7 @@ glibtop_get_proc_args_p (glibtop *server, glibtop_proc_args *buf,
/* Get the process data */
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid,
sizeof (*pinfo), &count);
if ((pinfo == NULL) || (count < 1)) {
if (pinfo == NULL) {
glibtop_suid_leave (server);
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
return NULL;

View File

@@ -1,5 +1,3 @@
/* $OpenBSD: prockernel.c,v 1.4 2011/05/31 14:02:26 jasper Exp $ */
/* Copyright (C) 1998 Joshua Sled
This file is part of LibGTop 1.0.
@@ -36,12 +34,13 @@
#include <fcntl.h>
static const unsigned long _glibtop_sysdeps_proc_kernel_pstats =
(1L << GLIBTOP_PROC_KERNEL_K_FLAGS) +
(1L << GLIBTOP_PROC_KERNEL_MIN_FLT) +
(1L << GLIBTOP_PROC_KERNEL_MAJ_FLT);
static const unsigned long _glibtop_sysdeps_proc_kernel_wchan =
(1L << GLIBTOP_PROC_KERNEL_NWCHAN) +
(1L << GLIBTOP_PROC_KERNEL_WCHAN);
(1L << GLIBTOP_PROC_KERNEL_WCHAN) +
(1L << GLIBTOP_PROC_KERNEL_NWCHAN);
/* Init function. */
@@ -70,20 +69,39 @@ glibtop_get_proc_kernel_p (glibtop *server,
/* It does not work for the swapper task. */
if (pid == 0) return;
glibtop_suid_enter (server);
/* Get the process information */
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid,
sizeof(*pinfo), &count);
if ((pinfo == NULL) || (count != 1)) {
if (pinfo == NULL) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
glibtop_suid_leave (server);
return;
}
if (pinfo->p_wmesg[0])
g_strlcpy(buf->wchan, pinfo->p_wmesg[0], sizeof(buf->wchan));
buf->min_flt = pinfo[0].p_uru_minflt;
buf->maj_flt = pinfo[0].p_uru_majflt;
glibtop_suid_leave (server);
buf->flags |= (_glibtop_sysdeps_proc_kernel_wchan
| _glibtop_sysdeps_proc_kernel_pstats);
#define PROC_WCHAN p_wchan
#define PROC_WMESG p_wmesg
buf->nwchan = (unsigned long) pinfo [0].PROC_WCHAN;
buf->flags |= (1L << GLIBTOP_PROC_KERNEL_NWCHAN);
if (pinfo [0].PROC_WCHAN && pinfo [0].PROC_WMESG[0] != 0) {
g_strlcpy (buf->wchan, pinfo [0].PROC_WMESG,
sizeof buf->wchan);
buf->flags |= (1L << GLIBTOP_PROC_KERNEL_WCHAN);
} else {
buf->wchan [0] = 0;
}
buf->k_flags = (unsigned long) pinfo [0].p_flag;
buf->min_flt = (unsigned long) pinfo [0].p_uru_minflt;
buf->maj_flt = (unsigned long) pinfo [0].p_uru_majflt;
buf->flags |= _glibtop_sysdeps_proc_kernel_pstats;
return;
}

View File

@@ -1,5 +1,3 @@
/* $OpenBSD: proclist.c,v 1.3 2011/05/23 19:35:55 jasper Exp $ */
/* Copyright (C) 1998 Joshua Sled
This file is part of LibGTop 1.0.

View File

@@ -1,5 +1,3 @@
/* $OpenBSD: patch-sysdeps_openbsd_procmap_c,v 1.7 2012/03/11 08:45:24 ajacoutot Exp $ */
/* Copyright (C) 1998 Joshua Sled
This file is part of LibGTop 1.0.
@@ -184,7 +182,7 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
/* Get the process data */
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, sizeof(struct kinfo_proc), &count);
if ((pinfo == NULL) || (count < 1)) {
if (pinfo == NULL) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
return (glibtop_map_entry*) g_array_free(maps, TRUE);
}
@@ -193,8 +191,11 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
if (kvm_read (server->machine.kd,
(unsigned long) pinfo [0].p_vmspace,
(char *) &vmspace, sizeof (vmspace)) != sizeof (vmspace))
glibtop_error_io_r (server, "kvm_read (vmspace)");
(char *) &vmspace, sizeof (vmspace)) != sizeof (vmspace)) {
glibtop_warn_io_r (server, "kvm_read (vmspace)");
glibtop_suid_leave (server);
return NULL;
}
RB_INIT(&root);
nentries = load_vmmap_entries(server,
@@ -238,6 +239,7 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
&vnode, sizeof (vnode)) != sizeof (vnode)) {
glibtop_warn_io_r (server, "kvm_read (vnode)");
unload_vmmap_entries(RB_ROOT(&root));
glibtop_suid_leave (server);
return (glibtop_map_entry*) g_array_free(maps, TRUE);
}
@@ -250,8 +252,12 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
if (kvm_read (server->machine.kd,
(unsigned long) vnode.v_data,
&inode, sizeof (inode)) != sizeof (inode))
glibtop_error_io_r (server, "kvm_read (inode)");
&inode, sizeof (inode)) != sizeof (inode)) {
glibtop_warn_io_r (server, "kvm_read (inode)");
unload_vmmap_entries(RB_ROOT(&root));
glibtop_suid_leave (server);
return (glibtop_map_entry*) g_array_free(maps, TRUE);
}
inum = inode.i_number;
dev = inode.i_dev;
@@ -278,6 +284,8 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
mentry->perm |= GLIBTOP_MAP_PERM_EXECUTE;
}
glibtop_suid_leave (server);
buf->flags = _glibtop_sysdeps_proc_map;
buf->number = maps->len;

View File

@@ -1,5 +1,3 @@
/* $OpenBSD: procmem.c,v 1.4 2011/05/24 10:40:47 jasper Exp $ */
/* Copyright (C) 1998 Joshua Sled
This file is part of LibGTop 1.0.

View File

@@ -1,8 +1,7 @@
/* $OpenBSD: procopenfiles.c,v 1.2 2011/05/23 19:35:55 jasper Exp $ */
/* Copyright (C) 1998-99 Martin Baulig
Copyright (C) 2004 Nicol\ufffds Lichtmaier
Copyright (C) 2007 Joe Marcus Clarke
Copyright (C) 2013 Robert Nagy
This file is part of LibGTop 1.0.
Modified by Nicol\ufffds Lichtmaier to give a process open files.
@@ -33,7 +32,12 @@
#include <sys/socket.h>
#include <sys/param.h>
#include <sys/sysctl.h>
#define _KERNEL
#include <sys/file.h>
#undef _KERNEL
#include <sys/mount.h>
#include <sys/un.h>
#include <sys/vnode.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
@@ -46,6 +50,20 @@ static const unsigned long _glibtop_sysdeps_proc_open_files =
(1L << GLIBTOP_PROC_OPEN_FILES_TOTAL)|
(1L << GLIBTOP_PROC_OPEN_FILES_SIZE);
kvm_t *kd;
struct filearg {
SLIST_ENTRY(filearg) next;
dev_t dev;
ino_t ino;
char *name;
TAILQ_HEAD(fuserhead, fuser) fusers;
};
SLIST_HEAD(fileargs, filearg);
struct fileargs fileargs = SLIST_HEAD_INITIALIZER(fileargs);
/* Init function. */
void
@@ -54,167 +72,121 @@ _glibtop_init_proc_open_files_s (glibtop *server)
server->sysdeps.proc_open_files = _glibtop_sysdeps_proc_open_files;
}
static GArray *
parse_output(const char *output) {
GArray *entries;
char **lines;
char *ftype = NULL;
char *fname = NULL;
guint i;
guint len;
int fd = -1;
static char *
addr_to_string(struct kinfo_file *kf)
{
char *buffer = NULL;
struct in_addr faddr;
entries = g_array_new(FALSE, FALSE, sizeof(glibtop_open_files_entry));
memcpy(&faddr, kf->inp_faddru, sizeof(faddr));
lines = g_strsplit(output, "\n", 0);
len = g_strv_length(lines);
for (i = 0; i < len && lines[i]; i++) {
glibtop_open_files_entry entry = {0};
if (strlen(lines[i]) < 2)
continue;
if (!g_str_has_prefix(lines[i], "f") &&
!g_str_has_prefix(lines[i], "t") &&
!g_str_has_prefix(lines[i], "n"))
continue;
if (g_str_has_prefix(lines[i], "f")) {
if (!g_ascii_isdigit(*(lines[i] + 1)))
i += 2;
else
fd = atoi(lines[i] + 1);
continue;
if ((kf->so_protocol == IPPROTO_TCP) ||
(kf->so_protocol == IPPROTO_UDP)) {
if (kf->inp_fport) {
buffer = g_strdup(faddr.s_addr == INADDR_ANY ? "*" :
inet_ntoa(faddr));
}
if (g_str_has_prefix(lines[i], "t")) {
ftype = lines[i];
ftype++;
continue;
} else {
fname = lines[i];
fname++;
}
if (ftype == NULL || fname == NULL)
continue;
if (!strcmp(ftype, "unix")) {
entry.type = GLIBTOP_FILE_TYPE_LOCALSOCKET;
g_strlcpy(entry.info.localsock.name, fname,
sizeof(entry.info.localsock.name));
} else if (!strcmp(ftype, "PIPE")) {
entry.type = GLIBTOP_FILE_TYPE_PIPE;
} else if (!strcmp(ftype, "VREG") ||
!strcmp(ftype, "GDIR") ||
!strcmp(ftype, "GREG") ||
!strcmp(ftype, "VCHR") ||
!strcmp(ftype, "VBLK") ||
!strcmp(ftype, "DIR") ||
!strcmp(ftype, "LINK") ||
!strcmp(ftype, "REG") ||
!strcmp(ftype, "VDIR")) {
entry.type = GLIBTOP_FILE_TYPE_FILE;
g_strlcpy(entry.info.file.name, fname,
sizeof(entry.info.file.name));
} else if (!strcmp(ftype, "IPv4")) {
char **hosts;
char **remote_host;
if (!strstr(fname, "->")) {
remote_host = g_strsplit(fname, ":", 0);
} else {
hosts = g_strsplit(fname, "->", 0);
if (g_strv_length(hosts) < 2) {
g_strfreev(hosts);
continue;
}
remote_host = g_strsplit(hosts[1], ":", 0);
g_strfreev(hosts);
}
if (g_strv_length(remote_host) < 2) {
g_strfreev(remote_host);
continue;
}
entry.type = GLIBTOP_FILE_TYPE_INETSOCKET;
if (!strcmp(remote_host[0], "*"))
g_strlcpy(entry.info.sock.dest_host, "0.0.0.0",
sizeof(entry.info.sock.dest_host));
else
g_strlcpy(entry.info.sock.dest_host,
remote_host[0],
sizeof(entry.info.sock.dest_host));
entry.info.sock.dest_port = atoi(remote_host[1]);
g_strfreev(remote_host);
} else if (!strcmp(ftype, "IPv6")) {
char **hosts;
char **remote_host;
if (!strstr(fname, "->")) {
remote_host = g_strsplit(fname, ":", 0);
} else {
hosts = g_strsplit(fname, "->", 0);
if (g_strv_length(hosts) < 2) {
g_strfreev(hosts);
continue;
}
remote_host = g_strsplit(hosts[1], "]", 0);
g_strfreev(hosts);
}
if (g_strv_length(remote_host) < 2) {
g_strfreev(remote_host);
continue;
}
entry.type = GLIBTOP_FILE_TYPE_INET6SOCKET;
if (!strcmp(remote_host[0], "*"))
g_strlcpy(entry.info.sock.dest_host, "0.0.0.0",
sizeof(entry.info.sock.dest_host));
else
g_strlcpy(entry.info.sock.dest_host,
remote_host[0] + 1,
sizeof(entry.info.sock.dest_host));
entry.info.sock.dest_port = atoi(remote_host[1] + 1);
g_strfreev(remote_host);
} else
continue;
entry.fd = fd;
fd = -1;
ftype = NULL;
fname = NULL;
g_array_append_val(entries, entry);
}
g_strfreev(lines);
return entries;
return buffer;
}
glibtop_open_files_entry *
glibtop_get_proc_open_files_s (glibtop *server, glibtop_proc_open_files *buf, pid_t pid)
{
char *output;
struct kinfo_file *kf, *kflast;
int cnt;
char kbuf[_POSIX2_LINE_MAX];
GArray *entries;
memset(buf, 0, sizeof (glibtop_proc_open_files));
output = execute_lsof(pid);
if (output == NULL) return NULL;
if ((kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, kbuf)) == NULL)
g_warning("%s", kbuf);
entries = parse_output(output);
if ((kf = kvm_getfiles(kd, KERN_FILE_BYPID, pid, sizeof(*kf), &cnt)) == NULL)
g_warning("%s", kvm_geterr(kd));
g_free(output);
entries = g_array_new(FALSE, FALSE, sizeof(glibtop_open_files_entry));
for (kflast = &kf[cnt]; kf < kflast; ++kf) {
glibtop_open_files_entry entry = {0};
if (kf->fd_fd < 0)
continue;
if (kf->f_type == DTYPE_SOCKET) {
if (kf->so_family == AF_LOCAL) {
entry.type = GLIBTOP_FILE_TYPE_LOCALSOCKET;
static char *stypename[] = {
"unused", /* 0 */
"stream",
"dgram",
"raw",
"rdm",
"seqpak"
};
#define STYPEMAX 5
char *stype, stypebuf[24];
if (kf->so_type > STYPEMAX) {
snprintf(stypebuf, sizeof(stypebuf), "?%d", kf->so_type);
stype = stypebuf;
} else {
stype = stypename[kf->so_type];
}
g_strlcpy(entry.info.localsock.name, stype,
sizeof(entry.info.localsock.name));
} else if (kf->so_family == AF_INET ||
kf->so_family == AF_INET6) {
char *addrstr;
if (kf->so_family == AF_INET)
entry.type = GLIBTOP_FILE_TYPE_INETSOCKET;
else
entry.type = GLIBTOP_FILE_TYPE_INET6SOCKET;
addrstr = addr_to_string(kf);
g_strlcpy(entry.info.sock.dest_host,
addrstr,
sizeof(entry.info.sock.dest_host));
g_free(addrstr);
entry.info.sock.dest_port = kf->inp_fport ? ntohs(kf->inp_fport) : 0;
}
} else if (kf->f_type == DTYPE_PIPE) {
entry.type = GLIBTOP_FILE_TYPE_PIPE;
} else if (kf->f_type == DTYPE_VNODE) {
int badtype = 0;
char nbuf[MAXPATHLEN];
entry.type = GLIBTOP_FILE_TYPE_FILE;
if ((kf->v_type == VNON) ||
(kf->v_type == VBAD) ||
(kf->v_tag == VT_NON && !(kf->v_flag & VCLONE))) {
badtype = 1;
}
if (badtype)
continue;
if ((kf->v_type == VBLK) ||
(kf->v_type == VCHR)) {
snprintf(nbuf, sizeof(nbuf), "/dev/%s",
devname(kf->va_rdev, kf->v_type == VCHR ? S_IFCHR : S_IFBLK));
} else {
snprintf(nbuf, sizeof(nbuf), "inode %llu on %s", kf->va_fileid,
kf->f_mntonname);
}
g_strlcpy(entry.info.file.name, nbuf,
sizeof(entry.info.file.name));
} else
continue;
entry.fd = kf->fd_fd;
g_array_append_val(entries, entry);
}
buf->flags = _glibtop_sysdeps_proc_open_files;
buf->number = entries->len;

View File

@@ -1,5 +1,3 @@
/* $OpenBSD: procsegment.c,v 1.2 2011/05/23 19:35:55 jasper Exp $ */
/* Copyright (C) 1998 Joshua Sled
This file is part of LibGTop 1.0.
@@ -32,13 +30,18 @@
#include <sys/param.h>
#include <sys/sysctl.h>
static const unsigned long _glibtop_sysdeps_proc_segment = 0;
static const unsigned long _glibtop_sysdeps_proc_segment =
(1L << GLIBTOP_PROC_SEGMENT_TEXT_RSS) +
(1L << GLIBTOP_PROC_SEGMENT_DATA_RSS);
static int pagesize;
/* Init function. */
void
_glibtop_init_proc_segment_p (glibtop *server)
{
pagesize = getpagesize ();
server->sysdeps.proc_segment = _glibtop_sysdeps_proc_segment;
}
@@ -49,35 +52,26 @@ glibtop_get_proc_segment_p (glibtop *server,
glibtop_proc_segment *buf,
pid_t pid)
{
struct kinfo_proc *pinfo;
int count = 0;
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_SEGMENT), 0);
memset (buf, 0, sizeof (glibtop_proc_segment));
#if 0
/* It does not work for the swapper task. */
if (pid == 0) return;
/* Get the process info from the kernel */
kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, count);
if (*count != 1) {
return; /* the zeroed-out buffer indicating no data */
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid,
sizeof (*pinfo), &count);
if (pinfo == NULL) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
return;
}
/* trs: text resident set size
pinfo[0]->kp_eproc.e_xrssize;
*/
/* buf->trs = pinfo[0]->kp_eproc.e_xrssize; */
/* lrs: shared-lib resident set size
? */
/* drs: data resident set size
pinfo[0]->kp_eproc.e_vm.vm_map.vm_dsize;
*/
/* dt: dirty pages
*/
/* start_code: address of beginning of code segment
buf->text_rss = pinfo[0].p_vm_tsize * pagesize;
buf->data_rss = pinfo[0].p_vm_dsize * pagesize;
*/
/* end_code: address of end of code segment
*/
/* start_stack: address of the bottom of stack segment
*/
#endif
buf->flags = _glibtop_sysdeps_proc_segment;
}

View File

@@ -1,5 +1,3 @@
/* $OpenBSD: procsignal.c,v 1.3 2011/05/23 19:35:55 jasper Exp $ */
/* Copyright (C) 1998 Joshua Sled
This file is part of LibGTop 1.0.
@@ -62,7 +60,7 @@ glibtop_get_proc_signal_p (glibtop *server,
/* Get the process information */
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid,
sizeof (*pinfo), &count);
if ((pinfo == NULL) || (count != 1)) {
if (pinfo == NULL) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
return;
}

View File

@@ -1,5 +1,3 @@
/* $OpenBSD: procstate.c,v 1.3 2011/05/23 19:35:55 jasper Exp $ */
/* Copyright (C) 1998 Joshua Sled
This file is part of LibGTop 1.0.
@@ -64,7 +62,7 @@ glibtop_get_proc_state_p (glibtop *server,
/* Get the process information */
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid,
sizeof (*pinfo), &count);
if ((pinfo == NULL) || (count != 1)) {
if (pinfo == NULL) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
return;
}

View File

@@ -1,5 +1,3 @@
/* $OpenBSD: proctime.c,v 1.5 2011/07/10 15:29:26 jasper Exp $ */
/* Copyright (C) 1998-99 Martin Baulig
This file is part of LibGTop 1.0.
@@ -58,59 +56,6 @@ _glibtop_init_proc_time_p (glibtop *server)
_glibtop_sysdeps_proc_time_user;
}
/* Taken from /usr/src/sys/kern/kern_resource.c */
/*
* Transform the running time and tick information in proc p into user,
* system, and interrupt time usage.
*/
static void
calcru(struct proc *p, struct timeval *up, struct timeval *sp,
struct timeval *ip)
{
quad_t totusec;
u_quad_t u, st, ut, it, tot;
long sec, usec;
struct timeval tv;
st = p->p_sticks;
ut = p->p_uticks;
it = p->p_iticks;
tot = st + ut + it;
if (tot == 0) {
st = 1;
tot = 1;
}
sec = p->p_rtime.tv_sec;
usec = p->p_rtime.tv_usec;
totusec = (quad_t)sec * 1000000 + usec;
if (totusec < 0) {
/* XXX no %qd in kernel. Truncate. */
fprintf (stderr, "calcru: negative time: %ld usec\n",
(long)totusec);
totusec = 0;
}
u = totusec;
st = (u * st) / tot;
sp->tv_sec = st / 1000000;
sp->tv_usec = st % 1000000;
ut = (u * ut) / tot;
up->tv_sec = ut / 1000000;
up->tv_usec = ut % 1000000;
if (ip != NULL) {
it = (u * it) / tot;
ip->tv_sec = it / 1000000;
ip->tv_usec = it % 1000000;
}
}
/* Provides detailed information about a process. */
void
@@ -131,7 +76,7 @@ glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf,
/* Get the process information */
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid,
sizeof (*pinfo), &count);
if ((pinfo == NULL) || (count != 1)) {
if (pinfo == NULL) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
return;
}

View File

@@ -1,5 +1,3 @@
/* $OpenBSD: procuid.c,v 1.3 2011/05/23 19:35:56 jasper Exp $ */
/* Copyright (C) 1998-99 Martin Baulig
This file is part of LibGTop 1.0.
@@ -67,7 +65,7 @@ glibtop_get_proc_uid_p (glibtop *server, glibtop_proc_uid *buf,
/* Get the process information */
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid,
sizeof (*pinfo), &count);
if ((pinfo == NULL) || (count != 1)) {
if (pinfo == NULL) {
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
return;
}

View File

@@ -1,5 +1,3 @@
/* $OpenBSD: procwd.c,v 1.2 2011/05/23 19:35:56 jasper Exp $ */
/* Copyright (C) 2007 Joe Marcus Clarke
This file is part of LibGTop 2.
@@ -41,84 +39,9 @@ _glibtop_init_proc_wd_s(glibtop *server)
server->sysdeps.proc_wd = _glibtop_sysdeps_proc_wd;
}
static GPtrArray *
parse_output(const char *output, glibtop_proc_wd *buf)
{
GPtrArray *dirs;
char **lines;
gboolean nextwd = FALSE;
gboolean nextrtd = FALSE;
gboolean havertd = FALSE;
guint i;
guint len;
dirs = g_ptr_array_sized_new(1);
lines = g_strsplit(output, "\n", 0);
len = g_strv_length(lines);
for (i = 0; i < len && lines[i]; i++) {
if (strlen(lines[i]) < 2)
continue;
if (!strcmp(lines[i], "fcwd")) {
nextwd = TRUE;
continue;
}
if (!strcmp(lines[i], "frtd")) {
nextrtd = TRUE;
continue;
}
if (!g_str_has_prefix(lines[i], "n"))
continue;
if (nextwd) {
g_ptr_array_add(dirs, g_strdup(lines[i] + 1));
nextwd = FALSE;
}
if (nextrtd && !havertd) {
g_strlcpy(buf->root, lines[i] + 1,
sizeof(buf->root));
buf->flags |= (1 << GLIBTOP_PROC_WD_ROOT);
nextrtd = FALSE;
havertd = TRUE;
}
}
g_strfreev(lines);
return dirs;
}
char**
glibtop_get_proc_wd_s(glibtop *server, glibtop_proc_wd *buf, pid_t pid)
{
char path[MAXPATHLEN];
char *output;
memset (buf, 0, sizeof (glibtop_proc_wd));
g_snprintf(path, sizeof(path), "/proc/%u/file", pid);
if (safe_readlink(path, buf->exe, sizeof(buf->exe)))
buf->flags |= (1 << GLIBTOP_PROC_WD_EXE);
output = execute_lsof(pid);
if (output != NULL) {
GPtrArray *dirs;
dirs = parse_output(output, buf);
g_free(output);
buf->number = dirs->len;
buf->flags |= (1 << GLIBTOP_PROC_WD_NUMBER);
g_ptr_array_add(dirs, NULL);
return (char **)g_ptr_array_free(dirs, FALSE);
}
/* TODO */
return NULL;
}

View File

@@ -1,5 +1,3 @@
/* $OpenBSD: sem_limits.c,v 1.3 2011/05/23 19:35:56 jasper Exp $ */
/* Copyright (C) 1998-99 Martin Baulig
This file is part of LibGTop 1.0.

View File

@@ -1,5 +1,3 @@
/* $OpenBSD: shm_limits.c,v 1.3 2011/05/23 19:35:56 jasper Exp $ */
/* Copyright (C) 1998-99 Martin Baulig
This file is part of LibGTop 1.0.

View File

@@ -1,5 +1,3 @@
/* $OpenBSD: siglist.c,v 1.2 2011/05/23 19:35:56 jasper Exp $ */
/* Copyright (C) 1998-99 Martin Baulig
This file is part of LibGTop 1.0.

View File

@@ -0,0 +1,92 @@
/* Copyright (C) 1998 Joshua Sled
This file is part of LibGTop 1.0.
Contributed by Joshua Sled <jsled@xcf.berkeley.edu>, July 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.h>
#include <glibtop/error.h>
#include <glibtop/cpu.h>
#include <glibtop/open.h>
#include <glibtop/init_hooks.h>
/* !!! THIS FUNCTION RUNS SUID ROOT - CHANGE WITH CAUTION !!! */
void
glibtop_init_p (glibtop *server, const unsigned long features,
const unsigned flags)
{
const _glibtop_init_func_t *init_fkt;
if (server == NULL)
glibtop_error_r (NULL, "glibtop_init_p (server == NULL)");
/* Do the initialization, but only if not already initialized. */
if ((server->flags & _GLIBTOP_INIT_STATE_SYSDEPS) == 0) {
glibtop_open_p (server, "glibtop", features, flags);
for (init_fkt = _glibtop_init_hook_p; *init_fkt; init_fkt++)
(*init_fkt) (server);
server->flags |= _GLIBTOP_INIT_STATE_SYSDEPS;
}
}
void
glibtop_open_p (glibtop *server, const char *program_name,
const unsigned long features,
const unsigned flags)
{
char errbuf[_POSIX2_LINE_MAX];
#ifdef DEBUG
fprintf (stderr, "DEBUG (%d): glibtop_open_p ()\n", getpid ());
#endif
/* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */
server->machine.uid = getuid ();
server->machine.euid = geteuid ();
server->machine.gid = getgid ();
server->machine.egid = getegid ();
/* Setup machine-specific data */
server->machine.kd = kvm_openfiles (NULL, NULL, NULL, O_RDONLY, errbuf);
if (server->machine.kd == NULL)
glibtop_error_io_r (server, "kvm_open");
/* Drop priviledges. */
if (setreuid (server->machine.euid, server->machine.uid))
_exit (1);
if (setregid (server->machine.egid, server->machine.gid))
_exit (1);
/* !!! END OF SUID ROOT PART !!! */
/* Our effective uid is now those of the user invoking the server,
* so we do no longer have any priviledges. */
/* NOTE: On OpenBSD, we do not need to be suid root, we just need to
* be sgid kmem.
*
* The server will only use setegid() to get back it's priviledges,
* so it will fail if it is suid root and not sgid kmem. */
}

View File

@@ -1,5 +1,3 @@
/* $OpenBSD: swap.c,v 1.7 2011/07/10 15:23:01 jasper Exp $ */
/* Copyright (C) 1998-99 Martin Baulig
This file is part of LibGTop 1.0.

View File

@@ -1,5 +1,3 @@
/* $OpenBSD: sysinfo.c,v 1.4 2011/05/31 14:02:26 jasper Exp $ */
/* Copyright (C) 1998-99 Martin Baulig
This file is part of LibGTop 1.0.

View File

@@ -1,5 +1,3 @@
/* $OpenBSD: uptime.c,v 1.6 2011/06/01 07:24:49 jasper Exp $ */
/* Copyright (C) 1998-99 Martin Baulig
This file is part of LibGTop 1.0.
@@ -39,7 +37,7 @@ static const unsigned long _required_cpu_flags =
/* Init function. */
void
_glibtop_init_uptime_p (glibtop *server)
_glibtop_init_uptime_s (glibtop *server)
{
server->sysdeps.uptime = _glibtop_sysdeps_uptime;
}
@@ -47,7 +45,7 @@ _glibtop_init_uptime_p (glibtop *server)
/* Provides uptime and idle time. */
void
glibtop_get_uptime_p (glibtop *server, glibtop_uptime *buf)
glibtop_get_uptime_s (glibtop *server, glibtop_uptime *buf)
{
time_t now;
int mib[2];
@@ -65,7 +63,7 @@ glibtop_get_uptime_p (glibtop *server, glibtop_uptime *buf)
buf->boot_time = boottime.tv_sec;
}
glibtop_get_cpu_p (server, &cpu);
glibtop_get_cpu_s (server, &cpu);
/* Put something clever in buf->idletime: CP_IDLE. */
buf->idletime = (double) cpu.idle / (double) cpu.frequency;