ECS 150: Operating system
File system naming
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?
Naming
Directory organization
Directory organization
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!
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?
Read in the super block
…
Super block
Disk block: 0
What’s next?
Read in the super block
inode_region_addr: 4
inode_region_len: 2
…
Super block
Disk block: 0
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]
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;
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]
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]
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
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
Directories
Single file system illusion
pc*.cs.ucdavis.edu ls /