COT 4600 Operating Systems Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 3:00-4:00 PM.

Slides:



Advertisements
Similar presentations
Chapter 12: File System Implementation
Advertisements

More on File Management
Chapter 4 : File Systems What is a file system?
File Systems.
Operating system services Program execution I/O operations File-system manipulation Communications Error detection Resource allocation Accounting Protection.
COS 318: Operating Systems File Layout and Directories
Chapter 10: File-System Interface
COT 4600 Operating Systems Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 3:00-4:00 PM.
File Management Chapter 12. File Management A file is a named entity used to save results from a program or provide data to a program. Access control.
File System Interface CSCI 444/544 Operating Systems Fall 2008.
File System Implementation: beyond the user’s view A possible file system layout on a disk.
Operating Systems File Systems (in a Day) Ch
Files. System Calls for File System Accessing files –Open, read, write, lseek, close Creating files –Create, mknod.
Ceng Operating Systems
6/24/2015B.RamamurthyPage 1 File System B. Ramamurthy.
1 Friday, July 07, 2006 “Vision without action is a daydream, Action without a vision is a nightmare.” - Japanese Proverb.
Lecture 17 FS APIs and vsfs. File and File Name What is a File? Array of bytes. Ranges of bytes can be read/written. File system consists of many files,
Chapter 40 File System Implementation
1 Course Outline Processes & Threads CPU Scheduling Synchronization & Deadlock Memory Management File Systems & I/O Networks, Protection and Security.
7/15/2015B.RamamurthyPage 1 File System B. Ramamurthy.
File System. NET+OS 6 File System Architecture Design Goals File System Layer Design Storage Services Layer Design RAM Services Layer Design Flash Services.
File Systems (1). Readings r Silbershatz et al: 10.1,10.2,
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
Lesson 7-Creating and Changing Directories. Overview Using directories to create order. Managing files in directories. Using pathnames to manage files.
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.
CSC 322 Operating Systems Concepts Lecture - 4: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
SIMULATED UNIX FILE SYSTEM Implementation in C Tarek Youssef Bipanjit Sihra.
File Systems CSCI What is a file? A file is information that is stored on disks or other external media.
UNIX Files File organization and a few primitives.
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.
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.
Some basic concepts and information on file systems Portions taken and modified from books by ANDREW S. TANENBAUM.
Files & File system. A Possible File System Layout Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved
Project 6 Unix File System. Administrative No Design Review – A design document instead 2-3 pages max No collaboration with peers – Piazza is for clarifications.
Linux+ Guide to Linux Certification, Third Edition
Linux+ Guide to Linux Certification, Third Edition
Why Do We Need Files? Must store large amounts of data. Information stored must survive the termination of the process using it - that is, be persistent.
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.
Linux File system Implementations
COT 4600 Operating Systems Spring 2011 Dan C. Marinescu Office: HEC 304 Office hours: Tu-Th 5:00 – 6:00 PM.
THE FILE SYSTEM Files long-term storage RAM short-term storage Programs, data, and text are all stored in files, which is stored on.
Lecture 19 Linux/Unix – File System
COT 4600 Operating Systems Spring 2011 Dan C. Marinescu Office: HEC 304 Office hours: Tu-Th 5:00 – 6:00 PM.
COT 4600 Operating Systems Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 3:00-4:00 PM.
Operating Systems Files, Directory and File Systems Operating Systems Files, Directory and File Systems.
Naming CSCI 6900/4900. Names & Naming System Names have unique importance –Resource sharing –Identifying entities –Location reference Name can be resolved.
Lecture 14 Page 1 CS 111 Online File Systems: Naming, Reliability, and Advanced Issues CS 111 On-Line MS Program Operating Systems Peter Reiher.
File Systems May 12, 2000 Instructor: Gary Kimura.
W4118 Operating Systems Instructor: Junfeng Yang.
COT 4600 Operating Systems Spring 2011 Dan C. Marinescu Office: HEC 304 Office hours: Tu-Th 5:00 – 6:00 PM.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
COP 4600 Operating Systems Fall 2010 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 3:30-4:30 PM.
Day 28 File System.
Chapter 11: File System Implementation
File System Implementation
File System Structure How do I organize a disk into a file system?
Filesystems.
File Sharing Sharing of files on multi-user systems is desirable
An overview of the kernel structure
COT 4600 Operating Systems Spring 2011
File System B. Ramamurthy B.Ramamurthy 11/27/2018.
COT 4600 Operating Systems Spring 2011
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.
COT 4600 Operating Systems Fall 2010
Lecture 11: Flash Memory and File System Abstraction
Internal Representation of Files
Chapter 5 File Systems -Compiled for MCA, PU
Introduction to Operating Systems
Presentation transcript:

COT 4600 Operating Systems Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 3:00-4:00 PM

222 Lecture 9 Last time:  Case study: the Unix file system Today:  Modular sharing  Metadata and Name Overloading  Addresses Next Time:  User-friendly names  Lifetime of names  Case study: URL

