nuta / kerla

A new operating system kernel with Linux binary compatibility written in Rust.
Other
3.33k stars 89 forks source link

`RootFs` need to be cloneable, so the whole state can be copies instead of inherit a reference on `fork()`/`clone()` #105

Open michalfita opened 2 years ago

michalfita commented 2 years ago

At the moment Process::fork() seem to clone the Arc<RootFs> instead of content of the RootFs itself, what leads to shared RootFs between processes, not independent file system states.

Found during work on #88 and belongs to Multithreading milestone (I can't add myself).

More details in the flags mask of clone(2), scroll down to CLONE_FS. I haven't checked yet how it's implemented in Linux Kernel.

nuta commented 2 years ago

I agree. We should make RootFs cloneable. Simply adding #[derive(Clone)] should work.

nuta commented 2 years ago

Just letting you know that according to clone(2)'s man page, mount points are controlled through another flag CLONE_NEWNS despite Kerla maintains them in RootFs. We'll need to isolate the mount_points field some day but for now, I think we don't need to support the flag unless we support running something like Docker.

michalfita commented 2 years ago

Yes, @nuta - all flags related to namespaces are for now excluded from my attempts, namespaces are huge topic related to contenerization.