Reading The Contents Of A Directory
If we'll just stop here, we'll get a system crash in the first "ls" to the
root directory - we want to be able to read the contents of the root directory,
and this requires a file-operation named readdir, implemented in
stamfs_readdir():
- Make sure the file "read-head" position is not located past the last
entry in the directory (for a large dir, we only return part of it,
and the user will perform another readdir to read the next chunk, etc.).
- If we're at the first position, insert info about directory '.' (we don't
keep it on disk).
- If we're at the second position, insert info about directory '..' (we don't
keep it on disk).
- Read the directory's data block from disk.
- As long as there's space in the user's buffer, scan the list of files
and add them to the user's buffer.
- Update the last access-time of the directory.
Now, here is the search-able STAMFS code.
Note: expect a kernel-panic when bdflush tries to sync this
directory - we'll get back to this later...
Originally written by
guy keren