procfs: add '/proc/pid/stat' to mckernel side and fix its comm

This lets ps show the proper executable name instead of mcexec's comm
on linux side

Change-Id: I62732037451f129fc2e905357ebdc351bf7f6d2d
Refs: #1114
This commit is contained in:
Dominique Martinet
2018-08-24 11:31:06 +09:00
committed by Masamichi Takagi
parent ecc850dfef
commit b70d470e20
4 changed files with 43 additions and 5 deletions

View File

@@ -631,6 +631,41 @@ int process_procfs_request(struct ikc_scd_packet *rpacket)
*/
if (!strcmp(p, "stat")) {
const char *comm = "exe";
char state;
if (proc->saved_cmdline) {
comm = strrchr(proc->saved_cmdline, '/');
if (comm)
comm++;
else
comm = proc->saved_cmdline;
}
switch (proc->status & (0x3f)) {
case PS_INTERRUPTIBLE:
state = 'S';
break;
case PS_UNINTERRUPTIBLE:
state = 'D';
break;
case PS_ZOMBIE:
state = 'Z';
break;
case PS_EXITED:
state = 'X';
break;
case PS_STOPPED:
state = 'T';
break;
case PS_RUNNING:
default:
if (proc->forwarding)
state = 'S';
else
state = 'R';
break;
}
/*
* pid (comm) state ppid
@@ -657,7 +692,7 @@ int process_procfs_request(struct ikc_scd_packet *rpacket)
"%lu %lu %lu %lu " // sigignore...
"%lu %d %d %u " // cnswap...
"%u %llu %lu %ld\n", // policy...
0, "exe", 'R', 0, // pid...
0, comm, state, 0, // pid...
0, 0, 0, 0, // pgrp...
0, 0L, 0L, 0L, // flags...
0L, 0L, 0L, 0L, // cmajflt...