Skip to content
UoL CS Notes

File Management

COMP124 Lectures

Disk Hardware

Disks are based around the concept of blocks:

  • Disks are split into block of a certain size.
  • Files fill up one or more blocks.
  • Only one file can fill each block, so some wasted space if a file is smaller than the block.

Operating system determines the block size and imposes programmatic access to physical devices.

File System

  • Logical vs. physical organisation of file.
  • Most file systems are tree-structured:

      graph TD
      / --- etc
      / --- bin
      / --- usr
      / --- home
      usr --- ub[bin]
      home --- staff
      home --- students
      students --- folder1
      students --- folder2
      folder1 --- file1
      folder1 --- file2
      folder1 --- file3
    

    The logical organisation is not related to the physical structure.

Directories

Non-leaf nodes are directories:

  • Contain list of filenames plus further into about each file.

Unix Inodes

Directory entry consists of filename and inode number:

  • Inode number references (points to) an inode file descriptor.

An inode contains info such as:

  • File owner
  • Permissions
  • Modify and Access Times
  • Size
  • Type
    • Regular
    • Special (such as /dev and links)
  • Location on Disk

File Types

Windows uses file extensions to indicate application.

On Unix you can execute any file:

  • Exec will look for magic number at head of a valid executable binary file.
  • If the number is not present, exec looks for #! followed by a name of a program to execute:

      #!/bin/bash
    
  • Otherwise it assumes it is a shell script and creates an instance of a user’s shell to process it.

File-store Allocation

File-store is divided into fixed-size blocks.

Blocks not currently allocated to files are maintained in a free list.

Several strategies for allocating blocks:

  • Contiguous
  • Linked
  • File allocation table (FAT)
  • Indexed (NTFS)

The Free List

This represents the free block on a block device.

It can be a simple bit vector. Bit vectors are simple and efficient if kept in memory. There can be issues though:

  • Needs writing to the disk every so often.
  • May be huge:
    • 80GB disk with 512 byte blocks needs 20MB for a free list.

An alternative is to chain all free blocks into a linked list.

These methods use the disk to store information about the allocation of the disk.