In the Linux kernel, is open(), mmap() or neither, the more fundamental way to access a file? By fundamental, I mean does either ultimately call the other or a simple helper function of the other?.There are a lot of questions on the stack network asking about the performance of these two functions. The hope of this question is to get at what is going on inside the Linux kernel a priori. Does open() call mmap() or some helper function that essentially implements mmap()? Alternatively, does mmap() call open() or call some helper function that essentially implements open()?The gist of the question is whether these two system calls are fundamentally different or whether one is a convenience function of the other.
Is `open()`, `mmap()`, or neither, the more fundamental function?
linux;files;c
Notice that mmap(2) often wants a file descriptor usually provided by open(2); in that sense, open is more fundamental. Notice also that the virtual address space of some process is modified not only by mmap, munmap, mprotect(2) but also by other system calls (including execve(2); see also shm_overview(7))BTW, the Linux kernel don't use mmap or open but provides and implements them (for application-level user-space programs).But the Linux kernel manages the page cache which is more fundamental and related to both system calls. See also LinuxAteMyRam and consider perhaps using madvise(2), posix_fadvise(2), readahead(2) to give hints to the page cache subsystem.whether these two system calls are fundamentally different All system calls (listed in syscalls(2)...) are different.Read also Advanced Linux Programming and Operating Systems : Three Easy Pieces (both are freely downloadable).