File-System Interface. File Structure. File Concept. File Concept Access Methods Directory Structure File-System Mounting File Sharing Protection

Similar documents
TDDB68 Concurrent Programming and Operating Systems. Lecture: File systems

Chapter 10: File-System Interface. Operating System Concepts with Java 8 th Edition

Chapter 10: File-System Interface

Chapter 10: File-System Interface

Part Four - Storage Management. Chapter 10: File-System Interface

CS3600 SYSTEMS AND NETWORKS

UNIT V SECONDARY STORAGE MANAGEMENT

V. File System. SGG9: chapter 11. Files, directories, sharing FS layers, partitions, allocations, free space. TDIU11: Operating Systems

File Systems: Interface and Implementation

File Systems: Interface and Implementation

Chapter 10: File System. Operating System Concepts 9 th Edition

Chapter 7: File-System

Chapter 11: File-System Interface

Chapter 11: File-System Interface

Chapter 10: File-System Interface

Chapter 11: File-System Interface

Chapter 11: File-System Interface. File Concept. File Structure

Chapter 10: File-System Interface. Operating System Concepts 8 th Edition

Lecture 10 File Systems - Interface (chapter 10)

Chapter 11: File-System Interface

File Systems: Interface and Implementation

Chapter 10: File System

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

Chapter 11: File-System Interface. File Concept. File Structure

Chapter 10: File-System Interface. File Concept Access Methods Directory Structure File-System Mounting File Sharing Protection

I.-C. Lin, Assistant Professor. Textbook: Operating System Concepts 8ed CHAPTER 10: FILE SYSTEM

F 4. Both the directory structure and the files reside on disk Backups of these two structures are kept on tapes

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

Chapter 11: File-System Interface

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

Chapter 11: File System Interface Capítulo 10 no livro adotado!

CS720 - Operating Systems

Chapter 11: File-System Interface

Virtual Memory cont d.; File System Interface. 03/30/2007 CSCI 315 Operating Systems Design 1

CMSC421: Principles of Operating Systems

CSE325 Principles of Operating Systems. File Systems. David P. Duggan. March 21, 2013

Chapter 9: File System Interface

Chapter 6 Storage Management File-System Interface 11.1

Chapter 11: File System Interface

File System: Interface and Implmentation

A file system is a clearly-defined method that the computer's operating system uses to store, catalog, and retrieve files.

File-System Interface

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

CMSC421: Principles of Operating Systems

File-System. File Concept. File Types Name, Extension. File Attributes. File Operations. Access Methods. CS307 Operating Systems

Principles of Operating Systems

ICS Principles of Operating Systems

Files and File Systems

Modulo V Sistema de Arquivos

CS370 Operating Systems

File Systems. CS170 Fall 2018

Chapter 11: File System Implementation. Objectives

Operating Systems. No. 9 ศร ณย อ นทโกส ม Sarun Intakosum

There is a general need for long-term and shared data storage: Files meet these requirements The file manager or file system within the OS

Storage, part 1. Michael Brockway. November 3, 2015

File Management By : Kaushik Vaghani

Memory Management. Contents: Memory Management. How to generate code? Background

DATA STRUCTURES USING C

Sharing may be done through a protection scheme. Network File System (NFS) is a common distributed file-sharing method

Outlook. File-System Interface Allocation-Methods Free Space Management

CS370 Operating Systems

Operating System: Chap10 File System Interface. National Tsing-Hua University 2016, Fall Semester

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

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

CHAPTER 10 AND 11 - FILE SYSTEM & IMPLEMENTING FILE- SYSTEMS

Advanced Operating Systems. File Systems Lecture 9

Virtual Memory. Overview: Virtual Memory. Virtual address space of a process. Virtual Memory

File System & Device Drive Mass Storage. File Attributes (Meta Data) File Operations. Directory Structure. Operations Performed on Directory

Chapter 11: Implementing File Systems. Operating System Concepts 8 th Edition,

File System Interface. ICS332 Operating Systems

Operating Systems. Steven Hand. Michaelmas / Lent Term 2008/ lectures for CST IA. Handout 4. Operating Systems

CSE 421/521 - Operating Systems Fall Lecture - XIX. File Systems. University at Buffalo

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

File System Interface: Overview. Objective. File Concept UNIT-IV FILE SYSTEMS

File Systems. CS 4410 Operating Systems

ELEC 377 Operating Systems. Week 8 Class 1

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

File System (FS) Highlights

Chapter 11: File System Implementation

Virtual Memory. Overview: Virtual Memory. Virtual address space of a process. Virtual Memory. Demand Paging

