Avoid opening System.map just to check it, etc.
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/sysmacros.h>
|
||||
#include "version.h"
|
||||
#include "devname.h"
|
||||
|
||||
#include <asm/page.h>
|
||||
@@ -195,7 +196,9 @@ int dev_to_tty(char *ret, int chop, int dev, int pid, unsigned int flags) {
|
||||
int i = 0;
|
||||
int c;
|
||||
if((short)dev == (short)-1) goto fail;
|
||||
if( link_name(tmp, major(dev), minor(dev), pid, "tty" )) goto abbrev;
|
||||
if(linux_version_code > LINUX_VERSION(2, 5, 0)){ /* didn't get done yet */
|
||||
if(link_name(tmp, major(dev), minor(dev), pid, "tty" )) goto abbrev;
|
||||
}
|
||||
if(driver_name(tmp, major(dev), minor(dev) )) goto abbrev;
|
||||
if( link_name(tmp, major(dev), minor(dev), pid, "fd/2" )) goto abbrev;
|
||||
if( guess_name(tmp, major(dev), minor(dev) )) goto abbrev;
|
||||
|
@@ -373,21 +373,32 @@ next_proc: /* get next PID for consideration */
|
||||
/* some number->text resolving which is time consuming */
|
||||
if (Do(FILLUSR)){
|
||||
strncpy(p->euser, user_from_uid(p->euid), sizeof p->euser);
|
||||
strncpy(p->egroup, group_from_gid(p->egid), sizeof p->egroup);
|
||||
if(Do(FILLSTATUS)) {
|
||||
strncpy(p->ruser, user_from_uid(p->ruid), sizeof p->ruser);
|
||||
strncpy(p->rgroup, group_from_gid(p->rgid), sizeof p->rgroup);
|
||||
strncpy(p->suser, user_from_uid(p->suid), sizeof p->suser);
|
||||
strncpy(p->sgroup, group_from_gid(p->sgid), sizeof p->sgroup);
|
||||
strncpy(p->fuser, user_from_uid(p->fuid), sizeof p->fuser);
|
||||
}
|
||||
}
|
||||
|
||||
/* some number->text resolving which is time consuming */
|
||||
if (Do(FILLGRP)){
|
||||
strncpy(p->egroup, group_from_gid(p->egid), sizeof p->egroup);
|
||||
if(Do(FILLSTATUS)) {
|
||||
strncpy(p->rgroup, group_from_gid(p->rgid), sizeof p->rgroup);
|
||||
strncpy(p->sgroup, group_from_gid(p->sgid), sizeof p->sgroup);
|
||||
strncpy(p->fgroup, group_from_gid(p->fgid), sizeof p->fgroup);
|
||||
}
|
||||
}
|
||||
|
||||
if (Do(FILLCMD)) /* read+parse /proc/#/cmdline */
|
||||
p->cmdline = file2strvec(path, "cmdline");
|
||||
else
|
||||
p->cmdline = NULL;
|
||||
|
||||
if (Do(FILLENV)) /* read+parse /proc/#/environ */
|
||||
p->environ = file2strvec(path, "environ");
|
||||
else
|
||||
p->environ = NULL;
|
||||
|
||||
if (p->state == 'Z') /* fixup cmd for zombies */
|
||||
strncat(p->cmd," <defunct>", sizeof p->cmd);
|
||||
@@ -448,10 +459,10 @@ next_proc: /* get next PID for consideration */
|
||||
goto next_proc; /* error reading /proc/#/stat */
|
||||
stat2proc(sbuf, p); /* parse /proc/#/stat */
|
||||
|
||||
/* if (Do(FILLMEM)) {*/ /* read, parse /proc/#/statm */
|
||||
if (Do(FILLMEM)) { /* read, parse /proc/#/statm */
|
||||
if ((file2str(path, "statm", sbuf, sizeof sbuf)) != -1 )
|
||||
statm2proc(sbuf, p); /* ignore statm errors here */
|
||||
/* } */ /* statm fields just zero */
|
||||
} /* statm fields just zero */
|
||||
|
||||
/* if (Do(FILLSTATUS)) { */ /* read, parse /proc/#/status */
|
||||
if ((file2str(path, "status", sbuf, sizeof sbuf)) != -1 ){
|
||||
@@ -460,23 +471,34 @@ next_proc: /* get next PID for consideration */
|
||||
/* }*/
|
||||
|
||||
/* some number->text resolving which is time consuming */
|
||||
/* if (Do(FILLUSR)){ */
|
||||
if (Do(FILLUSR)){
|
||||
strncpy(p->euser, user_from_uid(p->euid), sizeof p->euser);
|
||||
strncpy(p->egroup, group_from_gid(p->egid), sizeof p->egroup);
|
||||
/* if(Do(FILLSTATUS)) { */
|
||||
strncpy(p->ruser, user_from_uid(p->ruid), sizeof p->ruser);
|
||||
strncpy(p->rgroup, group_from_gid(p->rgid), sizeof p->rgroup);
|
||||
strncpy(p->suser, user_from_uid(p->suid), sizeof p->suser);
|
||||
strncpy(p->sgroup, group_from_gid(p->sgid), sizeof p->sgroup);
|
||||
strncpy(p->fuser, user_from_uid(p->fuid), sizeof p->fuser);
|
||||
/* }*/
|
||||
}
|
||||
|
||||
/* some number->text resolving which is time consuming */
|
||||
if (Do(FILLGRP)){
|
||||
strncpy(p->egroup, group_from_gid(p->egid), sizeof p->egroup);
|
||||
/* if(Do(FILLSTATUS)) { */
|
||||
strncpy(p->rgroup, group_from_gid(p->rgid), sizeof p->rgroup);
|
||||
strncpy(p->sgroup, group_from_gid(p->sgid), sizeof p->sgroup);
|
||||
strncpy(p->fgroup, group_from_gid(p->fgid), sizeof p->fgroup);
|
||||
/* }*/
|
||||
/* }*/
|
||||
}
|
||||
|
||||
/* if (Do(FILLCMD)) */ /* read+parse /proc/#/cmdline */
|
||||
if (Do(FILLCMD)) /* read+parse /proc/#/cmdline */
|
||||
p->cmdline = file2strvec(path, "cmdline");
|
||||
/* if (Do(FILLENV)) */ /* read+parse /proc/#/environ */
|
||||
else
|
||||
p->cmdline = NULL;
|
||||
|
||||
if (Do(FILLENV)) /* read+parse /proc/#/environ */
|
||||
p->environ = file2strvec(path, "environ");
|
||||
else
|
||||
p->environ = NULL;
|
||||
|
||||
if (p->state == 'Z') /* fixup cmd for zombies */
|
||||
strncat(p->cmd," <defunct>", sizeof p->cmd);
|
||||
|
@@ -194,10 +194,12 @@ extern void freeproc(proc_t* p);
|
||||
#define PROC_FILLMEM 0x01 /* read statm into the appropriate proc_t entries */
|
||||
#define PROC_FILLCMD 0x02 /* alloc and fill in `cmdline' part of proc_t */
|
||||
#define PROC_FILLENV 0x04 /* alloc and fill in `environ' part of proc_t */
|
||||
#define PROC_FILLUSR 0x08 /* resolve user id number -> user name via passwd */
|
||||
#define PROC_FILLSTATUS 0x10
|
||||
#define PROC_FILLSTAT 0x20
|
||||
#define PROC_FILLBUG 0x3f /* No idea what we need */
|
||||
#define PROC_FILLUSR 0x08 /* resolve user id number -> user name */
|
||||
#define PROC_FILLGRP 0x10 /* resolve group id number -> group name */
|
||||
#define PROC_FILLSTATUS 0x20
|
||||
#define PROC_FILLSTAT 0x40
|
||||
#define PROC_FILLWCHAN 0x80
|
||||
#define PROC_FILLBUG 0xff /* No idea what we need */
|
||||
|
||||
|
||||
/* Obsolete, consider only processes with one of the passed: */
|
||||
|
Reference in New Issue
Block a user