[prev] 42 [next]

File System Operations (cont)

int close(int FileDesc)
  • attempt to release an open file descriptor
  • if this is the last reference to object, release its resources
  • if successful, return 0
  • if unsuccessful, return -1 and set errno
Could be unsuccessful if FileDesc is not an open file descriptor

An aside: removing an object e.g. via rm

  • removes the object's entry from a directory
  • but the inode and data persist until
    • all processes accessing the object close() their handle
    • all references to the inode from other directories are removed
  • after this, the inode and the blocks on storage device are recycled