From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1C6BbE-0006Ol-2g for qemu-devel@nongnu.org; Sat, 11 Sep 2004 13:23:44 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1C6BbC-0006O9-F6 for qemu-devel@nongnu.org; Sat, 11 Sep 2004 13:23:43 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1C6BbC-0006Ny-Cf for qemu-devel@nongnu.org; Sat, 11 Sep 2004 13:23:42 -0400 Received: from [62.241.160.193] (helo=pengo.systems.pipex.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1C6BVW-0002u4-Jn for qemu-devel@nongnu.org; Sat, 11 Sep 2004 13:17:50 -0400 Received: from nowt.org (81-178-249-118.dsl.pipex.com [81.178.249.118]) by pengo.systems.pipex.net (Postfix) with ESMTP id 3ADCA4C0016C for ; Sat, 11 Sep 2004 18:17:44 +0100 (BST) Received: from wren.home (wren.home [192.168.1.7]) by nowt.org (Postfix) with ESMTP id 071D1AC92 for ; Sat, 11 Sep 2004 18:17:43 +0100 (BST) From: Paul Brook Date: Sat, 11 Sep 2004 18:17:43 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200409111817.43335.paul@codesourcery.com> Subject: [Qemu-devel] [patch] Bug in path.c Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org The path mangling code does the wrong thing when the prefix doesn't exist. For example path("/.") still returns "/usr/gnemul/qemu-arm", even if the latter doesn't exist (commonly the case when using a chroot). Patch below fixes this by setting base to NULL if the prefix contains no files. Paul Index: path.c =================================================================== RCS file: /cvsroot/qemu/qemu/linux-user/path.c,v retrieving revision 1.1 diff -u -p -r1.1 path.c --- path.c 11 Apr 2003 00:15:13 -0000 1.1 +++ path.c 11 Sep 2004 17:12:14 -0000 @@ -101,7 +101,11 @@ void init_paths(const char *prefix) base = new_entry("", NULL, prefix+1); base = add_dir_maybe(base); - set_parents(base, base); + if (base->num_entries == 0) { + free (base); + base = NULL; + } else + set_parents(base, base); } /* FIXME: Doesn't handle DIR/.. where DIR is not in emulated dir. */