1 of 17

ECS 150: Operating system

File system naming

2 of 17

Administrative

Project 4 due on June 5th, if you haven’t started yet you’re behind!

Finish up file systems today, move on to networking and APIs on Wednesday.

Have four lectures with some flexibility – I’ll use one to talk about my research – how should we use the others?

3 of 17

Naming

  • How do you specify which file you want to access?
    • Eventually OS must find the inode you want on disk
  • Typically user uses symbolic name
    • OS translates name to numeric inode number
    • Alternative is to describe to contents of the file

4 of 17

Directory organization

  • Directories typically have hierarchical struct.
    • Directory A has mapping to a bunch of files and directories in directory A
  • E.g., /home/kingst/a.txt
  • / is root directory
    • Contains list of files and other directories
    • For each file/directory in /, has a mapping from name to a inode #
    • One of these entries is home

5 of 17

Directory organization

  • home is directory entry within the / dir.
    • Contains a list of files and directories
    • One of the directories in /home is kingst
  • /home/kingst is a directory within the /home dir
    • Contains a list of files and other directories
    • One of the files it lists is a.txt

What is the minimum number of disk reads it takes to read in the contents of this file? Break into groups and see if you can solve this!

6 of 17

Read in the super block to get an overview of the file system

typedef struct __super {

int inode_bitmap_addr; // block address (in blocks)

int inode_bitmap_len; // in blocks

int data_bitmap_addr; // block address (in blocks)

int data_bitmap_len; // in blocks

int inode_region_addr; // block address (in blocks)

int inode_region_len; // in blocks

int data_region_addr; // block address (in blocks)

int data_region_len; // in blocks

int num_inodes; // just the number of inodes

int num_data; // and data blocks...

} super_t;

readSuperBlock(super_t *super) {

readDiskBlock(0, super)

}

// What’s wrong with this function?

7 of 17

Read in the super block

Super block

Disk block: 0

What’s next?

8 of 17

Read in the super block

inode_region_addr: 4

inode_region_len: 2

Super block

Disk block: 0

9 of 17

Read in the inode table

type: 1, size: 96, direct: [12]

type: 0, size: 22, direct: [18]

type: 1, size: 6400, direct: [14,22]

type: 1, size: 256, direct: [10]

Inode table

Disk block: 4

How do we know which entry to use for / and what do we do with it?

[0]

[1]

[2]

[3]

10 of 17

Directories are just files with structured data!

#define DIR_ENT_NAME_SIZE (28)

typedef struct {

char name[DIR_ENT_NAME_SIZE];

int inum;

} dir_ent_t;

11 of 17

Read in file data for the root inode

type: 1, size: 96, direct: [12]

type: 0, size: 22, direct: [18]

type: 1, size: 6400, direct: [14,22]

type: 1, size: 256, direct: [10]

Inode table

Disk block: 12

name: “bin”, inum: 4

name: “usr”, inum: 6

name: “home”, inum: 2

<unused space>

Array of dir_ent_t for /

[0]

[1]

[2]

[3]

12 of 17

Read in file data for home

type: 1, size: 96, direct: [12]

type: 0, size: 22, direct: [18]

type: 1, size: 6400, direct: [14,22]

type: 1, size: 256, direct: [10]

Inode table

Disk block: 14

name: “bin”, inum: 4

name: “usr”, inum: 6

name: “home”, inum: 2

<unused space>

Array of dir_ent_t for /

name: “kingst”, inum: 19

name: “nish”, inum: 32

name: “sai”, inum: 5

Array of dir_ent_t for home

name: “anirudh”, inum: 18

[0]

[1]

[2]

[3]

13 of 17

Read in file data for kingst

type: 1, size: 96, direct: [12]

type: 0, size: 22, direct: [18]

type: 1, size: 6400, direct: [14,22]

type: 1, size: 256, direct: [10]

Inode table

Disk block: 49

name: “kingst”, inum: 19

name: “nish”, inum: 32

name: “sai”, inum: 5

Array of dir_ent_t for home

name: “anirudh”, inum: 18

[0]

[1]

[2]

[3]

type: 1, size: 256, direct: [49]

[19]

name: “a.txt”, inum: 1

name: “ecs189e”, inum: 33

name: “src”, inum: 22

Array of dir_ent_t for kingst

name: “tmp”, inum: 14

14 of 17

Read in file data for a.txt

type: 1, size: 96, direct: [12]

type: 0, size: 22, direct: [18]

type: 1, size: 6400, direct: [14,22]

type: 1, size: 256, direct: [10]

Inode table

Disk block: 18

[0]

[1]

[2]

[3]

type: 1, size: 256, direct: [49]

[19]

name: “a.txt”, inum: 1

name: “ecs189e”, inum: 33

name: “src”, inum: 22

Array of dir_ent_t for kingst

name: “tmp”, inum: 14

“Hello world!”

File data for a.txt

15 of 17

Directories

  • Only reasonable performance improvement will be from caching
    • Temporal locality is favored heavily
    • E.g., cache /home/kingst inode, can skip half of the work

16 of 17

Single file system illusion

  • Each disk (or partition) has a file system
    • Each disk’s file system starts with its own root (/)
  • Can tie several disks together into single file system
    • Entry point in a directory to the root directory of another disk’s file system (mount point)

17 of 17

pc*.cs.ucdavis.edu ls /

  • /boot, /var from local disks
  • /home from a disk on another computer!