Please disable adblock to view this page.

← Go home

Files & File System

file-data-structure

September 18, 2016
Published By : Pratik Kataria
Categorised in:

UNIX file system

  • File is remarkable feature of UNIX
  • File is a sequence of bytes of data that reside in semi permanent form on some stable medium
  • Network interface, disk drive, keyboard, printer, etc are treated as file
  • File management is flexible and powerful
  • Provides hierarchical directory scheme

Internal Representation of File

  • Each file in UNIX is specified by an unique inode
  • Contains info. for a process to access a file
  • Fields of an inode:
    • –File owner identifier
    • –File type
    • File access permissions
    • File access times
    • Number of links to the file
    • Table of contents for the disk addresses of data in a file
    • File size
  • User File Descriptor Table, File Table, Inode Table

File Data Structures

file-data-structure

Algorithms

  • Allocation of In-Core Inodes: iget
  • Releasing an Inode : iput
  • Conversion of a Path Name to an Inode: namei

Race Condition in assigning inodes

  • Kernel assigns inode I to Process A
  • Process A sleeps before reading disk copy into memory
  • Process B wants an inode. It searches for free inodes, finds I is free, puts I on free list.
  • Process A wakes up, initializes I and use it
  • When process C requires inode, it gets I, but I is already initialized by Process A

Types of file

  • Simple/ordinary file
  • Directory file
  • Link file
  • Special file (Device file)

UNIX file system structure

unix-file-structure

Pratik Kataria is a budding programmer, web designer and developer.