Reflect latest interface changes.

This commit is contained in:
Martin Baulig
2000-01-18 15:55:11 +00:00
parent b54197c2e1
commit 490a05d01c
12 changed files with 162 additions and 16 deletions

View File

@@ -13,7 +13,8 @@ libgtop_sysdeps_la_LIBADD = -lmach
libgtop_sysdeps_suid_la_SOURCES = open_suid.c close_suid.c proclist.c \
procstate.c procuid.c proctime.c procmem.c \
procsignal.c prockernel.c procsegment.c \
procmap.c procargs.c netload.c
procmap.c procargs.c netload.c netinfo.c \
interfaces.c
libgtop_sysdeps_suid_la_LDFLAGS = $(LT_VERSION_INFO)
libgtop_sysdeps_suid_la_LIBADD = -lmach

View File

@@ -47,6 +47,8 @@ BEGIN_LIBGTOP_DECLS
#define GLIBTOP_SUID_PROC_MAP (1 << GLIBTOP_SYSDEPS_PROC_MAP)
#define GLIBTOP_SUID_PROC_ARGS (1 << GLIBTOP_SYSDEPS_PROC_ARGS)
#define GLIBTOP_SUID_NETLOAD (1 << GLIBTOP_SYSDEPS_NETLOAD)
#define GLIBTOP_SUID_NETINFO (1 << GLIBTOP_SYSDEPS_NETINFO)
#define GLIBTOP_SUID_INTERFACE_NAMES (1 << GLIBTOP_SYSDEPS_INTERFACE_NAMES)
#define GLIBTOP_SUID_PPP 0
END_LIBGTOP_DECLS

58
sysdeps/osf1/interfaces.c Normal file
View File

@@ -0,0 +1,58 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
This file is part of LibGTop 1.0.
Contributed by Martin Baulig <martin@home-of-linux.org>, 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., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <glibtop.h>
#include <glibtop/error.h>
#include <glibtop/interfaces.h>
#include <glibtop_suid.h>
static const unsigned long _glibtop_sysdeps_interface_names =
(1L << GLIBTOP_INTERFACE_NAMES_NUMBER) +
(1L << GLIBTOP_INTERFACE_NAMES_SIZE);
/* Init function. */
int
glibtop_init_interface_names_p (glibtop *server)
{
server->sysdeps.interface_names = _glibtop_sysdeps_interface_names;
return 0;
}
/* Provides network statistics. */
glibtop_interface *
glibtop_get_interface_names_p (glibtop *server, glibtop_array *array,
u_int64_t interface, u_int64_t number,
u_int64_t instance, u_int64_t strategy)
{
glibtop_init_p (server, GLIBTOP_SYSDEPS_INTERFACE_NAMES, 0);
memset (array, 0, sizeof (glibtop_array));
return NULL;
}

55
sysdeps/osf1/netinfo.c Normal file
View File

@@ -0,0 +1,55 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
This file is part of LibGTop 1.0.
Contributed by Martin Baulig <martin@home-of-linux.org>, 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., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <glibtop.h>
#include <glibtop/error.h>
#include <glibtop/netinfo.h>
#include <glibtop_suid.h>
static const unsigned long _glibtop_sysdeps_netinfo = 0;
/* Init function. */
int
glibtop_init_netinfo_p (glibtop *server)
{
server->sysdeps.netinfo = _glibtop_sysdeps_netinfo;
return 0;
}
/* Provides Network statistics. */
int
glibtop_get_netinfo_p (glibtop *server, glibtop_netinfo *buf,
const char *interface, unsigned transport)
{
glibtop_init_p (server, GLIBTOP_SYSDEPS_NETINFO, 0);
memset (buf, 0, sizeof (glibtop_netinfo));
return 0;
}

View File

@@ -37,6 +37,8 @@ int
glibtop_init_proc_kernel_p (glibtop *server)
{
server->sysdeps.proc_kernel = _glibtop_sysdeps_proc_kernel;
return 0;
}
/* Provides detailed information about a process. */
@@ -48,4 +50,6 @@ glibtop_get_proc_kernel_p (glibtop *server, glibtop_proc_kernel *buf,
glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_KERNEL, 0);
memset (buf, 0, sizeof (glibtop_proc_kernel));
return 0;
}

View File

@@ -36,13 +36,15 @@ int
glibtop_init_proc_map_p (glibtop *server)
{
server->sysdeps.proc_map = _glibtop_sysdeps_proc_map;
return 0;
}
/* Provides detailed information about a process. */
glibtop_map_entry *
glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf, pid_t pid)
glibtop_get_proc_map_p (glibtop *server, glibtop_array *array, pid_t pid)
{
memset (buf, 0, sizeof (glibtop_proc_map));
memset (array, 0, sizeof (glibtop_array));
return NULL;
}

View File

@@ -47,6 +47,8 @@ int
glibtop_init_proc_mem_p (glibtop *server)
{
server->sysdeps.proc_mem = _glibtop_sysdeps_proc_mem;
return 0;
}
/* Provides detailed information about a process. */
@@ -68,7 +70,7 @@ glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
ret = task_by_unix_pid (task_self(), pid, &thistask);
if (ret != KERN_SUCCESS) return;
if (ret != KERN_SUCCESS) return -1;
/* Get taskinfo about this task. */
@@ -77,7 +79,7 @@ glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
ret = task_info (thistask, TASK_BASIC_INFO,
(task_info_t) &taskinfo, &info_count);
if (ret != KERN_SUCCESS) return;
if (ret != KERN_SUCCESS) return -1;
buf->resident = taskinfo.resident_size;
buf->rss = taskinfo.resident_size;
@@ -94,7 +96,7 @@ glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
/* !!! END OF SUID ROOT PART !!! */
if (ret != 1) return;
if (ret != 1) return -1;
buf->rss_rlim = u.u_rlimit [RLIMIT_RSS].rlim_cur;
@@ -102,4 +104,6 @@ glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
buf->flags |= (1L << GLIBTOP_PROC_MEM_RSS_RLIM) |
(1L << GLIBTOP_PROC_MEM_SHARE);
return 0;
}