18-Sep CSCI 2132 Software Development Lecture 6: Links and Inodes. Faculty of Computer Science, Dalhousie University. Lecture 6 p.

Operating Systems: Lecture 12. File-System Interface and Implementation

TDDI04, K. Arvidsson, IDA, Linköpings universitet Operating System Structures. Operating System Structures Overview. Operating System Services

Processes and Threads

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

File System File Concept File Structure File Attributes Name Identifier Type Location Size Protection Time, date, and user identification

Introduction to File Systems

CS370 Operating Systems

FILE SYSTEMS. Tanzir Ahmed CSCE 313 Fall 2018

Chapter 12: File System Implementation

Long-term Information Storage Must store large amounts of data Information stored must survive the termination of the process using it Multiple proces

File Systems. What do we need to know?

Files and Directories

TDDB68 Concurrent Programming and Operating Systems. Lecture 1: Introduction, interrupts and system calls

Introduction to OS. File Management. MOS Ch. 4. Mahmoud El-Gayyar. Mahmoud El-Gayyar / Introduction to OS 1

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 18: Naming, Directories, and File Caching

File System Management

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 18: Naming, Directories, and File Caching

Operating Systems CMPSC 473. File System Implementation April 1, Lecture 19 Instructor: Trent Jaeger

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

Transcription:

TDIU11 Operating Systems File-System Interface File-System Interface [SGG7/8/9] Chapter 10 File Concept Access Methods Directory Structure File-System Mounting File Sharing Protection How the file system looks to the user and to application programs Copyright Notice: The lecture notes are mainly based on Silberschatz s, Galvin s and Gagne s book ( Operating System Copyright Notice: The lecture notes are modifications of the slides accompanying the course book Concepts, 7th ed., Wiley, 2005). No part of the lecture notes may be reproduced in any form, due to the copyrights Operating reserved by Wiley. System These Concepts, lecture notes 9should th edition, only be 2013 used for byinternal Silberschatz, teaching purposes Galvin and at the Gagne. Linköping University. Christoph Kessler, IDA, Linköpings universitet. 6.2 File Concept Primary memory is volatile need secondary storage for long-term storage For now: A disk is a linear sequence of numbered blocks With 2 operations: write block b, read block b Low level of abstraction, Portability across different storage devices Solution: OS provides the file abstraction Smallest allotment of secondary storage known to the user Attributes (Name, id, size, ) Typically, contiguous logical address space Organized in a directory of files API (operations on files and directories) 6.3 File Structure None - sequence of words, bytes Most common used by Unix, DOS, Windows,... Programs give meaning/structure to the byte sequence Minimal requirement: The OS must understand its own executable format Simple record structure Lines Fixed length Variable length Complex Structures 6.4

File Attributes Name the only information kept in human-readable form Identifier unique tag (number) identifies file within file system Type needed for systems that support different types Location pointer to file location on device Size current file size Protection controls who can read, write, execute Time, date, and user identification data for protection, security, and usage monitoring Such information about files (i.e., meta-data) is kept in a directory structure, which is maintained on the disk. Stored in a File Control Block (FCB) data structure for each file 6.5 File Operations (API) File is an abstract data type, with operations Create Write Read Reposition within file Delete... Open(F i ) search the directory structure on disk for entry F i, and move the content of that entry to memory Close (F i ) move the content of entry F i in memory to directory structure on disk 6.6 Unix / C example: open ( filename, mode ) returns a file descriptor / handle = index into a per-process table of open files (part of PCB) (or an error code) File descriptors and open file tables Process 1 Logical Address Space fp FILE data structure {, fd, } returned by fopen() C library call Process 2 Logical Address Space Process-local open file table 0 stdin (pos, ) 1 stdout (pos, ) 2 stderr (pos,) newfile(pos,) d Process-local open file table 0 stdin (pos, ) 1 stdout (pos, ) 2 stderr (pos,) KERNEL MEMORY SPACE 6.7 System-wide open file table Console input Console output newfile (loc.,) FCB contents stdin, stdout, stderr are opened upon process start FCB File data Disk open() syscall returns a file descriptor = index in local open file table Open Files Data needed to manage open files: Disk location of the file (and other metadata from FCB) File-open count: count number of times a file is opened to allow removal of data from open-file table when last process closes it shared by all processes that opened the file File pointer (seekpos): pointer to next read/write location one for every open system call (process) Collected in a system-wide table of open files and process-local open file tables (part of PCB) process-local open file table entries point to system-wide open file table entries Semantics of fork()? 6.8

