New upstream version 2.38.0
This commit is contained in:
7
sysdeps/openbsd/AUTHORS
Normal file
7
sysdeps/openbsd/AUTHORS
Normal file
@@ -0,0 +1,7 @@
|
||||
Martin Baulig (martin@home-of-linux.org)
|
||||
Josh Sled (jsled@scam.XCF.Berkeley.EDU)
|
||||
|
||||
Contributions/bugfixes by:
|
||||
Antoine Jacoutot <ajacoutot@openbsd.org>
|
||||
Ariane van der Steldt <ariane@stack.nl>
|
||||
Jasper Lievisse Adriaanse <jasper@openbsd.org>
|
||||
28
sysdeps/openbsd/Makefile.am
Normal file
28
sysdeps/openbsd/Makefile.am
Normal file
@@ -0,0 +1,28 @@
|
||||
AM_CPPFLAGS = @AM_CPPFLAGS@
|
||||
|
||||
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 \
|
||||
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 = 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)
|
||||
|
||||
libgtopinclude_HEADERS = glibtop_server.h glibtop_machine.h \
|
||||
glibtop_suid.h glibtop_private.h
|
||||
|
||||
libgtopincludedir = $(includedir)/libgtop-2.0
|
||||
791
sysdeps/openbsd/Makefile.in
Normal file
791
sysdeps/openbsd/Makefile.in
Normal file
@@ -0,0 +1,791 @@
|
||||
# Makefile.in generated by automake 1.15 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
|
||||
VPATH = @srcdir@
|
||||
am__is_gnu_make = { \
|
||||
if test -z '$(MAKELEVEL)'; then \
|
||||
false; \
|
||||
elif test -n '$(MAKE_HOST)'; then \
|
||||
true; \
|
||||
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
|
||||
true; \
|
||||
else \
|
||||
false; \
|
||||
fi; \
|
||||
}
|
||||
am__make_running_with_option = \
|
||||
case $${target_option-} in \
|
||||
?) ;; \
|
||||
*) echo "am__make_running_with_option: internal error: invalid" \
|
||||
"target option '$${target_option-}' specified" >&2; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
has_opt=no; \
|
||||
sane_makeflags=$$MAKEFLAGS; \
|
||||
if $(am__is_gnu_make); then \
|
||||
sane_makeflags=$$MFLAGS; \
|
||||
else \
|
||||
case $$MAKEFLAGS in \
|
||||
*\\[\ \ ]*) \
|
||||
bs=\\; \
|
||||
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
|
||||
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
|
||||
esac; \
|
||||
fi; \
|
||||
skip_next=no; \
|
||||
strip_trailopt () \
|
||||
{ \
|
||||
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
|
||||
}; \
|
||||
for flg in $$sane_makeflags; do \
|
||||
test $$skip_next = yes && { skip_next=no; continue; }; \
|
||||
case $$flg in \
|
||||
*=*|--*) continue;; \
|
||||
-*I) strip_trailopt 'I'; skip_next=yes;; \
|
||||
-*I?*) strip_trailopt 'I';; \
|
||||
-*O) strip_trailopt 'O'; skip_next=yes;; \
|
||||
-*O?*) strip_trailopt 'O';; \
|
||||
-*l) strip_trailopt 'l'; skip_next=yes;; \
|
||||
-*l?*) strip_trailopt 'l';; \
|
||||
-[dEDm]) skip_next=yes;; \
|
||||
-[JT]) skip_next=yes;; \
|
||||
esac; \
|
||||
case $$flg in \
|
||||
*$$target_option*) has_opt=yes; break;; \
|
||||
esac; \
|
||||
done; \
|
||||
test $$has_opt = yes
|
||||
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
|
||||
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkglibexecdir = $(libexecdir)/@PACKAGE@
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
install_sh_SCRIPT = $(install_sh) -c
|
||||
INSTALL_HEADER = $(INSTALL_DATA)
|
||||
transform = $(program_transform_name)
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
subdir = sysdeps/openbsd
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \
|
||||
$(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \
|
||||
$(top_srcdir)/m4/intlmacosx.m4 \
|
||||
$(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \
|
||||
$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
|
||||
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
|
||||
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
|
||||
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
|
||||
$(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
|
||||
$(top_srcdir)/acinclude.m4 $(top_srcdir)/libgtop-sysdeps.m4 \
|
||||
$(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(libgtopinclude_HEADERS) \
|
||||
$(am__DIST_COMMON)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
LTLIBRARIES = $(noinst_LTLIBRARIES)
|
||||
libgtop_sysdeps_2_0_la_LIBADD =
|
||||
am_libgtop_sysdeps_2_0_la_OBJECTS = nosuid.lo siglist.lo sysinfo.lo \
|
||||
cpu.lo loadavg.lo uptime.lo netlist.lo fsusage.lo mem.lo \
|
||||
mountlist.lo procopenfiles.lo procwd.lo procaffinity.lo \
|
||||
glibtop_private.lo open.lo
|
||||
libgtop_sysdeps_2_0_la_OBJECTS = $(am_libgtop_sysdeps_2_0_la_OBJECTS)
|
||||
AM_V_lt = $(am__v_lt_@AM_V@)
|
||||
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
|
||||
am__v_lt_0 = --silent
|
||||
am__v_lt_1 =
|
||||
libgtop_sysdeps_2_0_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
|
||||
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
|
||||
$(AM_CFLAGS) $(CFLAGS) $(libgtop_sysdeps_2_0_la_LDFLAGS) \
|
||||
$(LDFLAGS) -o $@
|
||||
am__DEPENDENCIES_1 =
|
||||
libgtop_sysdeps_suid_2_0_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
|
||||
am_libgtop_sysdeps_suid_2_0_la_OBJECTS = suid_open.lo close.lo swap.lo \
|
||||
proclist.lo procstate.lo procuid.lo proctime.lo procmem.lo \
|
||||
procsignal.lo prockernel.lo procsegment.lo procargs.lo \
|
||||
procmap.lo netload.lo ppp.lo shm_limits.lo msg_limits.lo \
|
||||
sem_limits.lo
|
||||
libgtop_sysdeps_suid_2_0_la_OBJECTS = \
|
||||
$(am_libgtop_sysdeps_suid_2_0_la_OBJECTS)
|
||||
libgtop_sysdeps_suid_2_0_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
|
||||
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
|
||||
$(AM_CFLAGS) $(CFLAGS) $(libgtop_sysdeps_suid_2_0_la_LDFLAGS) \
|
||||
$(LDFLAGS) -o $@
|
||||
AM_V_P = $(am__v_P_@AM_V@)
|
||||
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
|
||||
am__v_P_0 = false
|
||||
am__v_P_1 = :
|
||||
AM_V_GEN = $(am__v_GEN_@AM_V@)
|
||||
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
|
||||
am__v_GEN_0 = @echo " GEN " $@;
|
||||
am__v_GEN_1 =
|
||||
AM_V_at = $(am__v_at_@AM_V@)
|
||||
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
|
||||
am__v_at_0 = @
|
||||
am__v_at_1 =
|
||||
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
|
||||
depcomp = $(SHELL) $(top_srcdir)/depcomp
|
||||
am__depfiles_maybe = depfiles
|
||||
am__mv = mv -f
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
|
||||
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
|
||||
$(AM_CFLAGS) $(CFLAGS)
|
||||
AM_V_CC = $(am__v_CC_@AM_V@)
|
||||
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
|
||||
am__v_CC_0 = @echo " CC " $@;
|
||||
am__v_CC_1 =
|
||||
CCLD = $(CC)
|
||||
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
|
||||
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
|
||||
am__v_CCLD_0 = @echo " CCLD " $@;
|
||||
am__v_CCLD_1 =
|
||||
SOURCES = $(libgtop_sysdeps_2_0_la_SOURCES) \
|
||||
$(libgtop_sysdeps_suid_2_0_la_SOURCES)
|
||||
DIST_SOURCES = $(libgtop_sysdeps_2_0_la_SOURCES) \
|
||||
$(libgtop_sysdeps_suid_2_0_la_SOURCES)
|
||||
am__can_run_installinfo = \
|
||||
case $$AM_UPDATE_INFO_DIR in \
|
||||
n|no|NO) false;; \
|
||||
*) (install-info --version) >/dev/null 2>&1;; \
|
||||
esac
|
||||
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
|
||||
am__vpath_adj = case $$p in \
|
||||
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
|
||||
*) f=$$p;; \
|
||||
esac;
|
||||
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
|
||||
am__install_max = 40
|
||||
am__nobase_strip_setup = \
|
||||
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
|
||||
am__nobase_strip = \
|
||||
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
|
||||
am__nobase_list = $(am__nobase_strip_setup); \
|
||||
for p in $$list; do echo "$$p $$p"; done | \
|
||||
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
|
||||
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
|
||||
if (++n[$$2] == $(am__install_max)) \
|
||||
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
|
||||
END { for (dir in files) print dir, files[dir] }'
|
||||
am__base_list = \
|
||||
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
|
||||
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
|
||||
am__uninstall_files_from_dir = { \
|
||||
test -z "$$files" \
|
||||
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|
||||
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
|
||||
$(am__cd) "$$dir" && rm -f $$files; }; \
|
||||
}
|
||||
am__installdirs = "$(DESTDIR)$(libgtopincludedir)"
|
||||
HEADERS = $(libgtopinclude_HEADERS)
|
||||
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
|
||||
# Read a list of newline-separated strings from the standard input,
|
||||
# and print each of them once, without duplicates. Input order is
|
||||
# *not* preserved.
|
||||
am__uniquify_input = $(AWK) '\
|
||||
BEGIN { nonempty = 0; } \
|
||||
{ items[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in items) print i; }; } \
|
||||
'
|
||||
# Make sure the list of sources is unique. This is necessary because,
|
||||
# e.g., the same source file might be shared among _SOURCES variables
|
||||
# for different programs/libraries.
|
||||
am__define_uniq_tagged_files = \
|
||||
list='$(am__tagged_files)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | $(am__uniquify_input)`
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp AUTHORS
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
|
||||
ALLOCA = @ALLOCA@
|
||||
AMTAR = @AMTAR@
|
||||
AM_CPPFLAGS = @AM_CPPFLAGS@
|
||||
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
|
||||
AR = @AR@
|
||||
AS = @AS@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
DL_LIB = @DL_LIB@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
DUMPBIN = @DUMPBIN@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
|
||||
GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
|
||||
GLIB_CFLAGS = @GLIB_CFLAGS@
|
||||
GLIB_LIBS = @GLIB_LIBS@
|
||||
GMSGFMT = @GMSGFMT@
|
||||
GMSGFMT_015 = @GMSGFMT_015@
|
||||
GREP = @GREP@
|
||||
GTKDOC_CHECK = @GTKDOC_CHECK@
|
||||
GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@
|
||||
GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@
|
||||
GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@
|
||||
GTKDOC_MKPDF = @GTKDOC_MKPDF@
|
||||
GTKDOC_REBASE = @GTKDOC_REBASE@
|
||||
HTML_DIR = @HTML_DIR@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
INTLLIBS = @INTLLIBS@
|
||||
INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
|
||||
INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@
|
||||
INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@
|
||||
INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@
|
||||
INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@
|
||||
INTROSPECTION_LIBS = @INTROSPECTION_LIBS@
|
||||
INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@
|
||||
INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@
|
||||
INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@
|
||||
KVM_LIBS = @KVM_LIBS@
|
||||
LD = @LD@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBGTOP_BINDIR = @LIBGTOP_BINDIR@
|
||||
LIBGTOP_EXTRA_LIBS = @LIBGTOP_EXTRA_LIBS@
|
||||
LIBGTOP_INCS = @LIBGTOP_INCS@
|
||||
LIBGTOP_LIBS = @LIBGTOP_LIBS@
|
||||
LIBGTOP_MAJOR_VERSION = @LIBGTOP_MAJOR_VERSION@
|
||||
LIBGTOP_MICRO_VERSION = @LIBGTOP_MICRO_VERSION@
|
||||
LIBGTOP_MINOR_VERSION = @LIBGTOP_MINOR_VERSION@
|
||||
LIBGTOP_SERVER = @LIBGTOP_SERVER@
|
||||
LIBGTOP_SERVER_VERSION = @LIBGTOP_SERVER_VERSION@
|
||||
LIBGTOP_VERSION = @LIBGTOP_VERSION@
|
||||
LIBGTOP_VERSION_CODE = @LIBGTOP_VERSION_CODE@
|
||||
LIBICONV = @LIBICONV@
|
||||
LIBINTL = @LIBINTL@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LIPO = @LIPO@
|
||||
LN_S = @LN_S@
|
||||
LTLIBICONV = @LTLIBICONV@
|
||||
LTLIBINTL = @LTLIBINTL@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
|
||||
LT_VERSION_INFO = @LT_VERSION_INFO@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MANIFEST_TOOL = @MANIFEST_TOOL@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
MSGFMT = @MSGFMT@
|
||||
MSGFMT_015 = @MSGFMT_015@
|
||||
MSGMERGE = @MSGMERGE@
|
||||
NM = @NM@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJEXT = @OBJEXT@
|
||||
OTOOL = @OTOOL@
|
||||
OTOOL64 = @OTOOL64@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_URL = @PACKAGE_URL@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
PERL = @PERL@
|
||||
PKG_CONFIG = @PKG_CONFIG@
|
||||
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
|
||||
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
|
||||
POSUB = @POSUB@
|
||||
RANLIB = @RANLIB@
|
||||
SED = @SED@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
STRIP = @STRIP@
|
||||
USE_NLS = @USE_NLS@
|
||||
VERSION = @VERSION@
|
||||
XGETTEXT = @XGETTEXT@
|
||||
XGETTEXT_015 = @XGETTEXT_015@
|
||||
XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
|
||||
XMKMF = @XMKMF@
|
||||
X_CFLAGS = @X_CFLAGS@
|
||||
X_EXTRA_LIBS = @X_EXTRA_LIBS@
|
||||
X_LIBS = @X_LIBS@
|
||||
X_PRE_LIBS = @X_PRE_LIBS@
|
||||
abs_builddir = @abs_builddir@
|
||||
abs_srcdir = @abs_srcdir@
|
||||
abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_AR = @ac_ct_AR@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__quote = @am__quote@
|
||||
am__tar = @am__tar@
|
||||
am__untar = @am__untar@
|
||||
bindir = @bindir@
|
||||
build = @build@
|
||||
build_alias = @build_alias@
|
||||
build_cpu = @build_cpu@
|
||||
build_os = @build_os@
|
||||
build_vendor = @build_vendor@
|
||||
builddir = @builddir@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
docdir = @docdir@
|
||||
dvidir = @dvidir@
|
||||
exec_prefix = @exec_prefix@
|
||||
host = @host@
|
||||
host_alias = @host_alias@
|
||||
host_cpu = @host_cpu@
|
||||
host_os = @host_os@
|
||||
host_vendor = @host_vendor@
|
||||
htmldir = @htmldir@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
libgtop_have_sysinfo = @libgtop_have_sysinfo@
|
||||
libgtop_need_server = @libgtop_need_server@
|
||||
libgtop_postinstall = @libgtop_postinstall@
|
||||
libgtop_sysdeps_dir = @libgtop_sysdeps_dir@
|
||||
libgtop_top_builddir = @libgtop_top_builddir@
|
||||
libs_xauth = @libs_xauth@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
oldincludedir = @oldincludedir@
|
||||
pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
sbindir = @sbindir@
|
||||
server_programs = @server_programs@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
sysconfdir = @sysconfdir@
|
||||
sysdeps_dir = @sysdeps_dir@
|
||||
sysdeps_suid_lib = @sysdeps_suid_lib@
|
||||
target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
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 \
|
||||
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)
|
||||
|
||||
# TODO should be made nosuid like FreeBSD
|
||||
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 shm_limits.c msg_limits.c sem_limits.c
|
||||
libgtop_sysdeps_suid_2_0_la_LDFLAGS = $(LT_VERSION_INFO)
|
||||
libgtopinclude_HEADERS = glibtop_server.h glibtop_machine.h \
|
||||
glibtop_suid.h glibtop_private.h
|
||||
|
||||
libgtopincludedir = $(includedir)/libgtop-2.0
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .lo .o .obj
|
||||
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
|
||||
&& { if test -f $@; then exit 0; else break; fi; }; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu sysdeps/openbsd/Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --gnu sysdeps/openbsd/Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
|
||||
esac;
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
|
||||
$(top_srcdir)/configure: $(am__configure_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(am__aclocal_m4_deps):
|
||||
|
||||
clean-noinstLTLIBRARIES:
|
||||
-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
|
||||
@list='$(noinst_LTLIBRARIES)'; \
|
||||
locs=`for p in $$list; do echo $$p; done | \
|
||||
sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
|
||||
sort -u`; \
|
||||
test -z "$$locs" || { \
|
||||
echo rm -f $${locs}; \
|
||||
rm -f $${locs}; \
|
||||
}
|
||||
|
||||
libgtop_sysdeps-2.0.la: $(libgtop_sysdeps_2_0_la_OBJECTS) $(libgtop_sysdeps_2_0_la_DEPENDENCIES) $(EXTRA_libgtop_sysdeps_2_0_la_DEPENDENCIES)
|
||||
$(AM_V_CCLD)$(libgtop_sysdeps_2_0_la_LINK) $(libgtop_sysdeps_2_0_la_OBJECTS) $(libgtop_sysdeps_2_0_la_LIBADD) $(LIBS)
|
||||
|
||||
libgtop_sysdeps_suid-2.0.la: $(libgtop_sysdeps_suid_2_0_la_OBJECTS) $(libgtop_sysdeps_suid_2_0_la_DEPENDENCIES) $(EXTRA_libgtop_sysdeps_suid_2_0_la_DEPENDENCIES)
|
||||
$(AM_V_CCLD)$(libgtop_sysdeps_suid_2_0_la_LINK) $(libgtop_sysdeps_suid_2_0_la_OBJECTS) $(libgtop_sysdeps_suid_2_0_la_LIBADD) $(LIBS)
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.$(OBJEXT)
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/close.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fsusage.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glibtop_private.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/loadavg.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mem.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mountlist.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msg_limits.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netlist.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netload.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nosuid.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/open.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ppp.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/procaffinity.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/procargs.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/prockernel.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proclist.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/procmap.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/procmem.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/procopenfiles.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/procsegment.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/procsignal.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/procstate.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proctime.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/procuid.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/procwd.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sem_limits.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shm_limits.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/siglist.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/suid_open.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/swap.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sysinfo.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uptime.Plo@am__quote@
|
||||
|
||||
.c.o:
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
|
||||
|
||||
.c.obj:
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
|
||||
|
||||
.c.lo:
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
install-libgtopincludeHEADERS: $(libgtopinclude_HEADERS)
|
||||
@$(NORMAL_INSTALL)
|
||||
@list='$(libgtopinclude_HEADERS)'; test -n "$(libgtopincludedir)" || list=; \
|
||||
if test -n "$$list"; then \
|
||||
echo " $(MKDIR_P) '$(DESTDIR)$(libgtopincludedir)'"; \
|
||||
$(MKDIR_P) "$(DESTDIR)$(libgtopincludedir)" || exit 1; \
|
||||
fi; \
|
||||
for p in $$list; do \
|
||||
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
|
||||
echo "$$d$$p"; \
|
||||
done | $(am__base_list) | \
|
||||
while read files; do \
|
||||
echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(libgtopincludedir)'"; \
|
||||
$(INSTALL_HEADER) $$files "$(DESTDIR)$(libgtopincludedir)" || exit $$?; \
|
||||
done
|
||||
|
||||
uninstall-libgtopincludeHEADERS:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@list='$(libgtopinclude_HEADERS)'; test -n "$(libgtopincludedir)" || list=; \
|
||||
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
|
||||
dir='$(DESTDIR)$(libgtopincludedir)'; $(am__uninstall_files_from_dir)
|
||||
|
||||
ID: $(am__tagged_files)
|
||||
$(am__define_uniq_tagged_files); mkid -fID $$unique
|
||||
tags: tags-am
|
||||
TAGS: tags
|
||||
|
||||
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
|
||||
set x; \
|
||||
here=`pwd`; \
|
||||
$(am__define_uniq_tagged_files); \
|
||||
shift; \
|
||||
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
if test $$# -gt 0; then \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
"$$@" $$unique; \
|
||||
else \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$unique; \
|
||||
fi; \
|
||||
fi
|
||||
ctags: ctags-am
|
||||
|
||||
CTAGS: ctags
|
||||
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
|
||||
$(am__define_uniq_tagged_files); \
|
||||
test -z "$(CTAGS_ARGS)$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$unique
|
||||
|
||||
GTAGS:
|
||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
&& $(am__cd) $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) "$$here"
|
||||
cscopelist: cscopelist-am
|
||||
|
||||
cscopelist-am: $(am__tagged_files)
|
||||
list='$(am__tagged_files)'; \
|
||||
case "$(srcdir)" in \
|
||||
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
|
||||
*) sdir=$(subdir)/$(srcdir) ;; \
|
||||
esac; \
|
||||
for i in $$list; do \
|
||||
if test -f "$$i"; then \
|
||||
echo "$(subdir)/$$i"; \
|
||||
else \
|
||||
echo "$$sdir/$$i"; \
|
||||
fi; \
|
||||
done >> $(top_builddir)/cscope.files
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
list='$(DISTFILES)'; \
|
||||
dist_files=`for file in $$list; do echo $$file; done | \
|
||||
sed -e "s|^$$srcdirstrip/||;t" \
|
||||
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
|
||||
case $$dist_files in \
|
||||
*/*) $(MKDIR_P) `echo "$$dist_files" | \
|
||||
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
|
||||
sort -u` ;; \
|
||||
esac; \
|
||||
for file in $$dist_files; do \
|
||||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test -d "$(distdir)/$$file"; then \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
|
||||
else \
|
||||
test -f "$(distdir)/$$file" \
|
||||
|| cp -p $$d/$$file "$(distdir)/$$file" \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
all-am: Makefile $(LTLIBRARIES) $(HEADERS)
|
||||
installdirs:
|
||||
for dir in "$(DESTDIR)$(libgtopincludedir)"; do \
|
||||
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
|
||||
done
|
||||
install: install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
uninstall: uninstall-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
|
||||
installcheck: installcheck-am
|
||||
install-strip:
|
||||
if test -z '$(STRIP)'; then \
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
install; \
|
||||
else \
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
|
||||
fi
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
|
||||
mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -rf ./$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic \
|
||||
distclean-tags
|
||||
|
||||
dvi: dvi-am
|
||||
|
||||
dvi-am:
|
||||
|
||||
html: html-am
|
||||
|
||||
html-am:
|
||||
|
||||
info: info-am
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am: install-libgtopincludeHEADERS
|
||||
|
||||
install-dvi: install-dvi-am
|
||||
|
||||
install-dvi-am:
|
||||
|
||||
install-exec-am:
|
||||
|
||||
install-html: install-html-am
|
||||
|
||||
install-html-am:
|
||||
|
||||
install-info: install-info-am
|
||||
|
||||
install-info-am:
|
||||
|
||||
install-man:
|
||||
|
||||
install-pdf: install-pdf-am
|
||||
|
||||
install-pdf-am:
|
||||
|
||||
install-ps: install-ps-am
|
||||
|
||||
install-ps-am:
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -rf ./$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
|
||||
mostlyclean-libtool
|
||||
|
||||
pdf: pdf-am
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-am
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am: uninstall-libgtopincludeHEADERS
|
||||
|
||||
.MAKE: install-am install-strip
|
||||
|
||||
.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
|
||||
clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \
|
||||
ctags-am distclean distclean-compile distclean-generic \
|
||||
distclean-libtool distclean-tags distdir dvi dvi-am html \
|
||||
html-am info info-am install install-am install-data \
|
||||
install-data-am install-dvi install-dvi-am install-exec \
|
||||
install-exec-am install-html install-html-am install-info \
|
||||
install-info-am install-libgtopincludeHEADERS install-man \
|
||||
install-pdf install-pdf-am install-ps install-ps-am \
|
||||
install-strip installcheck installcheck-am installdirs \
|
||||
maintainer-clean maintainer-clean-generic mostlyclean \
|
||||
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
|
||||
pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \
|
||||
uninstall-libgtopincludeHEADERS
|
||||
|
||||
.PRECIOUS: Makefile
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
30
sysdeps/openbsd/close.c
Normal file
30
sysdeps/openbsd/close.c
Normal file
@@ -0,0 +1,30 @@
|
||||
/* 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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/close.h>
|
||||
|
||||
/* Closes pipe to gtop server. */
|
||||
|
||||
void
|
||||
glibtop_close_p (glibtop *server)
|
||||
{ }
|
||||
148
sysdeps/openbsd/cpu.c
Normal file
148
sysdeps/openbsd/cpu.c
Normal file
@@ -0,0 +1,148 @@
|
||||
/* 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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/cpu.h>
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_cpu =
|
||||
(1L << GLIBTOP_CPU_TOTAL) + (1L << GLIBTOP_CPU_USER) +
|
||||
(1L << GLIBTOP_CPU_NICE) + (1L << GLIBTOP_CPU_SYS) +
|
||||
(1L << GLIBTOP_CPU_IDLE) + (1L << GLIBTOP_CPU_FREQUENCY) +
|
||||
(1L << GLIBTOP_CPU_IRQ);
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_cpu_smp =
|
||||
(1L << GLIBTOP_XCPU_TOTAL) + (1L << GLIBTOP_XCPU_USER) +
|
||||
(1L << GLIBTOP_XCPU_NICE) + (1L << GLIBTOP_XCPU_SYS) +
|
||||
(1L << GLIBTOP_XCPU_IDLE) + (1L << GLIBTOP_XCPU_IRQ);
|
||||
|
||||
/* MIB array for sysctl */
|
||||
static int mib_length=2;
|
||||
static int mib_cr [] = { CTL_KERN, KERN_CLOCKRATE };
|
||||
static int mib_cptime [] = { CTL_KERN, KERN_CPTIME };
|
||||
static int mib_cptime_s [] = { CTL_KERN, KERN_CPTIME2, 0 };
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
_glibtop_init_cpu_s (glibtop *server)
|
||||
{
|
||||
server->sysdeps.cpu = _glibtop_sysdeps_cpu;
|
||||
|
||||
if (server->ncpu)
|
||||
server->sysdeps.cpu |= _glibtop_sysdeps_cpu_smp;
|
||||
}
|
||||
|
||||
/* Provides information about cpu usage. */
|
||||
|
||||
void
|
||||
glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf)
|
||||
{
|
||||
long cpts [CPUSTATES];
|
||||
int64_t *cp_times = NULL;
|
||||
struct clockinfo ci;
|
||||
size_t length;
|
||||
int ncpu, i;
|
||||
|
||||
glibtop_init_s (&server, GLIBTOP_SYSDEPS_CPU, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_cpu));
|
||||
|
||||
/* If this fails, the nlist may not be valid. */
|
||||
if (server->sysdeps.cpu == 0)
|
||||
return;
|
||||
|
||||
length = sizeof (cpts);
|
||||
if (sysctl (mib_cptime, mib_length, cpts, &length, NULL, 0)) {
|
||||
glibtop_warn_io_r (server, "sysctl (kern.cptime)");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Get the clockrate data */
|
||||
length = sizeof (struct clockinfo);
|
||||
if (sysctl (mib_cr, mib_length, &ci, &length, NULL, 0)) {
|
||||
glibtop_warn_io_r (server, "sysctl (kern.clockrate)");
|
||||
return;
|
||||
}
|
||||
|
||||
/* set user time */
|
||||
buf->user = cpts [CP_USER];
|
||||
/* set nice time */
|
||||
buf->nice = cpts [CP_NICE];
|
||||
/* set sys time */
|
||||
buf->sys = cpts [CP_SYS];
|
||||
/* set idle time */
|
||||
buf->idle = cpts [CP_IDLE];
|
||||
/* set irq */
|
||||
buf->irq = cpts [CP_INTR];
|
||||
|
||||
/* set frequency */
|
||||
buf->frequency = (ci.stathz ? ci.stathz : ci.hz);
|
||||
/* set total */
|
||||
buf->total = cpts [CP_USER] + cpts [CP_NICE] \
|
||||
+ cpts [CP_SYS] + cpts [CP_IDLE] + cpts [CP_INTR];
|
||||
|
||||
ncpu = server->ncpu + 1;
|
||||
|
||||
/*
|
||||
if (!cp_times) {
|
||||
if ((cp_times = calloc(sizeof(int64_t *), ncpu)) == NULL)
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
length = CPUSTATES * sizeof(int64_t);
|
||||
for (i = 0; i < ncpu; i++) {
|
||||
mib_cptime_s[2] = i;
|
||||
cp_times = g_malloc (length);
|
||||
if (sysctl (mib_cptime_s, 3, cp_times, &length, NULL, 0) < 0)
|
||||
free(cp_times);
|
||||
|
||||
if (cp_times) {
|
||||
buf->xcpu_user[i] = cp_times[CP_USER];
|
||||
buf->xcpu_nice[i] = cp_times[CP_NICE];
|
||||
buf->xcpu_sys[i] = cp_times[CP_SYS];
|
||||
buf->xcpu_idle[i] = cp_times[CP_IDLE];
|
||||
buf->xcpu_irq[i] = cp_times[CP_INTR];
|
||||
} else {
|
||||
buf->xcpu_user[i] = cpts [CP_USER] / ncpu;
|
||||
buf->xcpu_nice[i] = cpts [CP_NICE] / ncpu;
|
||||
buf->xcpu_sys[i] = cpts [CP_SYS] / ncpu;
|
||||
buf->xcpu_idle[i] = cpts [CP_IDLE] / ncpu;
|
||||
buf->xcpu_irq[i] = cpts [CP_INTR] / ncpu;
|
||||
}
|
||||
buf->xcpu_total[i] = buf->xcpu_user[i] + buf->xcpu_nice[i] \
|
||||
+ buf->xcpu_sys[i] + buf->xcpu_idle[i] \
|
||||
+ buf->xcpu_irq[i];
|
||||
}
|
||||
|
||||
g_free (cp_times);
|
||||
|
||||
/* Set the flags last. */
|
||||
buf->flags = _glibtop_sysdeps_cpu;
|
||||
|
||||
if (ncpu > 1) {
|
||||
buf->flags |= _glibtop_sysdeps_cpu_smp;
|
||||
}
|
||||
}
|
||||
65
sysdeps/openbsd/fsusage.c
Normal file
65
sysdeps/openbsd/fsusage.c
Normal file
@@ -0,0 +1,65 @@
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/fsusage.h>
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/statvfs.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
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);
|
||||
|
||||
static void
|
||||
_glibtop_get_fsusage_read_write (glibtop *server, glibtop_fsusage *buf, const char *path)
|
||||
{
|
||||
int result;
|
||||
struct statfs sfs;
|
||||
|
||||
result = statfs (path, &sfs);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
52
sysdeps/openbsd/glibtop_machine.h
Normal file
52
sysdeps/openbsd/glibtop_machine.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/* 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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GLIBTOP_MACHINE_H__
|
||||
#define __GLIBTOP_MACHINE_H__
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/sched.h>
|
||||
#include <nlist.h>
|
||||
#include <kvm.h>
|
||||
#include <time.h>
|
||||
#include <sys/user.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
struct _glibtop_machine
|
||||
{
|
||||
uid_t uid, euid;
|
||||
gid_t gid, egid;
|
||||
|
||||
/* The kernel descriptor, used by kvm_* calls. We keep and re-use
|
||||
* it rather than re-getting it for almost all function
|
||||
* invocations. */
|
||||
kvm_t *kd;
|
||||
};
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GLIBTOP_MACHINE_H__ */
|
||||
28
sysdeps/openbsd/glibtop_private.c
Normal file
28
sysdeps/openbsd/glibtop_private.c
Normal file
@@ -0,0 +1,28 @@
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
|
||||
#include "glibtop_private.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* Ported from linux/glibtop_private.c */
|
||||
gboolean
|
||||
safe_readlink(const char *path, char *buf, int bufsiz)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = readlink(path, buf, bufsiz - 1);
|
||||
|
||||
if (ret == -1) {
|
||||
g_warning("Could not read link %s : %s", path, strerror(errno));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
buf[ret] = '\0';
|
||||
return TRUE;
|
||||
}
|
||||
39
sysdeps/openbsd/glibtop_private.h
Normal file
39
sysdeps/openbsd/glibtop_private.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/* Copyright (C) 2007 Joe Marcus Clarke
|
||||
This file is part of LibGTop 2.0.
|
||||
|
||||
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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __OPENBSD__GLIBTOP_PRIVATE_H__
|
||||
#define __OPENBSD__GLIBTOP_PRIVATE_H__
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
gboolean safe_readlink(const char *path, char *buf, int bufsiz);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __OPENBSD__GLIBTOP_PRIVATE_H__ */
|
||||
53
sysdeps/openbsd/glibtop_server.h
Normal file
53
sysdeps/openbsd/glibtop_server.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/* 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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GLIBTOP_SERVER_H__
|
||||
#define __GLIBTOP_SERVER_H__
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GLIBTOP_SUID_SWAP (1 << GLIBTOP_SYSDEPS_SWAP)
|
||||
#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)
|
||||
#define GLIBTOP_SUID_PROCLIST (1 << GLIBTOP_SYSDEPS_PROCLIST)
|
||||
#define GLIBTOP_SUID_PROC_STATE (1 << GLIBTOP_SYSDEPS_PROC_STATE)
|
||||
#define GLIBTOP_SUID_PROC_UID (1 << GLIBTOP_SYSDEPS_PROC_UID)
|
||||
#define GLIBTOP_SUID_PROC_MEM (1 << GLIBTOP_SYSDEPS_PROC_MEM)
|
||||
#define GLIBTOP_SUID_PROC_TIME (1 << GLIBTOP_SYSDEPS_PROC_TIME)
|
||||
#define GLIBTOP_SUID_PROC_SIGNAL (1 << GLIBTOP_SYSDEPS_PROC_SIGNAL)
|
||||
#define GLIBTOP_SUID_PROC_KERNEL (1 << GLIBTOP_SYSDEPS_PROC_KERNEL)
|
||||
#define GLIBTOP_SUID_PROC_SEGMENT (1 << GLIBTOP_SYSDEPS_PROC_SEGMENT)
|
||||
#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_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
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
58
sysdeps/openbsd/glibtop_suid.h
Normal file
58
sysdeps/openbsd/glibtop_suid.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/* 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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GLIBTOP_SUID_H__
|
||||
#define __GLIBTOP_SUID_H__
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#if _IN_LIBGTOP
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#include <glibtop_machine.h>
|
||||
|
||||
#define KI_PROC(ki) (&(ki))->kp_proc)
|
||||
#define KI_EPROC(ki) (&(ki))->kp_eproc)
|
||||
|
||||
#define FORCEUREAD 1
|
||||
#define UREADOK(ki) (FORCEUREAD || (KI_PROC(ki)->p_flag & P_INMEM))
|
||||
|
||||
static inline void glibtop_suid_enter (glibtop *server) {
|
||||
setregid (server->machine->gid, server->machine->egid);
|
||||
};
|
||||
|
||||
static inline void glibtop_suid_leave (glibtop *server) {
|
||||
if (setregid (server->machine->egid, server->machine->gid))
|
||||
_exit (1);
|
||||
};
|
||||
|
||||
void
|
||||
glibtop_init_p (glibtop *server, const unsigned long features,
|
||||
const unsigned flags);
|
||||
void
|
||||
glibtop_open_p (glibtop *server, const char *program_name,
|
||||
const unsigned long features,
|
||||
const unsigned flags);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
59
sysdeps/openbsd/loadavg.c
Normal file
59
sysdeps/openbsd/loadavg.c
Normal file
@@ -0,0 +1,59 @@
|
||||
/* 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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/loadavg.h>
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_loadavg =
|
||||
(1L << GLIBTOP_LOADAVG_LOADAVG);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
_glibtop_init_loadavg_s (glibtop *server)
|
||||
{
|
||||
server->sysdeps.loadavg = _glibtop_sysdeps_loadavg;
|
||||
}
|
||||
|
||||
/* Provides load averange. */
|
||||
|
||||
void
|
||||
glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf)
|
||||
{
|
||||
double ldavg[3];
|
||||
int i;
|
||||
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_LOADAVG), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_loadavg));
|
||||
|
||||
getloadavg (ldavg, 3);
|
||||
|
||||
/* fill in the struct */
|
||||
buf->flags = _glibtop_sysdeps_loadavg;
|
||||
for (i = 0; i < 3; i++) {
|
||||
buf->loadavg [i] = ldavg [i];
|
||||
} /* end for */
|
||||
}
|
||||
116
sysdeps/openbsd/mem.c
Normal file
116
sysdeps/openbsd/mem.c
Normal file
@@ -0,0 +1,116 @@
|
||||
/* 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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/mem.h>
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
#include <sys/mount.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <uvm/uvm_extern.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_mem =
|
||||
(1L << GLIBTOP_MEM_TOTAL) + (1L << GLIBTOP_MEM_USED) +
|
||||
(1L << GLIBTOP_MEM_FREE) + (1L << GLIBTOP_MEM_SHARED) +
|
||||
(1L << GLIBTOP_MEM_BUFFER) + (1L << GLIBTOP_MEM_CACHED) +
|
||||
(1L << GLIBTOP_MEM_USER) + (1L << GLIBTOP_MEM_LOCKED);
|
||||
|
||||
#ifndef LOG1024
|
||||
#define LOG1024 10
|
||||
#endif
|
||||
|
||||
/* these are for getting the memory statistics */
|
||||
static int pageshift; /* log base 2 of the pagesize */
|
||||
|
||||
/* define pagetok in terms of pageshift */
|
||||
#define pagetok(size) ((size) << pageshift)
|
||||
|
||||
/* MIB array for sysctl */
|
||||
static int uvmexp_mib [] = { CTL_VM, VM_UVMEXP };
|
||||
static int bcstats_mib [] = { CTL_VFS, VFS_GENERIC, VFS_BCACHESTAT };
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
_glibtop_init_mem_s (glibtop *server)
|
||||
{
|
||||
register int pagesize;
|
||||
|
||||
/* get the page size and calculate pageshift from it */
|
||||
pagesize = sysconf(_SC_PAGESIZE);
|
||||
pageshift = 0;
|
||||
while (pagesize > 1) {
|
||||
pageshift++;
|
||||
pagesize >>= 1;
|
||||
}
|
||||
|
||||
/* we only need the amount of log(2)1024 for our conversion */
|
||||
pageshift -= LOG1024;
|
||||
|
||||
server->sysdeps.mem = _glibtop_sysdeps_mem;
|
||||
}
|
||||
|
||||
void
|
||||
glibtop_get_mem_s (glibtop *server, glibtop_mem *buf)
|
||||
{
|
||||
struct uvmexp uvmexp;
|
||||
struct bcachestats bcstats;
|
||||
size_t length;
|
||||
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_MEM), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_mem));
|
||||
|
||||
if (server->sysdeps.mem == 0)
|
||||
return;
|
||||
|
||||
/* Get the data from sysctl */
|
||||
length = sizeof (uvmexp);
|
||||
if (sysctl (uvmexp_mib, 2, &uvmexp, &length, NULL, 0)) {
|
||||
glibtop_warn_io_r (server, "sysctl (vm.uvmexp)");
|
||||
bzero(&uvmexp, sizeof(length));
|
||||
return;
|
||||
}
|
||||
|
||||
length = sizeof (bcstats);
|
||||
if (sysctl (bcstats_mib, 3, &bcstats, &length, NULL, 0)) {
|
||||
glibtop_warn_io_r (server, "sysctl (vfs.generic.bcstats)");
|
||||
bzero(&bcstats, sizeof(length));
|
||||
return;
|
||||
}
|
||||
|
||||
/* convert memory stats to Kbytes */
|
||||
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 (0 /* XXX */) << LOG1024;
|
||||
buf->cached = (guint64) pagetok (bcstats.numbufpages) << LOG1024;
|
||||
buf->buffer = 0;
|
||||
|
||||
buf->user = buf->total - buf->free - buf->cached - buf->buffer;
|
||||
|
||||
/* Set the values to return */
|
||||
buf->flags = _glibtop_sysdeps_mem;
|
||||
}
|
||||
168
sysdeps/openbsd/mountlist.c
Normal file
168
sysdeps/openbsd/mountlist.c
Normal 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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);
|
||||
}
|
||||
94
sysdeps/openbsd/msg_limits.c
Normal file
94
sysdeps/openbsd/msg_limits.c
Normal file
@@ -0,0 +1,94 @@
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, August 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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/msg_limits.h>
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
/* Define the appropriate macro (if any) to get declaration of `struct
|
||||
* msginfo'. Needed on, at least, FreeBSD. */
|
||||
#if defined (STRUCT_MSGINFO_NEEDS_KERNEL)
|
||||
#define KERNEL 1
|
||||
#elif defined (STRUCT_MSGINFO_NEEDS__KERNEL)
|
||||
#define _KERNEL 1
|
||||
#endif
|
||||
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/msg.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_msg_limits =
|
||||
(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'
|
||||
* since `msginfo' is already declared external in <sys/msg.h>. */
|
||||
static struct msginfo _msginfo;
|
||||
|
||||
/* nlist structure for kernel access */
|
||||
static struct nlist nlst [] = {
|
||||
{ "_msginfo" },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
_glibtop_init_msg_limits_p (glibtop *server)
|
||||
{
|
||||
if (kvm_nlist (server->machine->kd, nlst) < 0) {
|
||||
glibtop_warn_io_r (server, "kvm_nlist (msg_limits)");
|
||||
return;
|
||||
}
|
||||
|
||||
if (kvm_read (server->machine->kd, nlst [0].n_value,
|
||||
&_msginfo, sizeof (_msginfo)) != sizeof (_msginfo)) {
|
||||
glibtop_warn_io_r (server, "kvm_read (msginfo)");
|
||||
return;
|
||||
}
|
||||
|
||||
server->sysdeps.msg_limits = _glibtop_sysdeps_msg_limits;
|
||||
}
|
||||
|
||||
/* Provides information about sysv ipc limits. */
|
||||
|
||||
void
|
||||
glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf)
|
||||
{
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_MSG_LIMITS), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_msg_limits));
|
||||
|
||||
if (server->sysdeps.msg_limits == 0)
|
||||
return;
|
||||
|
||||
buf->msgmax = _msginfo.msgmax;
|
||||
buf->msgmni = _msginfo.msgmni;
|
||||
buf->msgmnb = _msginfo.msgmnb;
|
||||
buf->msgtql = _msginfo.msgtql;
|
||||
buf->msgssz = _msginfo.msgtql;
|
||||
|
||||
buf->flags = _glibtop_sysdeps_msg_limits;
|
||||
}
|
||||
66
sysdeps/openbsd/netlist.c
Normal file
66
sysdeps/openbsd/netlist.c
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
This file is part of LibGTop 2.0.
|
||||
|
||||
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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop/netlist.h>
|
||||
#include <glibtop/error.h>
|
||||
|
||||
#include <net/if.h>
|
||||
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_netlist = (1 << GLIBTOP_NETLIST_NUMBER);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
_glibtop_init_netlist_s (glibtop *server)
|
||||
{
|
||||
server->sysdeps.netlist = _glibtop_sysdeps_netlist;
|
||||
}
|
||||
|
||||
|
||||
char**
|
||||
glibtop_get_netlist_s (glibtop *server, glibtop_netlist *buf)
|
||||
{
|
||||
struct if_nameindex *ifstart, *ifs;
|
||||
GPtrArray *devices;
|
||||
|
||||
glibtop_init_s (&server, GLIBTOP_SYSDEPS_NETLIST, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_netlist));
|
||||
|
||||
ifs = ifstart = if_nameindex();
|
||||
|
||||
devices = g_ptr_array_new();
|
||||
|
||||
while(ifs && ifs->if_name) {
|
||||
g_ptr_array_add(devices, g_strdup(ifs->if_name));
|
||||
buf->number++;
|
||||
ifs++;
|
||||
}
|
||||
|
||||
if_freenameindex(ifstart);
|
||||
|
||||
buf->flags = _glibtop_sysdeps_netlist;
|
||||
|
||||
g_ptr_array_add(devices, NULL);
|
||||
|
||||
return (char **) g_ptr_array_free(devices, FALSE);
|
||||
}
|
||||
|
||||
237
sysdeps/openbsd/netload.c
Normal file
237
sysdeps/openbsd/netload.c
Normal file
@@ -0,0 +1,237 @@
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, October 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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/netload.h>
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/if_types.h>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <net/if_var.h>
|
||||
|
||||
#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) +
|
||||
(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);
|
||||
|
||||
static const unsigned _glibtop_sysdeps_netload_data =
|
||||
(1L << GLIBTOP_NETLOAD_ADDRESS) +
|
||||
(1L << GLIBTOP_NETLOAD_SUBNET) +
|
||||
(1L << GLIBTOP_NETLOAD_MTU);
|
||||
|
||||
/* nlist structure for kernel access */
|
||||
static struct nlist nlst [] = {
|
||||
{ "_ifnet" },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
_glibtop_init_netload_p (glibtop *server)
|
||||
{
|
||||
server->sysdeps.netload = _glibtop_sysdeps_netload;
|
||||
|
||||
if (kvm_nlist (server->machine->kd, nlst) < 0)
|
||||
glibtop_error_io_r (server, "kvm_nlist");
|
||||
}
|
||||
|
||||
/* Provides Network statistics. */
|
||||
|
||||
void
|
||||
glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
|
||||
const char *interface)
|
||||
{
|
||||
struct ifnet ifnet;
|
||||
u_long ifnetaddr, ifnetfound;
|
||||
struct sockaddr *sa = NULL;
|
||||
char name [32];
|
||||
|
||||
union {
|
||||
struct ifaddr ifa;
|
||||
struct in_ifaddr in;
|
||||
} ifaddr;
|
||||
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_NETLOAD), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_netload));
|
||||
|
||||
if (kvm_read (server->machine->kd, nlst [0].n_value,
|
||||
&ifnetaddr, sizeof (ifnetaddr)) != sizeof (ifnetaddr))
|
||||
glibtop_error_io_r (server, "kvm_read (ifnet)");
|
||||
|
||||
while (ifnetaddr) {
|
||||
struct sockaddr_in *sin;
|
||||
register char *cp;
|
||||
u_long ifaddraddr;
|
||||
|
||||
{
|
||||
ifnetfound = ifnetaddr;
|
||||
|
||||
if (kvm_read (server->machine->kd, ifnetaddr, &ifnet,
|
||||
sizeof (ifnet)) != sizeof (ifnet))
|
||||
glibtop_error_io_r (server, "kvm_read (ifnetaddr)");
|
||||
|
||||
g_strlcpy (name, ifnet.if_xname, sizeof(name));
|
||||
ifnetaddr = (u_long) ifnet.if_list.tqe_next;
|
||||
|
||||
if (strcmp (name, interface) != 0)
|
||||
continue;
|
||||
|
||||
ifaddraddr = (u_long) ifnet.if_addrlist.tqh_first;
|
||||
}
|
||||
if (ifnet.if_flags & IFF_UP)
|
||||
buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_UP);
|
||||
if (ifnet.if_flags & IFF_BROADCAST)
|
||||
buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_BROADCAST);
|
||||
if (ifnet.if_flags & IFF_DEBUG)
|
||||
buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_DEBUG);
|
||||
if (ifnet.if_flags & IFF_LOOPBACK)
|
||||
buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_LOOPBACK);
|
||||
if (ifnet.if_flags & IFF_POINTOPOINT)
|
||||
buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_POINTOPOINT);
|
||||
#ifdef IFF_DRV_RUNNING
|
||||
if (ifnet.if_drv_flags & IFF_DRV_RUNNING)
|
||||
#else
|
||||
if (ifnet.if_flags & IFF_RUNNING)
|
||||
#endif
|
||||
buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_RUNNING);
|
||||
if (ifnet.if_flags & IFF_NOARP)
|
||||
buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_NOARP);
|
||||
if (ifnet.if_flags & IFF_PROMISC)
|
||||
buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_PROMISC);
|
||||
if (ifnet.if_flags & IFF_ALLMULTI)
|
||||
buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_ALLMULTI);
|
||||
#ifdef IFF_DRV_OACTIVE
|
||||
if (ifnet.if_drv_flags & IFF_DRV_OACTIVE)
|
||||
#else
|
||||
if (ifnet.if_flags & IFF_OACTIVE)
|
||||
#endif
|
||||
buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_OACTIVE);
|
||||
if (ifnet.if_flags & IFF_SIMPLEX)
|
||||
buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_SIMPLEX);
|
||||
if (ifnet.if_flags & IFF_LINK0)
|
||||
buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_LINK0);
|
||||
if (ifnet.if_flags & IFF_LINK1)
|
||||
buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_LINK1);
|
||||
if (ifnet.if_flags & IFF_LINK2)
|
||||
buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_LINK2);
|
||||
if (ifnet.if_flags & IFF_MULTICAST)
|
||||
buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_MULTICAST);
|
||||
|
||||
buf->packets_in = ifnet.if_ipackets;
|
||||
buf->packets_out = ifnet.if_opackets;
|
||||
buf->packets_total = buf->packets_in + buf->packets_out;
|
||||
|
||||
buf->bytes_in = ifnet.if_ibytes;
|
||||
buf->bytes_out = ifnet.if_obytes;
|
||||
buf->bytes_total = buf->bytes_in + buf->bytes_out;
|
||||
|
||||
buf->errors_in = ifnet.if_ierrors;
|
||||
buf->errors_out = ifnet.if_oerrors;
|
||||
buf->errors_total = buf->errors_in + buf->errors_out;
|
||||
|
||||
buf->collisions = ifnet.if_collisions;
|
||||
buf->flags = _glibtop_sysdeps_netload;
|
||||
|
||||
while (ifaddraddr) {
|
||||
if ((kvm_read (server->machine->kd, ifaddraddr, &ifaddr,
|
||||
sizeof (ifaddr)) != sizeof (ifaddr)))
|
||||
glibtop_error_io_r (server, "kvm_read (ifaddraddr)");
|
||||
|
||||
#define CP(x) ((char *)(x))
|
||||
cp = (CP(ifaddr.ifa.ifa_addr) - CP(ifaddraddr)) +
|
||||
CP(&ifaddr);
|
||||
sa = (struct sockaddr *)cp;
|
||||
|
||||
if (sa->sa_family == AF_LINK) {
|
||||
struct sockaddr_dl *dl = (struct sockaddr_dl *) sa;
|
||||
|
||||
memcpy (buf->hwaddress, LLADDR (dl), sizeof (buf->hwaddress));
|
||||
buf->flags |= (1L << GLIBTOP_NETLOAD_HWADDRESS);
|
||||
} else if (sa->sa_family == AF_INET) {
|
||||
sin = (struct sockaddr_in *)sa;
|
||||
buf->subnet = ifaddr.in.ia_netmask;
|
||||
buf->address = sin->sin_addr.s_addr;
|
||||
buf->mtu = ifnet.if_mtu;
|
||||
|
||||
buf->flags |= _glibtop_sysdeps_netload_data;
|
||||
} else if (sa->sa_family == AF_INET6) {
|
||||
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) sa;
|
||||
int in6fd;
|
||||
|
||||
memcpy (buf->address6, &sin6->sin6_addr,
|
||||
sizeof (buf->address6));
|
||||
buf->flags |= (1L << GLIBTOP_NETLOAD_ADDRESS6);
|
||||
|
||||
if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
|
||||
sin6->sin6_scope_id =
|
||||
ntohs(*(u_int16_t *)&sin6->sin6_addr.s6_addr[2]);
|
||||
sin6->sin6_addr.s6_addr[2] = sin6->sin6_addr.s6_addr[3] = 0;
|
||||
}
|
||||
|
||||
buf->scope6 = (guint8) sin6->sin6_scope_id;
|
||||
buf->flags |= (1L << GLIBTOP_NETLOAD_SCOPE6);
|
||||
|
||||
in6fd = socket (AF_INET6, SOCK_DGRAM, 0);
|
||||
if (in6fd >= 0) {
|
||||
struct in6_ifreq ifr;
|
||||
|
||||
memset (&ifr, 0, sizeof (ifr));
|
||||
ifr.ifr_addr = *sin6;
|
||||
g_strlcpy (ifr.ifr_name, interface,
|
||||
sizeof (ifr.ifr_name));
|
||||
if (ioctl (in6fd, SIOCGIFNETMASK_IN6, (char *) &ifr) >= 0) {
|
||||
memcpy (buf->prefix6, &ifr.ifr_addr.sin6_addr,
|
||||
sizeof (buf->prefix6));
|
||||
buf->flags |= (1L << GLIBTOP_NETLOAD_PREFIX6);
|
||||
}
|
||||
close (in6fd);
|
||||
}
|
||||
}
|
||||
ifaddraddr = (u_long) ifaddr.ifa.ifa_list.tqe_next;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
28
sysdeps/openbsd/nosuid.c
Normal file
28
sysdeps/openbsd/nosuid.c
Normal file
@@ -0,0 +1,28 @@
|
||||
/* 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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/close.h>
|
||||
|
||||
void
|
||||
glibtop_close_s (glibtop *server)
|
||||
{ }
|
||||
58
sysdeps/openbsd/open.c
Normal file
58
sysdeps/openbsd/open.c
Normal file
@@ -0,0 +1,58 @@
|
||||
/* 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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/open.h>
|
||||
#include <glibtop/cpu.h>
|
||||
#include <glibtop/error.h>
|
||||
|
||||
#include <glibtop_private.h>
|
||||
|
||||
|
||||
void
|
||||
glibtop_open_s (glibtop *server, const char *program_name,
|
||||
const unsigned long features,
|
||||
const unsigned flags)
|
||||
{
|
||||
int ncpus = 1;
|
||||
int mib[2] = { CTL_HW, HW_NCPU };
|
||||
size_t len;
|
||||
|
||||
len = sizeof(ncpus);
|
||||
if (sysctl(mib, 2, &ncpus, &len, NULL, 0) != 0)
|
||||
printf("Couldn't determine hw.ncpu.\n");
|
||||
|
||||
server->real_ncpu = ncpus - 1;
|
||||
server->ncpu = MIN(GLIBTOP_NCPU - 1, server->real_ncpu);
|
||||
|
||||
server->os_version_code = OpenBSD;
|
||||
|
||||
if (server->real_ncpu != server->ncpu) {
|
||||
glibtop_warn_r(server,
|
||||
"This machine has %d CPUs, "
|
||||
"%d are being monitored.",
|
||||
server->real_ncpu + 1,
|
||||
server->ncpu + 1);
|
||||
}
|
||||
}
|
||||
139
sysdeps/openbsd/ppp.c
Normal file
139
sysdeps/openbsd/ppp.c
Normal file
@@ -0,0 +1,139 @@
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, October 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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/ppp.h>
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
#ifdef HAVE_I4B
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_types.h>
|
||||
|
||||
#ifdef HAVE_NET_IF_VAR_H
|
||||
#include <net/if_var.h>
|
||||
#endif
|
||||
|
||||
#include <net/netisr.h>
|
||||
#include <net/route.h>
|
||||
|
||||
#include <net/if_sppp.h>
|
||||
|
||||
/* Read `misc/i4b_acct.txt' for details ... */
|
||||
#ifdef HAVE_I4B_ACCT
|
||||
#include <machine/i4b_acct.h>
|
||||
#endif
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_ppp =
|
||||
(1L << GLIBTOP_PPP_STATE);
|
||||
|
||||
#ifdef HAVE_I4B_ACCT
|
||||
static const unsigned long _glibtop_sysdeps_ppp_acct =
|
||||
(1L << GLIBTOP_PPP_BYTES_IN) + (1L << GLIBTOP_PPP_BYTES_OUT);
|
||||
#endif
|
||||
|
||||
#endif /* HAVE_I4B */
|
||||
|
||||
/* nlist structure for kernel access */
|
||||
static struct nlist nlst [] = {
|
||||
#ifdef HAVE_I4B
|
||||
{ "_i4bisppp_softc" },
|
||||
#endif
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
_glibtop_init_ppp_p (glibtop *server)
|
||||
{
|
||||
#ifdef HAVE_I4B
|
||||
#ifdef HAVE_I4B_ACCT
|
||||
server->sysdeps.ppp = _glibtop_sysdeps_ppp |
|
||||
_glibtop_sysdeps_ppp_acct;
|
||||
#else
|
||||
server->sysdeps.ppp = _glibtop_sysdeps_ppp;
|
||||
#endif
|
||||
#endif /* HAVE_I4B */
|
||||
|
||||
if (kvm_nlist (server->machine->kd, nlst) < 0)
|
||||
glibtop_error_io_r (server, "kvm_nlist");
|
||||
}
|
||||
|
||||
/* Provides information about ppp usage. */
|
||||
|
||||
void
|
||||
glibtop_get_ppp_p (glibtop *server, glibtop_ppp *buf, unsigned short device)
|
||||
{
|
||||
#ifdef HAVE_I4B
|
||||
#ifdef HAVE_I4B_ACCT
|
||||
struct i4bisppp_softc data;
|
||||
#else
|
||||
struct sppp data;
|
||||
#endif
|
||||
int phase;
|
||||
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PPP), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_ppp));
|
||||
|
||||
if (kvm_read (server->machine->kd, nlst [0].n_value,
|
||||
&data, sizeof (data)) != sizeof (data))
|
||||
glibtop_error_io_r (server, "kvm_read (i4bisppp_softc)");
|
||||
|
||||
#ifdef HAVE_I4B_ACCT
|
||||
phase = data.sc_if_un.scu_sp.pp_phase;
|
||||
#else
|
||||
/* FIXME: Which FreeBSD version have this field and
|
||||
* which not. */
|
||||
#if 0
|
||||
phase = data.pp_phase;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
switch (phase) {
|
||||
#ifdef HAVE_I4B_ACCT
|
||||
case PHASE_DEAD:
|
||||
case PHASE_TERMINATE:
|
||||
buf->state = GLIBTOP_PPP_STATE_HANGUP;
|
||||
break;
|
||||
case PHASE_ESTABLISH:
|
||||
case PHASE_NETWORK:
|
||||
buf->state = GLIBTOP_PPP_STATE_ONLINE;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
buf->state = GLIBTOP_PPP_STATE_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
|
||||
buf->flags = _glibtop_sysdeps_ppp;
|
||||
|
||||
#ifdef HAVE_I4B_ACCT
|
||||
buf->bytes_in = data.sc_inb;
|
||||
buf->bytes_out = data.sc_outb;
|
||||
buf->flags |= _glibtop_sysdeps_ppp_acct;
|
||||
#endif
|
||||
#endif /* HAVE_I4B */
|
||||
}
|
||||
26
sysdeps/openbsd/procaffinity.c
Normal file
26
sysdeps/openbsd/procaffinity.c
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* TODO (procaffinity stub)
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop/procaffinity.h>
|
||||
#include <glibtop/error.h>
|
||||
|
||||
|
||||
void
|
||||
_glibtop_init_proc_affinity_s(glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_affinity =
|
||||
(1 << GLIBTOP_PROC_AFFINITY_NUMBER) |
|
||||
(1 << GLIBTOP_PROC_AFFINITY_ALL);
|
||||
|
||||
}
|
||||
|
||||
|
||||
guint16 *
|
||||
glibtop_get_proc_affinity_s(glibtop *server, glibtop_proc_affinity *buf, pid_t pid)
|
||||
{
|
||||
memset(buf, 0, sizeof *buf);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
99
sysdeps/openbsd/procargs.c
Normal file
99
sysdeps/openbsd/procargs.c
Normal file
@@ -0,0 +1,99 @@
|
||||
/* 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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/procargs.h>
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
#include <kvm.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/proc.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_args =
|
||||
(1L << GLIBTOP_PROC_ARGS_SIZE);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
_glibtop_init_proc_args_p (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_args = _glibtop_sysdeps_proc_args;
|
||||
}
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
char *
|
||||
glibtop_get_proc_args_p (glibtop *server, glibtop_proc_args *buf,
|
||||
pid_t pid, unsigned max_len)
|
||||
{
|
||||
struct kinfo_proc *pinfo;
|
||||
char *retval, **args, **ptr;
|
||||
size_t size = 0, pos = 0;
|
||||
int count;
|
||||
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_ARGS), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_args));
|
||||
|
||||
/* Ignore init */
|
||||
if (pid < 2) return NULL;
|
||||
|
||||
glibtop_suid_enter (server);
|
||||
|
||||
/* Get the process data */
|
||||
pinfo = kvm_getprocs (server->machine->kd, KERN_PROC_PID, pid,
|
||||
sizeof (*pinfo), &count);
|
||||
if (pinfo == NULL) {
|
||||
glibtop_suid_leave (server);
|
||||
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
args = kvm_getargv (server->machine->kd, pinfo, max_len);
|
||||
if (args == NULL) {
|
||||
glibtop_suid_leave (server);
|
||||
glibtop_warn_io_r (server, "kvm_getargv (%d)", pid);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
glibtop_suid_leave (server);
|
||||
|
||||
for (ptr = args; *ptr; ptr++)
|
||||
size += strlen (*ptr)+1;
|
||||
|
||||
size += 2;
|
||||
retval = g_malloc0 (size);
|
||||
|
||||
for (ptr = args; *ptr; ptr++) {
|
||||
const size_t len = strlen (*ptr)+1;
|
||||
memcpy (retval+pos, *ptr, len);
|
||||
pos += len;
|
||||
}
|
||||
|
||||
buf->size = pos ? pos-1 : 0;
|
||||
|
||||
buf->flags = _glibtop_sysdeps_proc_args;
|
||||
|
||||
return retval;
|
||||
}
|
||||
107
sysdeps/openbsd/prockernel.c
Normal file
107
sysdeps/openbsd/prockernel.c
Normal file
@@ -0,0 +1,107 @@
|
||||
/* 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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/prockernel.h>
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
#include <kvm.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/proc.h>
|
||||
#include <unistd.h>
|
||||
#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_WCHAN) +
|
||||
(1L << GLIBTOP_PROC_KERNEL_NWCHAN);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
_glibtop_init_proc_kernel_p (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_kernel = _glibtop_sysdeps_proc_kernel_pstats |
|
||||
_glibtop_sysdeps_proc_kernel_wchan;
|
||||
}
|
||||
|
||||
void
|
||||
glibtop_get_proc_kernel_p (glibtop *server,
|
||||
glibtop_proc_kernel *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
struct kinfo_proc *pinfo;
|
||||
int count;
|
||||
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_KERNEL), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_kernel));
|
||||
|
||||
if (server->sysdeps.proc_time == 0)
|
||||
return;
|
||||
|
||||
/* 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) {
|
||||
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
|
||||
glibtop_suid_leave (server);
|
||||
return;
|
||||
}
|
||||
|
||||
glibtop_suid_leave (server);
|
||||
|
||||
#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;
|
||||
}
|
||||
106
sysdeps/openbsd/proclist.c
Normal file
106
sysdeps/openbsd/proclist.c
Normal file
@@ -0,0 +1,106 @@
|
||||
/* 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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/proclist.h>
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proclist =
|
||||
(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:
|
||||
* buf->flags is only set if the call succeeded, in this case pids_chain,
|
||||
* a list of the pids of all currently running processes is returned,
|
||||
* buf->number is the number of elements of this list and buf->size is
|
||||
* the size of one single element (sizeof (unsigned)). The total size is
|
||||
* stored in buf->total.
|
||||
*
|
||||
* The calling function has to free the memory to which a pointer is returned.
|
||||
*
|
||||
* IMPORTANT NOTE:
|
||||
* On error, this function MUST return NULL and set buf->flags to zero !
|
||||
* On success, it returnes a pointer to a list of buf->number elements
|
||||
* each buf->size big. The total size is stored in buf->total.
|
||||
* The calling function has to free the memory to which a pointer is returned.
|
||||
*
|
||||
* On error, NULL is returned and buf->flags is zero. */
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
_glibtop_init_proclist_p (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proclist = _glibtop_sysdeps_proclist;
|
||||
}
|
||||
|
||||
pid_t *
|
||||
glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf,
|
||||
gint64 real_which, gint64 arg)
|
||||
{
|
||||
struct kinfo_proc *pinfo;
|
||||
unsigned *pids = NULL;
|
||||
int which, count;
|
||||
int i,j;
|
||||
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROCLIST), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proclist));
|
||||
|
||||
which = (int)(real_which & GLIBTOP_KERN_PROC_MASK);
|
||||
|
||||
/* Get the process data */
|
||||
pinfo = kvm_getprocs (server->machine->kd, which, arg,
|
||||
sizeof (*pinfo), &count);
|
||||
if ((pinfo == NULL) || (count < 1)) {
|
||||
glibtop_warn_io_r (server, "kvm_getprocs (proclist)");
|
||||
return NULL;
|
||||
}
|
||||
count--;
|
||||
|
||||
/* Allocate count objects in the pids_chain array
|
||||
* Same as malloc is pids is NULL, which it is. */
|
||||
pids = g_realloc (pids, count * sizeof (unsigned));
|
||||
/* Copy the pids over to this chain */
|
||||
for (i=j=0; i < count; i++) {
|
||||
#define PROC_STAT p_stat
|
||||
#define PROC_RUID p_ruid
|
||||
#define PROC_PID p_pid
|
||||
|
||||
if ((real_which & GLIBTOP_EXCLUDE_IDLE) &&
|
||||
(pinfo[i].PROC_STAT != SRUN))
|
||||
continue;
|
||||
else if ((real_which & GLIBTOP_EXCLUDE_SYSTEM) &&
|
||||
(pinfo[i].PROC_RUID == 0))
|
||||
continue;
|
||||
pids [j++] = (unsigned) pinfo[i].PROC_PID;
|
||||
} /* end for */
|
||||
/* Set the fields in buf */
|
||||
buf->number = j;
|
||||
buf->size = sizeof (unsigned);
|
||||
buf->total = j * sizeof (unsigned);
|
||||
buf->flags = _glibtop_sysdeps_proclist;
|
||||
return pids;
|
||||
}
|
||||
313
sysdeps/openbsd/procmap.c
Normal file
313
sysdeps/openbsd/procmap.c
Normal file
@@ -0,0 +1,313 @@
|
||||
/* 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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/procmap.h>
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
#include <kvm.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/resource.h>
|
||||
#include <uvm/uvm_extern.h>
|
||||
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/mount.h>
|
||||
#include <ufs/ufs/quota.h>
|
||||
#include <ufs/ufs/inode.h>
|
||||
|
||||
#include <sys/ucred.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
/* XXX until uvm gets cleaned up */
|
||||
#include <sys/mutex.h>
|
||||
typedef int boolean_t;
|
||||
|
||||
#undef _KERNEL
|
||||
#define _UVM_UVM_AMAP_I_H_ 1
|
||||
#define _UVM_UVM_MAP_I_H_ 1
|
||||
#include <uvm/uvm.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_map =
|
||||
(1L << GLIBTOP_PROC_MAP_TOTAL) + (1L << GLIBTOP_PROC_MAP_NUMBER) +
|
||||
(1L << GLIBTOP_PROC_MAP_SIZE);
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_map_entry =
|
||||
(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);
|
||||
|
||||
/* Local helper functions. */
|
||||
|
||||
ssize_t load_vmmap_entries(glibtop*, unsigned long, struct vm_map_entry**,
|
||||
struct vm_map_entry*);
|
||||
void unload_vmmap_entries(struct vm_map_entry *);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
_glibtop_init_proc_map_p (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_map = _glibtop_sysdeps_proc_map;
|
||||
}
|
||||
|
||||
/*
|
||||
* Download vmmap_entries from the kernel into our address space.
|
||||
* We fix up the addr tree while downloading.
|
||||
*
|
||||
* Returns: the size of the tree on succes, or -1 on failure.
|
||||
* On failure, *rptr needs to be passed to unload_vmmap_entries to free
|
||||
* the lot.
|
||||
*/
|
||||
ssize_t
|
||||
load_vmmap_entries(glibtop *server, unsigned long kptr,
|
||||
struct vm_map_entry **rptr, struct vm_map_entry *parent)
|
||||
{
|
||||
struct vm_map_entry *entry;
|
||||
unsigned long left_kptr, right_kptr;
|
||||
ssize_t left_sz;
|
||||
ssize_t right_sz;
|
||||
|
||||
if (kptr == 0)
|
||||
return 0;
|
||||
|
||||
/* Need space. */
|
||||
entry = malloc(sizeof(*entry));
|
||||
if (entry == NULL)
|
||||
return -1;
|
||||
|
||||
/* Download entry at kptr. */
|
||||
if (kvm_read (server->machine->kd, kptr,
|
||||
(char *)entry, sizeof(*entry)) != sizeof(*entry)) {
|
||||
free(entry);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Update addr pointers to have sane values in this address space.
|
||||
* We save the kernel pointers in {left,right}_kptr, so we have them
|
||||
* available to download children.
|
||||
*/
|
||||
left_kptr = (unsigned long) RB_LEFT(entry, daddrs.addr_entry);
|
||||
right_kptr = (unsigned long) RB_RIGHT(entry, daddrs.addr_entry);
|
||||
RB_LEFT(entry, daddrs.addr_entry) =
|
||||
RB_RIGHT(entry, daddrs.addr_entry) = NULL;
|
||||
/* Fill in parent pointer. */
|
||||
RB_PARENT(entry, daddrs.addr_entry) = parent;
|
||||
|
||||
/*
|
||||
* Consistent state reached, fill in *rptr.
|
||||
*/
|
||||
*rptr = entry;
|
||||
|
||||
/*
|
||||
* Download left, right.
|
||||
* On failure, our map is in a state that can be handled by
|
||||
* unload_vmmap_entries.
|
||||
*/
|
||||
left_sz = load_vmmap_entries(server, left_kptr,
|
||||
&RB_LEFT(entry, daddrs.addr_entry), entry);
|
||||
if (left_sz == -1)
|
||||
return -1;
|
||||
right_sz = load_vmmap_entries(server, right_kptr,
|
||||
&RB_RIGHT(entry, daddrs.addr_entry), entry);
|
||||
if (right_sz == -1)
|
||||
return -1;
|
||||
|
||||
return 1 + left_sz + right_sz;
|
||||
}
|
||||
|
||||
/*
|
||||
* Free the vmmap entries in the given tree.
|
||||
*/
|
||||
void
|
||||
unload_vmmap_entries(struct vm_map_entry *entry)
|
||||
{
|
||||
if (entry == NULL)
|
||||
return;
|
||||
|
||||
unload_vmmap_entries(RB_LEFT(entry, daddrs.addr_entry));
|
||||
unload_vmmap_entries(RB_RIGHT(entry, daddrs.addr_entry));
|
||||
free(entry);
|
||||
}
|
||||
|
||||
/*
|
||||
* Provides detailed information about a process.
|
||||
* Due to the fact we are only requested info about one process, it's possible
|
||||
* the process has been reaped before we get to kvm_getprocs. Tough luck.
|
||||
*/
|
||||
|
||||
glibtop_map_entry *
|
||||
glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
struct kinfo_proc *pinfo;
|
||||
struct vm_map_entry *entry;
|
||||
struct uvm_map_addr root;
|
||||
struct vmspace vmspace;
|
||||
struct vnode vnode;
|
||||
struct inode inode;
|
||||
ssize_t nentries;
|
||||
GArray *maps = g_array_sized_new(FALSE, FALSE,
|
||||
sizeof(glibtop_map_entry),
|
||||
100);
|
||||
int count = 0;
|
||||
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_MAP), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_map));
|
||||
|
||||
/* It does not work for the swapper task. */
|
||||
if (pid == 0) return (glibtop_map_entry*) g_array_free(maps, TRUE);
|
||||
|
||||
glibtop_suid_enter (server);
|
||||
|
||||
/* Get the process data */
|
||||
pinfo = kvm_getprocs (server->machine->kd, KERN_PROC_PID, pid, sizeof(struct kinfo_proc), &count);
|
||||
if (pinfo == NULL) {
|
||||
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
|
||||
return (glibtop_map_entry*) g_array_free(maps, TRUE);
|
||||
}
|
||||
|
||||
/* Now we get the memory maps. */
|
||||
|
||||
if (kvm_read (server->machine->kd,
|
||||
(unsigned long) pinfo [0].p_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,
|
||||
(unsigned long) RB_ROOT(&vmspace.vm_map.addr),
|
||||
&RB_ROOT(&root), NULL);
|
||||
if (nentries == -1) {
|
||||
unload_vmmap_entries(RB_ROOT(&root));
|
||||
glibtop_error_io_r (server, "kvm_read (entry)");
|
||||
}
|
||||
|
||||
/* Allocate space. */
|
||||
|
||||
buf->number = nentries;
|
||||
buf->size = sizeof (glibtop_map_entry);
|
||||
|
||||
buf->total = buf->number * buf->size;
|
||||
|
||||
buf->flags = _glibtop_sysdeps_proc_map;
|
||||
|
||||
/* Walk through the `vm_map_entry' list ... */
|
||||
|
||||
/* I tested this a few times with `mmap'; as soon as you write
|
||||
* to the mmap'ed area, the object type changes from OBJT_VNODE
|
||||
* to OBJT_DEFAULT so it seems this really works.
|
||||
*/
|
||||
|
||||
RB_FOREACH(entry, uvm_map_addr, &root) {
|
||||
glibtop_map_entry *mentry;
|
||||
unsigned long inum, dev;
|
||||
guint len;
|
||||
|
||||
if (UVM_ET_ISSUBMAP(entry))
|
||||
continue;
|
||||
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)");
|
||||
unload_vmmap_entries(RB_ROOT(&root));
|
||||
glibtop_suid_leave (server);
|
||||
return (glibtop_map_entry*) g_array_free(maps, TRUE);
|
||||
}
|
||||
|
||||
#if defined(UVM_VNODE_VALID)
|
||||
if (!vnode.v_uvm.u_flags & UVM_VNODE_VALID)
|
||||
continue;
|
||||
#endif
|
||||
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_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;
|
||||
|
||||
len = maps->len;
|
||||
g_array_set_size(maps, len + 1);
|
||||
mentry = &g_array_index(maps, glibtop_map_entry, len);
|
||||
|
||||
mentry->flags = _glibtop_sysdeps_map_entry;
|
||||
|
||||
mentry->start = (guint64) entry->start;
|
||||
mentry->end = (guint64) entry->end;
|
||||
mentry->offset = (guint64) entry->offset;
|
||||
mentry->device = (guint64) dev;
|
||||
mentry->inode = (guint64) inum;
|
||||
|
||||
mentry->perm = (guint64) 0;
|
||||
|
||||
if (entry->protection & PROT_READ)
|
||||
mentry->perm |= GLIBTOP_MAP_PERM_READ;
|
||||
if (entry->protection & PROT_WRITE)
|
||||
mentry->perm |= GLIBTOP_MAP_PERM_WRITE;
|
||||
if (entry->protection & PROT_EXEC)
|
||||
mentry->perm |= GLIBTOP_MAP_PERM_EXECUTE;
|
||||
}
|
||||
|
||||
glibtop_suid_leave (server);
|
||||
|
||||
buf->flags = _glibtop_sysdeps_proc_map;
|
||||
|
||||
buf->number = maps->len;
|
||||
buf->size = sizeof (glibtop_map_entry);
|
||||
buf->total = buf->number * buf->size;
|
||||
|
||||
unload_vmmap_entries(RB_ROOT(&root));
|
||||
return (glibtop_map_entry*) g_array_free(maps, FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Don't implement address comparison.
|
||||
*/
|
||||
static __inline int
|
||||
no_impl(void *p, void *q)
|
||||
{
|
||||
abort(); /* Should not be called. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
RB_GENERATE(uvm_map_addr, vm_map_entry, daddrs.addr_entry, no_impl);
|
||||
136
sysdeps/openbsd/procmem.c
Normal file
136
sysdeps/openbsd/procmem.c
Normal file
@@ -0,0 +1,136 @@
|
||||
/* 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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/procmem.h>
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
#include <kvm.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/resource.h>
|
||||
#include <uvm/uvm_extern.h>
|
||||
|
||||
#include <sys/vnode.h>
|
||||
#include <ufs/ufs/quota.h>
|
||||
#include <ufs/ufs/inode.h>
|
||||
|
||||
#include <sys/ucred.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
/* XXX until uvm gets cleaned up */
|
||||
#include <sys/mutex.h>
|
||||
typedef int boolean_t;
|
||||
#include <uvm/uvm.h>
|
||||
|
||||
/* Fixme ... */
|
||||
#undef _KERNEL
|
||||
#define _UVM_UVM_AMAP_I_H_ 1
|
||||
#define _UVM_UVM_MAP_I_H_ 1
|
||||
#include <uvm/uvm.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_mem =
|
||||
(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 =
|
||||
(1L << GLIBTOP_PROC_MEM_SHARE);
|
||||
|
||||
#ifndef LOG1024
|
||||
#define LOG1024 10
|
||||
#endif
|
||||
|
||||
/* these are for getting the memory statistics */
|
||||
static int pageshift; /* log base 2 of the pagesize */
|
||||
|
||||
/* define pagetok in terms of pageshift */
|
||||
#define pagetok(size) ((size) << pageshift)
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
_glibtop_init_proc_mem_p (glibtop *server)
|
||||
{
|
||||
register int pagesize;
|
||||
|
||||
/* get the page size and calculate pageshift from it */
|
||||
pagesize = sysconf(_SC_PAGESIZE);
|
||||
pageshift = 0;
|
||||
while (pagesize > 1) {
|
||||
pageshift++;
|
||||
pagesize >>= 1;
|
||||
}
|
||||
|
||||
/* we only need the amount of log(2)1024 for our conversion */
|
||||
pageshift -= LOG1024;
|
||||
|
||||
server->sysdeps.proc_mem = _glibtop_sysdeps_proc_mem |
|
||||
_glibtop_sysdeps_proc_mem_share;
|
||||
}
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
void
|
||||
glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
struct kinfo_proc *pinfo;
|
||||
|
||||
int count;
|
||||
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_MEM), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_mem));
|
||||
|
||||
if (server->sysdeps.proc_mem == 0)
|
||||
return;
|
||||
|
||||
/* It does not work for the swapper task. */
|
||||
if (pid == 0) return;
|
||||
|
||||
/* Get the process data */
|
||||
pinfo = kvm_getprocs (server->machine->kd, KERN_PROC_PID, pid,
|
||||
sizeof (*pinfo), &count);
|
||||
if ((pinfo == NULL) || (count < 1)) {
|
||||
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
|
||||
return;
|
||||
}
|
||||
|
||||
buf->rss_rlim = pinfo[0].p_uru_maxrss;
|
||||
buf->vsize = buf->size = (guint64)pagetok
|
||||
(pinfo[0].p_vm_tsize + pinfo[0].p_vm_dsize + pinfo[0].p_vm_ssize)
|
||||
<< LOG1024;
|
||||
buf->resident = buf->rss = (guint64)pagetok
|
||||
(pinfo[0].p_vm_rssize) << LOG1024;
|
||||
|
||||
/* Now we get the shared memory. */
|
||||
|
||||
buf->share = pinfo[0].p_uru_ixrss;
|
||||
|
||||
buf->flags = _glibtop_sysdeps_proc_mem |
|
||||
_glibtop_sysdeps_proc_mem_share;
|
||||
}
|
||||
198
sysdeps/openbsd/procopenfiles.c
Normal file
198
sysdeps/openbsd/procopenfiles.c
Normal file
@@ -0,0 +1,198 @@
|
||||
/* 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.
|
||||
|
||||
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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/procopenfiles.h>
|
||||
#include <sys/types.h>
|
||||
#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>
|
||||
#include <stdlib.h>
|
||||
#include <kvm.h>
|
||||
|
||||
#include "glibtop_private.h"
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_open_files =
|
||||
(1L << GLIBTOP_PROC_OPEN_FILES_NUMBER)|
|
||||
(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
|
||||
_glibtop_init_proc_open_files_s (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_open_files = _glibtop_sysdeps_proc_open_files;
|
||||
}
|
||||
|
||||
static char *
|
||||
addr_to_string(struct kinfo_file *kf)
|
||||
{
|
||||
char *buffer = NULL;
|
||||
struct in_addr faddr;
|
||||
|
||||
memcpy(&faddr, kf->inp_faddru, sizeof(faddr));
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
glibtop_open_files_entry *
|
||||
glibtop_get_proc_open_files_s (glibtop *server, glibtop_proc_open_files *buf, pid_t pid)
|
||||
{
|
||||
struct kinfo_file *kf, *kflast;
|
||||
int cnt;
|
||||
char kbuf[_POSIX2_LINE_MAX];
|
||||
GArray *entries;
|
||||
|
||||
memset(buf, 0, sizeof (glibtop_proc_open_files));
|
||||
|
||||
if ((kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, kbuf)) == NULL)
|
||||
g_warning("%s", kbuf);
|
||||
|
||||
if ((kf = kvm_getfiles(kd, KERN_FILE_BYPID, pid, sizeof(*kf), &cnt)) == NULL)
|
||||
g_warning("%s", kvm_geterr(kd));
|
||||
|
||||
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;
|
||||
buf->size = sizeof(glibtop_open_files_entry);
|
||||
buf->total = buf->number * buf->size;
|
||||
|
||||
return (glibtop_open_files_entry*)g_array_free(entries, FALSE);
|
||||
}
|
||||
77
sysdeps/openbsd/procsegment.c
Normal file
77
sysdeps/openbsd/procsegment.c
Normal file
@@ -0,0 +1,77 @@
|
||||
/* 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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/procsegment.h>
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
#include <kvm.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
void
|
||||
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));
|
||||
|
||||
/* It does not work for the swapper task. */
|
||||
if (pid == 0) return;
|
||||
|
||||
/* Get the process info from the kernel */
|
||||
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;
|
||||
}
|
||||
|
||||
buf->text_rss = pinfo[0].p_vm_tsize * pagesize;
|
||||
buf->data_rss = pinfo[0].p_vm_dsize * pagesize;
|
||||
|
||||
buf->flags = _glibtop_sysdeps_proc_segment;
|
||||
}
|
||||
89
sysdeps/openbsd/procsignal.c
Normal file
89
sysdeps/openbsd/procsignal.c
Normal file
@@ -0,0 +1,89 @@
|
||||
/* 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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/procsignal.h>
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_signal =
|
||||
(1L << GLIBTOP_PROC_SIGNAL_SIGNAL) +
|
||||
(1L << GLIBTOP_PROC_SIGNAL_BLOCKED) +
|
||||
(1L << GLIBTOP_PROC_SIGNAL_SIGIGNORE) +
|
||||
(1L << GLIBTOP_PROC_SIGNAL_SIGCATCH);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
_glibtop_init_proc_signal_p (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_signal = _glibtop_sysdeps_proc_signal;
|
||||
}
|
||||
|
||||
void
|
||||
glibtop_get_proc_signal_p (glibtop *server,
|
||||
glibtop_proc_signal *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
struct kinfo_proc *pinfo;
|
||||
int count = 0;
|
||||
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_SIGNAL), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_signal));
|
||||
|
||||
/* It does not work for the swapper task. */
|
||||
if (pid == 0) return;
|
||||
|
||||
/* Get the process information */
|
||||
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;
|
||||
}
|
||||
|
||||
/* signal: mask of pending signals.
|
||||
* pinfo [0].kp_proc.p_siglist
|
||||
*/
|
||||
buf->signal [0] = pinfo [0].p_siglist;
|
||||
|
||||
/* blocked: mask of blocked signals.
|
||||
* pinfo [0].kp_proc.p_sigmask
|
||||
*/
|
||||
buf->blocked [0] = pinfo [0].p_sigmask;
|
||||
|
||||
/* sigignore: mask of ignored signals.
|
||||
* pinfo [0].kp_proc.p_sigignore
|
||||
*/
|
||||
buf->sigignore [0] = pinfo [0].p_sigignore;
|
||||
|
||||
/* sigcatch: mask of caught signals.
|
||||
* pinfo [0].kp_proc.p_sigcatch
|
||||
*/
|
||||
buf->sigcatch [0] = pinfo [0].p_sigcatch;
|
||||
|
||||
buf->flags = _glibtop_sysdeps_proc_signal;
|
||||
}
|
||||
131
sysdeps/openbsd/procstate.c
Normal file
131
sysdeps/openbsd/procstate.c
Normal file
@@ -0,0 +1,131 @@
|
||||
/* 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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/procstate.h>
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_state =
|
||||
(1L << GLIBTOP_PROC_STATE_CMD) + (1L << GLIBTOP_PROC_STATE_UID) +
|
||||
(1L << GLIBTOP_PROC_STATE_GID);
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_state_new =
|
||||
0;
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
_glibtop_init_proc_state_p (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_state = _glibtop_sysdeps_proc_state |
|
||||
_glibtop_sysdeps_proc_state_new;
|
||||
}
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
void
|
||||
glibtop_get_proc_state_p (glibtop *server,
|
||||
glibtop_proc_state *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
struct kinfo_proc *pinfo;
|
||||
int count = 0;
|
||||
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_STATE), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_state));
|
||||
|
||||
/* It does not work for the swapper task. */
|
||||
if (pid == 0) return;
|
||||
|
||||
/* Get the process information */
|
||||
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;
|
||||
}
|
||||
|
||||
#define PROC_COMM p_comm
|
||||
#define PROC_SVUID p_svuid
|
||||
#define PROC_SVGID p_svgid
|
||||
#define PROC_STAT p_stat
|
||||
|
||||
g_strlcpy (buf->cmd, pinfo [0].PROC_COMM, sizeof buf->cmd);
|
||||
|
||||
buf->uid = pinfo [0].PROC_SVUID;
|
||||
buf->gid = pinfo [0].PROC_SVGID;
|
||||
|
||||
/* Set the flags for the data we're about to return*/
|
||||
buf->flags = _glibtop_sysdeps_proc_state |
|
||||
_glibtop_sysdeps_proc_state_new;
|
||||
|
||||
#if LIBGTOP_VERSION_CODE >= 1001000
|
||||
switch (pinfo [0].PROC_STAT) {
|
||||
case SIDL:
|
||||
buf->state = 0;
|
||||
break;
|
||||
case SRUN:
|
||||
buf->state = GLIBTOP_PROCESS_RUNNING;
|
||||
break;
|
||||
#ifdef SSLEEP
|
||||
case SSLEEP:
|
||||
buf->state = GLIBTOP_PROCESS_INTERRUPTIBLE;
|
||||
break;
|
||||
#endif
|
||||
case SSTOP:
|
||||
buf->state = GLIBTOP_PROCESS_STOPPED;
|
||||
break;
|
||||
case SZOMB:
|
||||
buf->state = GLIBTOP_PROCESS_ZOMBIE;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
#else
|
||||
switch (pinfo [0].PROC_STAT) {
|
||||
case SIDL:
|
||||
buf->state = 'D';
|
||||
break;
|
||||
case SRUN:
|
||||
buf->state = 'R';
|
||||
break;
|
||||
#ifdef SSLEEP
|
||||
case SSLEEP:
|
||||
buf->state = 'S';
|
||||
break;
|
||||
#endif
|
||||
case SSTOP:
|
||||
buf->state = 'T';
|
||||
break;
|
||||
case SZOMB:
|
||||
buf->state = 'Z';
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
buf->flags |= (1L << GLIBTOP_PROC_STATE_STATE);
|
||||
}
|
||||
101
sysdeps/openbsd/proctime.c
Normal file
101
sysdeps/openbsd/proctime.c
Normal file
@@ -0,0 +1,101 @@
|
||||
/* 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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/proctime.h>
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_time =
|
||||
(1L << GLIBTOP_PROC_TIME_RTIME) + (1L << GLIBTOP_PROC_TIME_FREQUENCY);
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_time_user =
|
||||
(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) (((guint64) tv.tv_sec * 1000000) + (guint64) tv.tv_usec)
|
||||
|
||||
static unsigned int clockrate;
|
||||
static int mib [] = { CTL_KERN, KERN_CLOCKRATE };
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
_glibtop_init_proc_time_p (glibtop *server)
|
||||
{
|
||||
struct clockinfo ci;
|
||||
size_t length;
|
||||
length = sizeof (ci);
|
||||
if (sysctl (mib, 2, &ci, &length, NULL, 0) == 0)
|
||||
clockrate = ci.hz;
|
||||
if (!clockrate)
|
||||
clockrate = 1; /* XXX avoid div by 0 later */
|
||||
|
||||
server->sysdeps.proc_time = _glibtop_sysdeps_proc_time |
|
||||
_glibtop_sysdeps_proc_time_user;
|
||||
}
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
void
|
||||
glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
struct kinfo_proc *pinfo;
|
||||
int count;
|
||||
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_TIME), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_time));
|
||||
|
||||
/* It does not work for the swapper task. */
|
||||
if (pid == 0) return;
|
||||
|
||||
|
||||
/* Get the process information */
|
||||
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;
|
||||
}
|
||||
|
||||
buf->rtime = pinfo[0].p_rtime_sec * clockrate
|
||||
+ pinfo[0].p_rtime_usec * clockrate / 1000000;
|
||||
buf->frequency = clockrate;
|
||||
|
||||
buf->flags = _glibtop_sysdeps_proc_time;
|
||||
|
||||
buf->utime = pinfo[0].p_uutime_sec * 1000000
|
||||
+ pinfo[0].p_uutime_usec;
|
||||
buf->stime = pinfo[0].p_ustime_sec * 1000000
|
||||
+ pinfo[0].p_ustime_usec;
|
||||
buf->cutime = pinfo[0].p_uctime_sec * 1000000
|
||||
+ pinfo[0].p_uctime_usec; /* XXX is u+s */
|
||||
buf->cstime = 0; /* XXX */
|
||||
buf->start_time = pinfo[0].p_ustart_sec;
|
||||
|
||||
buf->flags |= _glibtop_sysdeps_proc_time_user;
|
||||
}
|
||||
|
||||
102
sysdeps/openbsd/procuid.c
Normal file
102
sysdeps/openbsd/procuid.c
Normal file
@@ -0,0 +1,102 @@
|
||||
/* 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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/procuid.h>
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_uid =
|
||||
(1L << GLIBTOP_PROC_UID_UID) + (1L << GLIBTOP_PROC_UID_EUID) +
|
||||
(1L << GLIBTOP_PROC_UID_GID) +
|
||||
(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 =
|
||||
0L;
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
_glibtop_init_proc_uid_p (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_uid = _glibtop_sysdeps_proc_uid |
|
||||
_glibtop_sysdeps_proc_uid_groups;
|
||||
}
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
void
|
||||
glibtop_get_proc_uid_p (glibtop *server, glibtop_proc_uid *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
struct kinfo_proc *pinfo;
|
||||
int count = 0;
|
||||
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_UID), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_uid));
|
||||
|
||||
/* It does not work for the swapper task. */
|
||||
if (pid == 0) return;
|
||||
|
||||
/* Get the process information */
|
||||
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;
|
||||
}
|
||||
|
||||
#define PROC_RUID p_ruid
|
||||
#define PROC_SVUID p_svuid
|
||||
#define PROC_RGID p_rgid
|
||||
#define PROC_SVGID p_svgid
|
||||
#define PROC_PID p_pid
|
||||
#define PROC_PPID p_ppid
|
||||
#define PROC_PGID p__pgid
|
||||
#define PROC_TPGID p_tpgid
|
||||
#define PROC_NICE p_nice
|
||||
#define PROC_PRIORITY p_priority
|
||||
|
||||
buf->uid = pinfo [0].PROC_RUID;
|
||||
buf->euid = pinfo [0].PROC_SVUID;
|
||||
buf->gid = pinfo [0].PROC_RGID;
|
||||
buf->egid = pinfo [0].PROC_SVGID;
|
||||
|
||||
buf->pid = pinfo [0].PROC_PID;
|
||||
buf->ppid = pinfo [0].PROC_PPID;
|
||||
buf->pgrp = pinfo [0].PROC_PGID;
|
||||
buf->tpgid = pinfo [0].PROC_TPGID;
|
||||
|
||||
buf->nice = pinfo [0].PROC_NICE;
|
||||
buf->priority = pinfo [0].PROC_PRIORITY;
|
||||
|
||||
/* 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. */
|
||||
}
|
||||
47
sysdeps/openbsd/procwd.c
Normal file
47
sysdeps/openbsd/procwd.c
Normal file
@@ -0,0 +1,47 @@
|
||||
/* Copyright (C) 2007 Joe Marcus Clarke
|
||||
This file is part of LibGTop 2.
|
||||
|
||||
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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop/procwd.h>
|
||||
#include <glibtop/error.h>
|
||||
|
||||
#include <glibtop_private.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/param.h>
|
||||
#include <string.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_wd =
|
||||
(1 << GLIBTOP_PROC_WD_EXE) |
|
||||
(1 << GLIBTOP_PROC_WD_ROOT) |
|
||||
(1 << GLIBTOP_PROC_WD_NUMBER);
|
||||
|
||||
void
|
||||
_glibtop_init_proc_wd_s(glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_wd = _glibtop_sysdeps_proc_wd;
|
||||
}
|
||||
|
||||
char**
|
||||
glibtop_get_proc_wd_s(glibtop *server, glibtop_proc_wd *buf, pid_t pid)
|
||||
{
|
||||
/* TODO */
|
||||
return NULL;
|
||||
}
|
||||
94
sysdeps/openbsd/sem_limits.c
Normal file
94
sysdeps/openbsd/sem_limits.c
Normal file
@@ -0,0 +1,94 @@
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, August 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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/sem_limits.h>
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
/* #define _KERNEL to get declaration of `struct seminfo'. */
|
||||
|
||||
#define _KERNEL 1
|
||||
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/sem.h>
|
||||
|
||||
static unsigned long _glibtop_sysdeps_sem_limits =
|
||||
(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'
|
||||
* since `seminfo' is already declared external in <sys/sem.h>. */
|
||||
static struct seminfo _seminfo;
|
||||
|
||||
/* nlist structure for kernel access */
|
||||
static struct nlist nlst [] = {
|
||||
{ "_seminfo" },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
_glibtop_init_sem_limits_p (glibtop *server)
|
||||
{
|
||||
if (kvm_nlist (server->machine->kd, nlst) < 0) {
|
||||
glibtop_warn_io_r (server, "kvm_nlist (sem_limits)");
|
||||
return;
|
||||
}
|
||||
|
||||
if (kvm_read (server->machine->kd, nlst [0].n_value,
|
||||
&_seminfo, sizeof (_seminfo)) != sizeof (_seminfo)) {
|
||||
glibtop_warn_io_r (server, "kvm_read (seminfo)");
|
||||
return;
|
||||
}
|
||||
|
||||
server->sysdeps.sem_limits = _glibtop_sysdeps_sem_limits;
|
||||
}
|
||||
|
||||
/* Provides information about sysv sem limits. */
|
||||
|
||||
void
|
||||
glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf)
|
||||
{
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SEM_LIMITS), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_sem_limits));
|
||||
|
||||
if (server->sysdeps.sem_limits == 0)
|
||||
return;
|
||||
|
||||
buf->semmni = _seminfo.semmni;
|
||||
buf->semmns = _seminfo.semmns;
|
||||
buf->semmnu = _seminfo.semmnu;
|
||||
buf->semmsl = _seminfo.semmsl;
|
||||
buf->semopm = _seminfo.semopm;
|
||||
buf->semvmx = _seminfo.semvmx;
|
||||
buf->semaem = _seminfo.semaem;
|
||||
|
||||
buf->flags = _glibtop_sysdeps_sem_limits;
|
||||
}
|
||||
86
sysdeps/openbsd/shm_limits.c
Normal file
86
sysdeps/openbsd/shm_limits.c
Normal file
@@ -0,0 +1,86 @@
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, August 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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/shm_limits.h>
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
|
||||
static unsigned long _glibtop_sysdeps_shm_limits =
|
||||
(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'
|
||||
* since `shminfo' is already declared external in <sys/shm.h>. */
|
||||
static struct shminfo _shminfo;
|
||||
|
||||
/* nlist structure for kernel access */
|
||||
static struct nlist nlst [] = {
|
||||
{ "_shminfo" },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
_glibtop_init_shm_limits_p (glibtop *server)
|
||||
{
|
||||
if (kvm_nlist (server->machine->kd, nlst) < 0) {
|
||||
glibtop_warn_io_r (server, "kvm_nlist (shm_limits)");
|
||||
return;
|
||||
}
|
||||
|
||||
if (kvm_read (server->machine->kd, nlst [0].n_value,
|
||||
&_shminfo, sizeof (_shminfo)) != sizeof (_shminfo)) {
|
||||
glibtop_warn_io_r (server, "kvm_read (shminfo)");
|
||||
return;
|
||||
}
|
||||
|
||||
server->sysdeps.shm_limits = _glibtop_sysdeps_shm_limits;
|
||||
}
|
||||
|
||||
/* Provides information about sysv ipc limits. */
|
||||
|
||||
void
|
||||
glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf)
|
||||
{
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SHM_LIMITS), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_shm_limits));
|
||||
|
||||
if (server->sysdeps.shm_limits == 0)
|
||||
return;
|
||||
|
||||
buf->shmmax = _shminfo.shmmax;
|
||||
buf->shmmin = _shminfo.shmmin;
|
||||
buf->shmmni = _shminfo.shmmni;
|
||||
buf->shmseg = _shminfo.shmseg;
|
||||
buf->shmall = _shminfo.shmall;
|
||||
|
||||
buf->flags = _glibtop_sysdeps_shm_limits;
|
||||
}
|
||||
60
sysdeps/openbsd/siglist.c
Normal file
60
sysdeps/openbsd/siglist.c
Normal file
@@ -0,0 +1,60 @@
|
||||
/* 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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/signal.h>
|
||||
|
||||
const glibtop_signame glibtop_sys_siglist [] =
|
||||
{ { 1, "SIGHUP", "Hangup" },
|
||||
{ 2, "SIGINT", "Interrupt" },
|
||||
{ 3, "SIGQUIT", "Quit" },
|
||||
{ 4, "SIGILL", "Illegal Instruction" },
|
||||
{ 5, "SIGTRAP", "Trace/Breakpoint Trap" },
|
||||
{ 6, "SIGABRT", "Abort" },
|
||||
{ 7, "SIGEMT", "Emulation Trap" },
|
||||
{ 8, "SIGFPE", "Arithmetic Exception" },
|
||||
{ 9, "SIGKILL", "Killed" },
|
||||
{ 10, "SIGBUS", "Bus Error" },
|
||||
{ 11, "SIGSEGV", "Segmentation Fault" },
|
||||
{ 12, "SIGSYS", "Bad System Call" },
|
||||
{ 13, "SIGPIPE", "Broken Pipe" },
|
||||
{ 14, "SIGALRM", "Alarm Clock" },
|
||||
{ 15, "SIGTERM", "Terminated" },
|
||||
{ 16, "SIGURG", "Urgent Condition Present On Socket" },
|
||||
{ 17, "SIGSTOP", "Stop (cannot be caught or ignored)" },
|
||||
{ 18, "SIGTSTP", "Stop Signal Generated From Keyboard" },
|
||||
{ 19, "SIGCONT", "Continue After Stop" },
|
||||
{ 20, "SIGCHLD", "Child Status Has Changed" },
|
||||
{ 21, "SIGTTIN", "Background Read Attempted From Control Terminal" },
|
||||
{ 22, "SIGTTOU", "Background Write Attempted To Control Terminal" },
|
||||
{ 23, "SIGIO", "I/O Is Possible On A Descriptor" },
|
||||
{ 24, "SIGXCPU", "CPU Time Limit Exceeded" },
|
||||
{ 25, "SIGXFSZ", "File Size Limit Exceeded" },
|
||||
{ 26, "SIGVTALRM","Virtual Time Alarm" },
|
||||
{ 27, "SIGPROF", "Profiling Timer Alarm" },
|
||||
{ 28, "SIGWINCH","Window Size Change" },
|
||||
{ 29, "SIGINFO", "Status Request From Keyboard" },
|
||||
{ 30, "SIGUSR1", "User Defined Signal 1" },
|
||||
{ 31, "SIGUSR2", "User Defined Signal 2" },
|
||||
{ 32, "SIGTHR", "Thread Interrupt" },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
95
sysdeps/openbsd/suid_open.c
Normal file
95
sysdeps/openbsd/suid_open.c
Normal file
@@ -0,0 +1,95 @@
|
||||
/* 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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/cpu.h>
|
||||
#include <glibtop/open.h>
|
||||
#include <glibtop/init_hooks.h>
|
||||
#include <glibtop/machine.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <kvm.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 LIBGTOP_ENABLE_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. */
|
||||
}
|
||||
129
sysdeps/openbsd/swap.c
Normal file
129
sysdeps/openbsd/swap.c
Normal file
@@ -0,0 +1,129 @@
|
||||
/* 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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/swap.h>
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_swap =
|
||||
(1L << GLIBTOP_SWAP_TOTAL) + (1L << GLIBTOP_SWAP_USED) +
|
||||
(1L << GLIBTOP_SWAP_FREE) + (1L << GLIBTOP_SWAP_PAGEIN) +
|
||||
(1L << GLIBTOP_SWAP_PAGEOUT);
|
||||
|
||||
#include <sys/vmmeter.h>
|
||||
#include <uvm/uvm_extern.h>
|
||||
#include <sys/swap.h>
|
||||
|
||||
static int mib_uvmexp [] = { CTL_VM, VM_UVMEXP };
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
_glibtop_init_swap_p (glibtop *server)
|
||||
{
|
||||
server->sysdeps.swap = _glibtop_sysdeps_swap;
|
||||
}
|
||||
|
||||
/* Provides information about swap usage. */
|
||||
|
||||
/*
|
||||
* This function is based on a program called swapinfo written
|
||||
* by Kevin Lahey <kml@rokkaku.atl.ga.us>.
|
||||
*/
|
||||
|
||||
void
|
||||
glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
|
||||
{
|
||||
struct swapent *swaplist;
|
||||
|
||||
int nswap, i;
|
||||
guint64 avail = 0, inuse = 0;
|
||||
|
||||
int blocksize = 512; /* Default blocksize, use getbize() ? */
|
||||
int blockdiv = blocksize / DEV_BSIZE;
|
||||
|
||||
struct uvmexp uvmexp;
|
||||
size_t length_uvmexp;
|
||||
static int swappgsin = -1;
|
||||
static int swappgsout = -1;
|
||||
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SWAP), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_swap));
|
||||
|
||||
if (server->sysdeps.swap == 0)
|
||||
return;
|
||||
|
||||
length_uvmexp = sizeof (uvmexp);
|
||||
if (sysctl (mib_uvmexp, 2, &uvmexp, &length_uvmexp, NULL, 0)) {
|
||||
glibtop_warn_io_r (server, "sysctl (vm.uvmexp)");
|
||||
return;
|
||||
}
|
||||
|
||||
if (swappgsin < 0) {
|
||||
buf->pagein = 0;
|
||||
buf->pageout = 0;
|
||||
} else {
|
||||
buf->pagein = uvmexp.pgswapin - swappgsin;
|
||||
buf->pageout = uvmexp.pgswapout - swappgsout;
|
||||
}
|
||||
|
||||
swappgsin = uvmexp.pgswapin;
|
||||
swappgsout = uvmexp.pgswapout;
|
||||
|
||||
nswap = swapctl (SWAP_NSWAP, 0, 0);
|
||||
if (nswap < 0) {
|
||||
glibtop_warn_io_r (server, "swapctl (SWAP_NSWAP)");
|
||||
return;
|
||||
}
|
||||
|
||||
swaplist = g_malloc (nswap * sizeof (struct swapent));
|
||||
|
||||
if (swapctl (SWAP_STATS, swaplist, nswap) != nswap) {
|
||||
glibtop_warn_io_r (server, "swapctl (SWAP_STATS)");
|
||||
g_free (swaplist);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Total things up, returns in 512 bytes blocks! */
|
||||
for (i = 0; i < nswap; i++) {
|
||||
if (swaplist[i].se_flags & SWF_ENABLE) {
|
||||
avail += (swaplist[i].se_nblks / blockdiv);
|
||||
inuse += (swaplist[i].se_inuse / blockdiv);
|
||||
}
|
||||
}
|
||||
|
||||
/* Convert back to bytes, the libgtop2 is not clear about unites... */
|
||||
avail *= 512;
|
||||
inuse *= 512;
|
||||
|
||||
g_free (swaplist);
|
||||
|
||||
buf->flags = _glibtop_sysdeps_swap;
|
||||
|
||||
buf->used = inuse;
|
||||
buf->free = avail;
|
||||
|
||||
buf->total = inuse + avail;
|
||||
}
|
||||
114
sysdeps/openbsd/sysinfo.c
Normal file
114
sysdeps/openbsd/sysinfo.c
Normal file
@@ -0,0 +1,114 @@
|
||||
/* 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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/cpu.h>
|
||||
#include <glibtop/sysinfo.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_sysinfo =
|
||||
(1L << GLIBTOP_SYSINFO_CPUINFO);
|
||||
|
||||
static glibtop_sysinfo sysinfo = { .flags = 0 };
|
||||
|
||||
static void
|
||||
init_sysinfo (glibtop *server)
|
||||
{
|
||||
char *model = NULL;
|
||||
int mib[2];
|
||||
guint ncpus = 1;
|
||||
guint mhz = 0;
|
||||
size_t len;
|
||||
|
||||
if (G_LIKELY (sysinfo.flags))
|
||||
return;
|
||||
|
||||
glibtop_init_s (&server, GLIBTOP_SYSDEPS_CPU, 0);
|
||||
|
||||
mib[0] = CTL_HW;
|
||||
|
||||
/* Get the number of CPU's present */
|
||||
mib[1] = HW_NCPU;
|
||||
|
||||
len = sizeof(ncpus);
|
||||
if (sysctl(mib, 2, &ncpus, &len, NULL, 0) != 0)
|
||||
printf("Couldn't determine hw.ncpu.\n");
|
||||
|
||||
/* Get the CPU model */
|
||||
mib[1] = HW_MODEL;
|
||||
len = 0;
|
||||
|
||||
if (sysctl(mib, 2, NULL, &len, NULL, 0) != -1) {
|
||||
model = g_malloc (len);
|
||||
sysctl(mib, 2, model, &len, NULL, 0);
|
||||
} else {
|
||||
printf("Couldn't determine hw.model.\n");
|
||||
}
|
||||
|
||||
/* Get the clockrate */
|
||||
mib[1] = HW_CPUSPEED;
|
||||
len = sizeof(mhz);
|
||||
|
||||
if (sysctl(mib, 2, &mhz, &len, NULL, 0) != 0)
|
||||
printf("Couldn't determine hw.cpuspeed.\n");
|
||||
|
||||
for (sysinfo.ncpu = 0;
|
||||
sysinfo.ncpu < GLIBTOP_NCPU && sysinfo.ncpu < ncpus;
|
||||
sysinfo.ncpu++) {
|
||||
glibtop_entry * const cpuinfo = &sysinfo.cpuinfo[sysinfo.ncpu];
|
||||
|
||||
cpuinfo->labels = g_ptr_array_new ();
|
||||
|
||||
cpuinfo->values = g_hash_table_new_full(g_str_hash,
|
||||
g_str_equal,
|
||||
NULL, g_free);
|
||||
|
||||
g_ptr_array_add (cpuinfo->labels, "processor");
|
||||
g_hash_table_insert (cpuinfo->values, "processor",
|
||||
g_strdup_printf("%u", (guint)sysinfo.ncpu));
|
||||
|
||||
g_ptr_array_add (cpuinfo->labels, "vendor_id");
|
||||
g_hash_table_insert (cpuinfo->values, "vendor_id",
|
||||
g_strdup(model));
|
||||
|
||||
g_ptr_array_add (cpuinfo->labels, "model name");
|
||||
g_hash_table_insert (cpuinfo->values, "model name",
|
||||
g_strdup(model));
|
||||
|
||||
g_ptr_array_add (cpuinfo->labels, "cpu MHz");
|
||||
g_hash_table_insert (cpuinfo->values, "cpu MHz",
|
||||
g_strdup_printf("%d", mhz));
|
||||
}
|
||||
|
||||
g_free (model);
|
||||
|
||||
sysinfo.flags = _glibtop_sysdeps_sysinfo;
|
||||
}
|
||||
|
||||
const glibtop_sysinfo *
|
||||
glibtop_get_sysinfo_s (glibtop *server)
|
||||
{
|
||||
init_sysinfo (server);
|
||||
return &sysinfo;
|
||||
}
|
||||
75
sysdeps/openbsd/uptime.c
Normal file
75
sysdeps/openbsd/uptime.c
Normal file
@@ -0,0 +1,75 @@
|
||||
/* 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., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/uptime.h>
|
||||
|
||||
#include <glibtop/cpu.h>
|
||||
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_uptime =
|
||||
(1L << GLIBTOP_UPTIME_UPTIME) + (1L << GLIBTOP_UPTIME_IDLETIME) +
|
||||
(1UL << GLIBTOP_UPTIME_BOOT_TIME);
|
||||
|
||||
static const unsigned long _required_cpu_flags =
|
||||
(1L << GLIBTOP_CPU_TOTAL) + (1L << GLIBTOP_CPU_IDLE) +
|
||||
(1L << GLIBTOP_CPU_FREQUENCY);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
_glibtop_init_uptime_s (glibtop *server)
|
||||
{
|
||||
server->sysdeps.uptime = _glibtop_sysdeps_uptime;
|
||||
}
|
||||
|
||||
/* Provides uptime and idle time. */
|
||||
|
||||
void
|
||||
glibtop_get_uptime_s (glibtop *server, glibtop_uptime *buf)
|
||||
{
|
||||
time_t now;
|
||||
int mib[2];
|
||||
struct timeval boottime;
|
||||
size_t size;
|
||||
glibtop_cpu cpu;
|
||||
|
||||
mib[0] = CTL_KERN;
|
||||
mib[1] = KERN_BOOTTIME;
|
||||
size = sizeof(boottime);
|
||||
if (sysctl(mib, 2, &boottime, &size, NULL, 0) != -1 &&
|
||||
boottime.tv_sec != 0) {
|
||||
time(&now);
|
||||
buf->uptime = now - boottime.tv_sec;
|
||||
buf->boot_time = boottime.tv_sec;
|
||||
}
|
||||
|
||||
glibtop_get_cpu_s (server, &cpu);
|
||||
|
||||
/* Put something clever in buf->idletime: CP_IDLE. */
|
||||
buf->idletime = (double) cpu.idle / (double) cpu.frequency;
|
||||
buf->idletime /= (double) (server->ncpu + 1);
|
||||
|
||||
buf->flags = _glibtop_sysdeps_uptime;
|
||||
}
|
||||
Reference in New Issue
Block a user