procfs: handle 'comm' on mckernel side

Change-Id: Ie68514ba3e5161b931b88eeee9e8a2267ee69354
This commit is contained in:
Dominique Martinet
2018-08-30 14:14:24 +09:00
committed by Masamichi Takagi
parent a032dc3d1b
commit c86d168165
2 changed files with 22 additions and 3 deletions

View File

@ -1102,7 +1102,7 @@ static const struct procfs_entry pid_entry_stuff[] = {
// PROC_REG("cgroup", S_IXUSR, NULL),
// PROC_REG("clear_refs", S_IWUSR, NULL),
PROC_REG("cmdline", 0444, &mckernel_buff_io),
// PROC_REG("comm", S_IRUGO|S_IWUSR, NULL),
PROC_REG("comm", 0644, &mckernel_buff_io),
// PROC_REG("coredump_filter", S_IRUGO|S_IWUSR, NULL),
// PROC_REG("cpuset", S_IRUGO, NULL),
// PROC_REG("environ", S_IRUSR, NULL),

View File

@ -78,12 +78,13 @@ static void buf_free(unsigned long phys)
}
static int buf_add(struct mckernel_procfs_buffer **top,
struct mckernel_procfs_buffer **cur, void *buf, int l)
struct mckernel_procfs_buffer **cur,
const void *buf, int l)
{
int pos = 0;
int r;
int bufmax = PAGE_SIZE - sizeof(struct mckernel_procfs_buffer);
char *chr = buf;
const char *chr = buf;
if (!*top) {
*top = *cur = buf_alloc(NULL, 0);
@ -633,6 +634,24 @@ int process_procfs_request(struct ikc_scd_packet *rpacket)
* of the process. The count is the length of the area.
*/
if (!strcmp(p, "comm")) {
const char *comm = "exe";
if (proc->saved_cmdline) {
comm = strrchr(proc->saved_cmdline, '/');
if (comm)
comm++;
else
comm = proc->saved_cmdline;
}
ans = snprintf(buf, count, "%s\n", comm);
if (buf_add(&buf_top, &buf_cur, buf, ans) < 0)
goto err;
ans = 0;
goto end;
}
if (!strcmp(p, "stat")) {
const char *comm = "exe";
char state;