0%

File System

File Types

  1. Regular file. There is no distinction to the Unix kernel whether this data is text or binary. Any interpretation of the contents of a regular fiel is left to the application processing the file.

    To execute a program, the kernel must understand its format. All binary executable files conform to a format that allows the kernel to identify where to load a program’s text and data.

  2. Directory file. A file that contains the name of other files and pointers to information on these files. Any process that has read permission for a directory file can read the contents of the directory, but only the kernel can write directly to a directory file. Processes must use specify functions to make change to a directory.
  3. Block special file. A type of file proving buffered I/O access in fixed-size units to devices as disk drives.
  4. Character special file. A type of file providing unbuffered I/O access in variable-sized units to devices. All devices on a system are either block-special files or character special files.
  5. FIFO. A type of file used for communication between process. It’s sometimes called a named pipe.
  6. Socket. A type of file used for network commucation between processes. A socket can also be used for non-network communication between processes on a single host.
  7. Symbolic link. A type of file that points to another file.

File Access

The file access tests that the kernel perform each time a process opens, creates or deletes a file. The tests depend on the owners of the file and the effective IDs of the process. The tests performed by the kernel are as follows:

  1. If the effective Id of the process is 0(the superuser), access is allowed.
  2. If the effective user ID of the process equals the owner ID of the file, access is allowed if the appropriate access permission bit is set. Otherwise, permission is denied.
  3. If the effective user ID of the process of one of the supplementary group IDs of the process equals the group ID of the file, access is allowed if the appropriate group access permission bit is set. Otherwise, permission is denied.
  4. If the appropriate other access permission bit is set, access is allowed. Otherwise, permission is denied.

These four steps are tried in sequence. For example, if the process owns the file, access is granted or denied based only on the user access permission; the froup permission are never looked at.

Reference

Adcanced Programming in the Unix Environment(Third Edition)