1 Lecture 15: File System Interface  file system interface reasons for delegating storage management to OS file definition and operations on a file file.

Slides:



Advertisements
Similar presentations
Chapter 12: File System Implementation
Advertisements

File Management.
Chapter 4 : File Systems What is a file system?
File Systems.
Allocation Methods - Contiguous
COS 318: Operating Systems File Layout and Directories
Chapter 10: File-System Interface
File System Interface CSCI 444/544 Operating Systems Fall 2008.
File System Implementation
File System Implementation CSCI 444/544 Operating Systems Fall 2008.
File Systems. 2 Storing Information Applications can store it in the process address space Why is it a bad idea? –Size is limited to size of virtual address.
Ceng Operating Systems
1 File Management in Representative Operating Systems.
1 Outline File Systems Implementation How disks work How to organize data (files) on disks Data structures Placement of files on disk.
1 Friday, July 07, 2006 “Vision without action is a daydream, Action without a vision is a nightmare.” - Japanese Proverb.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
1 Course Outline Processes & Threads CPU Scheduling Synchronization & Deadlock Memory Management File Systems & I/O Networks, Protection and Security.
File Systems (1). Readings r Silbershatz et al: 10.1,10.2,
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
File Systems and Disk Management. File system Interface between applications and the mass storage/devices Provide abstraction for the mass storage and.
File Implementation. File System Abstraction How to Organize Files on Disk Goals: –Maximize sequential performance –Easy random access to file –Easy.
1Fall 2008, Chapter 11 Disk Hardware Arm can move in and out Read / write head can access a ring of data as the disk rotates Disk consists of one or more.
File Systems Long-term Information Storage Store large amounts of information Information must survive the termination of the process using it Multiple.
File System Implementation Chapter 12. File system Organization Application programs Application programs Logical file system Logical file system manages.
Operating System Concepts and Techniques Lecture 17
NETW3005 File System Interface. Reading For this lecture, you should have read Chapter 10 (Sections 1-5) and Chapter 11 (Sections 1-4). NETW3005 (Operating.
File Systems CSCI What is a file? A file is information that is stored on disks or other external media.
OSes: 11. FS Impl. 1 Operating Systems v Objectives –discuss file storage and access on secondary storage (a hard disk) Certificate Program in Software.
CSCI-375 Operating Systems Lecture Note: Many slides and/or pictures in the following are adapted from: slides ©2005 Silberschatz, Galvin, and Gagne Some.
File Management Chapter 12. File Management File management system is considered part of the operating system Input to applications is by means of a file.
1 Comp 104: Operating Systems Concepts Files and Filestore Allocation.
File Storage Organization The majority of space on a device is reserved for the storage of files. When files are created and modified physical blocks are.
Chapter 11: Implementing File Systems Silberschatz, Galvin and Gagne ©2005 Operating System Principles Chapter 11: Implementing File Systems Chapter.
File System Implementation
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 11: File System Implementation.
Module 4.0: File Systems File is a contiguous logical address space.
Chapter 16 File Management The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander John.
CE Operating Systems Lecture 17 File systems – interface and implementation.
File Systems. 2 What is a file? A repository for data Is long lasting (until explicitly deleted).
Lecture 10 Page 1 CS 111 Summer 2013 File Systems Control Structures A file is a named collection of information Primary roles of file system: – To store.
CS 3204 Operating Systems Godmar Back Lecture 21.
File system In computing, a file system is a method of storing and organizing computer files and the data they contain to make it easy to find and access.
Operating Systems 1 K. Salah Module 4.0: File Systems  File is a contiguous logical address space (of related records)  Access Methods  Directory Structure.
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally FILE SYSTEM.
File Systems.  Issues for OS  Organize files  Directories structure  File types based on different accesses  Sequential, indexed sequential, indexed.
Operating Systems Files, Directory and File Systems Operating Systems Files, Directory and File Systems.
Part III Storage Management
File System Department of Computer Science Southern Illinois University Edwardsville Spring, 2016 Dr. Hiroshi Fujinoki CS 314.
W4118 Operating Systems Instructor: Junfeng Yang.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 12: File System Implementation.
File Systems and Disk Management
Chapter 11: File System Implementation
File System Structure How do I organize a disk into a file system?
Chapter 11: File System Implementation
Filesystems.
Chapter 11: File System Implementation
File Systems and Disk Management
File Systems Implementation
Chapter 11: File System Implementation
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.
File Systems and Disk Management
File Systems and Disk Management
File Systems and Disk Management
File Systems and Disk Management
Chapter 14: File-System Implementation
File Systems and Disk Management
File Systems and Disk Management
Chapter 11: File System Implementation
Chapter 5 File Systems -Compiled for MCA, PU
The File Manager Implementation issues
Presentation transcript:

1 Lecture 15: File System Interface  file system interface reasons for delegating storage management to OS file definition and operations on a file file access patterns directories  file system structures i-nodes on-disk file system structures in-memory file system structures  disk space allocation methods continuous chained (linked) indexed multilevel indexed

2 Why Manage Secondary Storage  use of raw disk is inconvenient to the users  use of raw disk by multiple users is inefficient system calls device- independent interface device interface applicationsdaemonsservers open( ) close( ) read( ) write( ) link( ) rename( ) create( ) delete( ) trackssectors blocks seek( ) readblock( ) writeblock( ) other hardwaredisk  OS provides an interface to conveniently access the disk  OS manages this interface efficiently

3 What Is a File?  a file is a named collection of data:  what is stored in a file? c++ source code, object files, executable files, shell scripts, PostScript… Macintosh OS explicitly supports file types — TEXT, PICT, etc. Windows uses file naming conventions — “.exe” and “.com” for executables, etc. UNIX looks at contents to determine type: F Shell scripts — start with “#!” F PostScript — starts with “%!PS-Adobe…” F Executables — starts with magic number  for ease of reference files are grouped into a directory

4 File Operations  create(name) constructs an entry on disk to represent the newly created file adds a file entry to a directory allocates disk space for the file  fileid = open(name, mode) allocates a unique identifier called the fileid (identifier) (returned to the user) to use by the program to refer to the file sets the mode (r, w, rw) to control concurrent access to the file  close(fileId)  delete(name) deletes the file from the disk and removes its name from the directory

5  sequential access data is processed in order, one byte at a time, always going forward most accesses are of this form example: compiler reading a source file  direct / random access can access any byte in the file directly, without accessing any of its predecessors example: accessing database record 12  keyed access can access a byte based on a key value example: database search, dictionary OS usually does not support keyed access F user program must determine the address from the key, then use random access (provided by the OS) into the file Common File Access Patterns

6 File Operations (cont.)  read(fileId, from, size, bufAddress) random access read reads size bytes from file fileId, starting at position from, into the buffer specified by bufAddress  read(fileId, size, bufAddress) sequential access read reads size bytes from file fileId, starting at the current file position fp, into the buffer specified by bufAddress, and then increments fp by size  write — similar to Read

7  directories of named files user and OS must have some way to refer to files stored on the disk OS needs to use numbers (index into an array of inodes) (efficient, etc.) user wants to use textual names (readable, mnemonic, etc.)  simple naming one name space for the entire disk F every name must be unique implementation: F store directory on disk F directory contains pairs used by early mainframes, early MacOS, and MS DOS Directories and Naming

8  user-based naming one name space for each user F every name in that user’s directory must be unique, but two different users can use the same name for a file in their directory used by TOPS-10 (DEC mainframe from the early 1980s)  multilevel naming tree-structured name space implementation: F store directories on disk, just like files F each directory contains pairs in no particular order the file pointed to by a directory can be another directory –names have “/” separating levels used in UNIX Directories and Naming (cont.)

9  multilevel naming - unambiguous but cumbersome:  this file’s name is: /home/mikhail/public_html/classes/os.s07/Slides/l15files.ppt  OS maintains current working directory as part of process state thus a program may refer to files relative to current working directory  each directory has two special entries:. - refers to the directory itself.. - refers to parent directory (root directory has.. pointing to itself)  each file can be listed in several different directories. Each reference is called hard-link; file continues to exist as long as there is at least one hard-link hence Unix directory structure is more complex than just tree Unix Directories

10 I-nodes  every file is described by an i-node (UNIX term – stands for index node), which may contain (varies with OS): type access permissions — read, write, etc. link count — number of directories that contain this file owner, group size access times — when created, last accessed, last modified blocks where file is located on disk  not included: name of file

11 Unix File System  an i-node represents a file all i-nodes are stored on the disk in a fixed-size array called the ilist F the size of the ilist array is determined when the disk is initialized F the index of a file descriptor in the array is called its inode number, or inumber i-nodes for active files are also cached in memory in the active inode table  a UNIX disk may be divided into partitions, each of which contains: blocks for storing directories and files blocks for storing the ilist F i-nodes corresponding to files some special blocks F boot block — code for booting the system F super block - size of disk, number of free blocks, list of free blocks, size of ilist, number of free inodes in ilist, etc.

12 Unix file system (cont.)  Note that in practice the picture is more complicated because the directory structure is added: a directory is a file that contains the list of file names and inodes partition disk drive partition bootb.superb.ilistdirectory blocks and file data blocks inode high level view

13 Working With Directories (Lookup)  a directory is a table of entries: 2 bytes — inumber 14 bytes — file name (improved in BSD 4.2 and later)  search to find the file begins with either root, or the current working directory Inode 2 points to the root directory (“ / ”) example above shows lookup of /usr/ast/mbox

14 File Descriptors, File Tables  open file table (one, belongs to OS) lists all open files each entry contains: F a file descriptor (sometimes also called i-node - don’t confuse with i-node on the disk!) F open count — number of processes that have the file open  per-process file table (many) list all open files for that process each entry contains: F pointer to entry in open file table F current position (offset) in file position Per-Process File Table Per-Process File Table position Open File Table count file descrip. count file descrip. OS

15 Continuous Allocation  OS keeps an ordered list of free blocks  allocates contiguous groups of blocks when it creates a file  i-node must store start block and length of file  used in IBM 370, some write-only disks  have to use usual dynamic allocation techniques (first-fit, best-fit, etc.)  advantages: simple efficient sequential access, reasonably efficient random access small number of seeks (head movement), most may be on same track good for storing data on CDROM  disadvantages: may have difficulty changing file size (size is specified when file is created) problems with external fragmentation  compaction - relocation of files so that there is no free space between them

16 Chained (Linked) Allocation  OS keeps an ordered list of free blocks  file descriptor stores pointer to first block  each block stores pointer to next block  used in DEC TOPS-10, Xerox Alto  advantages: no external fragmentation any free space is as good as any other can easily change file size (no need to declare in advance)  disadvantages: reasonable, but not great, for sequential access (one seek each time) inefficient random access — have to follow many links lost space due to lots of pointers (small, but adds up) lots of seeks to find a block not very robust — lose a block, lose rest of file  compaction can be used so that blocks of one file are located continuously on the disk - optimizes disk access.

17 Linked Allocation Variant: FAT  file allocation table (FAT) a variant of linked list allocation  used in MS-DOS, OS/2, Windows  the beginning of each partition contains the indexing table FAT  directory entry has the number of the first block  FAT has an entry for each block the FAT entry indexed by the first block has the number of the second block and so on last block’s FAT entry has reserved EOF symbol unused blocks have \0 entry

18 Indexed Allocation  OS keeps a list of free blocks OS allocates an array (called the index block) to hold pointers to all the blocks used by the file allocates blocks only on demand  used in DEC VMS  advantages: can easily grow up to maximum size both sequential and random accesses are easy  disadvantages: limit on maximum file size lots of seeks since data is not contiguous wasted space for pointers (need a whole block even for one pointer)

19 Multilevel indexed allocation  used in UNIX (numbers below are for traditional UNIX, BSD UNIX 4.1)  each i-node contains 13 block pointers first 10 pointers point to data blocks (each 512 bytes long) of a file F if the file is bigger than 10 blocks (5,120 bytes), the 11th pointer points to a single indirect block, which contains 128 pointers to 128 more data blocks (can support files up to 70,656 bytes) if the file is bigger than that, the 12th pointer points to a double indirect block, which contains 128 pointers to 128 more single indirect blocks (can support files up to 8,459,264 bytes) –if the file is bigger than that, the 13th pointer points to a triple indirect block, which contains 128 pointers to 128 more double indirect blocks max file size is 1,082,201,087 bytes

20 Multilevel Indexed Allocation (cont.)  advantages: simple to implement supports incremental file growth works well for small files  disadvantages: inefficient access to very large files data gets spread around - more seeks

21 Unix File System “The Big Picture” partition disk drive partition bootb.superb.ilistdirectory blocks and file data blocks inode File attributes block #... 1st indirect block # block dir’s inode block block #... block # dir. attributes pointer block inode #... File’s inode 1st indi- rect block dir’s block name inode #name directory and file data blocks

22 Why OS manages secondary storage? (cont.)  Important to the user: Persistence — data stays around between power cycles and crashes Ease of use — can easily find, examine, modify, etc. data Efficiency — uses disk space well Speed — can get to data quickly Protection — others can’t corrupt (or sometimes even see) my data  OS provides: File system with directories and naming — allows user to specify directories and names instead of location on disk Disk management — keeps track of where files are located on the disk, accesses those files quickly Protection — no unauthorized access