Read in text books that there are mainly two file access methods; sequential and direct. Which one we are using in Linux?
In read command we are giving the how much bytes to read and to which buffer. So we are having sequential access in Linux?
But physically we have files stored is blocks? I couldnt relate to it.
Whether direct access possible in Linux?
I read about these access models in Operating System Concepts by Galvin
Both are possible.
When you do a
readon an ordinary file, it does read the file sequentially, advancing the file pointer each time by the right amount.But you can also use
seekto move to an arbitrary point in the file.Not all files support random/direct access. Pipes for instance are typically only sequential access (you can’t rewind or skip forward).
So pretty much everything is possible, but some file types have restrictions.
(File access with direct I/O (
O_DIRECTflag) is a different concept altogether.)