aboutsummaryrefslogtreecommitdiff
path: root/os-posix.c
diff options
context:
space:
mode:
authorJes Sorensen <Jes.Sorensen@redhat.com>2010-06-10 11:42:27 +0200
committerBlue Swirl <blauwirbel@gmail.com>2010-06-12 08:49:15 +0300
commit0766379d4c58c5c1edc6adc414bfb25fc979b083 (patch)
treef75949d3ba1ce0d19023871c6a447a061141157e /os-posix.c
parent8847cfe8aa9d8f6b8648aafd5d929a57d836cc61 (diff)
downloadqemu-arm-0766379d4c58c5c1edc6adc414bfb25fc979b083.tar.gz
Move chroot handling to OS specific files.
Move chroot handling to OS specific files. Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Acked-by: Juan Quintela <quintela@redhat.com> Acked-by: Richard Henderson <rth@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'os-posix.c')
-rw-r--r--os-posix.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/os-posix.c b/os-posix.c
index 8b686a44e1..6417d16dca 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -38,6 +38,7 @@
#include "qemu-options.h"
static struct passwd *user_pwd;
+static const char *chroot_dir;
void os_setup_early_signal_handling(void)
{
@@ -156,6 +157,9 @@ void os_parse_cmd_args(int index, const char *optarg)
exit(1);
}
break;
+ case QEMU_OPTION_chroot:
+ chroot_dir = optarg;
+ break;
}
return;
}
@@ -177,3 +181,18 @@ void os_change_process_uid(void)
}
}
}
+
+void os_change_root(void)
+{
+ if (chroot_dir) {
+ if (chroot(chroot_dir) < 0) {
+ fprintf(stderr, "chroot failed\n");
+ exit(1);
+ }
+ if (chdir("/")) {
+ perror("not able to chdir to /");
+ exit(1);
+ }
+ }
+
+}