File Systems: Organization, Access, and Protection in Operating Systems, Study notes of Operating Systems

A lecture note from cse 120: principles of operating systems, focusing on file systems. It covers topics such as disks and the os, physical disk structure, disk interaction, disk scheduling, file systems, files, basic file operations, file access methods, directory internals, basic directory operations, path name translation, file sharing, protection, representing protection, and file system layout. The lecture also discusses unix and nt file systems.

Typology: Study notes

2018/2019

Uploaded on 12/05/2019

johnwanjama
johnwanjama 🇰🇪

2 documents

1 / 30

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lecture 13:
Lecture 13:
File Systems
File Systems
CSE 120: Principles of Operating Systems
Alex C. Snoeren
HW 3 Due 11/9, Lab 2 Due 11/14
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e

Partial preview of the text

Download File Systems: Organization, Access, and Protection in Operating Systems and more Study notes Operating Systems in PDF only on Docsity!

Lecture 13:Lecture 13:

File Systems File Systems

CSE 120: Principles of Operating Systems

Alex C. Snoeren

HW 3 Due 11/9, Lab 2 Due 11/

File Systems File Systems

 First we’ll discuss properties of physical disks

◆ Structure ◆ Performance ◆ Scheduling

 Then we’ll discuss how we build file systems on them

◆ Files ◆ Directories ◆ Sharing ◆ Protection ◆ File System Layouts ◆ File Buffer Cache ◆ Read Ahead

Physical Disk Structure Physical Disk Structure

 Disk components ◆ Platters ◆ Surfaces ◆ Tracks ◆ Sectors ◆ Cylinders ◆ Arm ◆ Heads  Logically, disk broken down into sectors ◆ Addressed by cylinder, head, sector (CHS) Arm Heads Track Platter Surface Cylinder Sector

Disk Interaction Disk Interaction

 Specifying disk requests requires a lot of info:

◆ Cylinder #, surface #, track #, sector #, transfer size…

 Older disks required the OS to specify all of this

◆ The OS needed to know all disk parameters

 Modern disks are more complicated

◆ Not all sectors are the same size, sectors are remapped, etc.

 Current disks provide a higher-level interface (SCSI)

◆ The disk exports its data as a logical array of blocks [0…N] » Disk maps logical blocks to cylinder/surface/track/sector ◆ Only need to specify the logical block # to read/write ◆ But now the disk parameters are hidden from the OS

Disk Performance Disk Performance

 Disk request performance depends upon a number of

steps

◆ Seek – moving the disk arm to the correct cylinder » Depends on how fast disk arm can move (increasing very slowly) ◆ Rotation – waiting for the sector to rotate under the head » Depends on rotation rate of disk (increasing, but slowly) ◆ Transfer – transferring data from surface into disk controller electronics, sending it back to the host » Depends on density (increasing quickly)

 When the OS uses the disk, it tries to minimize the cost

of all of these steps

◆ Particularly seeks and rotation

Disk Scheduling Disk Scheduling

 Because seeks are so expensive (milliseconds!), the

OS tries to schedule disk requests that are queued

waiting for the disk

◆ FCFS (do nothing) » Reasonable when load is low » Long waiting times for long request queues ◆ SSTF (shortest seek time first) » Minimize arm movement (seek time), maximize request rate » Favors middle blocks ◆ SCAN (elevator) » Service requests in one direction until done, then reverse ◆ C-SCAN » Like SCAN, but only go in one direction (typewriter)

File Systems File Systems

 File systems

◆ Implement an abstraction (files) for secondary storage ◆ Organize files logically (directories) ◆ Permit sharing of data between processes, people, and machines ◆ Protect data from unwanted access (security)

Files Files

 A file is data with some properties

◆ Contents, size, owner, last read/write time, protection, etc.

 A file can also have a type

◆ Understood by the file system » Block, character, device, portal, link, etc. ◆ Understood by other parts of the OS or runtime libraries » Executable, dll, souce, object, text, etc.

 A file’s type can be encoded in its name or contents

◆ Windows encodes type in name » .com, .exe, .bat, .dll, .jpg, etc. ◆ Unix encodes type in contents » Magic numbers, initial characters (e.g., #! for shell scripts)

File Access Methods File Access Methods

 Some file systems provide different access methods

that specify different ways for accessing data in a file

◆ Sequential access – read bytes one at a time, in order ◆ Direct access – random access given block/byte number ◆ Record access – file is array of fixed- or variable-length records, read/written sequentially or randomly by record # ◆ Indexed access – file system contains an index to a particular field of each record in a file, reads specify a value for that field and the system finds the record via the index (DBs)

 What file access method does Unix, NT provide?

 Older systems provide more complicated methods

Directories Directories

 Directories serve two purposes

◆ For users, they provide a structured way to organize files ◆ For the file system, they provide a convenient naming interface that allows the implementation to separate logical file organization from physical file placement on the disk

 Most file systems support multi-level directories

◆ Naming hierarchies (/, /usr, /usr/local/, …)

 Most file systems support the notion of a current

directory

◆ Relative names specified with respect to current directory ◆ Absolute names start from the root of directory tree

Basic Directory Operations Basic Directory Operations

Unix  Directories implemented in files ◆ Use file ops to create dirs  C runtime library provides a higher-level abstraction for reading directories ◆ opendir(name) ◆ readdir(DIR) ◆ seekdir(DIR) ◆ closedir(DIR)

NT

 Explicit dir operations ◆ CreateDirectory(name) ◆ RemoveDirectory(name)  Very different method for reading directory entries ◆ FindFirstFile(pattern) ◆ FindNextFile()

Path Name Translation Path Name Translation

 Let’s say you want to open “/one/two/three”

 What does the file system do?

◆ Open directory “/” (well known, can always find) ◆ Search for the entry “one”, get location of “one” (in dir entry) ◆ Open directory “one”, search for “two”, get location of “two” ◆ Open directory “two”, search for “three”, get location of “three” ◆ Open file “three”

 Systems spend a lot of time walking directory paths

◆ This is why open is separate from read/write ◆ OS will cache prefix lookups for performance » /a/b, /a/bb, /a/bbb, etc., all share “/a” prefix

Protection Protection

 File systems implement some kind of protection

system

◆ Who can access a file ◆ How they can access it

 More generally…

◆ Objects are “what”, subjects are “who”, actions are “how”

 A protection system dictates whether a given action

performed by a given subject on a given object should

be allowed

◆ You can read and/or write your files, but others cannot ◆ You can read “/etc/motd”, but you cannot write it

Representing Protection Representing Protection

Access Control Lists (ACL)  For each object, maintain a list of subjects and their permitted actions Capabilities  For each subject, maintain a list of objects and their permitted actions Charlie w r rw Bob w - r Alice rw - rw /one /two /three Subjects Objects ACL Capability