Compare commits
8 Commits
LIBGTOP_2_
...
LIBGTOP_2_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f509067d4 | ||
|
|
a085c85db6 | ||
|
|
c6a7459bc9 | ||
|
|
3d06443c2c | ||
|
|
3f49e555fc | ||
|
|
e156172e7c | ||
|
|
c9385972bd | ||
|
|
b411ee115f |
48
.cvsignore
48
.cvsignore
@@ -1,48 +0,0 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
config.cache
|
||||
config.h
|
||||
config.h.in
|
||||
config.log
|
||||
config.sub
|
||||
config.guess
|
||||
config.status
|
||||
configure
|
||||
gtopConf.sh
|
||||
i386-bsdi
|
||||
i686-pc-linux-gnu
|
||||
intl
|
||||
libgtop-mirror.sh.swp
|
||||
libgtopConf.sh
|
||||
libtool
|
||||
ltconfig
|
||||
ltmain.sh
|
||||
macros
|
||||
stamp-h
|
||||
stamp-h.in
|
||||
sun4
|
||||
sun4sol2
|
||||
support
|
||||
i386-freebsd
|
||||
alpha-dec-osf3.0
|
||||
i686-pc-linux-gnu-linux
|
||||
libgtop-config
|
||||
ABOUT-NLS
|
||||
libgtop.spec
|
||||
libgtop*.tar.gz
|
||||
*-debstamp
|
||||
libgtop*.pc
|
||||
autom4te.cache
|
||||
COPYING
|
||||
INSTALL
|
||||
install-sh
|
||||
missing
|
||||
mkinstalldirs
|
||||
libgtopconfig.h
|
||||
intltool-extract.in
|
||||
intltool-extract
|
||||
intltool-merge.in
|
||||
intltool-merge
|
||||
intltool-update.in
|
||||
intltool-update
|
||||
23
ChangeLog
23
ChangeLog
@@ -1,3 +1,26 @@
|
||||
2007-02-10 Benoît Dejean <benoit@placenet.org>
|
||||
|
||||
* NEWS:
|
||||
* configure.in:
|
||||
|
||||
Released 2.14.7.
|
||||
|
||||
2007-01-14 Benoît Dejean <benoit@placenet.org>
|
||||
|
||||
* NEWS:
|
||||
|
||||
Released 2.14.6.
|
||||
|
||||
2007-01-11 Benoît Dejean <benoit@placenet.org>
|
||||
|
||||
* configure.in:
|
||||
|
||||
Bumped version number to 2.14.6.
|
||||
|
||||
* *:
|
||||
|
||||
Got rid of CVS admin files.
|
||||
|
||||
2006-12-03 Benoît Dejean <benoit@placenet.org>
|
||||
|
||||
* doc/reference/libgtop-docs.xml:
|
||||
|
||||
14
NEWS
14
NEWS
@@ -1,3 +1,17 @@
|
||||
February 10, 2007: Overview of changes in 2.14.7
|
||||
================================================
|
||||
* bsd:
|
||||
- massive kfreeBSD and FreeBSD updates by Roy Marples and Petr Salinger.
|
||||
* mountlist can now ignore objfs and ctfs filesystems.
|
||||
* fsusage won't return bavail > bfree anymore.
|
||||
|
||||
January 14, 2007: Overview of changes in 2.14.6
|
||||
===============================================
|
||||
* linux:
|
||||
- fixed stack overflow in glibtop_get_proc_map
|
||||
- fixed handling of long filenames in glibtop_get_proc_map and glibtop_get_proc_open_files.
|
||||
- micro-optimization
|
||||
|
||||
December 3, 2006: Overview of changes in 2.14.5
|
||||
===============================================
|
||||
* Added kfreebsd support (Petr Salinger <Petr.Salinger@seznam.cz>).
|
||||
|
||||
@@ -4,7 +4,7 @@ dnl
|
||||
|
||||
m4_define([libgtop_major_version], [2])
|
||||
m4_define([libgtop_minor_version], [14])
|
||||
m4_define([libgtop_micro_version], [5])
|
||||
m4_define([libgtop_micro_version], [7])
|
||||
m4_define([libgtop_version], [libgtop_major_version.libgtop_minor_version.libgtop_micro_version])
|
||||
|
||||
dnl increment if the interface has additions, changes, removals.
|
||||
|
||||
9
debian/.cvsignore
vendored
9
debian/.cvsignore
vendored
@@ -1,9 +0,0 @@
|
||||
control
|
||||
rules
|
||||
build
|
||||
tmp
|
||||
*.postinst
|
||||
*.debhelper
|
||||
*.files
|
||||
files
|
||||
substvars
|
||||
@@ -1,11 +0,0 @@
|
||||
texinfo.tex
|
||||
*.info
|
||||
Makefile.in
|
||||
Makefile
|
||||
*.log *.toc *.dvi *.aux *.cp *.fn *.vr *.tp *.ky *.pg
|
||||
*.ps
|
||||
auto-macros.texi
|
||||
version.texi
|
||||
stamp-vti
|
||||
*.html *.pdf
|
||||
mdate-sh
|
||||
@@ -1,27 +0,0 @@
|
||||
.deps
|
||||
.libs
|
||||
Makefile
|
||||
Makefile.in
|
||||
first
|
||||
first_linux
|
||||
first_static
|
||||
second
|
||||
third
|
||||
third_linux
|
||||
third_static
|
||||
second_static
|
||||
second_linux
|
||||
smp_static sysdeps_static netload_static procmap_static mountlist_static
|
||||
smp sysdeps netload procmap mountlist
|
||||
timings timings_static
|
||||
pprint
|
||||
pprint_static
|
||||
procargs
|
||||
procargs_static
|
||||
proclist
|
||||
df
|
||||
df_static
|
||||
netlist
|
||||
netlist_static
|
||||
openfiles
|
||||
openfiles_static
|
||||
@@ -1,2 +0,0 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
@@ -1,2 +0,0 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
@@ -1,8 +0,0 @@
|
||||
.deps
|
||||
.libs
|
||||
Makefile
|
||||
Makefile.in
|
||||
libgtop.la
|
||||
*.lo
|
||||
lib.c
|
||||
error.loT
|
||||
@@ -203,6 +203,7 @@ AC_DEFUN([GNOME_LIBGTOP_SYSDEPS],[
|
||||
msginfo_needs=
|
||||
for def in nothing KERNEL _KERNEL; do
|
||||
AC_COMPILE_IFELSE([#define $def
|
||||
#include <sys/types.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/msg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
Makefile.in
|
||||
Makefile
|
||||
@@ -1,14 +0,0 @@
|
||||
*.gmo
|
||||
*.mo
|
||||
*.pot
|
||||
Makefile
|
||||
Makefile.in
|
||||
Makefile.in.in
|
||||
POTFILES
|
||||
cat-id-tbl.c
|
||||
messages
|
||||
missing
|
||||
notexist
|
||||
po2tbl.sed
|
||||
po2tbl.sed.in
|
||||
stamp-cat-id
|
||||
@@ -1,2 +0,0 @@
|
||||
Makefile.in
|
||||
Makefile
|
||||
@@ -1,2 +0,0 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
@@ -1,7 +0,0 @@
|
||||
Makefile.in
|
||||
Makefile
|
||||
libgtop_daemon2
|
||||
libgtop_server2
|
||||
server.conf
|
||||
.libs
|
||||
.deps
|
||||
@@ -1,5 +0,0 @@
|
||||
Makefile.in
|
||||
Makefile
|
||||
mkinodedb2
|
||||
file_by_inode2
|
||||
.deps
|
||||
@@ -1,2 +0,0 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
@@ -1,2 +0,0 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
@@ -1,8 +0,0 @@
|
||||
.deps
|
||||
.libs
|
||||
Makefile
|
||||
Makefile.in
|
||||
libgtop_common.la
|
||||
so_locations
|
||||
*.lo
|
||||
*.la
|
||||
@@ -1,3 +1,18 @@
|
||||
2007-02-10 Benoît Dejean <benoit@placenet.org>
|
||||
|
||||
* fsusage.c: (glibtop_get_fsusage_s):
|
||||
|
||||
Make sure avail <= free.
|
||||
Closes #406280.
|
||||
|
||||
2007-01-31 Benoît Dejean <benoit@placenet.org>
|
||||
|
||||
* mountlist.c: (ignore_mount_entry):
|
||||
|
||||
Fixed order.
|
||||
Added objfs and ctfs.
|
||||
Closes #400557.
|
||||
|
||||
2006-09-21 Benoît Dejean <benoit@placenet.org>
|
||||
|
||||
* mountlist.c: (ignore_mount_entry):
|
||||
|
||||
@@ -286,7 +286,7 @@ glibtop_get_fsusage_s (glibtop *server, glibtop_fsusage *buf,
|
||||
|
||||
buf->blocks = fsd.f_blocks;
|
||||
buf->bfree = fsd.f_bfree;
|
||||
buf->bavail = fsd.f_bavail;
|
||||
buf->bavail = (fsd.f_bavail > fsd.f_bfree) ? 0 : fsd.f_bavail;
|
||||
buf->files = fsd.f_files;
|
||||
buf->ffree = fsd.f_ffree;
|
||||
|
||||
|
||||
@@ -540,14 +540,16 @@ static gboolean ignore_mount_entry(const struct mount_entry *me)
|
||||
static const char ignored[][12] = {
|
||||
"autofs",
|
||||
"binfmt_misc",
|
||||
"ctfs",
|
||||
"devfs",
|
||||
"devpts",
|
||||
"linprocfs",
|
||||
"mfs",
|
||||
"mntfs",
|
||||
"mqueue",
|
||||
"nsfd",
|
||||
"none",
|
||||
"nsfd",
|
||||
"objfs",
|
||||
"openpromfs",
|
||||
"proc",
|
||||
"procfs",
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
.deps
|
||||
.libs
|
||||
Makefile
|
||||
Makefile.in
|
||||
*.lo
|
||||
*.la
|
||||
@@ -1,3 +1,18 @@
|
||||
2007-01-31 Benoît Dejean <benoit@placenet.org>
|
||||
|
||||
* fsusage.c: (_glibtop_freebsd_get_fsusage_read_write):
|
||||
* netload.c: (glibtop_get_netload_p):
|
||||
* prockernel.c: (glibtop_get_proc_kernel_p):
|
||||
* procmap.c: (glibtop_get_proc_map_p):
|
||||
* proctime.c:
|
||||
* siglist.c:
|
||||
* /libgtop-sysdeps.m4:
|
||||
|
||||
Various FreeBSD and kFreeBSD updates.
|
||||
Patch by Roy Marples <uberlord@gentoo.org>.
|
||||
Reviewed by Petr Salinger <Petr.Salinger@seznam.cz>.
|
||||
Closes #387200.
|
||||
|
||||
2006-11-27 Benoît Dejean <benoit@placenet.org>
|
||||
|
||||
* fsusage.c: (_glibtop_freebsd_get_fsusage_read_write):
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
#include <config.h>
|
||||
|
||||
/* Although FreeBSD ships with statvfs it seems incomplete, so prefer statfs */
|
||||
#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
|
||||
#undef HAVE_SYS_STATVFS_H
|
||||
#undef STAT_STATVFS
|
||||
#endif
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/fsusage.h>
|
||||
@@ -46,9 +53,8 @@ _glibtop_freebsd_get_fsusage_read_write(glibtop *server,
|
||||
if (result == -1) {
|
||||
return;
|
||||
}
|
||||
#if !defined(__FreeBSD_kernel__)
|
||||
|
||||
buf->read = sfs.f_syncreads + sfs.f_asyncreads;
|
||||
buf->write = sfs.f_syncwrites + sfs.f_asyncwrites;
|
||||
#endif
|
||||
buf->flags |= (1 << GLIBTOP_FSUSAGE_READ) | (1 << GLIBTOP_FSUSAGE_WRITE);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/if_types.h>
|
||||
@@ -83,9 +85,11 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
|
||||
const char *interface)
|
||||
{
|
||||
struct ifnet ifnet;
|
||||
u_long ifnetaddr, ifnetfound, ifaddraddr;
|
||||
u_long ifnetaddr, ifnetfound;
|
||||
struct sockaddr *sa = NULL;
|
||||
#if (defined(__FreeBSD__) && (__FreeBSD_version < 501113)) || defined(__bsdi__)
|
||||
char tname [16];
|
||||
#endif
|
||||
char name [32];
|
||||
|
||||
union {
|
||||
@@ -101,12 +105,12 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
|
||||
&ifnetaddr, sizeof (ifnetaddr)) != sizeof (ifnetaddr))
|
||||
glibtop_error_io_r (server, "kvm_read (ifnet)");
|
||||
|
||||
ifaddraddr = 0;
|
||||
while (ifnetaddr || ifaddraddr) {
|
||||
while (ifnetaddr) {
|
||||
struct sockaddr_in *sin;
|
||||
register char *cp;
|
||||
u_long ifaddraddr;
|
||||
|
||||
if (ifaddraddr == 0) {
|
||||
{
|
||||
ifnetfound = ifnetaddr;
|
||||
|
||||
if (kvm_read (server->machine.kd, ifnetaddr, &ifnet,
|
||||
@@ -151,7 +155,11 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
|
||||
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);
|
||||
@@ -159,7 +167,11 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
|
||||
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);
|
||||
@@ -191,7 +203,7 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
|
||||
buf->collisions = ifnet.if_collisions;
|
||||
buf->flags = _glibtop_sysdeps_netload;
|
||||
|
||||
if (ifaddraddr) {
|
||||
while (ifaddraddr) {
|
||||
if ((kvm_read (server->machine.kd, ifaddraddr, &ifaddr,
|
||||
sizeof (ifaddr)) != sizeof (ifaddr)))
|
||||
glibtop_error_io_r (server, "kvm_read (ifaddraddr)");
|
||||
@@ -201,7 +213,12 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
|
||||
CP(&ifaddr);
|
||||
sa = (struct sockaddr *)cp;
|
||||
|
||||
if (sa->sa_family == AF_INET) {
|
||||
if (sa->sa_family == AF_LINK) {
|
||||
struct sockaddr_dl *dl = (struct sockaddr_dl *) sa;
|
||||
|
||||
memcpy (buf->hwaddress, LLADDR (dl), sizeof (buf->hwaddress));
|
||||
buf->flags |= GLIBTOP_NETLOAD_HWADDRESS;
|
||||
} else if (sa->sa_family == AF_INET) {
|
||||
sin = (struct sockaddr_in *)sa;
|
||||
#if !defined(__bsdi__)
|
||||
/* Commenting out to "fix" #13345. */
|
||||
@@ -211,8 +228,14 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
|
||||
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;
|
||||
|
||||
memcpy (buf->address6, &sin6->sin6_addr, sizeof (buf->address6));
|
||||
buf->flags |= GLIBTOP_NETLOAD_ADDRESS6;
|
||||
}
|
||||
/* FIXME prefix6, scope6 */
|
||||
ifaddraddr = (u_long) ifaddr.ifa.ifa_link.tqe_next;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -116,8 +116,10 @@ glibtop_get_proc_kernel_p (glibtop *server,
|
||||
|
||||
/* Get the process information */
|
||||
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
|
||||
if ((pinfo == NULL) || (count != 1))
|
||||
glibtop_error_io_r (server, "kvm_getprocs (%d)", pid);
|
||||
if ((pinfo == NULL) || (count != 1)) {
|
||||
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
|
||||
return;
|
||||
}
|
||||
|
||||
#if (defined(__FreeBSD__) && (__FreeBSD_version >= 500013)) || defined(__FreeBSD_kernel__)
|
||||
|
||||
|
||||
@@ -108,7 +108,9 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
|
||||
#else
|
||||
struct vm_object object;
|
||||
#endif
|
||||
glibtop_map_entry *maps;
|
||||
GArray *maps = g_array_sized_new(FALSE, FALSE,
|
||||
sizeof(glibtop_map_entry),
|
||||
100);
|
||||
#if (defined __FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
struct vnode vnode;
|
||||
#if (__FreeBSD_version < 500039) && !defined(__FreeBSD_kernel__)
|
||||
@@ -123,15 +125,15 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
|
||||
memset (buf, 0, sizeof (glibtop_proc_map));
|
||||
|
||||
/* It does not work for the swapper task. */
|
||||
if (pid == 0) return NULL;
|
||||
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, &count);
|
||||
if ((pinfo == NULL) || (count < 1)) {
|
||||
glibtop_error_io_r (server, "kvm_getprocs (%d)", pid);
|
||||
return 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. */
|
||||
@@ -159,8 +161,6 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
|
||||
|
||||
buf->total = buf->number * buf->size;
|
||||
|
||||
maps = g_malloc0(buf->total);
|
||||
|
||||
buf->flags = _glibtop_sysdeps_proc_map;
|
||||
|
||||
/* Walk through the `vm_map_entry' list ... */
|
||||
@@ -170,6 +170,10 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
|
||||
* to OBJT_DEFAULT so if seems this really works. */
|
||||
|
||||
do {
|
||||
glibtop_map_entry *mentry;
|
||||
unsigned long inum, dev;
|
||||
guint len;
|
||||
|
||||
if (update) {
|
||||
if (kvm_read (server->machine.kd,
|
||||
(unsigned long) entry.next,
|
||||
@@ -197,22 +201,6 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
|
||||
#endif
|
||||
#endif
|
||||
|
||||
maps [i].flags = _glibtop_sysdeps_map_entry;
|
||||
|
||||
maps [i].start = entry.start;
|
||||
maps [i].end = entry.end;
|
||||
maps [i].offset = entry.offset;
|
||||
|
||||
maps [i].perm = 0;
|
||||
|
||||
if (entry.protection & VM_PROT_READ)
|
||||
maps [i].perm |= GLIBTOP_MAP_PERM_READ;
|
||||
if (entry.protection & VM_PROT_WRITE)
|
||||
maps [i].perm |= GLIBTOP_MAP_PERM_WRITE;
|
||||
if (entry.protection & VM_PROT_EXECUTE)
|
||||
maps [i].perm |= GLIBTOP_MAP_PERM_EXECUTE;
|
||||
|
||||
i++;
|
||||
|
||||
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
|
||||
if (!entry.object.uvm_obj)
|
||||
@@ -224,7 +212,7 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
|
||||
(unsigned long) entry.object.uvm_obj,
|
||||
&vnode, sizeof (vnode)) != sizeof (vnode)) {
|
||||
glibtop_warn_io_r (server, "kvm_read (vnode)");
|
||||
return NULL;
|
||||
return (glibtop_map_entry*) g_array_free(maps, TRUE);
|
||||
}
|
||||
#else
|
||||
if (!entry.object.vm_object)
|
||||
@@ -251,8 +239,8 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
|
||||
&inode, sizeof (inode)) != sizeof (inode))
|
||||
glibtop_error_io_r (server, "kvm_read (inode)");
|
||||
|
||||
maps [i-1].inode = inode.i_number;
|
||||
maps [i-1].device = inode.i_dev;
|
||||
inum = inode.i_number;
|
||||
dev = inode.i_dev;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -274,8 +262,8 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
|
||||
switch (vnode.v_type) {
|
||||
case VREG:
|
||||
#if (__FreeBSD_version < 600006) && !defined(__FreeBSD_kernel__)
|
||||
maps [i-1].inode = vnode.v_cachedid;
|
||||
maps [i-1].device = vnode.v_cachedfs;
|
||||
inum = vnode.v_cachedid;
|
||||
dev = vnode.v_cachedfs;
|
||||
#endif
|
||||
default:
|
||||
continue;
|
||||
@@ -289,11 +277,37 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
|
||||
&inode, sizeof (inode)) != sizeof (inode))
|
||||
glibtop_error_io_r (server, "kvm_read (inode)");
|
||||
|
||||
maps [i-1].inode = inode.i_number;
|
||||
maps [i-1].device = inode.i_dev;
|
||||
inum = inode.i_number;
|
||||
dev = inode.i_dev;
|
||||
#endif
|
||||
#endif
|
||||
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 & VM_PROT_READ)
|
||||
mentry->perm |= GLIBTOP_MAP_PERM_READ;
|
||||
if (entry.protection & VM_PROT_WRITE)
|
||||
mentry->perm |= GLIBTOP_MAP_PERM_WRITE;
|
||||
if (entry.protection & VM_PROT_EXECUTE)
|
||||
mentry->perm |= GLIBTOP_MAP_PERM_EXECUTE;
|
||||
} while (entry.next != first);
|
||||
|
||||
return maps;
|
||||
buf->flags = _glibtop_sysdeps_proc_map;
|
||||
|
||||
buf->number = maps->len;
|
||||
buf->size = sizeof (glibtop_map_entry);
|
||||
buf->total = buf->number * buf->size;
|
||||
|
||||
return (glibtop_map_entry*) g_array_free(maps, FALSE);
|
||||
}
|
||||
|
||||
@@ -139,8 +139,10 @@ glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf,
|
||||
|
||||
/* Get the process information */
|
||||
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
|
||||
if ((pinfo == NULL) || (count != 1))
|
||||
glibtop_error_io_r (server, "kvm_getprocs (%d)", pid);
|
||||
if ((pinfo == NULL) || (count != 1)) {
|
||||
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
|
||||
return;
|
||||
}
|
||||
|
||||
#if (defined(__FreeBSD__) && (__FreeBSD_version >= 500013)) || defined(__FreeBSD_kernel__)
|
||||
buf->rtime = pinfo [0].ki_runtime;
|
||||
@@ -186,9 +188,13 @@ glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf,
|
||||
if ((pinfo [0].ki_flag & P_INMEM)) {
|
||||
#endif
|
||||
buf->utime = pinfo [0].ki_runtime;
|
||||
buf->stime = 0; /* XXX */
|
||||
buf->stime = tv2sec (pinfo [0].ki_rusage.ru_stime);
|
||||
buf->cutime = tv2sec (pinfo [0].ki_childtime);
|
||||
buf->cstime = 0; /* XXX */
|
||||
#if (__FreeBSD_version >= 600000) || (__FreeBSD_kernel_version >= 600000)
|
||||
buf->cstime = tv2sec (pinfo [0].ki_rusage_ch.ru_stime);
|
||||
#else
|
||||
buf->cstime = 0;
|
||||
#endif
|
||||
buf->start_time = tv2sec (pinfo [0].ki_start);
|
||||
buf->flags = _glibtop_sysdeps_proc_time_user;
|
||||
}
|
||||
|
||||
@@ -26,4 +26,37 @@
|
||||
#include <glibtop/signal.h>
|
||||
|
||||
const glibtop_signame glibtop_sys_siglist [] =
|
||||
{ { 0, NULL, NULL } };
|
||||
{ { 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 }
|
||||
};
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
.deps
|
||||
.libs
|
||||
Makefile
|
||||
Makefile.in
|
||||
libgtop_sysdeps.la
|
||||
*.lo
|
||||
@@ -1,3 +1,19 @@
|
||||
2007-01-14 Benoît Dejean <benoit@placenet.org>
|
||||
|
||||
* procmap.c: (glibtop_get_proc_map_s):
|
||||
* procopenfiles.c: (parse_file):
|
||||
|
||||
Fixed stack overflow in proc_map.
|
||||
Switched to Glibc getline because fgets gets fooled by long
|
||||
lines.
|
||||
Closes #396477.
|
||||
|
||||
2007-01-11 Benoît Dejean <benoit@placenet.org>
|
||||
|
||||
* glibtop_private.c: (get_scaled):
|
||||
|
||||
Replaced two strstr by a hand-written loop in this critical code.
|
||||
|
||||
2006-09-11 Benoît Dejean <benoit@placenet.org>
|
||||
|
||||
* procmap.c: (glibtop_get_proc_map_s):
|
||||
|
||||
@@ -25,10 +25,16 @@ get_scaled(const char *buffer, const char *key)
|
||||
{
|
||||
ptr += strlen(key);
|
||||
value = strtoull(ptr, &next, 0);
|
||||
if (strchr(next, 'k'))
|
||||
value *= 1024;
|
||||
else if (strchr(next, 'M'))
|
||||
value *= 1024 * 1024;
|
||||
|
||||
for ( ; *next; ++next) {
|
||||
if (*next == 'k') {
|
||||
value *= 1024;
|
||||
break;
|
||||
} else if (*next == 'M') {
|
||||
value *= 1024 * 1024;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else
|
||||
g_warning("Could not read key '%s' in buffer '%s'",
|
||||
key, buffer);
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#define SMAPS_FILE "/proc/%u/smaps"
|
||||
|
||||
|
||||
#define PROC_MAPS_FORMAT "%16llx-%16llx %4c %16llx %02hx:%02hx %llu%*[ ]%[^\n]\n"
|
||||
#define PROC_MAPS_FORMAT "%16llx-%16llx %4c %16llx %02hx:%02hx %llu%*[ ]%n"
|
||||
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_map =
|
||||
@@ -132,6 +132,8 @@ glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid)
|
||||
FILE *maps;
|
||||
const char *filename;
|
||||
gboolean has_smaps;
|
||||
char *line = NULL;
|
||||
size_t line_size = 0;
|
||||
|
||||
glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_MAP, 0);
|
||||
|
||||
@@ -152,32 +154,28 @@ glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid)
|
||||
|
||||
while(TRUE)
|
||||
{
|
||||
char line[1024];
|
||||
|
||||
unsigned long perm = 0;
|
||||
int rv;
|
||||
guint len;
|
||||
int line_end;
|
||||
|
||||
unsigned short dev_major, dev_minor;
|
||||
guint64 start, end, offset, inode;
|
||||
char flags[4];
|
||||
char filename [GLIBTOP_MAP_FILENAME_LEN+1];
|
||||
char *filename;
|
||||
|
||||
glibtop_map_entry *entry;
|
||||
|
||||
if (!fgets(line, sizeof line, maps))
|
||||
if (getline(&line, &line_size, maps) == -1)
|
||||
break;
|
||||
|
||||
/* 8 arguments */
|
||||
rv = sscanf(line, PROC_MAPS_FORMAT,
|
||||
&start, &end, flags, &offset,
|
||||
&dev_major, &dev_minor, &inode, filename);
|
||||
if (sscanf(line, PROC_MAPS_FORMAT,
|
||||
&start, &end, flags, &offset,
|
||||
&dev_major, &dev_minor, &inode, &line_end) != 7)
|
||||
break;
|
||||
|
||||
if(rv == EOF || rv < 7)
|
||||
break;
|
||||
|
||||
if(rv == 7) /* no filename */
|
||||
filename[0] = '\0';
|
||||
filename = line + line_end;
|
||||
g_strstrip(filename);
|
||||
|
||||
/* Compute access permissions. */
|
||||
|
||||
@@ -217,6 +215,7 @@ glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid)
|
||||
|
||||
}
|
||||
|
||||
free(line);
|
||||
fclose (maps);
|
||||
|
||||
buf->flags = _glibtop_sysdeps_proc_map;
|
||||
|
||||
@@ -58,7 +58,8 @@ static void
|
||||
parse_file(const char *filename, LineParser parser, GHashTable *dict)
|
||||
{
|
||||
FILE *f;
|
||||
char line[1024];
|
||||
char *line = NULL;
|
||||
size_t size = 0;
|
||||
|
||||
f = fopen(filename, "r");
|
||||
|
||||
@@ -67,15 +68,16 @@ parse_file(const char *filename, LineParser parser, GHashTable *dict)
|
||||
return;
|
||||
}
|
||||
|
||||
/* skip the first line */
|
||||
if(!fgets(line, sizeof line, f)) goto eof;
|
||||
|
||||
while(fgets(line, sizeof line, f))
|
||||
{
|
||||
/* skip the first line */
|
||||
if (getline(&line, &size, f) == -1)
|
||||
goto eof;
|
||||
|
||||
while (getline(&line, &size, f) != -1)
|
||||
parser(dict, line);
|
||||
}
|
||||
|
||||
eof:
|
||||
free(line);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
.deps
|
||||
.libs
|
||||
Makefile
|
||||
Makefile.in
|
||||
close.lo
|
||||
cpu.lo
|
||||
libgtop_sysdeps.la
|
||||
libsysdeps.la
|
||||
loadavg.lo
|
||||
mem.lo
|
||||
msg_limits.lo
|
||||
open.lo
|
||||
proclist.lo
|
||||
sem_limits.lo
|
||||
shm_limits.lo
|
||||
swap.lo
|
||||
sysdeps.lo
|
||||
uptime.lo
|
||||
so_locations
|
||||
*.lo
|
||||
*.la
|
||||
@@ -1,7 +0,0 @@
|
||||
.deps
|
||||
.libs
|
||||
Makefile
|
||||
Makefile.in
|
||||
libgtop_sysdeps.la
|
||||
*.lo
|
||||
libgtop_sysdeps_suid.la
|
||||
@@ -1,27 +0,0 @@
|
||||
.deps
|
||||
.libs
|
||||
Makefile
|
||||
Makefile.in
|
||||
close.lo
|
||||
cpu.lo
|
||||
init.lo
|
||||
libgtop_sysdeps.la
|
||||
loadavg.lo
|
||||
mem.lo
|
||||
msg_limits.lo
|
||||
open.lo
|
||||
prockernel.lo
|
||||
proclist.lo
|
||||
procmem.lo
|
||||
procsegment.lo
|
||||
procsignal.lo
|
||||
procstate.lo
|
||||
proctime.lo
|
||||
procuid.lo
|
||||
sem_limits.lo
|
||||
shm_limits.lo
|
||||
swap.lo
|
||||
sysdeps.lo
|
||||
uptime.lo
|
||||
*.lo
|
||||
so_locations
|
||||
@@ -1,28 +0,0 @@
|
||||
.deps
|
||||
.libs
|
||||
Makefile
|
||||
Makefile.in
|
||||
close.lo
|
||||
cpu.lo
|
||||
init.lo
|
||||
libgtop_sysdeps.la
|
||||
loadavg.lo
|
||||
mem.lo
|
||||
msg_limits.lo
|
||||
open.lo
|
||||
prockernel.lo
|
||||
proclist.lo
|
||||
procmem.lo
|
||||
procsegment.lo
|
||||
procsignal.lo
|
||||
procstate.lo
|
||||
proctime.lo
|
||||
procuid.lo
|
||||
sem_limits.lo
|
||||
shm_limits.lo
|
||||
swap.lo
|
||||
sysdeps.lo
|
||||
uptime.lo
|
||||
*.lo
|
||||
*.la
|
||||
so_locations
|
||||
@@ -1,17 +0,0 @@
|
||||
.deps
|
||||
.libs
|
||||
Makefile
|
||||
Makefile.in
|
||||
close.lo
|
||||
cpu.lo
|
||||
libgtop_sysdeps.la
|
||||
loadavg.lo
|
||||
mem.lo
|
||||
msg_limits.lo
|
||||
open.lo
|
||||
proclist.lo
|
||||
sem_limits.lo
|
||||
shm_limits.lo
|
||||
swap.lo
|
||||
sysdeps.lo
|
||||
uptime.lo
|
||||
Reference in New Issue
Block a user