Files & I/O. Today. Comp 104: Operating Systems Concepts. Operating System An Abstract View. Files and Filestore Allocation

Similar documents
CS3600 SYSTEMS AND NETWORKS

Main Points. File layout Directory layout

Che-Wei Chang Department of Computer Science and Information Engineering, Chang Gung University

makes floppy bootable o next comes root directory file information ATTRIB command used to modify name

Frequently asked questions from the previous class survey

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

File Systems: Interface and Implementation

File Systems: Interface and Implementation

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

FILE SYSTEMS. CS124 Operating Systems Winter , Lecture 23

Filesystem. Disclaimer: some slides are adopted from book authors slides with permission

File Systems: Interface and Implementation

Table 12.2 Information Elements of a File Directory

File Systems. CSE 2431: Introduction to Operating Systems Reading: Chap. 11, , 18.7, [OSC]

Operating Systems. Lecture File system implementation. Master of Computer Science PUF - Hồ Chí Minh 2016/2017

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

Chapter 14: File-System Implementation

Motivation. Operating Systems. File Systems. Outline. Files: The User s Point of View. File System Concepts. Solution? Files!

CHAPTER 11: IMPLEMENTING FILE SYSTEMS (COMPACT) By I-Chen Lin Textbook: Operating System Concepts 9th Ed.

UNIX File Systems. How UNIX Organizes and Accesses Files on Disk

CS370 Operating Systems

CS370 Operating Systems

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

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

COMP091 Operating Systems 1. File Systems

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

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

Main Points. File layout Directory layout

(32 KB) 216 * 215 = 231 = 2GB

File System: Interface and Implmentation

Chapter 11: Implementing File

File System Internals. Jo, Heeseung

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

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

Chapter 11: Implementing File Systems. Operating System Concepts 9 9h Edition

File System Management

Advanced Operating Systems

File Systems. What do we need to know?

File System Implementation

Chapter 7: File-System

Computer Systems Laboratory Sungkyunkwan University

ECE 598 Advanced Operating Systems Lecture 14

The UNIX File System

Chapter 11: File System Implementation. Objectives

Operating Systems. Operating Systems Professor Sina Meraji U of T

Principles of Operating Systems

CS370 Operating Systems

Hard facts. Hard disk drives

The UNIX File System

CMSC421: Principles of Operating Systems

CS 4284 Systems Capstone

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

Chapter 11: Implementing File Systems

File System Concepts File Allocation Table (FAT) New Technology File System (NTFS) Extended File System (EXT) Master File Table (MFT)

Chapter 12: File System Implementation

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

File system internals Tanenbaum, Chapter 4. COMP3231 Operating Systems

OPERATING SYSTEM. Chapter 12: File System Implementation

Guide to Computer Forensics and Investigations Fourth Edition. Chapter 6 Working with Windows and DOS Systems

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

Segmentation with Paging. Review. Segmentation with Page (MULTICS) Segmentation with Page (MULTICS) Segmentation with Page (MULTICS)

Windows File System. File allocation table (FAT) NTFS - New Technology File System. used in Windows 95, and MS-DOS

Chapter 12: File System Implementation

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

CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

ELEC 377 Operating Systems. Week 8 Class 1

Preview. COSC350 System Software, Fall

Filesystem. Disclaimer: some slides are adopted from book authors slides with permission 1

Chapter 11: File-System Interface

CS370: System Architecture & Software [Fall 2014] Dept. Of Computer Science, Colorado State University

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

NTFS Recoverability. CS 537 Lecture 17 NTFS internals. NTFS On-Disk Structure

Chapter 9: File System Interface

Chapter 12: File System Implementation

Chapter 10: File System Implementation

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

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

Lecture S3: File system data layout, naming

File System. Preview. File Name. File Structure. File Types. File Structure. Three essential requirements for long term information storage

CS 318 Principles of Operating Systems

Da-Wei Chang CSIE.NCKU. Professor Hao-Ren Ke, National Chiao Tung University Professor Hsung-Pin Chang, National Chung Hsing University

Frequently asked questions from the previous class survey

ICS Principles of Operating Systems

UNIT V SECONDARY STORAGE MANAGEMENT

CS720 - Operating Systems

File Management. Ezio Bartocci.

File Systems. CS170 Fall 2018

File System (FS) Highlights

Chapter 12 File-System Implementation

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

FILE SYSTEM IMPLEMENTATION. Sunu Wibirama

Outline. Operating Systems. File Systems. File System Concepts. Example: Unix open() Files: The User s Point of View

COMP 530: Operating Systems File Systems: Fundamentals

Introduction. Secondary Storage. File concept. File attributes

SMD149 - Operating Systems - File systems

Arvind Krishnamurthy Spring Implementing file system abstraction on top of raw disks

