VFS — Virtual File System
The VFS is the kernel abstraction that presents a common filesystem interface to applications regardless of the backing filesystem. Path resolution traverses directory entries and mount points; a dentry connects a name in a parent directory to an inode (or records a negative lookup). Opening creates a file object referenced by a descriptor; its state includes an offset and file status flags. A duplicated descriptor shares this open file description; an independent open normally has a separate offset. Looking up metadata does not require creating an open file description for the target. Individual filesystems implement operations behind this interface. A pathname can be replaced while an already-open descriptor still refers to the original object. To investigate, compare stat on a pathname with fstat on a descriptor; compare device and inode together, not inode alone. Symlink traversal, mount boundaries, permissions and concurrent rename matter. The example uses only a private temporary directory and demonstrates stable descriptor identity after rename; it does not inspect kernel VFS objects directly. Example prerequisites: Linux, Bash and Python 3 standard library; run as a non-root user in a private temporary working directory. Example scope: native userspace observation. Expected output: renamed object still open; replacement is distinct. No system configuration changes.
Formal Syntax & Structure
Lookup: pathname → mount + dentry → inode; open: descriptor → open file description → path + file operationsParameters & Attributes
| Name | Type | Description |
|---|---|---|
| dentry | kernel object | Name lookup and parent association. |
| inode | kernel object | Metadata and filesystem operation association. |
| open file description | kernel object | Open instance with offset and flags. |
Return Value
The model describes object relationships, not a callable function. stat/fstat expose selected metadata; example prints a stable identity comparison.
Working Example
python3 - <<'PY'import os, tempfilefrom pathlib import Pathwith tempfile.TemporaryDirectory() as d: p = Path(d) / 'original' p.write_bytes(b'old') with p.open('rb') as f: p.rename(Path(d) / 'moved') p.write_bytes(b'new') old, new = os.fstat(f.fileno()), p.stat() assert (old.st_dev, old.st_ino) != (new.st_dev, new.st_ino) assert f.read() == b'old' and p.read_bytes() == b'new'print('renamed object still open; replacement is distinct')PY