Content
    Process Control Block (PCB)

Files and File descriptors on Linux

Some information on this page is taken from here (German).

Process Control Block (PCB)

Contains the information about a process.

  • C struct task_struct
  • Pointer to code section (text)
  • Pointer to data section
  • State: running, ready, blocked, terminated
  • Instruction pointer (IP): next instruction to execute
  • Saved registers
  • Memory information: pages
  • Scheduler information
    • Priority
    • Pointer to scheduler queue
  • Table with open file descriptors hold by this process

File Table

  • 1 entry for each open file
  • different processes can point to the same entry
  • Entry:
    • number of i-nodes
    • position pointer
    • mode (read, write, append…)
    • pointer to v-node table

v-node Table

  • i-node information
    • copied to v-node table when file is opened
    • owner
    • rights
    • user/group ids
    • number of links
  • file information
  • file size
  • functions (file system dependent)

File Descriptors

File descriptors are unique ID’s (ints) that identify an open file.

3 descriptors are reserved by the system in <unistd.h>:

ConstantNumberMeaning
STDIN_FILENO0Standard input
STDOUT_FILENO1Standard output
STDERR_FILENO2Standard error

The number can differ but the given ones are common.

Functions that return a file descriptor (e.g. open(...)or creat(...)) return -1 if en error occurred.

File Types

There are 6 different file types in Linux:

  • Regular files
  • Directories
  • Device files
  • Sockets
  • Pipes (named Pipes and FIFOs)
  • Links (Soft- and Hardlinks)

Special Device Files

See here for a description for device files.



  • Category

  • Programming

  • Tags

  • Computer Science
    OS
    Linux

  • Created

  • 3. June 2016


  • Modified

  • 16. May 2022