Received: from eggs.gnu.org ([140.186.70.92]:33723) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RM26a-0004kR-KK for qemu-devel@nongnu.org; Thu, 03 Nov 2011 14:33:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RM26W-0002IR-Cl for qemu-devel@nongnu.org; Thu, 03 Nov 2011 14:33:36 -0400 Received: from cantor2.suse.de ([195.135.220.15]:47660 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RM26W-0002Dx-3P for qemu-devel@nongnu.org; Thu, 03 Nov 2011 14:33:32 -0400 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> In-Reply-To: Mime-Version: 1.0 (iPhone Mail 8G4) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Message-Id: <4640D068-69FE-4F67-8414-E35B0C9174CB@suse.de> From: Alexander Graf Date: Thu, 3 Nov 2011 11:33:01 -0700 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: David Gilbert Cc: "adrian@suse.de" , "riku.voipio@iki.fi" , "qemu-devel@nongnu.org" On 03.11.2011, at 02:34, David Gilbert wrote: > 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. >>=20 >> Signed-off-by: Alexander Graf >> --- >> linux-user/syscall.c | 52 ++++++++++++++++++++++++++++++++++++++++++++= +++-- >> 1 files changed, 49 insertions(+), 3 deletions(-) >>=20 >> 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) >> return osversion; >> } >>=20 >> +static int do_open(void *cpu_env, const char *pathname, int flags, mode_= t mode) >=20 > Once you open the pandoras-box that is emulating /proc, I think you'll pro= bably > need to hook it in more places and be more general; although you may > well get away > with it for this particular case. >=20 > Isn't it better to put the filename interception code somewhere more gener= al > so that it can also be misused by other calls - e.g. stat(). We can move it when we get there :). >=20 > 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. I was hoping to get away with a bit less involving. Sure, we could actually o= pen the pandora box of emulating all of /proc, but I really don't want to go= down that route. Since all these files already do exist on the host view, I don't think we ha= ve to fake stat(). The file size will be wrong either way. So yes, eventually we might have to use the big sledge hammer of emulating a= ll of /proc, but as long as I can refrain from it I will :). It's just a _lo= t_ of work. Alex >=20 > Dave