3

As I understand, kernel provides mainly two interface for user space to do something in kernel, these are System Call and Virtual File system (procfs, sysfs etc). What I read in a book, that internally VFS also uses System Call.

So I want to know, how these two are connected exactly? And what are the situation where we should use VFS over System Call and vice versa.

Rahul
  • 1,607
  • 3
  • 23
  • 41

1 Answers1

2

A system call is the generic facility for any user space process to switch from user space mode to kernel mode.

It is like a function call that resides in the kernel and being invoked from user space with a variable number of parameters, the most important one is the syscall number.

The kernel will always maintain an architecture-specific array of supported system calls (=kernel functions) and will basically dispatch any syscall coming from user space to the correct function based on the system call number passed from user space.

Virtual File System is just an abstraction of a file system that provides you with standard functions to deal with any thing that can be considered a file. So for example you can call "open", "close", "read", etc. on any file without being concerned about what filesystem is this file stored in.

The relation here between VFS and syscalls is that VFS is basically code that resides in the kernel and the only way to get to the kernel is through syscalls ( "open" is a syscall, so is "close", etc )

KarimRaslan
  • 333
  • 2
  • 6
  • This article about VFS would help to understand more about VFS which would helpful. https://opensource.com/article/19/3/virtual-filesystems-linux – Anit Shrestha May 08 '21 at 13:09