From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:43076) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlgXk-00077V-Pf for qemu-devel@nongnu.org; Fri, 13 Jan 2012 07:47:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RlgXj-0003OS-8g for qemu-devel@nongnu.org; Fri, 13 Jan 2012 07:47:40 -0500 Received: from isrv.corpit.ru ([86.62.121.231]:35564) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlgXi-0003Nx-V3 for qemu-devel@nongnu.org; Fri, 13 Jan 2012 07:47:39 -0500 Message-ID: <4F1027E7.3080808@msgid.tls.msk.ru> Date: Fri, 13 Jan 2012 16:47:35 +0400 From: Michael Tokarev MIME-Version: 1.0 References: <20120113090951.3D333341@gandalf.tls.msk.ru> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] do not chdir(/) in qemu-nbd List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Kevin Wolf , qemu-devel@nongnu.org On 13.01.2012 15:57, Stefan Hajnoczi wrote: > On Fri, Jan 13, 2012 at 9:04 AM, Michael Tokarev wrote: >> When qemu-nbd becomes a daemon it calls daemon(3) with >> nochdir=0, so daemon(3) changes current directory to /. >> But at this time, qemu-nbd did not open any user-specified >> files yet, so by changing current directory, all non-absolute >> paths becomes wrong. The solution is to pass nochdir=1 to >> daemon(3) function. > > It's polite to chdir("/") so that file systems can be unmounted (even > more important when chroot was involved, but I think qemu-nbd doesn't > do that). Is it possible to manually do a chdir("/") later on after > we've opened necessary files? Yes that was something I wasn't happy about too -- lack of chdir(/) in daemons is annoying. But instead of adding a chdir later, I'll try to rearrange code a bit to do all init in the parent instead. Will send a follow-up. Thanks, /mjt