Open File Locking Access Methods Provided by some operating systems and file systems Similar to reader-writer locks ( TDIU16) Shared lock similar to reader lock several processes can acquire concurrently Exclusive lock similar to writer lock Mediates access to a file Mandatory or advisory: Mandatory access is denied depending on locks held and requested (usually adopted by windows) Advisory processes can find status of locks and decide what to do (usually adopted by unix) Sequential Access Direct Access read next block write next block reset (rewind) read block n write block n position to n read next block write next block n = relative block number from beginning of file) 6.9 6.10 Directory Structure A Typical File-system Organization Files in a system must be organized in some way. Directory: A collection of nodes containing information about all files API: Search for a file Create a file Delete a file List a directory Rename a file Traverse the file system Directory Files F 1 F 2 F 3 F 4 Both the directory structure and the files reside on disk. F n 6.11 6.12

Organize the Directory (Logically) to Obtain Efficiency locating a file quickly Naming convenient to users Two users can use the same name for different files The same file can have several different names Grouping logical grouping of files by properties e.g., all Java programs, all games, Single-Level Directory A single directory for all users Very simple Naming problem Grouping problem Still used on simple devices, embedded systems, Pintos 6.13 6.14 Two-Level Directory Tree-Structured Directories Separate directory for each user Path name: username / filename Can have the same file name for different user Efficient searching No grouping capability 6.15 Directories have subdirectories Efficient searching Grouping Capability Current directory (working directory) cd /spell/mail/prog; type list; Absolute vs. relative file names 6.16

Tree-Structured Directories (Cont) Absolute or relative path name Creating a new file is done in current directory touch <file-name> Delete a file in current working directory rm <file-name> Creating a new subdirectory is done in current directory mkdir <dir-name> Example: if in current directory /mail mkdir count mail Acyclic-Graph Directories Have shared subdirectories and files Done with links prog copy prt exp count 6.17 6.18 Acyclic-Graph Directories (Cont.) Two different names (aliasing) Hard links vs. Soft links (1) Example directory: If dict deletes list dangling pointer Solutions: Backpointers, so we can delete all pointers Variable size records a problem Backpointers using a daisy chain organization Entry-hold-count solution New directory entry type Link another name (pointer) to an existing file Resolve the link follow pointer to locate the file 6.19 Name Location myfile 371 file2 524 mylink_hard 371 mylink_soft./myfile 6.20

Hard links vs. Soft links (2) Hard links vs. Soft links (3) Hard links direct pointer (block address) to a directory or file cannot span partition boundaries need be updated when file moves to different place on disk Unix: ln <filename> <linkname> 6.21 Name Location myfile 371 file2 524 mylink_hard 371 mylink_soft./myfile Soft links (symbolic links, shortcut, alias ) files containing the actual (full) file name still valid if file moves on disk no longer valid if file name (or path) changes Not as efficient as hard links one extra block read Unix: ln s <filename> <linkname> 6.22 Name Location myfile 371 file2 524 mylink_hard 371 mylink_soft./myfile Hard Links - Remarks If the entry in the directory contains size information, what happens if the file grows? All directory entries pointing to this file must be updated The Unix solution: The directory entries point to an inode ( ) which contains file information If the inode changes, see the change from all directories Hard links can cause (true) cycles in the file system Removal of hard links (including the original parent) can create disconnected subareas 6.23 General Graph Directory How do we guarantee no cycles? Every time a new hard link is added, use a cycle detection algorithm to determine whether it is OK (not for soft links) Allow only links to files, not to directories Garbage collection mark all reachable files, delete the rest 6.24

File System Mounting A file system must be mounted before it can be accessed Mounting combines multiple file systems in one namespace An unmounted file system is mounted at a mount point In Windows, mount points are given names C:, D:, File Sharing Sharing of files on multi-user systems is desirable Sharing may be done through a protection scheme On distributed systems, files may be shared across a network Network File System (NFS) is a common distributed file-sharing method SMB (Windows shares) is another In order to have a protection scheme, the system should have Existing file system Unmounted volume residing on /device/dsk 6.25 Mount point: Mounted /device/dsk over /users User IDs - identify users, allowing permissions and protections to be per-user Group IDs - allow users to be in groups, permitting group access rights 6.26 Protection Access Lists and Groups File owner/creator should be able to control: what can be done by whom Types of access Read Write Execute Append Delete List 3 modes of access: read, write, execute 3 classes of users: RWX a) owner access 7 1 1 1 RWX b) group access 6 1 1 0 RWX c) public access 1 0 0 1 Ask manager to create a group (unique name), say G, and add some users to the group. For a particular file (say game) or subdirectory, define an appropriate access. Attach a group to a file: chgrp G game owner group public chmod 761 game 6.27 6.28

A Sample UNIX Directory Listing > ls -l owner group name 6.29