Added basic support for BSDI. It compiles without problems on BSDI 2.1 and

1999-03-19  Martin Baulig  <martin@home-of-linux.org>

	Added basic support for BSDI. It compiles without problems on
	BSDI 2.1 and 3.1, but it is *untested* - I'm neither root on
	the machine nor have I access to /dev/kmem, so I don't know
	whether it will work.

	You need to give configure the `--enable-hacker-mode' parameter
	to use the code.

	If someone can verify whether it actually works, please let me
	know.
This commit is contained in:
Martin Baulig
1999-03-19 10:47:44 +00:00
committed by Martin Baulig
parent 5fcfc95280
commit 005357e821
11 changed files with 106 additions and 14 deletions

View File

@@ -1,3 +1,16 @@
1999-03-19 Martin Baulig <martin@home-of-linux.org>
Added basic support for BSDI. It compiles without problems on
BSDI 2.1 and 3.1, but it is *untested* - I'm neither root on
the machine nor have I access to /dev/kmem, so I don't know
whether it will work.
You need to give configure the `--enable-hacker-mode' parameter
to use the code.
If someone can verify whether it actually works, please let me
know.
1999-03-18 Martin Baulig <martin@home-of-linux.org>
* ppp.c: Don't use `sppp.pp_phase' if we don't HAVE_I4B_ACCT.

View File

@@ -28,12 +28,17 @@
#include <glibtop_suid.h>
#include <sys/sysctl.h>
#ifndef __bsdi__
#include <sys/vmmeter.h>
#endif
#include <vm/vm_param.h>
static const unsigned long _glibtop_sysdeps_mem =
(1 << GLIBTOP_MEM_TOTAL) + (1 << GLIBTOP_MEM_USED) +
(1 << GLIBTOP_MEM_FREE) + (1 << GLIBTOP_MEM_SHARED) +
(1 << GLIBTOP_MEM_FREE) +
#ifndef __bsdi__
(1 << GLIBTOP_MEM_SHARED) +
#endif
(1 << GLIBTOP_MEM_BUFFER) +
#ifdef __FreeBSD__
(1 << GLIBTOP_MEM_CACHED) +
@@ -61,9 +66,11 @@ static struct nlist nlst [] = {
{ 0 }
};
#ifndef __bsdi__
/* MIB array for sysctl */
/* static int mib_length=2; */
static int mib [] = { CTL_VM, VM_METER };
#endif /* __bsdi__ */
/* Init function. */
@@ -95,8 +102,10 @@ glibtop_init_mem_p (glibtop *server)
void
glibtop_get_mem_p (glibtop *server, glibtop_mem *buf)
{
#ifndef __bsdi__
struct vmtotal vmt;
size_t length_vmt;
#endif
struct vmmeter vmm;
u_int v_used_count;
u_int v_total_count;
@@ -109,6 +118,7 @@ glibtop_get_mem_p (glibtop *server, glibtop_mem *buf)
if (server->sysdeps.mem == 0)
return;
#ifndef __bsdi__
/* [FIXME: On FreeBSD 2.2.6, sysctl () returns an incorrect
* value for `vmt.vm'. We use some code from Unix top
* here.] */
@@ -119,6 +129,7 @@ glibtop_get_mem_p (glibtop *server, glibtop_mem *buf)
glibtop_warn_io_r (server, "sysctl");
return;
}
#endif
/* Get the data from kvm_* */
if (kvm_read (server->machine.kd, nlst[0].n_value,
@@ -154,7 +165,9 @@ glibtop_get_mem_p (glibtop *server, glibtop_mem *buf)
#endif
buf->locked = (u_int64_t) pagetok (vmm.v_wire_count) << LOG1024;
#ifndef __bsdi__
buf->shared = (u_int64_t) pagetok (vmt.t_rmshr) << LOG1024;
#endif
#if __FreeBSD__
buf->buffer = (u_int64_t) bufspace;

View File

@@ -27,9 +27,26 @@
#include <glibtop_suid.h>
#if (defined __bsdi__) && (_BSDI_VERSION < 199700)
/* Older versions of BSDI don't seem to have this. */
void
glibtop_init_msg_limits_p (glibtop *server)
{ }
void
glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf)
{
glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_MSG_LIMITS), 0);
memset (buf, 0, sizeof (glibtop_msg_limits));
}
#else
/* #define KERNEL to get declaration of `struct msginfo'. */
#ifdef __FreeBSD__
#if (defined __FreeBSD__) || (defined __bsdi__)
#define KERNEL 1
#else
#define _KERNEL 1
@@ -93,3 +110,6 @@ glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf)
buf->flags = _glibtop_sysdeps_msg_limits;
}
#endif /* either a newer BSDI or no BSDI at all. */

View File

