Introduction to File Systems

Slides:



Advertisements
Similar presentations
1 Chapter 11: File-System Interface  File Concept  Access Methods  Directory Structure  File System Mounting  File Sharing  Protection  Chapter.
Advertisements

Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 11: File-System Interface File Concept Access Methods Directory Structure.
File System Interface CSCI 444/544 Operating Systems Fall 2008.
Dr. Kalpakis CMSC 421, Operating Systems. Fall File-System Interface.
File SystemsCS-502 Fall File Systems CS-502 Operating Systems Fall 2006 (Slides include materials from Operating System Concepts, 7 th ed., by Silbershatz,
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 10: File-System Interface.
CS-3013 & CS-502, Summer 2006 File Systems1 Review – I/O subsystems OS responsibilities to device drivers Device API, buffering, naming, interrupt handling.
FilesCS-4513, D-Term Introduction to File Systems CS-4513 Distributed Computing Systems (Slides include materials from Operating System Concepts,
Files and File Systems 1 CS502 Spring 2006 Files and File Systems CS502 – Operating Systems Spring 2006.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition File-System Interface.
File Systems Topics –File –Directory –File System Implementation Reference: Chapter 5: File Systems Operating Systems Design and Implementation (Second.
1 File Systems Chapter Files 6.2 Directories 6.3 File system implementation 6.4 Example file systems.
6/24/2015B.RamamurthyPage 1 File System B. Ramamurthy.
10.1 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Chapter 10: File-System Objectives To discuss file-system design tradeoffs, including.
Chapter 10: File-System Interface Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 10: File-System Interface File Concept.
1 Friday, July 07, 2006 “Vision without action is a daydream, Action without a vision is a nightmare.” - Japanese Proverb.
Accessing Files in CCS-2303, C-Term Accessing Files in C CS-2303 System Programming Concepts (Slides include materials from The C Programming Language,
7/15/2015B.RamamurthyPage 1 File System B. Ramamurthy.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 10: File-System Interface.
Chapter 10 File System Interface
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
Computer Studies (AL) File Management File system interface.
ITEC 502 컴퓨터 시스템 및 실습 Chapter 10-1: File Systems Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 10: File-System Interface.
Silberschatz, Galvin and Gagne  Operating System Concepts File Concept Contiguous logical address space Smallest user allocation Non-volatile.
File Systems Long-term Information Storage Store large amounts of information Information must survive the termination of the process using it Multiple.
Introduction to FilesCS-502 Fall Introduction to File Systems CS-502 Operating Systems Fall 2007 (Slides include materials from Operating System.
Chapter 10: File-System Interface 10.1 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts – 8 th Edition 2014.
File Systems CSCI What is a file? A file is information that is stored on disks or other external media.
File System Interface. File Concept Access Methods Directory Structure File-System Mounting File Sharing (skip)‏ File Protection.
File Systems (1). Readings r Reading: Disks, disk scheduling (3.7 of textbook; “How Stuff Works”) r Reading: File System Implementation ( of textbook)
Operating Systems COMP 4850/CISG 5550 File Systems Files Dr. James Money.
CS333 Intro to Operating Systems Jonathan Walpole.
Module 4.0: File Systems File is a contiguous logical address space.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 11: File-System Interface File Concept Access Methods Directory Structure.
CS 346 – Chapter 11 File system –Files –Access –Directories –Mounting –Sharing –Protection.
CE Operating Systems Lecture 17 File systems – interface and implementation.
Chapter 10: File-System Interface Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 10: File-System Interface File Concept.
Annotated by B. Hirsbrunner File Systems Chapter Files 5.2 Directories 5.3 File System Implementation 5.4 Security 5.5 Protection Mechanism 5.6 Overview.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 10: File-System Interface.
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally FILE SYSTEM.
Lecture Topics: 11/29 File System Interface –Files and Directories –Access Methods –Protection –Consistency.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 11: File-System Interface File Concept Access Methods Directory Structure.
Lecture 14 Page 1 CS 111 Online File Systems: Naming, Reliability, and Advanced Issues CS 111 On-Line MS Program Operating Systems Peter Reiher.
W4118 Operating Systems Instructor: Junfeng Yang.
SVBIT SUBJECT:- Operating System TOPICS:- File Management
Lecture : chapter 9 and 10 file system 1. File Concept A file is a collection of related information defined by its creator. Contiguous logical address.
File System Interface CSSE 332 Operating Systems
Module 10: File-System Interface
Chapter 11: File-System Interface
Processes in Unix, Linux, and Windows
CS510 Operating System Foundations
Chapter 11: File-System Interface
EECE.4810/EECE.5730 Operating Systems
Processes in Unix, Linux, and Windows
File System B. Ramamurthy B.Ramamurthy 11/27/2018.
Directory Structure A collection of nodes containing information about all files Directory Files F 1 F 2 F 3 F 4 F n Both the directory structure and the.
CSE 451: Operating Systems Autumn 2003 Lecture 13 File Systems
Accessing Files in C Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2nd edition,
Chapter 10: File-System Interface
Files Management – The interfacing
CSE 451: Operating Systems Winter 2003 Lecture 13 File Systems
Processes in Unix, Linux, and Windows
Module 10: File-System Interface
Lecture 4: File-System Interface
CSE 451: Operating Systems Autumn 2001 Lecture 13 File Systems
Lecture Topics: 11/20 HW 7 What happens on a memory reference Traps
Chapter 5 File Systems -Compiled for MCA, PU
Introduction to Operating Systems
Presentation transcript:

Introduction to File Systems CS-3013 Operating Systems Hugh C. Lauer (Slides include materials from Slides include materials from Modern Operating Systems, 3rd ed., by Andrew Tanenbaum and from Operating System Concepts, 7th ed., by Silbershatz, Galvin, & Gagne) CS-3013, C-Term 2012 Introduction to File Systems

Discussion (laptops closed, please) What is a file? CS-3013, C-Term 2012 Introduction to File Systems

Introduction to File Systems Reading Assignment Tanenbaum, §4.1 – 4.2 Note:– there is a lot more in this chapter than can be covered in these lecture topics! Mostly deferred to CS-4513 CS-3013, C-Term 2012 Introduction to File Systems

Introduction to File Systems File (an abstraction) A (potentially) large amount of information or data that lives a (potentially) very long time Often much larger than the memory of the computer Often much longer than any computation Sometimes longer than life of machine itself (Usually) organized as a linear array of bytes or blocks Internal structure is imposed by application (Occasionally) blocks may be variable length (Often) requiring concurrent access by multiple processes Even by processes on different machines! CS-3013, C-Term 2012 Introduction to File Systems

Review — Four Fundamental Abstractions Processes & threads This course (Tanenbaum, Chapter 2) Virtual memory This course (Tanenbaum, Chapter 3) Files & persistent storage CS-4513 with intro in this course (Tanenbaum, Chapter 4) Sockets & connections CS-3516 or CS-513 (Computer Networks) CS-3013, C-Term 2012 Introduction to File Systems

Review — Four Fundamental Abstractions Processes & threads This course (Tanenbaum, Chapter 2) Virtual memory This course (Tanenbaum, Chapter 3) Files & persistent storage CS-4513 with intro in this course (Tanenbaum, Chapter 4) Sockets & connections CS-3516 or CS-513 (Computer Networks) CS-3013, C-Term 2012 Introduction to File Systems

Introduction to File Systems The third major abstraction of almost all operating systems An organizing abstraction The way information is organized, stored, kept for a long time, and updated CS-3013, C-Term 2012 Introduction to File Systems

Introduction to File Systems File Systems and Disks User view File is a named, persistent collection of data OS & file system view File is collection of disk blocks — i.e., a container File System maps file names and offsets to disk blocks CS-3013, C-Term 2012 Introduction to File Systems

Fundamental Ambiguity Is the file the “container of the information” or the “information” itself? Almost all systems confuse the two. Almost all people confuse the two. CS-3013, C-Term 2012 Introduction to File Systems

Example Suppose that you e-mail me a document Later, how do either of us know that we are using the same version of the document? Windows/Outlook/Exchange/MacOS: Time-stamp is a pretty good indication that they are Time-stamps preserved on copy, drag and drop, transmission via e-mail, etc. Unix/Linux By default, time-stamps not preserved on copy, ftp, e-mail, etc. Time-stamp associated with container, not with information CS-3013, C-Term 2012 Introduction to File Systems

Introduction to File Systems Rule of Thumb Almost always, people and applications think in terms of the information Many systems think in terms of containers Professional Guidance: Be aware of the distinction, even when the system is not CS-3013, C-Term 2012 Introduction to File Systems

Introduction to File Systems Attributes of Files Name: Although the name is not always what you think it is! Type: May be encoded in the name (e.g., .cpp, .txt) Dates: Creation, updated, last accessed, etc. (Usually) associated with container Better if associated with content Size: Length in number of bytes; occasionally rounded up Protection: Owner, group, etc. Authority to read, update, extend, etc. Locks: For managing concurrent access … Many systems co-opt container dates to be used in lieu of content dates CS-3013, C-Term 2012 Introduction to File Systems

Definition — File Metadata Information about a file Maintained by the file system Separate from file itself Usually attached or connected to the file E.g., in block # –1 Some information visible to user/application Dates, permissions, type, name, etc. Some information primarily for OS Location on disk, locks, cached attributes CS-3013, C-Term 2012 Introduction to File Systems

Introduction to File Systems Observation Some attributes are not visible to user or program E.g., location Location is stored in metadata Location can change, even if file does not Location is not visible to user or program CS-3013, C-Term 2012 Introduction to File Systems

Question – Is Location a File Attribute? Example 1:– mv ~lauer/project4.doc ~cs3013/public_html/c12 Does location of file on disk change? Example 2:– System moves file from disk block 10,000 to disk block 20,000 (e.g., during defragmentation) System restores a file from backup May or may not be reflected in metadata CS-3013, C-Term 2012 Introduction to File Systems

Question – Is Location a File Attribute? Answer: It is an attribute of the container Not an attribute of the information! CS-3013, C-Term 2012 Introduction to File Systems

Introduction to File Systems File Name Attribute Not attached to file in most modern systems Stored in directory (see below) Unix/Linux – file may have multiple names I.e., hard links Windows – file normally has only one name Still stored in directory May be changed without touching the file! CS-3013, C-Term 2012 Introduction to File Systems

Introduction to File Systems File Types File type may be tattooed on file as an attribute Or it may be embedded in file name by convention CS-3013, C-Term 2012 Introduction to File Systems

Introduction to File Systems Questions? CS-3013, C-Term 2012 Introduction to File Systems

Traditional Operations on Files Open, Close Gain or relinquish access to a file OS returns a file handle – an internal data structure letting it cache internal information needed for efficient file access Read, Write, Truncate Read: return a sequence of n bytes from file Write: replace n bytes in file, and/or append to end Truncate: throw away all but the first n bytes of file Seek, Tell Seek: reposition file pointer for subsequent reads and writes Tell: get current file pointer Create, Delete: Conjure up a new file; or blow away an existing one CS-3013, C-Term 2012 Introduction to File Systems

File – a very powerful Abstraction Documents, code Databases Very large, possibly spanning multiple disks Streams Input, output, keyboard, display Pipes, network connections, … Virtual memory backing store Temporary repositories of OS information … Any time you need to remember something beyond the life of a particular process/computation CS-3013, C-Term 2012 Introduction to File Systems

Methods for Accessing Files Sequential access Random access Keyed (or indexed) access Hardly ever used any more! CS-3013, C-Term 2012 Introduction to File Systems

Sequential Access Method Read all bytes or records in order from the beginning Writing implicitly truncates Cannot jump around Could possibly rewind or back up for some media Appropriate for certain media or systems Magnetic tape or punched cards Video tape (VHS, etc.) Unix-Linux-Windows pipes Network streams CS-3013, C-Term 2012 Introduction to File Systems

Introduction to File Systems Random Access Method Bytes/records can be read in any order Writing can Replace existing bytes or records Append to end of file Cannot insert data between existing bytes! Seek operation moves current file pointer Maintained as part of “open” file information Discarded on close Typical of most modern information storage Data base systems Randomly accessible multi-media (CD, DVD, etc) … CS-3013, C-Term 2012 Introduction to File Systems

Keyed (or indexed) Access Methods Access items in file based on the contents of (part of) an item in the file Provided in older commercial operating systems IBM ISAM (Usually) handled separately by modern database systems CS-3013, C-Term 2012 Introduction to File Systems

Introduction to File Systems Questions? CS-3013, C-Term 2012 Introduction to File Systems

Directory – A Special Kind of File A tool for users & applications to organize and find files User-friendly names Names that are meaningful over long periods of time The data structure for OS to locate files (i.e., containers) on disk CS-3013, C-Term 2012 Introduction to File Systems

Introduction to File Systems Directory structures Single level One directory per system, one entry pointing to each file Small, single-user or single-use systems PDA, cell phone, etc. Two-level Single “master” directory per system Each entry points to one single-level directory per user Uncommon in modern operating systems Hierarchical Any directory entry may point to Individual file Another directory Common in most modern operating systems CS-3013, C-Term 2012 Introduction to File Systems

Directory Considerations Efficiency – locate a file quickly Naming – convenient to users Separate users can use same name for separate files The same file can have different names for different users Names need only be unique within a directory Preferably in user’s own language! Grouping – logical grouping of files by properties e.g., all Java programs, all games, … CS-3013, C-Term 2012 Introduction to File Systems

Directory Organization – Hierarchical Most systems support idea of current (working) directory Absolute names – fully qualified from root of file system /usr/group/foo.c, ~/kernelSrc/config.h Relative names – specified with respect to working directory foo.c, bar/bar2.h A special name – the working directory itself “.” CS-3013, C-Term 2012 Introduction to File Systems

Directory Organization (continued) Modified Hierarchical – Acyclic Graph (no loops) and General Graph Allow directories and files to have multiple names Links are file names (directory entries) that point to existing (source) files CS-3013, C-Term 2012 Introduction to File Systems

Introduction to File Systems Links Substitute this string for the name you were looking for Symbolic (soft) links: uni-directional relationship between a file name and the file Directory entry contains text describing absolute or relative path name of original file If the source file is deleted, the link exists but points to nowhere! Hard links: bi-directional relationship between file names and file A hard link is directory entry that points to a source file’s metadata Metadata maintains reference count of the number of hard links pointing to it – link reference count Link reference count is decremented when a hard link is deleted File data is deleted and space freed when the link reference count goes to zero CS-3013, C-Term 2012 Introduction to File Systems

Introduction to File Systems Unix-Linux Hard Links File may have more than one name or path rm, mv —directory operations, not file operations! The real name of a Unix file is internal name of its metadata Known only to OS! Hard links are not used very often in modern Unix practice Exception: Linked copies of large directory trees! When building your Linux kernel in OS course (Usually) safe to regard last element of path as name of file CS-3013, C-Term 2012 Introduction to File Systems

Path Name Translation Assume that I want to open “/home/lauer/foo.c” fd = open("/home/lauer/foo.c", O_RDWR); File System does the following Opens directory "/" – the root directory is in a known place on disk Search root directory for the directory home and get its location Open home and search for the directory lauer and get its location Open lauer and search for the file foo.c and get its location Open the file foo.c Note that the process needs the appropriate permissions at every step … CS-3013, C-Term 2012 Introduction to File Systems

Path Name Translation (continued) … File Systems spend a lot of time walking down directory paths This is why open calls are separate from other file operations File System attempts to cache prefix lookups to speed up common searches – “~” for user’s home directory “.” for current working directory Once open, file system caches the metadata of the file CS-3013, C-Term 2012 Introduction to File Systems

Introduction to File Systems See Tanenbaum §4.2.4 Directory Operations Create: Make a new directory Add, Delete entry: Invoked by file create & destroy, directory create & destroy Find, List: Search or enumerate directory entries Rename: Change name of an entry without changing anything else about it Link, Unlink: Add or remove entry pointing to another entry elsewhere Introduces possibility of loops in directory graph Destroy: Removes directory; must be empty CS-3013, C-Term 2012 Introduction to File Systems

Directories (continued) Orphan: a file not named in any directory Cannot be opened by any application (or even OS) May not even have name! Tools FSCK – check & repair file system, find orphans Delete_on_close attribute (in metadata) Special directory entry: “..”  parent in hierarchy Essential for maintaining integrity of directory system Useful for relative naming CS-3013, C-Term 2012 Introduction to File Systems

Introduction to File Systems Directories — Summary Fundamental mechanism for interpreting file names in an operating system Widely used by system, applications, and users CS-3013, C-Term 2012 Introduction to File Systems

Introduction to File Systems Reading Assignment Tanenbaum, §4.1 – 4.2 CS-3013, C-Term 2012 Introduction to File Systems

Introduction to File Systems Questions? CS-3013, C-Term 2012 Introduction to File Systems