From 97902ce2dddfc138d9fcffd137ae7c95b3af6b7f Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 18 Aug 1998 13:42:16 +0000 Subject: [PATCH] Set version number to 0.25.0. There is now really a feature freeze until 1998-08-18 Martin Baulig * LIBGTOP-VERSION: Set version number to 0.25.0. There is now really a feature freeze until it's released, bug fixes only ... * include/glibtop/procmap (glibtop_map_entry): Added `flags' and `filename' fields. --- ChangeLog | 6 ++++ examples/procmap.c | 53 ++++++++++++++++++++++---------- include/glibtop/procmap.h | 29 +++++++++++++++--- libgtop.spec | 10 ++++-- sysdeps/linux/procmap.c | 64 +++++++++++++++++++++++++++------------ 5 files changed, 118 insertions(+), 44 deletions(-) diff --git a/ChangeLog b/ChangeLog index 38c11043..de47dc8a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 1998-08-18 Martin Baulig + * LIBGTOP-VERSION: Set version number to 0.25.0. There is now really + a feature freeze until it's released, bug fixes only ... + + * include/glibtop/procmap (glibtop_map_entry): Added `flags' and + `filename' fields. + * LIBGTOP-VERSION: Added `LIBGTOP_MICRO_VERSION'. * libgtopConf.sh.in: Likewise. diff --git a/examples/procmap.c b/examples/procmap.c index 74b21d9f..f54d31f6 100644 --- a/examples/procmap.c +++ b/examples/procmap.c @@ -49,7 +49,7 @@ main (int argc, char *argv []) #endif glibtop_proc_map procmap; glibtop_map_entry *maps; - unsigned method, count, port, i, *ptr; + unsigned method, count, port, i; char buffer [BUFSIZ]; pid_t pid; @@ -92,28 +92,49 @@ main (int argc, char *argv []) for (i = 0; i < procmap.number; i++) { const char *filename = NULL; + unsigned device, device_major, device_minor; + char perm [5]; + + if (maps [i].flags & GLIBTOP_MAP_ENTRY_FILENAME) + filename = maps [i].filename; #ifdef GLIBTOP_INODEDB - if (inodedb) + if (inodedb && !filename) filename = glibtop_inodedb_lookup (inodedb, maps [i].device, maps [i].inode); #endif - if (filename) - fprintf (stderr, "%08x - %08x - %08lu - %08lu - %s\n", - (unsigned long) maps [i].start, - (unsigned long) maps [i].end, - (unsigned long) maps [i].device, - (unsigned long) maps [i].inode, - filename); - else - fprintf (stderr, "%08x - %08x - %08lu - %08lu\n", - (unsigned long) maps [i].start, - (unsigned long) maps [i].end, - (unsigned long) maps [i].device, - (unsigned long) maps [i].inode); + perm [0] = (maps [i].perm & GLIBTOP_MAP_PERM_READ) ? 'r' : '-'; + perm [1] = (maps [i].perm & GLIBTOP_MAP_PERM_WRITE) ? 'w' : '-'; + perm [2] = (maps [i].perm & GLIBTOP_MAP_PERM_EXECUTE) ? 'x' : '-'; + perm [3] = (maps [i].perm & GLIBTOP_MAP_PERM_SHARED) ? 's' : '-'; + perm [4] = (maps [i].perm & GLIBTOP_MAP_PERM_PRIVATE) ? 'p' : '-'; - glibtop_free (filename); + device = (unsigned long) maps [i].device; + device_minor = (device & 255); + device_major = ((device >> 8) & 255); + + if (filename) + fprintf (stderr, "%08lx-%08lx %08lx - " + "%02x:%02x %08lu - %4s - %s\n", + (unsigned long) maps [i].start, + (unsigned long) maps [i].end, + (unsigned long) maps [i].offset, + device_major, device_minor, + (unsigned long) maps [i].inode, + perm, filename); + else + fprintf (stderr, "%08lx-%08lx %08lx - " + "%02x:%02x %08lu - %4s\n", + (unsigned long) maps [i].start, + (unsigned long) maps [i].end, + (unsigned long) maps [i].offset, + device_major, device_minor, + (unsigned long) maps [i].inode, + perm); + + if (filename && (filename != maps [i].filename)) + glibtop_free (filename); } glibtop_free (maps); diff --git a/include/glibtop/procmap.h b/include/glibtop/procmap.h index 75e19f67..1f1305f4 100644 --- a/include/glibtop/procmap.h +++ b/include/glibtop/procmap.h @@ -27,11 +27,29 @@ __BEGIN_DECLS -#define GLIBTOP_PROC_MAP_NUMBER 0 -#define GLIBTOP_PROC_MAP_TOTAL 1 -#define GLIBTOP_PROC_MAP_SIZE 2 +#define GLIBTOP_PROC_MAP_NUMBER 0 +#define GLIBTOP_PROC_MAP_TOTAL 1 +#define GLIBTOP_PROC_MAP_SIZE 2 -#define GLIBTOP_MAX_PROC_MAP 3 +#define GLIBTOP_MAX_PROC_MAP 3 + +#define GLIBTOP_MAP_ENTRY_START 1 +#define GLIBTOP_MAP_ENTRY_END 2 +#define GLIBTOP_MAP_ENTRY_OFFSET 3 +#define GLIBTOP_MAP_ENTRY_PERM 4 +#define GLIBTOP_MAP_ENTRY_INODE 5 +#define GLIBTOP_MAP_ENTRY_DEVICE 6 +#define GLIBTOP_MAP_ENTRY_FILENAME 7 + +#define GLIBTOP_MAX_MAP_ENTRY 8 + +#define GLIBTOP_MAP_FILENAME_LEN 215 + +#define GLIBTOP_MAP_PERM_READ 1 +#define GLIBTOP_MAP_PERM_WRITE 2 +#define GLIBTOP_MAP_PERM_EXECUTE 4 +#define GLIBTOP_MAP_PERM_SHARED 8 +#define GLIBTOP_MAP_PERM_PRIVATE 16 typedef struct _glibtop_map_entry glibtop_map_entry; @@ -39,7 +57,8 @@ typedef struct _glibtop_proc_map glibtop_proc_map; struct _glibtop_map_entry { - u_int64_t start, end, offset, perm, inode, device; + u_int64_t flags, start, end, offset, perm, inode, device; + char filename [GLIBTOP_MAP_FILENAME_LEN+1]; }; struct _glibtop_proc_map diff --git a/libgtop.spec b/libgtop.spec index 41593724..45364ca4 100644 --- a/libgtop.spec +++ b/libgtop.spec @@ -1,5 +1,5 @@ # Note that this is NOT a relocatable package -%define ver 0.25pre1 +%define ver 0.25.0 %define rel SNAP %define prefix /usr @@ -27,6 +27,10 @@ information from /dev/kmem or whatever. %changelog +* Tue Aug 18 1998 Martin Baulig + +- released libgtop 0.25.0 + * Sun Aug 16 1998 Martin Baulig - first version of the RPM @@ -37,9 +41,9 @@ information from /dev/kmem or whatever. %build # Needed for snapshot releases. if [ ! -f configure ]; then - CFLAGS="$RPM_OPT_FLAGS" ./autogen.sh --prefix=%prefix --without-linux-table + CFLAGS="$RPM_OPT_FLAGS" ./autogen.sh --prefix=%prefix --without-linux-table --without-libgtop-examples else - CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%prefix --without-linux-table + CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%prefix --without-linux-table --without-libgtop-examples fi if [ "$SMP" != "" ]; then diff --git a/sysdeps/linux/procmap.c b/sysdeps/linux/procmap.c index 5591e83e..00c2fe1e 100644 --- a/sysdeps/linux/procmap.c +++ b/sysdeps/linux/procmap.c @@ -24,7 +24,15 @@ #include #include -static const unsigned long _glibtop_sysdeps_proc_map = 0; +static const unsigned long _glibtop_sysdeps_proc_map = +(1 << GLIBTOP_PROC_MAP_NUMBER) + (1 << GLIBTOP_PROC_MAP_TOTAL) + +(1 << GLIBTOP_PROC_MAP_SIZE); + +static const unsigned long _glibtop_sysdeps_map_entry = +(1 << GLIBTOP_MAP_ENTRY_START) + (1 << GLIBTOP_MAP_ENTRY_END) + +(1 << GLIBTOP_MAP_ENTRY_OFFSET) + (1 << GLIBTOP_MAP_ENTRY_PERM) + +(1 << GLIBTOP_MAP_ENTRY_INODE) + (1 << GLIBTOP_MAP_ENTRY_DEVICE) + +(1 << GLIBTOP_MAP_ENTRY_FILENAME); /* Init function. */ @@ -55,7 +63,7 @@ glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid) do { short dev_major, dev_minor; - unsigned long start, end, offset, inode; + unsigned long start, end, offset, inode, perm; char flags [5]; size_t size; @@ -66,38 +74,54 @@ glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid) flags [4] = 0; + /* Compute access permissions. */ + + perm = 0; + + if (flags [0] == 'r') + perm |= GLIBTOP_MAP_PERM_READ; + if (flags [1] == 'w') + perm |= GLIBTOP_MAP_PERM_WRITE; + if (flags [2] == 'x') + perm |= GLIBTOP_MAP_PERM_EXECUTE; + if (flags [3] == 's') + perm |= GLIBTOP_MAP_PERM_SHARED; + if (flags [3] == 'p') + perm |= GLIBTOP_MAP_PERM_PRIVATE; + + /* Read filename. */ + fn [0] = fgetc (maps); - /* printf ("fn [0] '%c' %x\n", fn [0], fn [0]); */ if (fn [0] != '\n' && fn [0] != EOF) { fscanf (maps, "%*[ ]%[^\n]\n", fn); - /* row->filename = glibtop_strdup_r (server, fn); */ - } /* else row->filename = NULL; */ + } else fn [0] = 0; - /* if (rv != EOF) - printf ("%08lx-%08lx %s\n", - row->VMstart, row->VMend, - row->filename); */ - - n++; - - size = n * sizeof (glibtop_map_entry); + size = (n+1) * sizeof (glibtop_map_entry); entry_list = glibtop_realloc_r (server, entry_list, size); - entry_list [n-1].start = (u_int64_t) start; - entry_list [n-1].end = (u_int64_t) end; - entry_list [n-1].offset = (u_int64_t) offset; - entry_list [n-1].device = (u_int64_t) (dev_major << 8) + + memset (&(entry_list [n]), 0, sizeof (glibtop_map_entry)); + + entry_list [n].flags = _glibtop_sysdeps_map_entry; + + entry_list [n].start = (u_int64_t) start; + entry_list [n].end = (u_int64_t) end; + entry_list [n].offset = (u_int64_t) offset; + entry_list [n].perm = (u_int64_t) perm; + entry_list [n].device = (u_int64_t) (dev_major << 8) + (u_int64_t) dev_minor; - entry_list [n-1].inode = (u_int64_t) inode; + entry_list [n].inode = (u_int64_t) inode; + + strncpy (entry_list [n].filename, fn, GLIBTOP_MAP_FILENAME_LEN); + entry_list [n].filename [GLIBTOP_MAP_FILENAME_LEN] = 0; + n++; + } while (rv != EOF && rv && fn [0] != EOF); - /* printf ("allocated: %d\n", i); */ - fclose (maps); buf->number = n;