2

Linux has a distinct directory system such as /sys /usr /media /opt etc. I would like to know what part of linux kernel maps its self to the directory to listen to syscalls as all operation in linux is done using files?

If i have to change the directory system to include a directory like /foo by default, will I have to look into kernel or an image that runs on top of kernel?

In summary what part of the linux kernel code is responsible for binding with these directories?

  • Apart from trying to find an init program and /dev/console, the kernel doesn't care much about the contents of the root file system. – Ian Abbott Jan 17 '21 at 17:14
  • 1
    It's specified by LSB, not code. – stark Jan 17 '21 at 21:40
  • @stark so how do i bind some new kernel functionality to say a new directory `/foo` something must be done inside the kernel code to achieve such functionality..right? – BiologyEnthusiast Jan 18 '21 at 14:03
  • @IanAbbott when you say init program, you mean the GUI that loads when say, Ubuntu gets loaded? like Unity UI? – BiologyEnthusiast Jan 18 '21 at 14:04
  • @BiologyEnthusiast No, I mean something like Systemd's `/sbin/init` program. (However, for Ubuntu (at least on typical x86 systems) it will load `/init` from the initial ramdisk image, and switch over to the real root filesystem later.) – Ian Abbott Jan 18 '21 at 14:12
  • @IanAbbott this is what concerns me as i read that in linux everything is done via root file system (system calls, drivers etc are all file system) and directory system is pehaps the interface between userland and kernel (as far as I understood) so shouldnt kernel care about the rootfile system? – BiologyEnthusiast Jan 18 '21 at 14:15
  • 1
    @BiologyEnthusiast It cares about maintaining the file systems in a valid state, but the contents of the file system are controlled externally to the kernel. The kernel doesn't care if you have a `/foo` directory or not, but will return an error to any syscall from userspace that tries to open a non-existent file or directory. – Ian Abbott Jan 18 '21 at 14:52
  • 1
    There is no *"directory system"*. Elevating the organization/implementation to the level of "system" is an overreach. – sawdust Jan 20 '21 at 00:03
  • @sawdust thanks for the correction so perhaps would it be fair to ask what part of linux kernel is involved in maintaining directory implementation and organization? – BiologyEnthusiast Jan 20 '21 at 11:43
  • 1
    The filesystem support is implemented in the kernel. There are kernel APIs that use **/sys** and **/proc**, but otherwise the kernel is generally unaware of the directory structure. For the organization see [Filesystem Hierarchy Standard](https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard) which "defines the directory structure and directory contents in Linux distributions." The need for such a standard indicates that the directory structure is not dictated by the kernel. – sawdust Jan 20 '21 at 20:41

0 Answers0