>From a87514cad8d2d1d31dcdb706e4a4ce2b0167fe3f Mon Sep 17 00:00:00 2001 From: Richard W.M. Jones Date: Thu, 27 Jan 2011 16:54:48 +0000 Subject: [PATCH 5/5] daemon: Allow -r option to set root directory as sysroot. This allows the user to set the sysroot directory to be the root directory (normally it is "/sysroot"). --- daemon/daemon.h | 20 ++++++++++++-------- daemon/guestfsd.c | 9 +++++++-- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/daemon/daemon.h b/daemon/daemon.h index da991b1..2253b04 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -253,17 +253,21 @@ extern void notify_progress (uint64_t position, uint64_t total); */ #define CHROOT_IN \ do { \ - int __old_errno = errno; \ - if (chroot (sysroot) == -1) \ - perror ("CHROOT_IN: sysroot"); \ - errno = __old_errno; \ + if (sysroot_len > 0) { \ + int __old_errno = errno; \ + if (chroot (sysroot) == -1) \ + perror ("CHROOT_IN: sysroot"); \ + errno = __old_errno; \ + } \ } while (0) #define CHROOT_OUT \ do { \ - int __old_errno = errno; \ - if (chroot (".") == -1) \ - perror ("CHROOT_OUT: ."); \ - errno = __old_errno; \ + if (sysroot_len > 0) { \ + int __old_errno = errno; \ + if (chroot (".") == -1) \ + perror ("CHROOT_OUT: ."); \ + errno = __old_errno; \ + } \ } while (0) /* Marks functions which are not implemented. diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c index 8d950fa..2db1fb7 100644 --- a/daemon/guestfsd.c +++ b/daemon/guestfsd.c @@ -125,13 +125,13 @@ static void usage (void) { fprintf (stderr, - "guestfsd [-f|--foreground] [-v|--verbose]\n"); + "guestfsd [-f|--foreground] [-v|--verbose] [-r]\n"); } int main (int argc, char *argv[]) { - static const char *options = "fv?"; + static const char *options = "frv?"; static const struct option long_options[] = { { "foreground", 0, 0, 'f' }, { "help", 0, 0, '?' }, @@ -171,6 +171,11 @@ main (int argc, char *argv[]) dont_fork = 1; break; + case 'r': + sysroot = ""; + sysroot_len = 0; + break; + case 'v': verbose = 1; break; -- 1.7.3.5