CSCI-3753: Operating Systems Fall 2019

Anh Nguyen Department of Computer Science University of Colorado Boulder Week 13: Virtual

CSCI 3753 Fall 2019 2 File System

• Control how data is stored and retrieved • Types of file system • Local data storage How to check out what filesystems are on • NTFS, FAT16, FAT32, exFAT your machine? • , , , , … à df -T • ISO 9660 • CDFS • Removable USB flash drive (UFD) • … How to check out the • Network data storage partitioning table on • NFS your machine? à • Plan 9 sudo parted -l • …

CSCI 3753 Fall 2019 3 Question File System How to bridge the differences in Windows, Mac OS, and User file systems so that applications can access files System Call Interfaceon local file systems of those types without having to know Abstraction layer (VFS) what type of file system they are accessing? ext3 NTFS CDFS NFS UFS

Block Layer / Device Drivers

Hard drive CD-ROM NIC USB Stick

CSCI 3753 Fall 2019 4

• An abstraction layer on top of a more concrete file system • Purpose: • To allow client applications to access different types of concrete file systems in a uniform way • To manage all of the different file systems that are mounted at any given time • Method: • Provide a set of standard interfaces for upper-layer applications to perform file I/O over a diverse set of file systems • Describe the system's files in terms of superblocks and

CSCI 3753 Fall 2019 5 VFS Implementation

• Major objects • Superblock • Index nodes (or inodes) • entries (or dentries) • File objects

CSCI 3753 Fall 2019 6 VFS Implementation

• Major objects • Superblock • Index nodes (or inodes) • Directory entries (or dentries) • File objects

• Auxiliary objects • Filesystem types • Struct vfsmount • Struct nameidata • Struct address_space

CSCI 3753 Fall 2019 7 VFS Implementation

• Superblock: • A container for essentially high-level metadata about a file system • A critical structure that • exists on disk and also in memory • is stored in multiple redundant copies for each file system • Provide the basis for dealing with the on-disk file system, as it defines the file system's managing parameters • File system type • File system size • File system status • Information about other metadata structures (metadata of metadata)

CSCI 3753 Fall 2019 8 VFS Implementation

• Index node () – 1: • An object through which uses to manage a bunch of attributes about all objects in a file system • Stored permanently

CSCI 3753 Fall 2019 9 VFS Implementation How to check view inode number? • Index node (inode) – 2: à ls -li à stat ~/Desktop/ • Stores information like • File type - regular file, directory, character device, etc • Owner • Group • Access permissions • Timestamps - mtime (time of last file modification), ctime (time of last attribute change), atime (time of last access) • Number of hardlinks to the file • Size of the file • Number of blocks allocated to the file • Pointers to the data blocks of the file - most important!

CSCI 3753 Fall 2019 10 VFS Implementation

• Index node (inode) – 3: • When are inodes created? • When a filesystem is created, the space for inodes is allocated as well. • Determining how much inode space needed depends on the volume of the disk and more. • Rare but possible to happen: errors for out of inodes !!! à Unable to create more files

CSCI 3753 Fall 2019 11 VFS Implementation

• Index node (inode) – 4: • How do inodes locate files? 12 pointers 15 pointers

Illustration of a file system

CSCI 3753 Fall 2019 12 VFS Implementation

• Directory entry (dentry) – 1: • A glue that holds inodes and files together by relating inode numbers to file names • Also play a role in directory caching which, ideally, keeps the most frequently used files on-hand for faster access. • Maintain a relationship between directories and their files for file system traversal

• The dentry objects exist only in file system memory and are not stored on disk as they are used to improve performance only.

CSCI 3753 Fall 2019 13 VFS Implementation

• Directory entry (dentry) – 2: • A file system will have one root dentry à Superblock à The only dentry without a parent. • All other dentries have parents, and some have children.

• How many dentry objects are created if the following file is opened? /home/user/name

CSCI 3753 Fall 2019 14 VFS Implementation

• File object: • For each opened file in a Linux system, a file object exists. • Contain information specific to the opening instance for a given user • Where the file is stored • What processes are using it • … • Thrown away when the file is closed

CSCI 3753 Fall 2019 15 Object Relationship

file object file object file object

dentry object dentry object

dentry object

inode object inode object vfsmount

super_block object

CSCI 3753 Fall 2019 16 Week 13 – Checklist q Discuss Virtual file system q Work on PA4

CSCI 3753 Fall 2019 17