@@ -107,7 +107,7 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
sizeof (ifnet)) != sizeof (ifnet))
glibtop_error_io_r (server, "kvm_read (ifnetaddr)");
#ifdef __FreeBSD__
#if (defined __FreeBSD__) || (defined __bsdi__)
if (kvm_read (server->machine.kd, (u_long) ifnet.if_name,
tname, 16) != 16)
glibtop_error_io_r (server, "kvm_read (if_name)");
@@ -118,7 +118,7 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
#if (defined __FreeBSD__) && (__FreeBSD_version >= 300000)
ifaddraddr = (u_long) ifnet.if_addrhead.tqh_first;
#elif (defined __FreeBSD__)
#elif (defined __FreeBSD__) || (defined __bsdi__)
ifaddraddr = (u_long) ifnet.if_addrlist;
#else
ifaddraddr = (u_long) ifnet.if_addrlist.tqh_first;
@@ -196,7 +196,7 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
#if (defined __FreeBSD__) && (__FreeBSD_version >= 300000)
ifaddraddr = (u_long)ifaddr.ifa.ifa_link.tqe_next;
#elif (defined __FreeBSD__)
#elif (defined __FreeBSD__) || (defined __bsdi__)
ifaddraddr = (u_long)ifaddr.ifa.ifa_next;
#else
ifaddraddr = (u_long)ifaddr.ifa.ifa_list.tqe_next;
@@ -205,7 +205,7 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
#if (defined __FreeBSD__) && (__FreeBSD_version >= 300000)
ifnetaddr = (u_long) ifnet.if_link.tqe_next;
#elif (defined __FreeBSD__)
#elif (defined __FreeBSD__) || (defined __bsdi__)
ifnetaddr = (u_long) ifnet.if_next;
#else
ifnetaddr = (u_long) ifnet.if_list.tqe_next;

View File

@@ -31,10 +31,12 @@
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/proc.h>
#ifndef __OpenBSD__
#if (!defined __OpenBSD__) && (!defined __bsdi__)
#include <sys/user.h>
#endif
#ifndef __bsdi__
#include <machine/pcb.h>
#endif
#ifdef __FreeBSD__
#include <machine/tss.h>
#endif
@@ -122,7 +124,7 @@ glibtop_get_proc_kernel_p (glibtop *server,
/* NOTE: You need to mount the /proc filesystem to make
* `kvm_uread' work. */
sprintf (filename, "/proc/%d/mem", pid);
sprintf (filename, "/proc/%d/mem", (int) pid);
if (stat (filename, &statb)) return;
glibtop_suid_enter (server);
@@ -162,7 +164,11 @@ glibtop_get_proc_kernel_p (glibtop *server,
#endif
#else
buf->kstk_esp = (u_int64_t) pcb.pcb_tss.tss_esp0;
#ifdef __bsdi__
buf->kstk_eip = (u_int64_t) pcb.pcb_tss.tss_eip;
#else
buf->kstk_eip = (u_int64_t) pcb.pcb_tss.__tss_eip;
#endif
buf->flags |= _glibtop_sysdeps_proc_kernel_pcb;
#endif

View File

@@ -42,7 +42,7 @@
#include <ufs/ufs/inode.h>
#include <sys/ucred.h>
#ifndef __OpenBSD__
#if (!defined __OpenBSD__) && (!defined __bsdi__)
#include <sys/user.h>
#endif
#include <sys/sysctl.h>

View File

@@ -39,7 +39,7 @@
#include <ufs/ufs/inode.h>
#include <sys/ucred.h>
#ifndef __OpenBSD__
#if (!defined __OpenBSD__) && (!defined __bsdi__)
#include <sys/user.h>
#endif
#include <sys/sysctl.h>

View File

@@ -27,7 +27,7 @@
#include <glibtop_suid.h>
#ifndef __OpenBSD__
#if (!defined __OpenBSD__) && (!defined __bsdi__)
#include <sys/user.h>
#endif

View File

@@ -140,7 +140,7 @@ glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf,
/* It does not work for the swapper task. */
if (pid == 0) return;
sprintf (filename, "/proc/%d/mem", pid);
sprintf (filename, "/proc/%d/mem", (int) pid);
if (stat (filename, &statb)) return;
/* Get the process information */

View File

@@ -27,9 +27,26 @@
#include <glibtop_suid.h>
#if (defined __bsdi__) && (_BSDI_VERSION < 199700)
/* Older versions of BSDI don't seem to have this. */
void
glibtop_init_sem_limits_p (glibtop *server)
{ }
void
glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf)
{
glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_SEM_LIMITS), 0);
memset (buf, 0, sizeof (glibtop_sem_limits));
}
#else
/* #define KERNEL to get declaration of `struct seminfo'. */
#ifdef __FreeBSD__
#if (defined __FreeBSD__) || (defined __bsdi__)
#define KERNEL 1
#else
#define _KERNEL 1
@@ -98,3 +115,6 @@ glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf)
buf->flags = _glibtop_sysdeps_sem_limits;
}
#endif /* either a newer BSDI or no BSDI at all. */

View File

@@ -27,9 +27,26 @@
#include <glibtop_suid.h>
#if (defined __bsdi__) && (_BSDI_VERSION < 199700)
/* Older versions of BSDI don't seem to have this. */
void
glibtop_init_shm_limits_p (glibtop *server)
{ }
void
glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf)
{
glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_SHM_LIMITS), 0);
memset (buf, 0, sizeof (glibtop_shm_limits));
}
#else
/* #define KERNEL to get declaration of `struct shminfo'. */
#ifdef __FreeBSD__
#if (defined __FreeBSD__) || (defined __bsdi__)
#define KERNEL 1
#else
#define _KERNEL 1
@@ -93,3 +110,6 @@ glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf)
buf->flags = _glibtop_sysdeps_shm_limits;
}
#endif /* either a newer BSDI or no BSDI at all. */