/*-- in guestfsd.c --*/
extern int verbose;
+extern int autosync_umount;
+
extern const char *sysroot;
extern int sysroot_len;
*/
#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.
const char *sysroot = "/sysroot"; /* No trailing slash. */
int sysroot_len = 8;
+/* If set (the default), do 'umount-all' when performing autosync. */
+int autosync_umount = 1;
+
/* Not used explicitly, but required by the gnulib 'error' module. */
const char *program_name = "guestfsd";
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, '?' },
dont_fork = 1;
break;
+ /* The -r flag is used when running standalone. It changes
+ * several aspects of the daemon.
+ */
+ case 'r':
+ sysroot = "";
+ sysroot_len = 0;
+ autosync_umount = 0;
+ break;
+
case 'v':
verbose = 1;
break;