VNODE

References:

vnode – internal representation of a file or a directory. The vnode is the focus of all file activity in UNIX. A vnode is described by struct vnode. There is a unique vnode allocated for each active file, each current directory, each mounted-on file, text file, and the root.

Three reference counts:

  • v_usecount, the number of clients within the kernel which are using the vnode.
    • Maintained by vref, vrele, vput
  • v_holdcnt, num of clients in the kernel who veto the recycling of the vnode.
    • Maintained by vhold and vdrop.
  • v_writecount, num of clients which is writing into the file.
    • Maintained by open and close system calls.

Any call which returns a vnode (e.g., vget, VOP_LOOKUP, etc.) will increase the v_usecount of the vnode by one. When the caller is finished with the vnode, it should release this reference by calling vrele (or vput if the vnode is locked).

More members:

  • v_id
  • v_mount, points at the file system which owns the vnode.
  • v_type, contains the type of the object the vnode represents.
  • v_data, used by the file system to store file system specific data with the vnode.
  • v_op, used by VOP_* macros to call functions in the file system which implement the vnode’s functionality. (Such as ???)
Created Aug 6, 2020 // Last Updated Aug 6, 2020

If you could revise
the fundmental principles of
computer system design
to improve security...

... what would you change?