[hacktree] parallel-debian: More in progress work...
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hacktree] parallel-debian: More in progress work...
- Date: Thu, 20 Oct 2011 00:55:10 +0000 (UTC)
commit 33232117d51c8f262d74d77e17ae2184f7e63892
Author: Colin Walters <walters verbum org>
Date: Wed Oct 19 20:54:28 2011 -0400
parallel-debian: More in progress work...
parallel-debian/README-testing-multiroot.md | 6 ++++
parallel-debian/create-wheezy-image.sh | 16 ----------
parallel-debian/make-image-parallel.sh | 20 -------------
parallel-debian/ostree_switch_root.c | 42 +++++++++++++++++++++++---
4 files changed, 43 insertions(+), 41 deletions(-)
---
diff --git a/parallel-debian/README-testing-multiroot.md b/parallel-debian/README-testing-multiroot.md
index 4fd0a12..1eadf88 100644
--- a/parallel-debian/README-testing-multiroot.md
+++ b/parallel-debian/README-testing-multiroot.md
@@ -2,6 +2,12 @@
Experimenting with multiple roots
---------------------------------
+ $ mkdir gnomeos-chroot
+ $ qemu-img create gnomeos.raw 2G
+ $ mkfs.ext2 -F gnomeos.raw
+ $ mount -o loop gnomeos.raw gnomeos-chroot
+ $ debootstrap --arch=amd64 squeeze gnomeos-chroot
+
<http://wiki.debian.org/QEMU#Setting_up_a_testing.2BAC8-unstable_system>
Follow the steps for making a disk image, downloading the business
diff --git a/parallel-debian/ostree_switch_root.c b/parallel-debian/ostree_switch_root.c
index 543dcb2..67a1cc6 100644
--- a/parallel-debian/ostree_switch_root.c
+++ b/parallel-debian/ostree_switch_root.c
@@ -143,7 +143,9 @@ static int make_readonly(const char *tree)
static int switchroot(const char *newroot, const char *subroot)
{
- const char *root_bind_mounts[] = { "/home", "/root", "/var", NULL };
+ const char *toproot_bind_mounts[] = { "/boot", NULL };
+ const char *ostree_inherit_mounts[] = { "/home", "/root", NULL };
+ const char *ostree_bind_mounts[] = { "/var", NULL };
const char *readonly_bind_mounts[] = { "/bin", "/etc", "/lib",
"/lib32", "/lib64", "/sbin",
"/usr",
@@ -151,13 +153,23 @@ static int switchroot(const char *newroot, const char *subroot)
int i;
int orig_cfd;
int new_cfd;
+ int subroot_cfd;
pid_t pid;
+ char subroot_path[PATH_MAX];
char srcpath[PATH_MAX];
char destpath[PATH_MAX];
+ struct stat stbuf;
orig_cfd = open("/", O_RDONLY);
new_cfd = open(newroot, O_RDONLY);
+ snprintf(subroot_path, sizeof(subroot_path), "%s/ostree/%s", newroot, subroot);
+ subroot_cfd = open(subroot_path, O_RDONLY);
+ if (subroot_cfd < 0) {
+ perrorv("failed to open subroot %s", subroot_path);
+ return -1;
+ }
+
/* For now just remount the rootfs r/w. Should definitely
* handle this better later... (famous last words)
*/
@@ -166,11 +178,31 @@ static int switchroot(const char *newroot, const char *subroot)
return -1;
}
- for (i = 0; root_bind_mounts[i] != NULL; i++) {
- snprintf(srcpath, sizeof(srcpath), "%s%s", newroot, root_bind_mounts[i]);
- snprintf(destpath, sizeof(destpath), "%s/%s%s", newroot, subroot, root_bind_mounts[i]);
+ for (i = 0; toproot_bind_mounts[i] != NULL; i++) {
+ snprintf(srcpath, sizeof(srcpath), "%s%s", newroot, toproot_bind_mounts[i]);
+ snprintf(destpath, sizeof(destpath), "%s/%s", subroot_path, toproot_bind_mounts[i]);
+ if (mount(srcpath, destpath, NULL, MS_BIND & ~MS_RDONLY, NULL) < 0) {
+ perrorv("failed to bind mount (class:toproot) %s to %s", srcpath, destpath);
+ return -1;
+ }
+ }
+
+ for (i = 0; ostree_inherit_mounts[i] != NULL; i++) {
+ snprintf(srcpath, sizeof(srcpath), "%s%s", newroot, ostree_inherit_mounts[i]);
+ if (stat (srcpath, &stbuf) < 0)
+ snprintf(srcpath, sizeof(srcpath), "%s/ostree%s", newroot, ostree_inherit_mounts[i]);
+ snprintf(destpath, sizeof(destpath), "%s%s", subroot_path, ostree_inherit_mounts[i]);
+ if (mount(srcpath, destpath, NULL, MS_BIND & ~MS_RDONLY, NULL) < 0) {
+ perrorv("failed to bind mount (class:inherit) %s to %s", srcpath, destpath);
+ return -1;
+ }
+ }
+
+ for (i = 0; ostree_bind_mounts[i] != NULL; i++) {
+ snprintf(srcpath, sizeof(srcpath), "%s/ostree%s", newroot, ostree_bind_mounts[i]);
+ snprintf(destpath, sizeof(destpath), "%s%s", subroot_path, ostree_bind_mounts[i]);
if (mount(srcpath, destpath, NULL, MS_BIND & ~MS_RDONLY, NULL) < 0) {
- perrorv("failed to bind mount %s to %s", srcpath, destpath);
+ perrorv("failed to bind mount (class:bind) %s to %s", srcpath, destpath);
return -1;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]