output like Solaris 9, not Solaris 7
This commit is contained in:
parent
a760a2c22d
commit
98f8cbd614
3
NEWS
3
NEWS
@ -1,5 +1,6 @@
|
|||||||
procps-3.1.15 --> procps-3.1.16
|
procps-3.1.15 --> procps-3.2.0
|
||||||
|
|
||||||
|
pmap: output like Solaris 9, not Solaris 7
|
||||||
ps: also handle SELinux on the 2.4.xx kernels
|
ps: also handle SELinux on the 2.4.xx kernels
|
||||||
top: during a ^Z, the terminal was messed up #228822
|
top: during a ^Z, the terminal was messed up #228822
|
||||||
future-proof the tty handling (thanks to Zhou Wei)
|
future-proof the tty handling (thanks to Zhou Wei)
|
||||||
|
61
pmap.c
61
pmap.c
@ -33,6 +33,8 @@ static void usage(void){
|
|||||||
static int V_option;
|
static int V_option;
|
||||||
static int r_option; // ignored -- for SunOS compatibility
|
static int r_option; // ignored -- for SunOS compatibility
|
||||||
static int x_option;
|
static int x_option;
|
||||||
|
static int d_option;
|
||||||
|
static int q_option;
|
||||||
|
|
||||||
|
|
||||||
static const char *get_args(unsigned pid){
|
static const char *get_args(unsigned pid){
|
||||||
@ -97,10 +99,9 @@ static int one_proc(unsigned pid){
|
|||||||
if(!freopen(buf, "r", stdin)) return 1;
|
if(!freopen(buf, "r", stdin)) return 1;
|
||||||
printf("%u: %s\n", pid, get_args(pid));
|
printf("%u: %s\n", pid, get_args(pid));
|
||||||
if(x_option)
|
if(x_option)
|
||||||
printf("Address kB Resident Shared Private Permissions Name\n");
|
printf("Address Kbytes RSS Anon Locked Mode Mapping\n");
|
||||||
while(fgets(mapbuf,sizeof mapbuf,stdin)){
|
while(fgets(mapbuf,sizeof mapbuf,stdin)){
|
||||||
char flags[32];
|
char flags[32];
|
||||||
const char *perms;
|
|
||||||
char *tmp; // to clean up unprintables
|
char *tmp; // to clean up unprintables
|
||||||
unsigned KLONG start, end, diff;
|
unsigned KLONG start, end, diff;
|
||||||
unsigned long long pgoff;
|
unsigned long long pgoff;
|
||||||
@ -117,32 +118,10 @@ static int one_proc(unsigned pid){
|
|||||||
if(flags[3]=='s') total_shared += diff;
|
if(flags[3]=='s') total_shared += diff;
|
||||||
if(flags[3]=='p') total_private += diff;
|
if(flags[3]=='p') total_private += diff;
|
||||||
|
|
||||||
#if 1
|
// format used by Solaris 9 and procps-3.2.0+
|
||||||
// format used by Solaris 7 and old procps
|
|
||||||
if(flags[0]=='r'){
|
|
||||||
if(flags[1]=='w'){
|
|
||||||
if(flags[2]=='x') perms = "read/write/exec";
|
|
||||||
else perms = "read/write ";
|
|
||||||
}else{
|
|
||||||
if(flags[2]=='x') perms = "read/exec ";
|
|
||||||
else perms = "read ";
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
if(flags[1]=='w'){
|
|
||||||
if(flags[2]=='x') perms = "write/exec ";
|
|
||||||
else perms = "write ";
|
|
||||||
}else{
|
|
||||||
if(flags[2]=='x') perms = "exec ";
|
|
||||||
else perms = "none ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// format used by Solaris 9 and future procps
|
|
||||||
perms = flags;
|
|
||||||
if(flags[3] == 'p') flags[3] = '-';
|
if(flags[3] == 'p') flags[3] = '-';
|
||||||
flags[4] = '-'; // an 'R' if swap not reserved (MAP_NORESERVE, SysV ISM shared mem, etc.)
|
flags[4] = '-'; // an 'R' if swap not reserved (MAP_NORESERVE, SysV ISM shared mem, etc.)
|
||||||
flags[5] = '\0';
|
flags[5] = '\0';
|
||||||
#endif
|
|
||||||
|
|
||||||
if(x_option){
|
if(x_option){
|
||||||
const char *cp = strrchr(mapbuf,'/');
|
const char *cp = strrchr(mapbuf,'/');
|
||||||
@ -150,13 +129,11 @@ static int one_proc(unsigned pid){
|
|||||||
if(!cp) cp = anon_name(pid, start, diff);
|
if(!cp) cp = anon_name(pid, start, diff);
|
||||||
printf(
|
printf(
|
||||||
(sizeof(KLONG)==8)
|
(sizeof(KLONG)==8)
|
||||||
? "%016"KLF"x %7lu - %7lu %7lu %s %s\n"
|
? "%016"KLF"x %7lu - - - %s %s\n"
|
||||||
: "%08lx %7lu - %7lu %7lu %s %s\n",
|
: "%08lx %7lu - - - %s %s\n",
|
||||||
start,
|
start,
|
||||||
(unsigned long)(diff>>10),
|
(unsigned long)(diff>>10),
|
||||||
(flags[3]=='s') ? (unsigned long)(diff>>10) : 0,
|
flags,
|
||||||
(flags[3]=='p') ? (unsigned long)(diff>>10) : 0,
|
|
||||||
perms,
|
|
||||||
cp
|
cp
|
||||||
);
|
);
|
||||||
}else{
|
}else{
|
||||||
@ -164,11 +141,11 @@ static int one_proc(unsigned pid){
|
|||||||
if(!cp) cp = anon_name(pid, start, diff);
|
if(!cp) cp = anon_name(pid, start, diff);
|
||||||
printf(
|
printf(
|
||||||
(sizeof(KLONG)==8)
|
(sizeof(KLONG)==8)
|
||||||
? "%016"KLF"x %6luK %s %s\n"
|
? "%016"KLF"x %6luK %s %s\n"
|
||||||
: "%08lx %6luK %s %s\n",
|
: "%08lx %6luK %s %s\n",
|
||||||
start,
|
start,
|
||||||
(unsigned long)(diff>>10),
|
(unsigned long)(diff>>10),
|
||||||
perms,
|
flags,
|
||||||
cp
|
cp
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -184,12 +161,10 @@ static int one_proc(unsigned pid){
|
|||||||
total_private >> 10
|
total_private >> 10
|
||||||
);
|
);
|
||||||
}else{
|
}else{
|
||||||
printf("-------- ------ ------ ------ ------\n");
|
printf("-------- ------- ------- ------- -------\n");
|
||||||
printf(
|
printf(
|
||||||
"total kB %7ld - %7ld %7ld\n",
|
"total kB %7ld - - -\n",
|
||||||
(total_shared + total_private) >> 10,
|
(total_shared + total_private) >> 10
|
||||||
total_shared >> 10,
|
|
||||||
total_private >> 10
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
@ -228,6 +203,12 @@ int main(int argc, char *argv[]){
|
|||||||
case 'r':
|
case 'r':
|
||||||
r_option++;
|
r_option++;
|
||||||
break;
|
break;
|
||||||
|
case 'd':
|
||||||
|
d_option++;
|
||||||
|
break;
|
||||||
|
case 'q':
|
||||||
|
q_option++;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
@ -248,9 +229,9 @@ int main(int argc, char *argv[]){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(x_option>1 || V_option>1 || r_option>1) usage(); // dupes
|
if( (x_option|V_option|r_option|d_option|q_option) >> 1 ) usage(); // dupes
|
||||||
if(V_option){
|
if(V_option){
|
||||||
if(count|x_option|r_option) usage();
|
if(count|x_option|r_option|d_option|q_option) usage();
|
||||||
fprintf(stdout, "pmap (%s)\n", procps_version);
|
fprintf(stdout, "pmap (%s)\n", procps_version);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user