Make it work with NetBSD 1.3.2.
1998-12-05 Martin Baulig <martin@home-of-linux.org> * Make it work with NetBSD 1.3.2. Well, it compiles without problems but not all features are currently working; need to look a little bit closer at it. Ok for now, think I'll install OpenBSD and test it there ... Martin
This commit is contained in:
committed by
Martin Baulig
parent
d414a22ee3
commit
67a344b9d4
@@ -1,3 +1,7 @@
|
|||||||
|
1998-12-05 Martin Baulig <martin@home-of-linux.org>
|
||||||
|
|
||||||
|
* Make it work with NetBSD 1.3.2.
|
||||||
|
|
||||||
1998-11-17 Martin Baulig <martin@home-of-linux.org>
|
1998-11-17 Martin Baulig <martin@home-of-linux.org>
|
||||||
|
|
||||||
* Make it work with FreeBSD 3.0.
|
* Make it work with FreeBSD 3.0.
|
||||||
|
@@ -31,7 +31,10 @@
|
|||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
#ifdef __FreeBSD__
|
||||||
#include <osreldate.h>
|
#include <osreldate.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
|
@@ -32,7 +32,10 @@
|
|||||||
static const unsigned long _glibtop_sysdeps_mem =
|
static const unsigned long _glibtop_sysdeps_mem =
|
||||||
(1 << GLIBTOP_MEM_TOTAL) + (1 << GLIBTOP_MEM_USED) +
|
(1 << GLIBTOP_MEM_TOTAL) + (1 << GLIBTOP_MEM_USED) +
|
||||||
(1 << GLIBTOP_MEM_FREE) + (1 << GLIBTOP_MEM_SHARED) +
|
(1 << GLIBTOP_MEM_FREE) + (1 << GLIBTOP_MEM_SHARED) +
|
||||||
(1 << GLIBTOP_MEM_BUFFER) + (1 << GLIBTOP_MEM_CACHED) +
|
(1 << GLIBTOP_MEM_BUFFER) +
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
(1 << GLIBTOP_MEM_CACHED) +
|
||||||
|
#endif
|
||||||
(1 << GLIBTOP_MEM_USER);
|
(1 << GLIBTOP_MEM_USER);
|
||||||
|
|
||||||
#ifndef LOG1024
|
#ifndef LOG1024
|
||||||
@@ -124,11 +127,24 @@ glibtop_get_mem_p (glibtop *server, glibtop_mem *buf)
|
|||||||
|
|
||||||
/* convert memory stats to Kbytes */
|
/* convert memory stats to Kbytes */
|
||||||
|
|
||||||
|
#ifdef __FreeBSD__
|
||||||
buf->total = (u_int64_t) pagetok (vmm.v_page_count) << LOG1024;
|
buf->total = (u_int64_t) pagetok (vmm.v_page_count) << LOG1024;
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
u_int total_count = vmm.v_kernel_pages +
|
||||||
|
vmm.v_free_count + vmm.v_wire_count +
|
||||||
|
vmm.v_active_count + vmm.v_inactive_count;
|
||||||
|
|
||||||
|
buf->total = (u_int64_t) pagetok (total_count) << LOG1024;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
buf->used = (u_int64_t) pagetok (vmm.v_active_count) << LOG1024;
|
buf->used = (u_int64_t) pagetok (vmm.v_active_count) << LOG1024;
|
||||||
buf->free = (u_int64_t) pagetok (vmm.v_free_count) << LOG1024;
|
buf->free = (u_int64_t) pagetok (vmm.v_free_count) << LOG1024;
|
||||||
|
|
||||||
|
#ifdef __FreeBSD__
|
||||||
buf->cached = (u_int64_t) pagetok (vmm.v_cache_count) << LOG1024;
|
buf->cached = (u_int64_t) pagetok (vmm.v_cache_count) << LOG1024;
|
||||||
|
#endif
|
||||||
buf->shared = (u_int64_t) pagetok (vmt.t_vmshr) << LOG1024;
|
buf->shared = (u_int64_t) pagetok (vmt.t_vmshr) << LOG1024;
|
||||||
|
|
||||||
buf->buffer = (u_int64_t) bufspace;
|
buf->buffer = (u_int64_t) bufspace;
|
||||||
|
@@ -27,7 +27,11 @@
|
|||||||
|
|
||||||
/* #define KERNEL to get declaration of `struct msginfo'. */
|
/* #define KERNEL to get declaration of `struct msginfo'. */
|
||||||
|
|
||||||
#define KERNEL
|
#ifdef __FreeBSD__
|
||||||
|
#define KERNEL 1
|
||||||
|
#else
|
||||||
|
#define _KERNEL 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <sys/ipc.h>
|
#include <sys/ipc.h>
|
||||||
#include <sys/msg.h>
|
#include <sys/msg.h>
|
||||||
|
@@ -101,16 +101,25 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
|
|||||||
if (ifaddraddr == 0) {
|
if (ifaddraddr == 0) {
|
||||||
ifnetfound = ifnetaddr;
|
ifnetfound = ifnetaddr;
|
||||||
|
|
||||||
if ((kvm_read (server->machine.kd, ifnetaddr, &ifnet,
|
if (kvm_read (server->machine.kd, ifnetaddr, &ifnet,
|
||||||
sizeof (ifnet)) != sizeof (ifnet)) ||
|
sizeof (ifnet)) != sizeof (ifnet))
|
||||||
(kvm_read (server->machine.kd, (u_long) ifnet.if_name,
|
glibtop_error_io_r (server, "kvm_read (ifnetaddr)");
|
||||||
tname, 16) != 16))
|
|
||||||
glibtop_error_io_r (server, "kvm_read (ifnetaddr)");
|
#ifdef __FreeBSD__
|
||||||
|
if (kvm_read (server->machine.kd, (u_long) ifnet.if_name,
|
||||||
|
tname, 16) != 16)
|
||||||
|
glibtop_error_io_r (server, "kvm_read (if_name)");
|
||||||
|
#else
|
||||||
|
strncpy (tname, ifnet.if_xname, 16);
|
||||||
|
tname [15] = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if (defined __FreeBSD__) && (__FreeBSD_version >= 300000)
|
#if (defined __FreeBSD__) && (__FreeBSD_version >= 300000)
|
||||||
ifaddraddr = (u_long) ifnet.if_addrhead.tqh_first;
|
ifaddraddr = (u_long) ifnet.if_addrhead.tqh_first;
|
||||||
#else
|
#elsif (defined __FreeBSD__)
|
||||||
ifaddraddr = (u_long) ifnet.if_addrlist;
|
ifaddraddr = (u_long) ifnet.if_addrlist;
|
||||||
|
#else
|
||||||
|
ifaddraddr = (u_long) ifnet.if_addrlist.tqh_first;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,8 +163,10 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
|
|||||||
buf->if_flags |= GLIBTOP_IF_FLAGS_LINK1;
|
buf->if_flags |= GLIBTOP_IF_FLAGS_LINK1;
|
||||||
if (ifnet.if_flags & IFF_LINK2)
|
if (ifnet.if_flags & IFF_LINK2)
|
||||||
buf->if_flags |= GLIBTOP_IF_FLAGS_LINK2;
|
buf->if_flags |= GLIBTOP_IF_FLAGS_LINK2;
|
||||||
|
#ifdef __FreeBSD__
|
||||||
if (ifnet.if_flags & IFF_ALTPHYS)
|
if (ifnet.if_flags & IFF_ALTPHYS)
|
||||||
buf->if_flags |= GLIBTOP_IF_FLAGS_ALTPHYS;
|
buf->if_flags |= GLIBTOP_IF_FLAGS_ALTPHYS;
|
||||||
|
#endif
|
||||||
if (ifnet.if_flags & IFF_MULTICAST)
|
if (ifnet.if_flags & IFF_MULTICAST)
|
||||||
buf->if_flags |= GLIBTOP_IF_FLAGS_MULTICAST;
|
buf->if_flags |= GLIBTOP_IF_FLAGS_MULTICAST;
|
||||||
|
|
||||||
@@ -183,15 +194,19 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
|
|||||||
|
|
||||||
#if (defined __FreeBSD__) && (__FreeBSD_version >= 300000)
|
#if (defined __FreeBSD__) && (__FreeBSD_version >= 300000)
|
||||||
ifaddraddr = (u_long)ifaddr.ifa.ifa_link.tqe_next;
|
ifaddraddr = (u_long)ifaddr.ifa.ifa_link.tqe_next;
|
||||||
#else
|
#elsif (defined __FreeBSD__)
|
||||||
ifaddraddr = (u_long)ifaddr.ifa.ifa_next;
|
ifaddraddr = (u_long)ifaddr.ifa.ifa_next;
|
||||||
|
#else
|
||||||
|
ifaddraddr = (u_long)ifaddr.ifa.ifa_list.tqe_next;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (defined __FreeBSD__) && (__FreeBSD_version >= 300000)
|
#if (defined __FreeBSD__) && (__FreeBSD_version >= 300000)
|
||||||
ifnetaddr = (u_long) ifnet.if_link.tqe_next;
|
ifnetaddr = (u_long) ifnet.if_link.tqe_next;
|
||||||
#else
|
#elsif (defined __FreeBSD__)
|
||||||
ifnetaddr = (u_long) ifnet.if_next;
|
ifnetaddr = (u_long) ifnet.if_next;
|
||||||
|
#else
|
||||||
|
ifnetaddr = (u_long) ifnet.if_list.tqe_next;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -62,7 +62,9 @@ glibtop_open_p (glibtop *server, const char *program_name,
|
|||||||
server->machine.gid = getgid ();
|
server->machine.gid = getgid ();
|
||||||
server->machine.egid = getegid ();
|
server->machine.egid = getegid ();
|
||||||
|
|
||||||
|
#ifdef __FreeBSD__
|
||||||
server->os_version_code = __FreeBSD_version;
|
server->os_version_code = __FreeBSD_version;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Setup machine-specific data */
|
/* Setup machine-specific data */
|
||||||
server->machine.kd = kvm_open (NULL, NULL, NULL, O_RDONLY, "kvm_open");
|
server->machine.kd = kvm_open (NULL, NULL, NULL, O_RDONLY, "kvm_open");
|
||||||
|
@@ -31,7 +31,9 @@
|
|||||||
#include <sys/proc.h>
|
#include <sys/proc.h>
|
||||||
#include <sys/user.h>
|
#include <sys/user.h>
|
||||||
#include <machine/pcb.h>
|
#include <machine/pcb.h>
|
||||||
|
#ifdef __FreeBSD__
|
||||||
#include <machine/tss.h>
|
#include <machine/tss.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@@ -148,10 +150,15 @@ glibtop_get_proc_kernel_p (glibtop *server,
|
|||||||
* FreeBSD 3.0 at the moment.
|
* FreeBSD 3.0 at the moment.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#else
|
#elsif (defined __FreeBSD__)
|
||||||
buf->kstk_esp = (u_int64_t) pcb.pcb_ksp;
|
buf->kstk_esp = (u_int64_t) pcb.pcb_ksp;
|
||||||
buf->kstk_eip = (u_int64_t) pcb.pcb_pc;
|
buf->kstk_eip = (u_int64_t) pcb.pcb_pc;
|
||||||
|
|
||||||
|
buf->flags |= _glibtop_sysdeps_proc_kernel_pcb;
|
||||||
|
#else
|
||||||
|
buf->kstk_esp = (u_int64_t) pcb.pcb_tss.tss_esp0;
|
||||||
|
buf->kstk_eip = (u_int64_t) pcb.pcb_tss.__tss_eip;
|
||||||
|
|
||||||
buf->flags |= _glibtop_sysdeps_proc_kernel_pcb;
|
buf->flags |= _glibtop_sysdeps_proc_kernel_pcb;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -135,8 +135,13 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
|
|||||||
update = 1;
|
update = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __FreeBSD__
|
||||||
if (entry.eflags & (MAP_ENTRY_IS_A_MAP|MAP_ENTRY_IS_SUB_MAP))
|
if (entry.eflags & (MAP_ENTRY_IS_A_MAP|MAP_ENTRY_IS_SUB_MAP))
|
||||||
continue;
|
continue;
|
||||||
|
#else
|
||||||
|
if (entry.is_a_map || entry.is_sub_map)
|
||||||
|
continue;
|
||||||
|
#endif
|
||||||
|
|
||||||
maps [i].flags = _glibtop_sysdeps_map_entry;
|
maps [i].flags = _glibtop_sysdeps_map_entry;
|
||||||
|
|
||||||
@@ -165,6 +170,7 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
|
|||||||
&object, sizeof (object)) != sizeof (object))
|
&object, sizeof (object)) != sizeof (object))
|
||||||
glibtop_error_io_r (server, "kvm_read (object)");
|
glibtop_error_io_r (server, "kvm_read (object)");
|
||||||
|
|
||||||
|
#ifdef __FreeBSD__
|
||||||
/* If the object is of type vnode, add its size */
|
/* If the object is of type vnode, add its size */
|
||||||
|
|
||||||
if (object.type != OBJT_VNODE)
|
if (object.type != OBJT_VNODE)
|
||||||
@@ -193,7 +199,7 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
|
|||||||
|
|
||||||
maps [i-1].inode = inode.i_number;
|
maps [i-1].inode = inode.i_number;
|
||||||
maps [i-1].device = inode.i_dev;
|
maps [i-1].device = inode.i_dev;
|
||||||
|
#endif
|
||||||
} while (entry.next != first);
|
} while (entry.next != first);
|
||||||
|
|
||||||
return maps;
|
return maps;
|
||||||
|
@@ -161,8 +161,13 @@ glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __FreeBSD__
|
||||||
if (entry.eflags & (MAP_ENTRY_IS_A_MAP|MAP_ENTRY_IS_SUB_MAP))
|
if (entry.eflags & (MAP_ENTRY_IS_A_MAP|MAP_ENTRY_IS_SUB_MAP))
|
||||||
continue;
|
continue;
|
||||||
|
#else
|
||||||
|
if (entry.is_a_map || entry.is_sub_map)
|
||||||
|
continue;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!entry.object.vm_object)
|
if (!entry.object.vm_object)
|
||||||
continue;
|
continue;
|
||||||
@@ -178,10 +183,14 @@ glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
|
|||||||
|
|
||||||
/* If the object is of type vnode, add its size */
|
/* If the object is of type vnode, add its size */
|
||||||
|
|
||||||
|
#ifdef __FreeBSD__
|
||||||
if (object.type != OBJT_VNODE)
|
if (object.type != OBJT_VNODE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
buf->share += object.un_pager.vnp.vnp_size;
|
buf->share += object.un_pager.vnp.vnp_size;
|
||||||
|
#else
|
||||||
|
buf->share += object.size;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
buf->flags = _glibtop_sysdeps_proc_mem;
|
buf->flags = _glibtop_sysdeps_proc_mem;
|
||||||
|
@@ -27,7 +27,11 @@
|
|||||||
|
|
||||||
/* #define KERNEL to get declaration of `struct seminfo'. */
|
/* #define KERNEL to get declaration of `struct seminfo'. */
|
||||||
|
|
||||||
#define KERNEL
|
#ifdef __FreeBSD__
|
||||||
|
#define KERNEL 1
|
||||||
|
#else
|
||||||
|
#define _KERNEL 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <sys/ipc.h>
|
#include <sys/ipc.h>
|
||||||
#include <sys/sem.h>
|
#include <sys/sem.h>
|
||||||
|
@@ -27,7 +27,11 @@
|
|||||||
|
|
||||||
/* #define KERNEL to get declaration of `struct shminfo'. */
|
/* #define KERNEL to get declaration of `struct shminfo'. */
|
||||||
|
|
||||||
#define KERNEL
|
#ifdef __FreeBSD__
|
||||||
|
#define KERNEL 1
|
||||||
|
#else
|
||||||
|
#define _KERNEL 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <sys/ipc.h>
|
#include <sys/ipc.h>
|
||||||
#include <sys/shm.h>
|
#include <sys/shm.h>
|
||||||
|
@@ -28,7 +28,9 @@
|
|||||||
#include <glibtop_suid.h>
|
#include <glibtop_suid.h>
|
||||||
|
|
||||||
#include <sys/conf.h>
|
#include <sys/conf.h>
|
||||||
|
#ifdef __FreeBSD__
|
||||||
#include <sys/rlist.h>
|
#include <sys/rlist.h>
|
||||||
|
#endif
|
||||||
#include <sys/vmmeter.h>
|
#include <sys/vmmeter.h>
|
||||||
|
|
||||||
static const unsigned long _glibtop_sysdeps_swap =
|
static const unsigned long _glibtop_sysdeps_swap =
|
||||||
@@ -79,9 +81,11 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
|
|||||||
int i, div, avail, nfree, npfree, used;
|
int i, div, avail, nfree, npfree, used;
|
||||||
struct swdevt *sw;
|
struct swdevt *sw;
|
||||||
long blocksize, *perdev;
|
long blocksize, *perdev;
|
||||||
|
#ifdef __FreeBSD__
|
||||||
struct rlist head;
|
struct rlist head;
|
||||||
struct rlisthdr swaplist;
|
struct rlisthdr swaplist;
|
||||||
struct rlist *swapptr;
|
struct rlist *swapptr;
|
||||||
|
#endif
|
||||||
size_t sw_size;
|
size_t sw_size;
|
||||||
u_long ptr;
|
u_long ptr;
|
||||||
|
|
||||||
@@ -109,12 +113,22 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
|
|||||||
buf->pagein = 0;
|
buf->pagein = 0;
|
||||||
buf->pageout = 0;
|
buf->pageout = 0;
|
||||||
} else {
|
} else {
|
||||||
|
#ifdef __FreeBSD__
|
||||||
buf->pagein = vmm.v_swappgsin - swappgsin;
|
buf->pagein = vmm.v_swappgsin - swappgsin;
|
||||||
buf->pageout = vmm.v_swappgsout - swappgsout;
|
buf->pageout = vmm.v_swappgsout - swappgsout;
|
||||||
|
#else
|
||||||
|
buf->pagein = vmm.v_pswpin - swappgsin;
|
||||||
|
buf->pageout = vmm.v_pswpout - swappgsout;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __FreeBSD__
|
||||||
swappgsin = vmm.v_swappgsin;
|
swappgsin = vmm.v_swappgsin;
|
||||||
swappgsout = vmm.v_swappgsout;
|
swappgsout = vmm.v_swappgsout;
|
||||||
|
#else
|
||||||
|
swappgsin = vmm.v_pswpin;
|
||||||
|
swappgsout = vmm.v_pswpout;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Size of largest swap device. */
|
/* Size of largest swap device. */
|
||||||
|
|
||||||
@@ -140,6 +154,8 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
|
||||||
/* List of free swap areas. */
|
/* List of free swap areas. */
|
||||||
|
|
||||||
if (kvm_read (server->machine.kd, nlst[VM_SWAPLIST].n_value,
|
if (kvm_read (server->machine.kd, nlst[VM_SWAPLIST].n_value,
|
||||||
@@ -148,6 +164,8 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Kernel offset of list of swap devices and sizes. */
|
/* Kernel offset of list of swap devices and sizes. */
|
||||||
|
|
||||||
if (kvm_read (server->machine.kd, nlst[VM_SWDEVT].n_value,
|
if (kvm_read (server->machine.kd, nlst[VM_SWDEVT].n_value,
|
||||||
@@ -173,6 +191,7 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
|
|||||||
nfree = 0;
|
nfree = 0;
|
||||||
memset (perdev, 0, nswdev * sizeof(*perdev));
|
memset (perdev, 0, nswdev * sizeof(*perdev));
|
||||||
|
|
||||||
|
#ifdef __FreeBSD__
|
||||||
swapptr = swaplist.rlh_list;
|
swapptr = swaplist.rlh_list;
|
||||||
|
|
||||||
while (swapptr) {
|
while (swapptr) {
|
||||||
@@ -212,6 +231,7 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
|
|||||||
|
|
||||||
swapptr = head.rl_next;
|
swapptr = head.rl_next;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
header = getbsize (&hlen, &blocksize);
|
header = getbsize (&hlen, &blocksize);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user