Operating System File-System Interface

Slides:



Advertisements
Similar presentations
Chapter 10: File-System Interface
Advertisements

1 Chapter 11: File-System Interface  File Concept  Access Methods  Directory Structure  File System Mounting  File Sharing  Protection  Chapter.
Chapter 10: File-System Interface
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 11: File-System Interface File Concept Access Methods Directory Structure.
Chapter 10: File-System Interface
File System Interface CSCI 444/544 Operating Systems Fall 2008.
Dr. Kalpakis CMSC 421, Operating Systems. Fall File-System Interface.
1 File Management (a). 2 File-System Interface  File Concept  Access Methods  Directory Structure  File System Mounting  File Sharing  Protection.
04/02/2004CSCI 315 Operating Systems Design1 File System Interface.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 10: File-System Interface.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition File-System Interface.
1 Operating Systems Chapter 7-File-System File Concept Access Methods Directory Structure Protection File-System Structure Allocation Methods Free-Space.
Chapter 10: File-System Interface
Chapter 10: File-System Interface Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 10: File-System Interface File Concept.
File Concept l Contiguous logical address space l Types: Data: numeric, character, binary Program: source, object (load image) Documents.
File Concept §Contiguous logical address space §Types: l Data: Numeric Character Binary l Program.
CSE 451: Operating Systems Winter 2010 Module 14 File Systems Mark Zbikowski Gary Kimura.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 10: File-System Interface.
Operating System Concepts with Java – 7 th Edition, Nov 15, 2006 Silberschatz, Galvin and Gagne ©2007 Chapter 10: File-System Interface.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Lecture 10 Operating Systems.
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.
Chap 10 File-System Interface. Objectives To explain the function of file systems To describe the interfaces to file systems To discuss file-system design.
Chapter 10: File-System Interface Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Jan 1, 2005 Chapter 10: File-System.
Chapter 10: File-System Interface 10.1 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts – 8 th Edition 2014.
Operating Systems (CS 340 D) Dr. Abeer Mahmoud Princess Nora University Faculty of Computer & Information Systems Computer science Department.
Page 110/19/2015 CSE 30341: Operating Systems Principles Chapter 10: File-System Interface  Objectives:  To explain the function of file systems  To.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 11: File-System Interface Modified.
10.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 10: File-System Interface.
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.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Lecture 18: File-System Interface (Ch 10)
Chapter 10: File-System Interface Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 10: File-System Interface File Concept.
14.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 10 & 11: File-System Interface and Implementation.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 10: File-System Interface.
CSE 451: Operating Systems Winter 2015 Module 15 File Systems Mark Zbikowski Allen Center 476 © 2013 Gribble, Lazowska, Levy, Zahorjan.
Operating Systems Files, Directory and File Systems Operating Systems Files, Directory and File Systems.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 11: File-System Interface File Concept Access Methods Directory Structure.
CSE Operating System Principles File Systems.
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
Filesystems.
Subject Name: Operating Systems Subject Code:10CS53
CSE 451: Operating Systems Autumn 2001 Module 16 File Systems
File Sharing Sharing of files on multi-user systems is desirable
CSE 451: Operating Systems Spring 2012 Module 15 File Systems
Chapter 11: File-System Interface
CSE 451: Operating Systems Spring 2013 Module 15 File Systems
CSE 153 Design of Operating Systems Winter 2018
Chapter 10: File-System Interface
CSE 451: Operating Systems Autumn 2004 File Systems
CSE 451: Operating Systems Winter 2007 Module 14 File Systems
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
IT 344: Operating Systems Winter 2008 Module 14 File Systems
Chapter 10: File-System Interface
File-System Interface
CSE 451: Operating Systems Winter 2009 Module 14 File Systems
CSE 451: Operating Systems Winter 2004 Module 14 File Systems
CSE 451: Operating Systems Winter 2003 Lecture 13 File Systems
CSE 153 Design of Operating Systems Winter 2019
CSE 451: Operating Systems Spring 2008 Module 14 File Systems
CS703 - Advanced Operating Systems
Module 10: File-System Interface
CSE 451: Operating Systems Autumn 2009 Module 14 File Systems
CSE 451: Operating Systems Autumn 2010 Module 14 File Systems
Lecture 4: File-System Interface
CSE 451: Operating Systems Autumn 2001 Lecture 13 File Systems
Presentation transcript:

Operating System File-System Interface

Files A file is a collection of data with some properties contents, size, owner, last read/write time, protection … Files may also have types understood by file system device, directory, symbolic link understood by other parts of OS or by runtime libraries executable, dll, source code, object code, text file, …

