From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:42181) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ri6Kn-00041v-Vf for qemu-devel@nongnu.org; Tue, 03 Jan 2012 10:31:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ri6Km-0006Lt-Is for qemu-devel@nongnu.org; Tue, 03 Jan 2012 10:31:29 -0500 Received: from mail-gy0-f173.google.com ([209.85.160.173]:42720) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ri6Km-0006Ll-Fa for qemu-devel@nongnu.org; Tue, 03 Jan 2012 10:31:28 -0500 Received: by ghbg16 with SMTP id g16so6391958ghb.4 for ; Tue, 03 Jan 2012 07:31:27 -0800 (PST) MIME-Version: 1.0 Sender: lxnay@sabayonlinux.org In-Reply-To: <32C931EE-C43F-424F-B750-3178F8C97836@suse.de> References: <32C931EE-C43F-424F-B750-3178F8C97836@suse.de> Date: Tue, 3 Jan 2012 16:31:27 +0100 Message-ID: From: Fabio Erculiani Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] linux-user: improved fake /proc/self/stat List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Graf Cc: riku.voipio@iki.fi, qemu-devel@nongnu.org On Tue, Jan 3, 2012 at 3:26 PM, Alexander Graf wrote: > Subject should have [PATCH] in the beginning. Why don't you just create t= he patch using git-format-patch? It makes sure the format is correct. You c= an also check out http://wiki.qemu.org/Contribute/SubmitAPatch for some hin= ts. > > And thanks a lot for fixing this! whoops, yeah this is my first contribution to qemu ;) > > On 03.01.2012, at 08:25, Fabio Erculiani wrote: > >> 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. > > Signed-off-by line is missing :). > >> >> --- 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, >> =C2=A0 =C2=A0 =C2=A0 int len; >> =C2=A0 =C2=A0 =C2=A0 uint64_t val =3D 0; >> >> - =C2=A0 =C2=A0 =C2=A0if (i =3D=3D 27) { >> + =C2=A0 =C2=A0 =C2=A0if (i =3D=3D 0) { >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* pid */ >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0snprintf(buf, sizeof(buf), "%jd ", (= intmax_t) ts->ts_tid); > > Is it the TID or the PID? If it's get PID, this should be getpid(). Also = why not simply use uint64_t and PRId64 like below? ts_tid contains the pid afaik. But ok, will use getpid() directly. > >> + =C2=A0 =C2=A0 =C2=A0} >> + =C2=A0 =C2=A0 =C2=A0else if (i =3D=3D 1) { > > Braces are incorrect. Please run scripts/checkpatch.pl on your patch :). Ok, thanks, will validate using checkpatch.pl. > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* app name */ >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0snprintf(buf, sizeof(buf), "(%s) ", = ts->bprm->filename); > > I would assume this is argv[0] and not the filename, so if I read the cod= e correctly this should be ts->bprm->>argv[0], right? whoops :) Yes. > >> + =C2=A0 =C2=A0 =C2=A0} >> + =C2=A0 =C2=A0 =C2=A0else if (i =3D=3D 27) { > > Braces again :) > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 /* stack bottom */ >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 val =3D start_stack; >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0snprintf(buf, sizeof(buf), "%"PRId64= " ", val); >> + =C2=A0 =C2=A0 =C2=A0} >> + =C2=A0 =C2=A0 =C2=A0else { > > Braces > > > Alex > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* for the rest, write zeros */ >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0snprintf(buf, sizeof(buf), "0%c", i = =3D=3D 43 ? '\n' : ' '); >> =C2=A0 =C2=A0 =C2=A0 } >> - =C2=A0 =C2=A0 =C2=A0snprintf(buf, sizeof(buf), "%"PRId64 "%c", val, i = =3D=3D 43 ? '\n' : ' '); >> =C2=A0 =C2=A0 =C2=A0 len =3D strlen(buf); >> =C2=A0 =C2=A0 =C2=A0 if (write(fd, buf, len) !=3D len) { >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return -1; >> >> -- >> Fabio Erculiani > --=20 Fabio Erculiani