Saturday, July 23, 2022

[SOLVED] How is /proc/[pid]/ns/mnt created by clone in kernel?

Issue

I know clone function creates /proc/[pid]/ns/mnt link. But I couldn’t find where it calls something like proc_mkdir to create such directory.


Solution

clone() doesn't create anything in /proc.

When you open /proc/[pid]/ns/mnt, the path lookup logic in VFS finds /proc and then gets to proc_root_lookup().

From there it goes to proc_pid_lookup() to proc_pid_instantiate(), which creates, on the fly, an in-memory directory inode for /proc/[pid] via proc_pid_make_inode().



Answered By - root
Answer Checked By - David Marino (WPSolving Volunteer)