Skip to content

linux/fs/open.c

Imported from _research/manual-study-linux/file-notes/linux__fs__open.c.md.

File Notes: fs/open.c

Status: reviewed.

Purpose: VFS open path and file descriptor setup.

Review target: path validation, file operation binding, user/kernel boundary, and Rust handle design.

Evidence

  • do_dentry_open() around line 885 is the internal file activation point.
  • finish_open() appears around line 1030 for finalizing an open operation.
  • vfs_open() appears around lines 1070-1074 as the helper for opening a resolved path.
  • build_open_flags() at line 1179 normalizes user open flags.
  • do_sys_openat2() at line 1386 is the shared openat2 implementation.
  • Syscall wrappers are SYSCALL_DEFINE3(open) line 1405, SYSCALL_DEFINE4(openat) line 1412, and SYSCALL_DEFINE4(openat2) line 1420.
  • Close unwinds through filp_close() line 1507 and SYSCALL_DEFINE1(close) line 1523.

Design Notes

The VFS open path is a staged constructor: normalize flags, resolve path, activate a file object, bind operations, then install a descriptor. A Rust equivalent should keep raw descriptor numbers outside the internal object API and expose validated open-flag builders plus typed file-operation traits.