[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] linux-user: improved fake /proc/self/stat
From: |
Fabio Erculiani |
Subject: |
[Qemu-devel] linux-user: improved fake /proc/self/stat |
Date: |
Tue, 3 Jan 2012 08:25:58 +0100 |
Hi all,
this is a patch on top of "[PATCH 4/5] linux-user: fake
/proc/self/stat" (sorry I couldn't find the git repo bound to this
patchwork) that also implements PID and binary name reading them from
the fake TSS.
The pid was just a "why not" while the binary name is required (as
well as the backets in order to make `ps` not segfault, because it
expects to find "(binary name)" on the second spot.
The only doubt I have is about printing ts->ts_tid which is a pid_t,
which is a signed int, so perhaps int would be enough.
--- qemu-1.0.orig/linux-user/syscall.c
+++ qemu-1.0/linux-user/syscall.c
@@ -4678,11 +4678,23 @@ static int open_self_stat(void *cpu_env,
int len;
uint64_t val = 0;
- if (i == 27) {
+ if (i == 0) {
+ /* pid */
+ snprintf(buf, sizeof(buf), "%jd ", (intmax_t) ts->ts_tid);
+ }
+ else if (i == 1) {
+ /* app name */
+ snprintf(buf, sizeof(buf), "(%s) ", ts->bprm->filename);
+ }
+ else if (i == 27) {
/* stack bottom */
val = start_stack;
+ snprintf(buf, sizeof(buf), "%"PRId64 " ", val);
+ }
+ else {
+ /* for the rest, write zeros */
+ snprintf(buf, sizeof(buf), "0%c", i == 43 ? '\n' : ' ');
}
- snprintf(buf, sizeof(buf), "%"PRId64 "%c", val, i == 43 ? '\n' : ' ');
len = strlen(buf);
if (write(fd, buf, len) != len) {
return -1;
--
Fabio Erculiani
- [Qemu-devel] linux-user: improved fake /proc/self/stat,
Fabio Erculiani <=