CrazySynthax CrazySynthax - 1 year ago 67
Linux Question

What happens in linux when opening a file?

When using the open() function in linux in order to open a file, is it true that the OS brings all the file blocks to the cache?

Answer Source

AFAIK, the kernel won't systematically on open(2) bring all file blocks into its page cache (in particular, that cannot work for files bigger than available RAM).

But it may bring some of them. I guess that for most (small) files, perhaps all blocks could be read. But I could be wrong, and it is highly system specific (and configuration specific too).

See also O_DIRECT flag to open(2) & posix_fadvise(2) and options for mount(8)