Actually Opening The File
Entry function: open_namei, in fs/namei.c.
- If not opening in create mode (no O_CREAT flag given):
lookup the file via the dentry cache (path_lookup -> path_walk ->
link_path_walk).
- Otherwise (it is an open in create mode):
- Lookup the parent directory (path_lookup again). If it does not
exist, or is not a directory - fail the operation.
- Lookup the file in the parent directory. If it does not exist, create
it (see vfs_create later on).
- Handle special cases (flags mismatch, file is a directory, file is
a link...).
- In both cases (open with create or file already exists):
- Perform sanity checks.
- Check permissions.
- Check various mode limitations (e.g. file is read-only and trying to
open for write, trying to open a device file on a 'no_dev' file-system
mount, etc.).
- Handle truncation.
Originally written by
guy keren