Use sefs mount for generating runtime boot rootfs
This commit is contained in:
parent
09ca34182e
commit
9089764b64
@ -11,7 +11,7 @@ The later step will use the image content to generate UnionFS image.
|
|||||||
|
|
||||||
### Build and start a [`gen_rootfs`](./gen_rootfs) Occlum instance
|
### Build and start a [`gen_rootfs`](./gen_rootfs) Occlum instance
|
||||||
|
|
||||||
This `gen_rootfs` mounts a empty UnionFS, copy the BASH Occlum image content to the mount point, unmount the UnionFS. It generates an encrypted UnionFS image containing the BASH image content. The **key** used in this demo is `"c7-32-b3-ed-44-df-ec-7b-25-2d-9a-32-38-8d-58-61"`.
|
This `gen_rootfs` mounts a empty **sefs** (uses the lower path as mount target dir), copy the BASH Occlum image content to the mount point, unmount the **sefs**. It generates an encrypted **sefs** image containing the BASH image content. The **key** used in this demo is `"c7-32-b3-ed-44-df-ec-7b-25-2d-9a-32-38-8d-58-61"`.
|
||||||
|
|
||||||
### Build customized [`init`](./init)
|
### Build customized [`init`](./init)
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ Occlum [`default init`](../../tools/init) calls syscall (363) `MountRootFS` to m
|
|||||||
The first parameter `key_ptr` is optional.
|
The first parameter `key_ptr` is optional.
|
||||||
The second parameter `rootfs_config` needs to be set as NULL.
|
The second parameter `rootfs_config` needs to be set as NULL.
|
||||||
|
|
||||||
But for runtime booting pre-generated UnionFS image, The first parameter `key_ptr` is must to have, the second parameter `rootfs_config` needs have valid members.
|
But for runtime booting pre-generated image, The first parameter `key_ptr` is must to have, the second parameter `rootfs_config` needs have valid members.
|
||||||
```
|
```
|
||||||
struct user_rootfs_config {
|
struct user_rootfs_config {
|
||||||
// length of the struct
|
// length of the struct
|
||||||
|
@ -9,15 +9,14 @@ fn main() {
|
|||||||
println!("{:?}", args);
|
println!("{:?}", args);
|
||||||
fs::create_dir("/mount").unwrap();
|
fs::create_dir("/mount").unwrap();
|
||||||
|
|
||||||
let fs_type = "unionfs";
|
let fs_type = "sefs";
|
||||||
let mount_path = Path::new("/mount");
|
let mount_path = Path::new("/mount");
|
||||||
let source = Path::new("unionfs");
|
let source = Path::new("sefs");
|
||||||
let flags = MsFlags::empty();
|
let flags = MsFlags::empty();
|
||||||
let key = &args[1];
|
let key = &args[1];
|
||||||
let options = format!(
|
let options = format!(
|
||||||
"lowerdir={},upperdir={},key={}",
|
"dir={},key={}",
|
||||||
"./mnt_unionfs/lower",
|
"./mnt_unionfs/lower",
|
||||||
"./mnt_unionfs/upper",
|
|
||||||
key
|
key
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -578,7 +578,7 @@ impl ConfigApp {
|
|||||||
.find(|m| m.target == Path::new("/") && m.type_ == ConfigMountFsType::TYPE_UNIONFS)
|
.find(|m| m.target == Path::new("/") && m.type_ == ConfigMountFsType::TYPE_UNIONFS)
|
||||||
.ok_or_else(|| errno!(Errno::ENOENT, "the root UnionFS is not valid"))?;
|
.ok_or_else(|| errno!(Errno::ENOENT, "the root UnionFS is not valid"))?;
|
||||||
|
|
||||||
if upper_layer.is_some() {
|
if lower_layer.is_some() {
|
||||||
let layer_mount_configs = root_mount_config.options.layers.as_mut().unwrap();
|
let layer_mount_configs = root_mount_config.options.layers.as_mut().unwrap();
|
||||||
// image SEFS in layers
|
// image SEFS in layers
|
||||||
let root_image_sefs_mount_config = layer_mount_configs
|
let root_image_sefs_mount_config = layer_mount_configs
|
||||||
@ -590,12 +590,12 @@ impl ConfigApp {
|
|||||||
})
|
})
|
||||||
.ok_or_else(|| errno!(Errno::ENOENT, "the image SEFS in layers is not valid"))?;
|
.ok_or_else(|| errno!(Errno::ENOENT, "the image SEFS in layers is not valid"))?;
|
||||||
|
|
||||||
root_image_sefs_mount_config.source = upper_layer;
|
root_image_sefs_mount_config.source = lower_layer;
|
||||||
root_image_sefs_mount_config.options.mac = None;
|
root_image_sefs_mount_config.options.mac = None;
|
||||||
root_image_sefs_mount_config.options.index = 1;
|
root_image_sefs_mount_config.options.index = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if lower_layer.is_some() {
|
if upper_layer.is_some() {
|
||||||
let layer_mount_configs = root_mount_config.options.layers.as_mut().unwrap();
|
let layer_mount_configs = root_mount_config.options.layers.as_mut().unwrap();
|
||||||
// container SEFS in layers
|
// container SEFS in layers
|
||||||
let root_container_sefs_mount_config = layer_mount_configs
|
let root_container_sefs_mount_config = layer_mount_configs
|
||||||
@ -610,7 +610,7 @@ impl ConfigApp {
|
|||||||
errno!(Errno::ENOENT, "the container SEFS in layers is not valid")
|
errno!(Errno::ENOENT, "the container SEFS in layers is not valid")
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
root_container_sefs_mount_config.source = lower_layer;
|
root_container_sefs_mount_config.source = upper_layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
if entry_point.is_some() {
|
if entry_point.is_some() {
|
||||||
|
Loading…
Reference in New Issue
Block a user