Solaris 2.5 & 2.5.1 portability fixes, based on patches from Steve Murphy
* glibtop_machine.h, open.c, procargs.c, proclist.c, procmap.c: Solaris 2.5 & 2.5.1 portability fixes, based on patches from Steve Murphy <murf@e-tools.com>.
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
1999-06-07 Drazen Kacar <dave@srce.hr>
|
||||||
|
|
||||||
|
* glibtop_machine.h, open.c, procargs.c, proclist.c, procmap.c:
|
||||||
|
Solaris 2.5 & 2.5.1 portability fixes, based on patches
|
||||||
|
from Steve Murphy <murf@e-tools.com>.
|
||||||
|
|
||||||
1999-05-30 Drazen Kacar <dave@srce.hr>
|
1999-05-30 Drazen Kacar <dave@srce.hr>
|
||||||
|
|
||||||
* procargs.c: Fixed bug in calculation of process argument list.
|
* procargs.c: Fixed bug in calculation of process argument list.
|
||||||
|
@@ -64,9 +64,13 @@ struct _glibtop_machine
|
|||||||
int ticks; /* clock ticks, as returned by sysconf() */
|
int ticks; /* clock ticks, as returned by sysconf() */
|
||||||
unsigned long long boot; /* boot time, although it's ui32 in kstat */
|
unsigned long long boot; /* boot time, although it's ui32 in kstat */
|
||||||
void *libproc; /* libproc handle */
|
void *libproc; /* libproc handle */
|
||||||
|
#if GLIBTOP_SOLARIS_RELEASE >= 560
|
||||||
void (*objname)(void *, uintptr_t, const char *, size_t);
|
void (*objname)(void *, uintptr_t, const char *, size_t);
|
||||||
struct ps_prochandle *(*pgrab)(pid_t, int, int *);
|
struct ps_prochandle *(*pgrab)(pid_t, int, int *);
|
||||||
void (*pfree)(void *);
|
void (*pfree)(void *);
|
||||||
|
#else
|
||||||
|
void *filler[3];
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
END_LIBGTOP_DECLS
|
END_LIBGTOP_DECLS
|
||||||
|
@@ -205,6 +205,8 @@ glibtop_open_s (glibtop *server, const char *program_name,
|
|||||||
|
|
||||||
/* Now let's have a bit of magic dust... */
|
/* Now let's have a bit of magic dust... */
|
||||||
|
|
||||||
|
#if GLIBTOP_SOLARIS_RELEASE >= 560
|
||||||
|
|
||||||
dl = dlopen("/usr/lib/libproc.so", RTLD_LAZY);
|
dl = dlopen("/usr/lib/libproc.so", RTLD_LAZY);
|
||||||
server->machine.libproc = dl;
|
server->machine.libproc = dl;
|
||||||
if(dl)
|
if(dl)
|
||||||
@@ -226,5 +228,6 @@ glibtop_open_s (glibtop *server, const char *program_name,
|
|||||||
server->machine.pgrab = NULL;
|
server->machine.pgrab = NULL;
|
||||||
server->machine.pfree = NULL;
|
server->machine.pfree = NULL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
server->machine.me = getpid();
|
server->machine.me = getpid();
|
||||||
}
|
}
|
||||||
|
@@ -43,7 +43,11 @@ char *
|
|||||||
glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf,
|
glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf,
|
||||||
pid_t pid, unsigned max_len)
|
pid_t pid, unsigned max_len)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_PROCFS_H
|
||||||
struct psinfo pinfo;
|
struct psinfo pinfo;
|
||||||
|
#else
|
||||||
|
struct prpsinfo pinfo;
|
||||||
|
#endif
|
||||||
int len, i;
|
int len, i;
|
||||||
char *ret, *p;
|
char *ret, *p;
|
||||||
|
|
||||||
|
@@ -77,8 +77,11 @@ glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf,
|
|||||||
{
|
{
|
||||||
if(mask)
|
if(mask)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_PROCFS_H
|
||||||
struct psinfo psinfo;
|
struct psinfo psinfo;
|
||||||
|
#else
|
||||||
|
struct prpsinfo psinfo;
|
||||||
|
#endif
|
||||||
if(glibtop_get_proc_data_psinfo_s(server, &psinfo, pid))
|
if(glibtop_get_proc_data_psinfo_s(server, &psinfo, pid))
|
||||||
return NULL;
|
return NULL;
|
||||||
if(mask & GLIBTOP_EXCLUDE_IDLE && !psinfo.pr_pctcpu)
|
if(mask & GLIBTOP_EXCLUDE_IDLE && !psinfo.pr_pctcpu)
|
||||||
|
@@ -57,7 +57,12 @@ glibtop_map_entry *
|
|||||||
glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid)
|
glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid)
|
||||||
{
|
{
|
||||||
int fd, i, nmaps, pr_err, heap;
|
int fd, i, nmaps, pr_err, heap;
|
||||||
|
#if GLIBTOP_SOLARIS_RELEASE >= 560
|
||||||
prxmap_t *maps;
|
prxmap_t *maps;
|
||||||
|
struct ps_prochandle *Pr;
|
||||||
|
#else
|
||||||
|
prmap_t *maps;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* A few defines, to make it shorter down there */
|
/* A few defines, to make it shorter down there */
|
||||||
|
|
||||||
@@ -67,7 +72,6 @@ glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid)
|
|||||||
# define OFFSET pr_off
|
# define OFFSET pr_off
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct ps_prochandle *Pr;
|
|
||||||
glibtop_map_entry *entry;
|
glibtop_map_entry *entry;
|
||||||
struct stat inode;
|
struct stat inode;
|
||||||
char buffer[BUFSIZ];
|
char buffer[BUFSIZ];
|
||||||
@@ -109,7 +113,7 @@ glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid)
|
|||||||
s_close(fd);
|
s_close(fd);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
maps = alloca((nmaps + 1) * sizeof(prxmap_t));
|
maps = alloca((nmaps + 1) * sizeof(prmap_t));
|
||||||
if(ioctl(fd, PIOCMAP, maps) < 0)
|
if(ioctl(fd, PIOCMAP, maps) < 0)
|
||||||
{
|
{
|
||||||
glibtop_warn_io_r(server, "ioctl(%s, PIOCMAP)", buffer);
|
glibtop_warn_io_r(server, "ioctl(%s, PIOCMAP)", buffer);
|
||||||
@@ -126,21 +130,28 @@ glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid)
|
|||||||
|
|
||||||
memset(entry, 0, nmaps * sizeof(glibtop_map_entry));
|
memset(entry, 0, nmaps * sizeof(glibtop_map_entry));
|
||||||
|
|
||||||
|
#if GLIBTOP_SOLARIS_RELEASE >= 560
|
||||||
|
|
||||||
if(server->machine.objname && server->machine.pgrab &&
|
if(server->machine.objname && server->machine.pgrab &&
|
||||||
server->machine.pfree)
|
server->machine.pfree)
|
||||||
Pr = (server->machine.pgrab)(pid, 1, &pr_err);
|
Pr = (server->machine.pgrab)(pid, 1, &pr_err);
|
||||||
|
#endif
|
||||||
for(heap = 0,i = 0; i < nmaps; ++i)
|
for(heap = 0,i = 0; i < nmaps; ++i)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
entry[i].start = maps[i].pr_vaddr;
|
entry[i].start = maps[i].pr_vaddr;
|
||||||
entry[i].end = maps[i].pr_vaddr + maps[i].pr_size;
|
entry[i].end = maps[i].pr_vaddr + maps[i].pr_size;
|
||||||
|
|
||||||
|
#if GLIBTOP_SOLARIS_RELEASE >= 560
|
||||||
|
|
||||||
if(maps[i].pr_dev != PRNODEV)
|
if(maps[i].pr_dev != PRNODEV)
|
||||||
{
|
{
|
||||||
entry[i].device = maps[i].pr_dev;
|
entry[i].device = maps[i].pr_dev;
|
||||||
entry[i].inode = maps[i].pr_ino;
|
entry[i].inode = maps[i].pr_ino;
|
||||||
entry[i].flags |= _glibtop_sysdeps_map_device;
|
entry[i].flags |= _glibtop_sysdeps_map_device;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
entry[i].offset = maps[i].OFFSET;
|
entry[i].offset = maps[i].OFFSET;
|
||||||
if(maps[i].pr_mflags & MA_READ)
|
if(maps[i].pr_mflags & MA_READ)
|
||||||
entry[i].perm |= GLIBTOP_MAP_PERM_READ;
|
entry[i].perm |= GLIBTOP_MAP_PERM_READ;
|
||||||
@@ -153,6 +164,9 @@ glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid)
|
|||||||
else
|
else
|
||||||
entry[i].perm |= GLIBTOP_MAP_PERM_PRIVATE;
|
entry[i].perm |= GLIBTOP_MAP_PERM_PRIVATE;
|
||||||
entry[i].flags = _glibtop_sysdeps_map_entry;
|
entry[i].flags = _glibtop_sysdeps_map_entry;
|
||||||
|
|
||||||
|
#if GLIBTOP_SOLARIS_RELEASE >= 560
|
||||||
|
|
||||||
if(maps[i].pr_mflags & MA_ANON)
|
if(maps[i].pr_mflags & MA_ANON)
|
||||||
{
|
{
|
||||||
if(!heap)
|
if(!heap)
|
||||||
@@ -179,9 +193,14 @@ glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid)
|
|||||||
entry[i].flags |= (1L << GLIBTOP_MAP_ENTRY_FILENAME);
|
entry[i].flags |= (1L << GLIBTOP_MAP_ENTRY_FILENAME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if GLIBTOP_SOLARIS_RELEASE >= 560
|
||||||
|
|
||||||
if(Pr)
|
if(Pr)
|
||||||
server->machine.pfree(Pr);
|
server->machine.pfree(Pr);
|
||||||
|
#endif
|
||||||
buf->flags = _glibtop_sysdeps_proc_map;
|
buf->flags = _glibtop_sysdeps_proc_map;
|
||||||
s_close(fd);
|
s_close(fd);
|
||||||
return entry;
|
return entry;
|
||||||
|
Reference in New Issue
Block a user