From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:51227) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RLtgr-0004u8-O2 for qemu-devel@nongnu.org; Thu, 03 Nov 2011 05:34:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RLtgq-0000K3-6i for qemu-devel@nongnu.org; Thu, 03 Nov 2011 05:34:29 -0400 Received: from mail-wy0-f173.google.com ([74.125.82.173]:37877) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RLtgp-0000Jw-Vy for qemu-devel@nongnu.org; Thu, 03 Nov 2011 05:34:28 -0400 Received: by wyh22 with SMTP id 22so1119245wyh.4 for ; Thu, 03 Nov 2011 02:34:26 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <1320261806-13194-3-git-send-email-agraf@suse.de> References: <1320261806-13194-1-git-send-email-agraf@suse.de> <1320261806-13194-2-git-send-email-agraf@suse.de> <1320261806-13194-3-git-send-email-agraf@suse.de> Date: Thu, 3 Nov 2011 09:34:26 +0000 Message-ID: From: David Gilbert Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 2/5] linux-user: add open() hijack infrastructure List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Graf Cc: adrian@suse.de, riku.voipio@iki.fi, qemu-devel@nongnu.org On 2 November 2011 19:23, Alexander Graf wrote: > There are a number of files in /proc that expose host information > to the guest program. This patch adds infrastructure to override > the open() syscall for guest programs to enable us to on the fly > generate guest sensible files. > > Signed-off-by: Alexander Graf > --- > =A0linux-user/syscall.c | =A0 52 ++++++++++++++++++++++++++++++++++++++++= +++++++-- > =A01 files changed, 49 insertions(+), 3 deletions(-) > > diff --git a/linux-user/syscall.c b/linux-user/syscall.c > index 9f5da36..38953ba 100644 > --- a/linux-user/syscall.c > +++ b/linux-user/syscall.c > @@ -4600,6 +4600,52 @@ int get_osversion(void) > =A0 =A0 return osversion; > =A0} > > +static int do_open(void *cpu_env, const char *pathname, int flags, mode_= t mode) Once you open the pandoras-box that is emulating /proc, I think you'll prob= ably need to hook it in more places and be more general; although you may well get away with it for this particular case. Isn't it better to put the filename interception code somewhere more genera= l so that it can also be misused by other calls - e.g. stat(). I guess you're also going to need to be able to do /proc/pid/* instead of /proc/self; something is bound to use that. Dave