マウント、pid、ユーザー名前空間などを含む新しい名前空間で複製されたコンテナーを実装しています。子が行う最初のステップは、システム コールなどのいくつかの重要なポイントをマウント/proc
すること/sys
です/tmp
。mount
if(::mount("proc", "/proc", "proc", 0, NULL)==-1) {
printf("Failed on mount: %s\n", strerror(errno));
return -1;
}
if(::mount("sysfs", "/sys", "sysfs", 0, NULL)==-1) {
printf("Failed on mount: %s\n", strerror(errno));
return -1;
}
if(::mount("tmp", "/tmp", "tmpfs", 0, NULL)==-1) {
printf("Failed on mount: %s\n", strerror(errno));
return -1;
}
source
ただし、 に渡される引数リストのフィールドに少し混乱していますmount
。
int mount(const char *source, const char *target,
const char *filesystemtype, unsigned long mountflags,
const void *data);
ソースは正確には何を意味しますか?たとえば、マウント/tmp
はソースの文字列とは何の関係もないようです。/tmp
を使用しても、新しい名前空間の下に作成された新しいフォルダーが表示されます::mount(nullptr, "/tmp", "tmpfs", 0, NULL)
。何か不足していますか?