From c86d168165059404fcb643721c9805ba10ce8ce4 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Thu, 30 Aug 2018 14:14:24 +0900 Subject: [PATCH] procfs: handle 'comm' on mckernel side Change-Id: Ie68514ba3e5161b931b88eeee9e8a2267ee69354 --- executer/kernel/mcctrl/procfs.c | 2 +- kernel/procfs.c | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/executer/kernel/mcctrl/procfs.c b/executer/kernel/mcctrl/procfs.c index 009750c4..da658f63 100644 --- a/executer/kernel/mcctrl/procfs.c +++ b/executer/kernel/mcctrl/procfs.c @@ -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), diff --git a/kernel/procfs.c b/kernel/procfs.c index 7873186a..5a311249 100644 --- a/kernel/procfs.c +++ b/kernel/procfs.c @@ -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;