CS 318 Principles of Operating Systems

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

Chapter 10: File-System Interface

CS333 Intro to Operating Systems. Jonathan Walpole

Transcription:

Comp 104: Operating Systems Concepts Files and Filestore Allocation Today Files Introduction Filestore allocation policies Contiguous allocation Linked allocation File allocation table Indexed allocation Links File deletion 1 2 Operating System An Abstract View User Command Interface Processor Manager Files & I/O Most filesystems are tree-structured (e.g. Unix) / (root) Device Manager Memory Manager etc bin usr users bin staff students u0abc u0def File Manager file1 file2 file3 3 4 1

Directories Non-leaf nodes are directories contain list of filenames plus further info about each file Example: Unix directory entry consists of filename and inode number inode number references an inode - a file descriptor Unix Inodes An inode contains info such as file owner permissions modify and access times size type (regular, special, etc.) location on disk 5 6 UNIX Permissions Permissions are read, write and execute (rwx) for user, group, others (ugo) e.g. rwxr--r-- (rwx for owner, r for everyone else) Permissions can be altered with chmod e.g. chmod go-r prog1 File Types Some systems (e.g. Windows) use file extension to indicate application e.g..doc,.ps,.ppt,.html Other systems more basic On UNIX, can try to execute any file Exec will look for magic number at head of valid executable binary file If number not present, exec looks for #! followed by name of program to execute e.g. #!/bin/ksh Otherwise, assumes file is shell script and creates instance of user s preferred shell to process it 7 8 2

Filestore Allocation Filestore divided into fixed-size blocks Blocks not currently allocated to files are maintained in a free list Several strategies for allocating blocks contiguous linked file allocation table (FAT) indexed 9 The Free List Can be a simple bit vector e.g. 1100111100000 where 1=in use, 0=free Simple and efficient if kept in memory : Needs writing to disk every so often May be huge for large disks e.g. 80GB disk with 512-byte blocks needs 20MB for free list An alternative is to chain all free blocks into a linked list 10 Exercise A free list is represented as A2A0. How many blocks are free? Contiguous Allocation Each file allocated a contiguous set of blocks Filestore Directory eeny meeny miny mo 11 12 3

Contiguous Allocation Location information consists simply of start block, no. of blocks fast, both for sequential and direct access fragmentation (c.f. linear memory) may need regular compaction number of blocks to allocate file growth Linked Allocation Each block contains a pointer to the next eeny meeny miny mo 13 14 Linked Allocation easy to grow/shrink files no fragmentation blocks widely dispersed sequential access less efficient direct access even worse requires n reads to get to block n danger of pointer corruption Can improve things by allocating blocks in clusters but this worsens internal fragmentation 15 Question Which of the following is true about linked filestore allocation versus contiguous allocation? a) Linked is slower for both sequential and direct access. b) Linked is faster for both sequential and direct access. c) Linked is faster for sequential access, but slower for direct access. d) Linked is slower for sequential access, but faster for direct access. e) The performance for linked and contiguous is roughly the same for both forms of access. Answer: a Linked is slower for both sequential and direct access 16 4

File Allocation Table (FAT) Block allocations held in table located at start of partition eeny 217 start block 217 339 618 FAT 618-1 339 0 = unused FAT all pointer info held in one place easier to protect no need for separate free list direct access much more efficient may require drive head to shift constantly between FAT and file blocks FAT may become huge for large disks clustering may help 17 18 Indexed Allocation First block holds index to all other blocks eeny 217 618 339-1 Indexed Allocation each file s pointer info held in one place very efficient for both sequential and direct access blocks may still be widely dispersed can run out of pointers for large files may have to chain several index blocks together Example: Windows NTFS Has a Master File Table (MFT) using a form of indexed allocation However, small files contained entirely within MFT itself 19 20 5

Links It is possible for several filenames to point to the same file contents e.g. Unix, the command $ ln /users/katie/public/prog.c myprog.c File Deletion To delete a file: remove directory entry add allocated blocks to free list (garbage collection) creates a new directory entry called myprog.c, with the same inode number as prog.c 21 22 Question When should a deleted file not be garbage collected? a) When there are multiple links to it. b) When the file contains program code. c) When there is only one copy of the file. d) When the file is a system file rather than a user file. e) When the file contains encrypted data. Log-Structured File Systems A system crash can cause loss of data and inconsistencies Log-structured file systems address issues of consistency checking Based on database log-based recovery algorithms Each update to the file system is recorded as a transaction and all transactions are written to a log When a transaction is written to the log it is considered to be committed However, the file system may not yet be updated Transactions in the log are asynchronously written to the file system then removed from the log once the modification is complete Answer: a When there are multiple links to it. If the system crashes all transactions that remain in the log must still be completed 23 24 6