View File

@@ -43,6 +43,8 @@ int
glibtop_init_proc_segment_p (glibtop *server)
{
server->sysdeps.proc_segment = _glibtop_sysdeps_proc_segment;
return 0;
}
/* Provides detailed information about a process. */
@@ -69,7 +71,7 @@ glibtop_get_proc_segment_p (glibtop *server, glibtop_proc_segment *buf,
/* !!! END OF SUID ROOT PART !!! */
if (ret != 1) return;
if (ret != 1) return -1;
buf->start_code = (unsigned long) u.u_text_start;
buf->end_code = (unsigned long) u.u_data_start;
@@ -79,4 +81,6 @@ glibtop_get_proc_segment_p (glibtop *server, glibtop_proc_segment *buf,
buf->data_rss = u.u_dsize;
buf->flags = _glibtop_sysdeps_proc_segment;
return 0;
}

View File

@@ -39,6 +39,8 @@ int
glibtop_init_proc_signal_p (glibtop *server)
{
server->sysdeps.proc_signal = _glibtop_sysdeps_proc_signal;
return 0;
}
/* Provides detailed information about a process. */
@@ -65,7 +67,7 @@ glibtop_get_proc_signal_p (glibtop *server, glibtop_proc_signal *buf,
/* !!! END OF SUID ROOT PART !!! */
if (ret != 1) return;
if (ret != 1) return -1;
buf->signal [0] = procinfo.pi_sig;
buf->blocked [0] = procinfo.pi_sigmask;
@@ -73,4 +75,6 @@ glibtop_get_proc_signal_p (glibtop *server, glibtop_proc_signal *buf,
buf->sigcatch [0] = procinfo.pi_sigcatch;
buf->flags = _glibtop_sysdeps_proc_signal;
return 0;
}

View File

@@ -44,6 +44,8 @@ int
glibtop_init_proc_state_p (glibtop *server)
{
server->sysdeps.proc_state = _glibtop_sysdeps_proc_state;
return 0;
}
/* Provides detailed information about a process. */
@@ -71,16 +73,16 @@ glibtop_get_proc_state_p (glibtop *server, glibtop_proc_state *buf,
/* !!! END OF SUID ROOT PART !!! */
if (ret != 1) return;
if (ret != 1) return -1;
/* Check whether the process actually exists. */
if (procinfo.pi_status == PI_EMPTY) return;
if (procinfo.pi_status == PI_EMPTY) return -1;
/* Check whether it is not a zombie. */
if (procinfo.pi_status == PI_ZOMBIE) {
buf->state = GLIBTOP_PROCESS_ZOMBIE;
buf->flags = (1L << GLIBTOP_PROC_STATE_STATE);
return;
return -1;
}
strncpy (buf->cmd, procinfo.pi_comm, sizeof (buf->cmd)-1);
@@ -130,7 +132,7 @@ glibtop_get_proc_state_p (glibtop *server, glibtop_proc_state *buf,
/* !!! END OF SUID ROOT PART !!! */
if (ret != KERN_SUCCESS) return;
if (ret != KERN_SUCCESS) return -1;
switch (minim_state) {
case TH_STATE_RUNNING:
@@ -154,4 +156,6 @@ glibtop_get_proc_state_p (glibtop *server, glibtop_proc_state *buf,
if (buf->state)
buf->flags |= (1L << GLIBTOP_PROC_STATE_STATE);
return 0;
}

View File

@@ -42,6 +42,8 @@ int
glibtop_init_proc_time_p (glibtop *server)
{
server->sysdeps.proc_time = _glibtop_sysdeps_proc_time;
return 0;
}
/* Provides detailed information about a process. */
@@ -68,7 +70,7 @@ glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf,
/* !!! END OF SUID ROOT PART !!! */
if (ret != 1) return;
if (ret != 1) return -1;
buf->start_time = u.u_start.tv_sec;
@@ -78,4 +80,6 @@ glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf,
buf->cstime = u.u_cru.ru_stime.tv_sec;
buf->flags = _glibtop_sysdeps_proc_time;
return 0;
}

View File

@@ -50,6 +50,8 @@ int
glibtop_init_proc_uid_p (glibtop *server)
{
server->sysdeps.proc_uid = _glibtop_sysdeps_proc_uid;
return 0;
}
int
@@ -76,7 +78,7 @@ glibtop_get_proc_uid_p (glibtop *server, glibtop_proc_uid *buf,
/* !!! END OF SUID ROOT PART !!! */
if (ret != 1) return;
if (ret != 1) return -1;
buf->uid = procinfo.pi_ruid;
buf->euid = procinfo.pi_svuid;
@@ -116,7 +118,7 @@ glibtop_get_proc_uid_p (glibtop *server, glibtop_proc_uid *buf,
/* !!! END OF SUID ROOT PART !!! */
if (ret != KERN_SUCCESS) return;
if (ret != KERN_SUCCESS) return -1;
buf->priority = taskinfo.base_priority;
@@ -126,9 +128,11 @@ glibtop_get_proc_uid_p (glibtop *server, glibtop_proc_uid *buf,
ret = getpriority (PRIO_PROCESS, pid);
if ((ret == -1) && (errno != 0)) return;
if ((ret == -1) && (errno != 0)) return -1;
buf->nice = ret;
buf->flags += (1L << GLIBTOP_PROC_UID_NICE);
return 0;
}