Type can be encoded in the file’s name or contents windows encodes type in name .com, .exe, .bat, .dll, .jpg, .mov, .mp3, … old Mac OS stored the name of the creating program along with the file unix has a smattering of both in content via magic numbers or initial characters (e.g., #!)

File Structure Simple record structure Lines Fixed length Variable length Complex Structures Formatted document Re-locatable load file Can simulate last two with first method by inserting appropriate control characters Who decides: Operating system Program

File Attributes Name – 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 do reading, writing, executing Time, date, and user identification – data for protection, security, and usage monitoring Information about files are kept in the directory structure, which is maintained on the disk

File Operations File is an abstract data type Create Write Read Reposition within file Delete Truncate Open(Fi) – search the directory structure on disk for entry Fi, and move the content of entry to memory Close (Fi) – move the content of entry Fi in memory to directory structure on disk

Basic operations Windows Unix CreateFile(name, CREATE) create(name) CreateFile(name, OPEN) ReadFile(handle, …) WriteFile(handle, …) FlushFileBuffers(handle, …) SetFilePointer(handle, …) CloseHandle(handle, …) DeleteFile(name) CopyFile(name) MoveFile(name) Unix create(name) open(name, mode) read(fd, buf, len) write(fd, buf, len) sync(fd) seek(fd, pos) close(fd) unlink(name) rename(old, new)

Open Files Several pieces of data are needed to manage open files: File pointer: pointer to last read/write location, per process that has the file open File-open count: counter of number of times a file is open – to allow removal of data from open-file table when last processes closes it Disk location of the file: cache of data access information Access rights: per-process access mode information

File Types – Name, Extension

File access methods Some file systems provide different access methods that specify ways the application will access data sequential access read bytes one at a time, in order direct access random access given a block/byte # record access file is array of fixed- or variable-sized records indexed access FS contains an index to a particular field of each record in a file apps can find a file based on value in that record (similar to DB) Why do we care about distinguishing sequential from direct access? what might the FS do differently in these cases?

Access Methods Sequential Access read next write next reset no read after last write (rewrite) Direct Access read n write n position to n rewrite n n = relative block number

Directories Directories provide: a way for users to organize their files a convenient file name space for both users and FS’s Most file systems support multi-level directories naming hierarchies (/, /usr, /usr/local, /usr/local/bin, …) Most file systems support the notion of current directory absolute names: fully-qualified starting from root of FS bash$ cd /usr/local relative names: specified with respect to current directory bash$ cd /usr/local (absolute) bash$ cd bin (relative, equivalent to cd /usr/local/bin)

Directory internals A directory is typically just a file that happens to contain special metadata directory = list of (name of file, file attributes) attributes include such things as: size, protection, location on disk, creation time, access time, … the directory list is usually unordered (effectively random) when you type “ls”, the “ls” command sorts the results for you

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 files reside on disk Backups of these two structures are kept on tapes

Operations Performed on Directory Search for a file Create a file Delete a file List a directory Rename a file Traverse the file system

Disk Structure Disk can be subdivided into partitions Entity containing file system known as a volume Each volume containing file system also tracks that file system’s info in device directory or volume table of contents As well as general-purpose file systems there are many special-purpose file systems, frequently all within the same operating system or computer

Tree-Structured Directories

Acyclic-Graph Directories Have shared subdirectories and files

General Graph Directory

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

File Sharing – Multiple 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

memory-resident i-node table Process 1 Process 2 (child) Process 3 channel table channel table channel table open file table file offset file offset memory-resident i-node table disk file buffer cache

File Sharing – Remote File Systems Uses networking to allow file system access between systems Manually via programs like FTP Automatically, seamlessly using distributed file systems Semi automatically via the world wide web Client-server model allows clients to mount remote file systems from servers Server can serve multiple clients Client and user-on-client identification is insecure or complicated NFS is standard UNIX client-server file sharing protocol CIFS is standard Windows protocol Standard operating system file calls are translated into remote calls

Protection File owner/creator should be able to control: what can be done by whom Types of access Read Write Execute Append Delete List

Access Lists and Groups Mode of access: read, write, execute Three classes of users RWX a) owner access 7  1 1 1 RWX b) group access 6  1 1 0 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.

ACLs vs. Capabilities Capabilities are easy to transfer they are like keys: can hand them off they make sharing easy ACLs are easier to manage object-centric, easy to grant and revoke to revoke capability, need to keep track of principals that have it hard to do, given that principals can hand off capabilities ACLs grow large when object is heavily shared can simplify by using “groups” put users in groups, put groups in ACLs you are all in the “VMware powerusers” group on Win2K additional benefit change group membership, affects ALL objects that have this group in its ACL

A Typical File Control Block

Allocation Methods An allocation method refers to how disk blocks are allocated for files: Contiguous allocation Linked allocation Indexed allocation

Contiguous Allocation Each file occupies a set of contiguous blocks on the disk. Simple – only starting location (block #) and length (number of blocks) are required. Random access. Wasteful of space (dynamic storage-allocation problem). Files cannot grow.

Contiguous Allocation of Disk Space Operating System Concepts

Linked Allocation Each file is a linked list of disk blocks: blocks may be scattered anywhere on the disk. pointer block = File-allocation table (FAT) – disk-space allocation used by MS-DOS and OS/2.

Linked Allocation

Indexed Allocation Brings all pointers together into the index block. Logical view. index table

Example of Indexed Allocation

Indexed Allocation (Cont.) Need index table Random access Dynamic access without external fragmentation, but have overhead of index block. Mapping from logical to physical in a file of maximum size of 256K words and block size of 512 words. We need only 1 block for index table.

The original Unix file system Dennis Ritchie and Ken Thompson, Bell Labs, 1969 “UNIX rose from the ashes of a multi-organizational effort in the early 1960s to develop a dependable timesharing operating system” – Multics Designed for a “workgroup” sharing a single system Did its job exceedingly well Although it has been stretched in many directions and made ugly in the process A wonderful study in engineering tradeoffs

(Old) Unix disks are divided into five parts … Boot block can boot the system by loading from this block Superblock specifies boundaries of next 3 areas, and contains head of freelists of inodes and file blocks i-node area contains descriptors (i-nodes) for each file on the disk; all i-nodes are the same size; head of freelist is in the superblock File contents area fixed-size blocks; head of freelist is in the superblock Swap area holds processes that have been swapped out of memory

i-node format User number Group number Protection bits Times (file last read, file last written, inode last written) File code: specifies if the i-node represents a directory, an ordinary user file, or a “special file” (typically an I/O device) Size: length of file in bytes Block list: locates contents of file (in the file contents area) more on this soon! Link count: number of directories referencing this i-node