44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
exit(EXIT_FAILURE);
}
int main(int argc, char **argv) {
/*
* Remount root filesystem read-write
*/
mount("/dev/vda2", "/", "ext2", MS_REMOUNT, NULL);
/*
* Mount needed filesystems
*/
mkdir("/dev", 0755);
mount("devtmpfs", "/dev", "devtmpfs", 0, NULL);
|
|
|
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
exit(EXIT_FAILURE);
}
int main(int argc, char **argv) {
/*
* Remount root filesystem read-write
*/
mount("/dev/vda2", "/", "ext4", MS_REMOUNT, NULL);
/*
* Mount needed filesystems
*/
mkdir("/dev", 0755);
mount("devtmpfs", "/dev", "devtmpfs", 0, NULL);
|
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
/*
* Setup networking
*/
run("/bin/init-networking", "init-networking", NULL);
run("/bin/init-fuse", "init-fuse", NULL);
mkdir("/bin", 0755);
mkdir("/lib", 0755);
mkdir("/opt", 0755);
mkdir("/opt/appfs", 0755);
mkdir("/var", 0755);
mkdir("/var/cache", 0755);
mkdir("/var/cache/appfs", 0755);
run("/bin/appfsd", "appfsd", "/var/cache/appfs", "/opt/appfs", NULL);
symlink(".", "/usr");
symlink("lib", "/lib64");
symlink("/opt/appfs/core.appfs.rkeene.org/bash/platform/latest/bin/bash", "/bin/bash");
symlink("/opt/appfs/core.appfs.rkeene.org/coreutils/platform/latest/bin/env", "/bin/env");
symlink("/bin/bash", "/bin/sh");
setenv("PATH", "/bin:/opt/appfs/core.appfs.rkeene.org/coreutils/platform/latest/bin", 1);
run("/bin/appfs-cache", "appfs-cache", "install", "-lib", "core.appfs.rkeene.org", "glibc", NULL);
run("/bin/appfs-cache", "appfs-cache", "install", "core.appfs.rkeene.org", "coreutils", NULL);
setenv("PATH", "/bin", 1);
run("/bin/sh", "sh", NULL);
return(0);
}
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
/*
* Setup networking
*/
run("/bin/init-networking", "init-networking", NULL);
run("/bin/init-fuse", "init-fuse", NULL);
mkdir("/etc", 0755);
mkdir("/bin", 0755);
mkdir("/lib", 0755);
mkdir("/opt", 0755);
mkdir("/opt/appfs", 0755);
mkdir("/var", 0755);
mkdir("/var/cache", 0755);
mkdir("/var/cache/appfs", 0755);
run("/bin/appfsd", "appfsd", "/var/cache/appfs", "/opt/appfs", NULL);
symlink(".", "/usr");
symlink("lib", "/lib64");
symlink("/proc/self/mounts", "/etc/mtab");
symlink("/opt/appfs/core.appfs.rkeene.org/bash/platform/latest/bin/bash", "/bin/bash");
symlink("/opt/appfs/core.appfs.rkeene.org/coreutils/platform/latest/bin/env", "/bin/env");
symlink("/bin/bash", "/bin/sh");
setenv("PATH", "/bin:/opt/appfs/core.appfs.rkeene.org/coreutils/platform/latest/bin", 1);
run("/bin/appfs-cache", "appfs-cache", "install", "-lib", "core.appfs.rkeene.org", "glibc", NULL);
run("/bin/appfs-cache", "appfs-cache", "install", "core.appfs.rkeene.org", "coreutils", NULL);
setenv("PATH", "/bin", 1);
run("/bin/sh", "sh", NULL);
/*
* Remount root filesystem read-only
*/
umount("/dev");
umount("/tmp");
umount("/proc");
umount("/sys");
umount("/opt/appfs");
mount("/dev/vda2", "/", "ext4", MS_REMOUNT | MS_RDONLY, NULL);
sync();
return(0);
}
|