Merged some stuff from `stub_suid'.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the Gnome Top Library.
|
||||
Contributed by Joshua Sled <jsled@xcf.berkeley.edu>, July 1998.
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
The Gnome Top Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
@@ -19,84 +19,28 @@
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/cpu.h>
|
||||
|
||||
#include <nlist.h>
|
||||
#include <kvm.h>
|
||||
#include <sys/dkstat.h>
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_cpu =
|
||||
(1 << GLIBTOP_CPU_TOTAL) + (1 << GLIBTOP_CPU_USER) +
|
||||
(1 << GLIBTOP_CPU_NICE) + (1 << GLIBTOP_CPU_SYS) +
|
||||
(1 << GLIBTOP_CPU_IDLE) + (1 << GLIBTOP_CPU_FREQUENCY);
|
||||
static const unsigned long _glibtop_sysdeps_cpu = 0;
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_cpu_p (glibtop *server)
|
||||
{
|
||||
server->sysdeps.cpu = _glibtop_sysdeps_cpu;
|
||||
}
|
||||
|
||||
/* Provides information about cpu usage. */
|
||||
|
||||
void
|
||||
glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf)
|
||||
glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf)
|
||||
{
|
||||
/* kvm_* vars */
|
||||
kvm_t *kd;
|
||||
static const int nlst_length=2;
|
||||
long cpts[CPUSTATES];
|
||||
/* sysctl vars*/
|
||||
static const int mib_length=2;
|
||||
int mib[mib_length];
|
||||
struct clockinfo ci;
|
||||
size_t length;
|
||||
|
||||
/* nlist structure for kernel access */
|
||||
struct nlist nlst[nlst_length] = {
|
||||
{ "_cp_time" },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
/* MIB array for sysctl(3) use */
|
||||
mib[0] = CTL_KERN;
|
||||
mib[1] = KERN_CLOCKRATE;
|
||||
|
||||
glibtop_init_r (& server);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_cpu));
|
||||
|
||||
/* Get the value out of the kernel */
|
||||
if (kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open") == NULL) {
|
||||
/* If we can't get at the kernel, return the null values we just
|
||||
gave the array. */
|
||||
return;
|
||||
}
|
||||
kvm_nlist(kd, &nlst);
|
||||
kvm_read(kd, nlst[0].n_value, &cpts, sizeof(cpts));
|
||||
kvm_close(kd);
|
||||
|
||||
/* Get the clockrate data */
|
||||
length = sizeof(clockinfo);
|
||||
sysctl(mib, mib_length, &ci, &len, NULL, 0);
|
||||
|
||||
buf->flags = _glibtop_sysdeps_cpu;
|
||||
|
||||
/* 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 frequency */
|
||||
/*
|
||||
FIXME -- is hz, tick, profhz or stathz wanted?
|
||||
buf->frequency = sysctl("kern.clockrate", ...);
|
||||
|
||||
struct clockinfo
|
||||
*/
|
||||
buf->frequency = ci.hz;
|
||||
/* set total */
|
||||
buf->total = cpts[CP_USER] + cpts[CP_NICE]
|
||||
+ cpts[CP_SYS] + cpts[CP_IDLE];
|
||||
|
||||
glibtop_init_p (server, GLIBTOP_SYSDEPS_CPU, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_cpu));
|
||||
}
|
||||
|
42
sysdeps/freebsd/glibtop_suid.h
Normal file
42
sysdeps/freebsd/glibtop_suid.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the Gnome Top Library.
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
The Gnome Top Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The Gnome Top Library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef __GLIBTOP_SUID_H__
|
||||
#define __GLIBTOP_SUID_H__
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
static inline void glibtop_suid_enter (glibtop *server) {
|
||||
setreuid (server->machine.uid, server->machine.euid);
|
||||
};
|
||||
|
||||
static inline void glibtop_suid_leave (glibtop *server) {
|
||||
if (setreuid (server->machine.euid, server->machine.uid))
|
||||
_exit (1);
|
||||
};
|
||||
|
||||
extern void glibtop_init_p __P((glibtop *, const unsigned long, const unsigned));
|
||||
|
||||
extern void glibtop_open_p __P((glibtop *, const char *, const unsigned long, const unsigned));
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the Gnome Top Library.
|
||||
Contributed by Joshua Sled <jsled@xcf.berkeley.edu>, July 1998.
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
The Gnome Top Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
@@ -19,31 +19,28 @@
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/loadavg.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_loadavg = 0;
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_loadavg_p (glibtop *server)
|
||||
{
|
||||
server->sysdeps.loadavg = _glibtop_sysdeps_loadavg;
|
||||
}
|
||||
|
||||
/* Provides load averange. */
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_loadavg =
|
||||
(1 << GLIBTOP_LOADAVG_LOADAVG);
|
||||
|
||||
void
|
||||
glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf)
|
||||
glibtop_get_loadavg_p (glibtop *server, glibtop_loadavg *buf)
|
||||
{
|
||||
double ldavg[3];
|
||||
|
||||
glibtop_init_r (&server);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_loadavg));
|
||||
|
||||
getloadavg(ldavg, 3);
|
||||
|
||||
/* fill in the struct */
|
||||
buf->flags = _glibtop_sysdeps_loadavg;
|
||||
for (int i=0; i<3; i++) {
|
||||
buf->loadavg[i] = ldavg[i];
|
||||
} /* end for */
|
||||
|
||||
glibtop_init_p (server, GLIBTOP_SYSDEPS_LOADAVG, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_loadavg));
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the Gnome Top Library.
|
||||
Contributed by Joshua Sled <jsled@xcf.berkeley.edu>, July 1998.
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
The Gnome Top Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
@@ -19,80 +19,28 @@
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/mem.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/vmmeter.h>
|
||||
#include <glibtop_suid.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_BUFFER) + (1 << GLIBTOP_MEM_CACHED);
|
||||
/* + (1 << GLIBTOP_MEM_USER); */
|
||||
static const unsigned long _glibtop_sysdeps_mem = 0;
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_mem_p (glibtop *server)
|
||||
{
|
||||
server->sysdeps.mem = _glibtop_sysdeps_mem;
|
||||
}
|
||||
|
||||
/* Provides information about memory usage. */
|
||||
|
||||
void
|
||||
glibtop_get_mem_s (glibtop *server, glibtop_mem *buf)
|
||||
glibtop_get_mem_p (glibtop *server, glibtop_mem *buf)
|
||||
{
|
||||
/* for kvm_*, which is needed to get cache and buffer data */
|
||||
kvm_t *kd;
|
||||
struct nlist nlst[3];
|
||||
static unsigned long cnt_offset;
|
||||
static unsigned long bufsize_offset;
|
||||
struct vmtotal vmt;
|
||||
static int bufspace = 0;
|
||||
/* for sysctl(3) */
|
||||
size_t length_vmt;
|
||||
int mib_vm[2];
|
||||
struct vmmeter vmm;
|
||||
|
||||
/* Setup nlist array */
|
||||
nlst = {
|
||||
{ "_cnt" },
|
||||
{ "_bufspace" },
|
||||
{ 0 }
|
||||
}
|
||||
|
||||
/* Setup MIB array for sysctl */
|
||||
mib_vm[0] = CTL_VM;
|
||||
mib_vm[1] = VM_METER;
|
||||
|
||||
glibtop_init_r (&server, 0, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_mem));
|
||||
|
||||
/* Get the data from sysctl */
|
||||
length_vmt = sizeof(vmt);
|
||||
sysctl(mib, 2, &vmt, &length_vmt, NULL, 0);
|
||||
|
||||
/* Get the data from kvm_* */
|
||||
kd = kvm_open(NULL, NULL, NULL, OD_RDONLY, "kvm_open");
|
||||
kvm_nlist(kd, &nlst);
|
||||
cnt_offset = nlst[0].n_value;
|
||||
bufspace_offset = nlst[1].n_value;
|
||||
kvm_read(kd, cnt_offset, &vmm, sizeof(vmm));
|
||||
kvm_read(kd, bufspace_offset, &bufspace, sizeof(bufspace));
|
||||
kvm_close(kd);
|
||||
|
||||
/* Set the values to return */
|
||||
buf->flags = _glibtop_sysdeps_mem;
|
||||
/* total */
|
||||
buf->total = (unsigned long)vmt.t_vm;
|
||||
/* used */
|
||||
buf->used = (unsigned long)vmt.t_avm;
|
||||
/* free */
|
||||
buf->free = (unsigned long)vmt.t_free;
|
||||
/* shared */
|
||||
buf->shared = (unsigned long)vmt.t_vmshr;
|
||||
/* buffer */
|
||||
buf->buffer = (unsigned long)bufspace;
|
||||
/* cached */
|
||||
buf->cache = (unsigned long)(vmm.v_cache_count * vmm.v_page_size);
|
||||
|
||||
/* user */
|
||||
/* FIXME: Any way to get or calculate this? */
|
||||
|
||||
glibtop_init_p (server, GLIBTOP_SYSDEPS_MEM, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_mem));
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the Gnome Top Library.
|
||||
Contributed by Joshua Sled <jsled@xcf.berkeley.edu>, July 1998.
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
The Gnome Top Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
@@ -19,43 +19,28 @@
|
||||
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/msg_limits.h>
|
||||
|
||||
#include <sys/msg.h>
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_msg_limits =
|
||||
(1 << GLIBTOP_IPC_MSGMAX) + (1 << GLIBTOP_IPC_MSGMNB) +
|
||||
(1 << GLIBTOP_IPC_MSGMNI) + (1 << GLIBTOP_IPC_MSGSSZ) +
|
||||
(1 << GLIBTOP_IPC_MSGTQL);
|
||||
static const unsigned long _glibtop_sysdeps_msg_limits = 0;
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_msg_limits_p (glibtop *server)
|
||||
{
|
||||
server->sysdeps.msg_limits = _glibtop_sysdeps_msg_limits;
|
||||
}
|
||||
|
||||
/* Provides information about sysv ipc limits. */
|
||||
|
||||
void
|
||||
glibtop_get_msg_limits_s (glibtop *server, glibtop_msg_limits *buf)
|
||||
glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf)
|
||||
{
|
||||
glibtop_init_r(&server, 0, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_msg_limits));
|
||||
|
||||
/* Set values */
|
||||
|
||||
/* msgpool */
|
||||
/* Any way to get this?
|
||||
Seems to be MSGMAX-bytes long.*/
|
||||
/* buf->msgpool = MSGMAX; */
|
||||
|
||||
/* msgmap: sys/msg.h ? */
|
||||
/* Different type in /usr/include/sys/msg.h */
|
||||
|
||||
/* msgmax: sys/msg.h:MSGMAX*/
|
||||
buf->msgmax = MSGMAX;
|
||||
/* msgmnb: sys/msg.h:MSGMNB */
|
||||
buf->msgmnb = MSGMNB;
|
||||
/* msgmni: sys/msg.h:MSGMNI */
|
||||
buf->msgmni = MSGMNI;
|
||||
/* msgssz: sys/msg.h:MSGSSZ */
|
||||
buf->msgssz = MSGSSZ;
|
||||
/* msgtql: sys/msg.h:MSGTQL */
|
||||
buf->msgtql = MSGTQL;
|
||||
glibtop_init_p (server, GLIBTOP_SYSDEPS_MSG_LIMITS, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_msg_limits));
|
||||
}
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the Gnome Top Library.
|
||||
Contributed by Joshua Sled <jsled@xcf.berkeley.edu>, July 1998.
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
The Gnome Top Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
@@ -19,89 +19,29 @@
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/prockernel.h>
|
||||
|
||||
#include <kvm.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/user.h>
|
||||
#include <machine/pcb.h>
|
||||
#include <machine/tss.h>
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
static const unsigned long _glibtop_sysdeps_proc_kernel = 0;
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_kernel =
|
||||
(1 << GLIBTOP_PROC_KERNEL_K_FLAGS) +
|
||||
(1 << GLIBTOP_PROC_KERNEL_MIN_FLT) +
|
||||
(1 << GLIBTOP_PROC_KERNEL_MAJ_FLT) +
|
||||
(1 << GLIBTOP_PROC_KERNEL_CMIN_FLT) +
|
||||
(1 << GLIBTOP_PROC_KERNEL_CMAJ_FLT) +
|
||||
(1 << GLIBTOP_PROC_KERNEL_KSTK_ESP) +
|
||||
(1 << GLIBTOP_PROC_KERNEL_KSTK_EIP) +
|
||||
(1 << GLIBTOP_PROC_KERNEL_WCHAN);
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_proc_kernel_p (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_kernel = _glibtop_sysdeps_proc_kernel;
|
||||
}
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
void
|
||||
glibtop_get_proc_kernel_s (glibtop *server,
|
||||
glibtop_proc_kernel *buf,
|
||||
glibtop_get_proc_kernel_p (glibtop *server, glibtop_proc_kernel *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
struct kinfo_proc *pinfo;
|
||||
int count;
|
||||
struct i386tss *pcb_tss;
|
||||
int kmem;
|
||||
struct pstats ps;
|
||||
struct user usr;
|
||||
|
||||
glibtop_init_r (&server, 0, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_kernel));
|
||||
|
||||
/* Get the information pertaining to the given PID */
|
||||
pinfo = kvm_getprocs(server->machine.kd, KERN_PROC_PID, pid, &count);
|
||||
if (count != 1) {
|
||||
return; /* the 0-filled struct, since we can't get any info */
|
||||
}
|
||||
|
||||
kmem = open("/dev/kmem", O_RDONLY, NULL);
|
||||
if (f == NULL) {
|
||||
/* FIXME: error */
|
||||
}
|
||||
/* Read the p_stats struct from kernel memory */
|
||||
lseek(f, (long)pinfo[0].kp_proc.p_stats, SEEK_SET);
|
||||
read(f, &ps, sizeof(pstats));
|
||||
/* Read the struct at kp_proc.p_addr */
|
||||
lseek(f, (long)pinfo[0].kp_proc.p_addr, SEEK_SET);
|
||||
read(f, &usr, sizeof(user));
|
||||
close(f);
|
||||
|
||||
|
||||
/* kflags:
|
||||
kinfo_proc.e_flag?
|
||||
proc.p_flag
|
||||
proc.p_stat
|
||||
*/
|
||||
buf->kflags = pinfo[0].kp_eproc.e_flag;
|
||||
|
||||
/* min_flt: rusage.ru_minflt */
|
||||
buf->min_flt = ps.p_ru.ru_minflt;
|
||||
/* maj_flt: rusage.ru_majflt */
|
||||
buf->majflt = ps.p_ru.ru_majflt;
|
||||
/* cmin_flt: */
|
||||
buf->cmin_flt = ps.p_cru.ru_minflt;
|
||||
/* cmaj_flt: */
|
||||
buf->cmaj_flt = ps.p_cru.ru_majflt;
|
||||
|
||||
/* kstk_esp: pcb_tss.tss_esp */
|
||||
buf->kstk_esp = (unsigned long)usr.u_pcb.pcb_ksp;
|
||||
/* kstk_eip: pcb_tss.tss_eip */
|
||||
buf->kstk_eip = (unsigned long)usr.u_pcb.pcb_pc;
|
||||
|
||||
/* wchan : kinfo_proc.proc.p_wchan */
|
||||
buf->wchan = (unsigned long)pinfo[0].kp_proc.p_wchan;
|
||||
|
||||
glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_KERNEL, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_kernel));
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the Gnome Top Library.
|
||||
Contributed by Joshua Sled <jsled@xcf.berkeley.edu>, July 1998.
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
The Gnome Top Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
@@ -19,63 +19,28 @@
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/proclist.h>
|
||||
|
||||
#include <kvm.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
#define GLIBTOP_PROCLIST_FLAGS 3
|
||||
static const unsigned long _glibtop_sysdeps_proclist = 0;
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proclist =
|
||||
(1 << GLIBTOP_PROCLIST_TOTAL) + (1 << GLIBTOP_PROCLIST_NUMBER) +
|
||||
(1 << GLIBTOP_PROCLIST_SIZE);
|
||||
/* Init function. */
|
||||
|
||||
/* 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. */
|
||||
void
|
||||
glibtop_init_proclist_p (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proclist = _glibtop_sysdeps_proclist;
|
||||
}
|
||||
|
||||
unsigned *
|
||||
glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf)
|
||||
glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf)
|
||||
{
|
||||
struct kinfo_proc *pinfo;
|
||||
unsigned *pids=NULL;
|
||||
int count;
|
||||
int i;
|
||||
glibtop_init_p (server, GLIBTOP_SYSDEPS_PROCLIST, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proclist));
|
||||
|
||||
glibtop_init_r (&server, 0, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proclist));
|
||||
|
||||
/* Get the process data */
|
||||
pinfo = kvm_getprocs(server->machine.kd, KERN_PROC_ALL, NULL, &count);
|
||||
/* Allocate count objects in the pids_chain array
|
||||
Same as malloc is pids is NULL, which it is. */
|
||||
pids = glibtop_realloc__r(server, pids, count * sizeof(unsigned));
|
||||
/* Copy the pids over to this chain */
|
||||
for (i=0; i < count; i++) {
|
||||
pids[i] = (unsigned)pinfo[i].kp_proc.p_pid;
|
||||
} /* end for */
|
||||
/* Set the fields in buf */
|
||||
buf->number = count;
|
||||
buf->size = sizeof(unsigned);
|
||||
buf->total = count * sizeof(unsigned);
|
||||
buf->flags = _glibtop_sysdeps_proclist;
|
||||
/* return the data */
|
||||
return pids;
|
||||
return NULL;
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the Gnome Top Library.
|
||||
Contributed by Joshua Sled <jsled@xcf.berkeley.edu>, July 1998.
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
The Gnome Top Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
@@ -19,102 +19,29 @@
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/procmem.h>
|
||||
|
||||
#include <kvm.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/user.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/resource.h>
|
||||
#include <vm/vm_map.h>
|
||||
#include <machine/pmap.h>
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_mem =
|
||||
(1 << GLIBTOP_PROC_MEM_SIZE) +
|
||||
(1 << GLIBTOP_PROC_MEM_VSIZE) +
|
||||
(1 << GLIBTOP_PROC_MEM_RESIDENT) +
|
||||
/* (1 << GLIBTOP_PROC_MEM_SHARE) + */
|
||||
(1 << GLIBTOP_PROC_MEM_RSS) +
|
||||
(1 << GLIBTOP_PROC_MEM_RSS_RLIM);
|
||||
static const unsigned long _glibtop_sysdeps_proc_mem = 0;
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_proc_mem_p (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_mem = _glibtop_sysdeps_proc_mem;
|
||||
}
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
void
|
||||
glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf,
|
||||
glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
struct kinfo_proc *pinfo;
|
||||
int count;
|
||||
struct vmspace vms;
|
||||
struct vm_map vmm;
|
||||
struct pstats ps;
|
||||
int f;
|
||||
|
||||
glibtop_init_r(&server, 0, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_mem));
|
||||
|
||||
if (pid == 0) {
|
||||
/* Client is only interested in the flags. */
|
||||
buf->flags = _glibtop_sysdeps_proc_mem;
|
||||
return;
|
||||
}
|
||||
|
||||
f = open("/dev/kmem", O_ORDONLY, NULL);
|
||||
if (f == NULL) {
|
||||
/* FIXME: error */
|
||||
}
|
||||
/* Read the vmspace from kernel memeory */
|
||||
lseek(f, (long)pinfo[0].kp_proc.p_vmspace, SEEK_SET);
|
||||
read(f, &vms, sizeof(vmspace));
|
||||
/* Read the vm_map from kernel memeory */
|
||||
lseek(f, (long)vms.vm_map, SEEK_SET);
|
||||
read(f, &vmm, sizeof(vm_map));
|
||||
/* Read the pstats [for the RSS rlimit] from kernel memory. */
|
||||
lseek(f, (long)pinfo[0].kp_proc.p_stats, SEEK_SET);
|
||||
read(f, &ps, sizeof(pstats));
|
||||
close(f);
|
||||
|
||||
/* Get the process information */
|
||||
kvm_getprocs(server->machine.kd, KERN_PROC_PID, pid, &count);
|
||||
if (count != 1) {
|
||||
/* Return no information */
|
||||
return;
|
||||
}
|
||||
|
||||
/* size: total # of pages in memory
|
||||
(segsz_t)pinfo[0].kp_proc.p_vmspace.(vm_tsize + vm_dsize + vm_ssize)
|
||||
*/
|
||||
buf->size = (unsigned long)(vms.vm_tsize + vms.vm_dsize + vms.vm_ssize);
|
||||
/* vsize: number of pages of VM
|
||||
(vm_size_t)pinfo[0].kp_proc.p_vmspace.vm_map.size
|
||||
*/
|
||||
buf->vsize = (unsigned long)vmm.size;
|
||||
|
||||
/* resident: number of resident (non-swapped) pages [4k]
|
||||
(long)pmap_resident_count(pinfo[0]->kp_proc.p_vmspace.vm_map.pmap);
|
||||
*/
|
||||
buf->resident = (unsigned long)pmap_resident_count(vmm.pmap);
|
||||
|
||||
/* share: number of pages shared (mmap'd) memory
|
||||
??? vm_object has this info, but how to get it?
|
||||
Even if we could, it's not reachable information.
|
||||
*/
|
||||
|
||||
|
||||
/* rss: resident set size
|
||||
(segsz_t)kp_proc.p_vmspace.vm_rssize
|
||||
*/
|
||||
buf->rss = (unsigned long)vms.vm_rssize;
|
||||
/* rss_rlim: current rss limit [bytes]
|
||||
(rlim_t)kp_proc.p_limit.pl_rlimit[RLIMIT_RSS].rlim_cur
|
||||
or
|
||||
(long)kp_proc.p_stats->p_ru.ru_maxrss */
|
||||
buf->rss_rlim = ps.p_ru.ru_maxrss;
|
||||
|
||||
/* Set the flags */
|
||||
buf->flags = _glibtop_sysdeps_proc_mem;
|
||||
|
||||
glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_MEM, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_mem));
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the Gnome Top Library.
|
||||
Contributed by Joshua Sled <jsled@xcf.berkeley.edu>, July 1998.
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
The Gnome Top Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
@@ -19,60 +19,29 @@
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/procsegment.h>
|
||||
|
||||
#include <kvm.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_segment =
|
||||
(1 << GLIBTOP_PROC_SEGMENT_TRS);
|
||||
/* (1 << GLIBTOP_PROC_SEGMENT_LRS) +
|
||||
(1 << GLIBTOP_PROC_SEGMENT_DRS) +
|
||||
(1 << GLIBTOP_PROC_SEGMENT_DT) +
|
||||
(1 << GLIBTOP_PROC_SEGMENT_START_CODE) +
|
||||
(1 << GLIBTOP_PROC_SEGMENT_END_CODE) +
|
||||
(1 << GLIBTOP_PROC_SEGMENT_START_STACK) */
|
||||
static const unsigned long _glibtop_sysdeps_proc_segment = 0;
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_proc_segment_p (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_segment = _glibtop_sysdeps_proc_segment;
|
||||
}
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
void
|
||||
glibtop_get_proc_segment_s (glibtop *server,
|
||||
glibtop_proc_segment *buf,
|
||||
glibtop_get_proc_segment_p (glibtop *server, glibtop_proc_segment *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
struct kinfo_proc *pinfo;
|
||||
int *count;
|
||||
|
||||
glibtop_init_r(&server, 0, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_segment));
|
||||
|
||||
/* Get the process info from the kernel */
|
||||
kvm_getprocs(server->machine.kd, KERN_PROC_PID, pid, count);
|
||||
if (*count != 1) {
|
||||
return; /* the zeroed-out buffer indicating no data */
|
||||
}
|
||||
|
||||
/* trs: text resident set size
|
||||
pinfo[0]->kp_eproc.e_xrssize;
|
||||
*/
|
||||
buf->trs = pinfo[0]->kp_eproc.e_xrssize;
|
||||
/* lrs: shared-lib resident set size
|
||||
? */
|
||||
/* drs: data resident set size
|
||||
pinfo[0]->kp_eproc.e_vm.vm_map.vm_dsize;
|
||||
*/
|
||||
/* dt: dirty pages
|
||||
*/
|
||||
/* start_code: address of beginning of code segment
|
||||
|
||||
*/
|
||||
/* end_code: address of end of code segment
|
||||
*/
|
||||
/* start_stack: address of the bottom of stack segment
|
||||
*/
|
||||
|
||||
glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_SEGMENT, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_segment));
|
||||
}
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the Gnome Top Library.
|
||||
Contributed by Joshua Sled <jsled@xcf.berkeley.edu>, July 1998.
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
The Gnome Top Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
@@ -19,51 +19,29 @@
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/procsignal.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_signal =
|
||||
(1 << GLIBTOP_PROC_SIGNAL_SIGNAL) +
|
||||
(1 << GLIBTOP_PROC_SIGNAL_BLOCKED) +
|
||||
(1 << GLIBTOP_PROC_SIGNAL_SIGIGNORE) +
|
||||
(1 << GLIBTOP_PROC_SIGNAL_SIGCATCH);
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_signal = 0;
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_proc_signal_p (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_signal = _glibtop_sysdeps_proc_signal;
|
||||
}
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
void
|
||||
glibtop_get_proc_signal_s (glibtop *server,
|
||||
glibtop_proc_signal *buf,
|
||||
glibtop_get_proc_signal_p (glibtop *server, glibtop_proc_signal *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
glibtop_init_r(&server, 0, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_signal));
|
||||
|
||||
if (pid == 0) {
|
||||
/* Client is only interested in the flags. */
|
||||
buf->flags = _glibtop_sysdeps_proc_signal;
|
||||
return;
|
||||
}
|
||||
|
||||
/* signal: mask of pending signals.
|
||||
pinfo[0].kp_proc.p_siglist
|
||||
*/
|
||||
buf->signal = pinfo[0].kp_proc.p_siglist;
|
||||
|
||||
/* blocked: mask of blocked signals.
|
||||
pinfo[0].kp_proc.p_sigmask
|
||||
*/
|
||||
buf->blocked = pinfo[0].kp_proc.p_sigmask;
|
||||
|
||||
/* sigignore: mask of ignored signals.
|
||||
pinfo[0].kp_proc.p_sigignore
|
||||
*/
|
||||
buf->sigignore = pinfo[0].kp_proc.p_sigignore;
|
||||
|
||||
/* sigcatch: mask of caught signals.
|
||||
pinfo[0].kp_proc.p_sigcatch
|
||||
*/
|
||||
buf->sigcatch = pinfo[0].kp_proc.p_sigcatch;
|
||||
|
||||
|
||||
glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_SIGNAL, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_signal));
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the Gnome Top Library.
|
||||
Contributed by Joshua Sled <jsled@xcf.berkeley.edu, July 1998.
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
The Gnome Top Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
@@ -19,34 +19,29 @@
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/procstate.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_state =
|
||||
(1 << GLIBTOP_PROC_STATE_CMD) +
|
||||
(1 << GLIBTOP_PROC_STATE_STATE) +
|
||||
(1 << GLIBTOP_PROC_STATE_UID) +
|
||||
(1 << GLIBTOP_PROC_STATE_GID);
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_state = 0;
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_proc_state_p (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_state = _glibtop_sysdeps_proc_state;
|
||||
}
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
void
|
||||
glibtop_get_proc_state_s (glibtop *server,
|
||||
glibtop_proc_state *buf,
|
||||
glibtop_get_proc_state_p (glibtop *server, glibtop_proc_state *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
glibtop_init_r (&server, 0, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_state));
|
||||
|
||||
if (pid == INVALID_PID) {
|
||||
/* Client is only interested in the flags. */
|
||||
buf->flags = _glibtop_sysdeps_proc_state;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Set the flags for the data we're about to return*/
|
||||
buf->flags = _glibtop_sysdeps_proc_state;
|
||||
glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_STATE, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_state));
|
||||
}
|
||||
|
@@ -19,14 +19,29 @@
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/proctime.h>
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_time = 0;
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_proc_time_p (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_time = _glibtop_sysdeps_proc_time;
|
||||
}
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
void
|
||||
glibtop_get_proc_time__r (glibtop *server, glibtop_proc_time *buf,
|
||||
pid_t pid)
|
||||
glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_TIME, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_time));
|
||||
}
|
||||
|
@@ -19,14 +19,29 @@
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/procuid.h>
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_uid = 0;
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_proc_uid_p (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_uid = _glibtop_sysdeps_proc_uid;
|
||||
}
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
void
|
||||
glibtop_get_proc_uid__r (glibtop *server, glibtop_proc_uid *buf,
|
||||
pid_t pid)
|
||||
glibtop_get_proc_uid_p (glibtop *server, glibtop_proc_uid *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_UID, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_uid));
|
||||
}
|
||||
|
@@ -19,12 +19,28 @@
|
||||
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/sem_limits.h>
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_sem_limits = 0;
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_sem_limits_p (glibtop *server)
|
||||
{
|
||||
server->sysdeps.sem_limits = _glibtop_sysdeps_sem_limits;
|
||||
}
|
||||
|
||||
/* Provides information about sysv sem limits. */
|
||||
|
||||
void
|
||||
glibtop_get_sem_limits__r (glibtop *server, glibtop_sem_limits *buf)
|
||||
glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf)
|
||||
{
|
||||
glibtop_init_p (server, GLIBTOP_SYSDEPS_SEM_LIMITS, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_sem_limits));
|
||||
}
|
||||
|
@@ -19,12 +19,28 @@
|
||||
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/shm_limits.h>
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_shm_limits = 0;
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_shm_limits_p (glibtop *server)
|
||||
{
|
||||
server->sysdeps.shm_limits = _glibtop_sysdeps_shm_limits;
|
||||
}
|
||||
|
||||
/* Provides information about sysv ipc limits. */
|
||||
|
||||
void
|
||||
glibtop_get_shm_limits__r (glibtop *server, glibtop_shm_limits *buf)
|
||||
glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf)
|
||||
{
|
||||
glibtop_init_p (server, GLIBTOP_SYSDEPS_SHM_LIMITS, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_shm_limits));
|
||||
}
|
||||
|
@@ -19,13 +19,28 @@
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/swap.h>
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_swap = 0;
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_swap_p (glibtop *server)
|
||||
{
|
||||
server->sysdeps.swap = _glibtop_sysdeps_swap;
|
||||
}
|
||||
|
||||
/* Provides information about swap usage. */
|
||||
|
||||
void
|
||||
glibtop_get_swap__r (glibtop *server, glibtop_swap *buf)
|
||||
glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
|
||||
{
|
||||
glibtop_init_p (server, GLIBTOP_SYSDEPS_SWAP, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_swap));
|
||||
}
|
||||
|
@@ -19,13 +19,28 @@
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <config.h>
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/uptime.h>
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_uptime = 0;
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
glibtop_init_uptime_p (glibtop *server)
|
||||
{
|
||||
server->sysdeps.uptime = _glibtop_sysdeps_uptime;
|
||||
}
|
||||
|
||||
/* Provides uptime and idle time. */
|
||||
|
||||
void
|
||||
glibtop_get_uptime__r (glibtop *server, glibtop_uptime *buf)
|
||||
glibtop_get_uptime_p (glibtop *server, glibtop_uptime *buf)
|
||||
{
|
||||
glibtop_init_p (server, GLIBTOP_SYSDEPS_UPTIME, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_uptime));
|
||||
}
|
||||
|
Reference in New Issue
Block a user