File Systems Overview. Jin-Soo Kim ( Computer Systems Laboratory Sungkyunkwan University

Similar documents
FILE SYSTEMS. Jo, Heeseung

File Systems. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Fall 2017 :: CSE 306. File Systems Basics. Nima Honarmand

I/O Systems. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

The bigger picture. File systems. User space operations. What s a file. A file system is the user space implementation of persistent storage.

CMPS 105 Systems Programming. Prof. Darrell Long E2.371

Files. Eric McCreath

File I/0. Advanced Programming in the UNIX Environment

I/O OPERATIONS. UNIX Programming 2014 Fall by Euiseong Seo

CSE 120 Principles of Operating Systems

I/O OPERATIONS. UNIX Programming 2014 Fall by Euiseong Seo

Advanced Unix Programming Module 06 Raju Alluri spurthi.com

CSE 333 SECTION 3. POSIX I/O Functions

Motivation: I/O is Important. CS 537 Lecture 12 File System Interface. File systems

Lecture files in /home/hwang/cs375/lecture05 on csserver.

Chapter 4 - Files and Directories. Information about files and directories Management of files and directories

CSE 120 Principles of Operating Systems

File and Directories. Advanced Programming in the UNIX Environment

File Systems. COMS W4118 Prof. Kaustubh R. Joshi hcp://

we are here I/O & Storage Layers Recall: C Low level I/O Recall: C Low Level Operations CS162 Operating Systems and Systems Programming Lecture 18

Hyo-bong Son Computer Systems Laboratory Sungkyunkwan University

Operating System Labs. Yuanbin Wu

CSE 451: Operating Systems Winter Module 15 File Systems

we are here Page 1 Recall: How do we Hide I/O Latency? I/O & Storage Layers Recall: C Low level I/O

Unix File and I/O. Outline. Storing Information. File Systems. (USP Chapters 4 and 5) Instructor: Dr. Tongping Liu

CSE 333 SECTION 3. POSIX I/O Functions

Goals of this Lecture

I/O Management! Goals of this Lecture!

I/O Management! Goals of this Lecture!

UNIX System Calls. Sys Calls versus Library Func

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017

Workloads. CS 537 Lecture 16 File Systems Internals. Goals. Allocation Strategies. Michael Swift

Recitation 8: Tshlab + VM

File Concept Access Methods Directory and Disk Structure File-System Mounting File Sharing Protection

CSci 4061 Introduction to Operating Systems. File Systems: Basics

Can Great Programmers Be Taught? Experiences with a Software Design Class. John Ousterhout Stanford University

File Systems. What do we need to know?

ADVANCED I/O. ISA 563: Fundamentals of Systems Programming

File System. Minsoo Ryu. Real-Time Computing and Communications Lab. Hanyang University.

Files and File Systems

File System Implementation. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

VIRTUAL FILE SYSTEM AND FILE SYSTEM CONCEPTS Operating Systems Design Euiseong Seo

CS240: Programming in C

ISA 563: Fundamentals of Systems Programming

Chapter 10: File-System Interface

Operating System Labs. Yuanbin Wu

Outline. OS Interface to Devices. System Input/Output. CSCI 4061 Introduction to Operating Systems. System I/O and Files. Instructor: Abhishek Chandra

Storage Systems. NPTEL Course Jan K. Gopinath Indian Institute of Science

Chapter 10: File-System Interface

[6 marks] All parts of this question assume the following C statement. Parts (b) through (e) assume a variable called ptrs.

File I/O - Filesystems from a user s perspective

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

EECS 3221 Operating System Fundamentals

EECS 3221 Operating System Fundamentals

UNIT I INTRODUCTION TO UNIX & FILE SYSTEM

COMP 2355 Introduction to Systems Programming

Processes often need to communicate. CSCB09: Software Tools and Systems Programming. Solution: Pipes. Recall: I/O mechanisms in C

CS2028 -UNIX INTERNALS

Chapter 11: File-System Interface

OPERATING SYSTEMS: Lesson 2: Operating System Services

Operating System Labs. Yuanbin Wu

Operating systems. Lecture 7

File System CS170 Discussion Week 9. *Some slides taken from TextBook Author s Presentation

File System Internals. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

CS , Spring Sample Exam 3

17: Filesystem Examples: CD-ROM, MS-DOS, Unix

Computer Systems Laboratory Sungkyunkwan University

Process Management! Goals of this Lecture!

Memory Mapped I/O. Michael Jantz. Prasad Kulkarni. EECS 678 Memory Mapped I/O Lab 1

MMAP AND PIPE. UNIX Programming 2015 Fall by Euiseong Seo

Contents. IPC (Inter-Process Communication) Representation of open files in kernel I/O redirection Anonymous Pipe Named Pipe (FIFO)

File System (FS) Highlights

Chapter 7: File-System

Input/Output. Input/Output and Files. Input/Output. I/O System Objectives

File System Internals. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Section 3: File I/O, JSON, Generics. Meghan Cowan

OPERATING SYSTEMS: Lesson 12: Directories

Programmation Systèmes Cours 8 Synchronization & File Locking

File System Case Studies. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Chapter 11: File-System Interface

Files and Directories Filesystems from a user s perspective

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING SOFTWARE ENGINEERING DEPARTMENT

Chapter 4. File Systems. Part 1

Introduction to File Systems. CSE 120 Winter 2001

Process Creation in UNIX

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

Last Week: ! Efficiency read/write. ! The File. ! File pointer. ! File control/access. This Week: ! How to program with directories

Chapter 11: File-System Interface. Operating System Concepts 9 th Edition

Lecture 3: System Calls & API Standards

NFS: Naming indirection, abstraction. Abstraction, abstraction, abstraction! Network File Systems: Naming, cache control, consistency

Chapter 11: File-System Interface. Long-term Information Storage. File Structure. File Structure. File Concept. File Attributes

Distributed File Systems

Announcements. is due Monday April 1 needs to include a paragraph write-up about the results of using the two different scheduling algorithms

Parents and Children

Lecture 10 File Systems - Interface (chapter 10)

UNIX File System. UNIX File System. The UNIX file system has a hierarchical tree structure with the top in root.

Preview. System Call. System Call. System Call. System Call. Library Functions 9/20/2018. System Call

Design Choices 2 / 29

EI 338: Computer Systems Engineering (Operating Systems & Computer Architecture)

Linux C C man mkdir( ) mkdir Linux man mkdir mkdir( ) mkdir mkdir( )

Transcription:

File Systems Overview Jin-Soo Kim ( jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu

Today s Topics File system basics Directory structure File system mounting File sharing Protection 2

Basic Concepts Requirements for long-term information storage Store a very large amount of information Survive the termination of the process using it Access the information concurrently by multiple processes File system Implement an abstraction for secondary storage (files) Organizes files logically (directories) Permit sharing of data between processes, people, and machines. Protect data from unwanted access (security) 3

Storage: A Logical View Block device abstraction 512B 512B 512B 0 1 N-1 Operations Identify(): returns N Read(start sector #, # of sectors) Write(start sector #, # of sectors) Source: Sang Lyul Min (Seoul National Univ.) 4

Files File A named collection of related information that is recorded on secondary storage. persistent through power failures and system reboots OS provides a uniform logical view of information storage via files. File structures Flat: byte sequence Structured: Lines Fixed length records Variable length records 5

File System Basics (1) For each file, we have File contents (data) File systems normally do not care what they are File attributes (metadata) File size Owner, access control lists Last access time (atime), last file modification time (mtime), last metadata modification time (ctime), File name (hierarchical) Pathname Metadata Contents e.g., open ( /etc/passwd, O_RDONLY); 6

meta1 a.out dog.jpg meta2 File System Basics (2) File system: A mapping problem <filename, data, metadata> <a set of blocks> a.out meta1 dog.jpg meta2 1 2 3 1 2 3 4 1 4 3 2 1 2 3 7

File System Basics (3) Goals Performance + Reliability + Scalability Design issues What information should be kept in metadata? How to locate metadata? Mapping from pathname to metadata How to locate data blocks? How to manage metadata and data blocks? Allocation, reclamation, free space management, etc. How to recover the file system after a crash? 8

File Attributes Attributes or metadata Protection Control flags For files whose records can be looked up using a key Other information 9

File Operations Unix operations int creat(const char *pathname, mode_t mode); int open(const char *pathname, int flags, mode_t mode); int close(int fd); ssize_t read(int fd, void *buf, size_t count); ssize_t write(int fd, const void *buf, size_t count); off_t lseek(int fd, off_t offset, int whence); int stat(const char *pathname, struct stat *buf); int chmod(const char *pathname, mode_t mode); int chown(const char *pathname, uid_t owner, gid_t grp); int flock(int fd, int operation); int fcntl(int fd, int cmd, long arg); 10

Directories Directories For users, provide a structured way to organize files For the file system, provide a convenient naming interface that allows the implementation to separate logical file organization from physical file placement on the disk A hierarchical directory system Most file systems support multi-level directories Most file systems support the notion of a current directory (or working directory) Relative names specified with respect to current directory Absolute names start from the root of directory tree 11

Directory Internals A directory is Typically just a file that happens to contain special metadata Only need to manage one kind of secondary storage unit. Directory = list of (file name, file attributes) Attributes include such things as: size, protection, creation time, access time, location on disk, etc. Usually unordered (effectively random) Entries usually sorted by program that reads directory. 12

Pathname Translation open( /a/b/c, ) Open directory / (well known, can always find) Search the directory for a, get location of a Open directory a, search for b, get location of b Open directory b, search for c, get location of c Open file c (Of course, permissions are checked at each step) System spends a lot of time walking down directory paths This is why open is separate from read/write. OS will cache prefix lookups to enhance performance. /a/b, /a/bb, /a/bbb, etc. all share the /a prefix 13

Directory Operations Unix operations Directories implemented in files. Use file operations to manipulate directories C runtime libraries provides a higher-level abstraction for reading directories. DIR *opendir(const char *name); struct dirent *readdir(dir *dir); void seekdir(dir *dir, off_t offset); int closedir(dir *dir); Other directory-related system calls. int rename(const char *oldpath, const char *newpath); int link(const char *oldpath, const char *newpath); int unlink(const char *pathname); 14

File System Mounting Mounting A file system must be mounted before it can be available to processes on the system Windows: to drive letters (e.g., C:\, D:\, ) Unix: to an existing empty directory (= mount point) 15

File Sharing File sharing File sharing has been around since timesharing. File sharing is incredibly important for getting work done. Basis for communication and synchronization. On distributed systems, files may be shared across a network (e.g., NFS). Three key issues when sharing files Semantics of concurrent access: - What happens when one process reads while another writes? - What happens when two processes open a file for writing? Concurrency control using locks Protection 16

Consistency Semantics UNIX semantics Writes to an open file are visible immediately to other users that have this file open at the same time. One mode of sharing allows users to share the pointer of current location into the file. via fork() or dup(). AFS session semantics Writes to an open file are not visible immediately. Once a file is closed, the changes made to it are visible only in sessions starting later. Immutable-shared-files semantics Once a file is declared as shared by its creator, it cannot be modified. 17

File Locking Advisory lock on a whole file int flock (int fd, int operation) LOCK_SH(shared), LOCK_EX(exclusive), LOCK_UN(unlock) POSIX record lock Discretionary lock: can lock portions of a file. If a process dies, its locks are automatically removed. int fcntl (int fd, int cmd, struct flock *lock); cmd: F_GETLK, F_SETLK, F_SETLKW struct flock { type, whence, start, len, pid }; System V mandatory lock A file is marked as a candidate by setting the setgid bit and removing the group execute bit. Must mount the file system to permit mandatory file locks. Use the existing flock()/fcntl() to apply locks. Every read() and write() is checked for locking. 18

Protection (1) Protection systems File systems must implement some kind of protection system. to control who can access a file (user) to control how they can access it (read/write/exec, etc.) More generally: generalize files to objects (the what ) generalize users to subjects (the who ) generalize read/write to actions (the how ) A protection system dictates whether a given action performed by a given subject on a given object should be allowed. You can read or write your files, but others can not. You can read /etc/motd, but you cannot write to it. 19

Protection (2) Representing protection Access control lists (ACLs) For each object, keep list of subjects and their allowed actions. Capabilities For each subject, keep list of objects and their allowed actions. objects /etc/passwd /home/jinsoo /home/guest subjects Capability root rw rw rw jinsoo r rw r guest - - r ACL 20

Protection (3) ACLs vs. Capabilities Two approaches differ only in how the table is represented. Capabilities are easy to transfer. They are like keys; can hand them off. They make sharing easy. In practice, ACLs are easier to manage. Object-centric, easy to grant and revoke. To revoke capabilities, need to keep track of all subjects that have the capability hard to do, given that subjects can hand off capabilities. ACLs grow large when object is heavily shared. Can simplify by using groups. Additional benefit: change group membership affects all objects that have this group in its ACL. 21