3 Unix File System Unix file system – hierarchical data organization: blocks  files  directories  file systems  the objects: files – linear arrays of blocks of data; each file has a cursor giving the current position directories – collections of files; tree structure metadata - useful information about the file, not contained in the file (e.g., owner, access modes, last modified date, length, etc.)  supports: creation, deletion, renaming of files and directories reading data from and writing data to a file reading and writing metadata describing a file

4 API for the Unix File System OPEN(name, flags, model)  connect to a file Open an existing file called name, or Create a new file with permissions set to mode if flags is set. Set the file pointer (cursor) to 0. Return the file descriptor (fd). CLOSE(fd)  disconnect from a file Delete file descriptor fd. READ(fd, buf,n)  read from file Read n bytes from file fd into buf; start at the current cursor position and update the file cursor (cursor = cursor + n). WRITE(fd, buf,n)  write to file Write n bytes to the file fd from buf; start at the current cursor position and update the file cursor (cursor = cursor + n). SEEK(fd, offset,whence)  move cursor of file Set the cursor position of file fd to offset from the position specified by whence (beginning, end, current position)

5 API for the Unix File System (cont’d) FSYNC(fd)  make all changes to file fd durable. STAT(name)  read metadata CHMOD, CHOWN  change access mode/ownership RENAME(from_name,to_name)  change file name LINK(name, link_name)  create a hard link UNLINK(name)  remove name from directory SYMLINK(name, link_name)  create a symbolic link MKDIR(name)  create directory name RMDIR(name)  delete directory name CHDIR(name)  change current directory to name CHROOT  Change the default root directory name MOUNT(name,device)  mount the file system name onto device UNMOUNT(name)  unmount file system name

6 Layers Unix file system uses a number of layers to hide the implementation of the storage abstraction from the users.  User-oriented names 1. Symbolic link layer  integrates multiple file systems with symbolic names 2. Absolute path name layer  provides a root for the naming hierarchies 3. Path name layer  organizes files into naming hierarchies  Machine-user interface 4. File name layer  Supplies human-oriented names for files  Machine-oriented names 5. Inode number layer  provides machine-oriented names for files 6. File layer  organizes blocks into files 7. Block layer  Provides the physical address of data blocks

7 7. Block layer The storage device (disk)  a linear array of cells/blocks Block  fixed-size allocation unit (e.g., 512 bytes, 2,048 bytes); occupies several disk sectors. Block name  integer from a compact set, the offset from the beginning of the device Boot block  usually contains a boot program; Has a well-known name, 0. Super block  provides a description of the layout of the file system on the disk. Has a well-known name,1. Bitmap to keep track of free blocks and of defective blocks.

8 Figure 2.20 Disk layout

9 Figure 2.22

10 6. File layer A file consists of multiple blocks. inode (index node)  container for the metadata about the file; context for naming the blocks of the file structure inode integer block_number[N] // the number of the block in the file integer size // file size in bytes Name mapping algorithm: procedure INDEX_TO_BLOCK_NUMBER (inode instance i, integer index) returns integer return i_block_numbers[index] Indirect blocks  blocks that contain block numbers rather than data  to accommodate large file. Doubly indirect blocks  blocks that contain block numbers of indirect blocks Example: UNIX V6  the first N entries in i_block_numbers are indirect blocks and the N+1 is a doubly indirect block  the block size is 512 bytes;  an index consists of 2 bytes  an indirect block may contain 256 block numbers  the maximum file size is: (N-1) x x 256 blocks

11 5. Inode number layer inodes are named and passed around by name (inode number) inode numbers are a compact set inode_table   maps inode names to the starting block of the inode  stored at a known-location (e.g., at the beginning of the storage device) Inode manipulation functions: allocate, dealocate, add to list of free inodes, remove from list of free inodes Name mapping algorithm  procedure that returns the block that contains the byte at offset in a file identified by inode_number: procedure INODE_NUMBER_TO_BLOCK(integer offset, integer inode _number) returns block inode instance i  INODE_NUMBER_TO_INODE [inode,number] offset_in_block  offset/blocksize b_number  INDEX_TO_BLOCK_NUMBER(i, offset_in_block) return BLOCK_NUMBER_TO_BLOCK [b_number ]

12 4. File name layer Maps human-oriented names to machine-oriented names. Hides the metadata required by file management from the user. Directory   durable object providing the context for binding between a file name and an inode number  it is a file  the inode data structure is extended with a type field to indicate if the inode is for a file or for a directory. To create a file:  allocate an inode  initialize the metadata for the file  bind the file name to the inode number

13 File name lookup The lookup procedure reads the blocks containing the data for directory dir searching for a file called filename and return the inode number for the file is it finds the filename procedure LOOKUP (character string filename, integer dir) returns integer block instance b inode instance i  INODE_NUMBER_TO_INODE [dir] if i.type ne then return FAILURE for offset from 0 to i.size -1 do b  INODE_NUMBER_TO_BLOCK (offset,dir) return BLOCK_NUMBER_TO_BLOCK [b_number ] if STRING_MATCH (filename, b) then return INODE_NUMBER (filename,b) offset  offset +BLOCKSIZE return FAILURE

