On Fri, Jan 13, 2012 at 04:47:35PM +0400, Michael Tokarev wrote: > On 13.01.2012 15:57, Stefan Hajnoczi wrote: > > On Fri, Jan 13, 2012 at 9:04 AM, Michael Tokarev <m...@tls.msk.ru> 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.
Or just canonicalize all relative paths before daemonizing. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|