14 3. Path name layer Directories are hierarchical collections of files. The path name layer  structure for naming files in directories The name resolution algorithm: procedure PATH_TO_INODE_NUMBER (character string path, integer dir) returns integer if (PLAIN_NAME(path) return NAME_TO_INODE_NUMBER(path,dir) else dir  LOOKUP (FIRST(path),dir) path  REST(path) return PATH_TO_INODE_NUMBER (path,dir)

15 Links link  synonym allowing the user to use in the context of the current directory a symbolic name instead of a long path name. This requires binding in a different context; it does not require any extension of the naming scheme. Example: link(“/usr/applications/project/bin/programA”,”progA” if the current directory is alpha (with inode # 113) then the link directive will add to the directory “/usr/applications/project/bin” a new entry  (progA, 113) The unlink removes the link. Removal of the last link to a file also removes the file.

16 2. Absolute path name layer UNIX shell starts execution with the working directory set to the inode number of user’s home directory. To allow users to share files with one another the UNIX file system creates a context available to every user. This root directory binds a name to to each user’s top-level directory

17 1. Symbolic link layer Allows a user to operate on multiple file systems mount(“dev/fd1”, “/flash”).

18 Practical design of naming schemes Transition from abstract models to practical ones. Name conflict  multiple modules have the same name. How to avoid name conflicts when modules are developed independently often by different individuals? The theoretical model tells us that we must specify a context for name resolution; but this is not so straightforward!!  Example: there are two versions of module A; one is used by module B and the other by module C. Conflict when module B uses C.

19 Figure 3.1 Single context  ambiguity WORD_PROCESSOR  (INITIALIZE,SPELL_CHECK) SPELL_CHECH  (INITIALIZE) (but a different version of it)

20 Figure 3.3 Two distinct contexts  how does the interpreter choose the context? It needs a basis for the contexts.

21 Figure 3.4 Add a context reference to each module telling the interpreter which context to use for that module? Not feasible to tinker with someone else’s modules.

22 Figure 3.5 Have separate contexts but establish a link between them; the link points to the new context for the shared object

23 An elegant solution We need a systematic rather than ad-hoc ways to deal with the problem because programs contain many references to objects. Solution  associate the name of the object not with the object itself but with a structure consisting of pairs (original object, context). Some programming languages implement such a structure called closure and use static references. File systems rarely apply this solutions.

24 Metadata and name overloading Metadata  information about an object that  is useful to know about the object but cannot be found inside the object  may be changed without changing the object, e.g., the last date a file was referenced. Examples:  A user-friendly name; e.g., quadratic_solver  /user/local/bin/ linpack/quad.exe  The type of an object: e.g., Lecture9.ppt Where to place metadata?  In the same place with the data; e.g., the Unix file system stores metadata in inodes  In a separate place  process control block stored in the kernel space.  Overloading the name  e.g., Lecture9.ppt Overloading  adding metadata to a name  Contradicts the principle that names should only be used to reference objects  Creates a tension between the need to keep the name unchanged and the need to modify overloading information.

Names and overloading Pure names  names with no overloading. Fragile names  overloaded names which violate the idea of modular design. E.g.., adding location information on the file name. Opaque name to a module  the name has no overloading the module knows how to interpret.  A name may pass through several modules before reaching a module which knows how to interpret it. Lecture 9 25

Addresses Address   A name used to locate an object  Not a pure name it is overloaded with metadata  Parsing an address provides a guide to the location Often chosen from a compact set of integers  Does address adjacency correspond to physical adjacency? True in some cases; e.g., sectors on a disk False in other cases; e.g., the area code of a phone number  Can we apply arithmetic operations to addresses? Yes in some cases; e.g., memory references No in other cases; e.g; telephone numbers (actually the phone numbers do not forms a dense set!!) Remember that overloading the causes name fragility Lecture 9 26

Changing addresses Changing addresses not hidden by a level of indirection is tricky. Solutions 1. Search for all addresses and change them 2. Make each user do a search for the object and if the search returns “object not found” detect that the address has been changed and supply the new address. 3. If possible bind the object to both the old and the new name 4. If the name is bond to an active agent place a forwarding scheme to the old address. The optimal solution  hide an address under a level of indirection. We’ll discuss DNS, domain name services that map host names to IP addresses. Lecture 9 27

Unique names Problems arise when names must be generated at a high rate., e.g., for online banking transactions (billions a week). Danger of name collision. Solution  Using a fine timestamp  read a fine digital clock (say with a resolution of microseconds) and convert the binary representation of the timestamp to a string of characters.  Use a random number generator with a very large name space.  For objects with a binary representation (e.g., files, images) use the object itself.  Hashing algorithms such as SHA (Secure Hash Algorithm) avoid the problem of long names. HSA produces names of fixed length. Lecture 9 28

Hierarchical naming schemes Think about naming in the Internet with hundred millions of hosts.  Unfeasible with a central authority.  Domain names  E.g., boticelli.cs.ucf.edu How to relate a hierarchical naming scheme used by Internet with the flat naming schemes used for MAC addresses?  MAC addresses do not have any overloading  ARP  RARP  DHCP Lecture 9 29

Application, Transport, Network, and Data Link Layer Protocols

Dynamic IP address assignment -DHCP