Presentation is loading. Please wait.

Presentation is loading. Please wait.

Silberschatz, Galvin and Gagne ©2009 Edited by Khoury, 2015 Operating System Concepts – 9 th Edition, Chapter 11: File-System Interface.

Similar presentations


Presentation on theme: "Silberschatz, Galvin and Gagne ©2009 Edited by Khoury, 2015 Operating System Concepts – 9 th Edition, Chapter 11: File-System Interface."— Presentation transcript:

1 Silberschatz, Galvin and Gagne ©2009 Edited by Khoury, 2015 Operating System Concepts – 9 th Edition, Chapter 11: File-System Interface

2 11.2 Chapter 11: File-System Interface File Concept Access Methods Directory Structure File-System Mounting File Sharing Protection

3 11.3 Objectives To explain the function of file systems To describe the interfaces to file systems To discuss file-system design tradeoffs, including access methods, file sharing, file locking, and directory structures To explore file-system protection

4 11.4 File Concept A file is an abstract data type a contiguous logical address space the smallest unit of stored physical information Non-volatile Types: Text Source code Object Executable

5 11.5 File Structure None - sequence of words, bytes Simple record structure Lines Fixed length Variable length Complex Structures Formatted document Relocatable load file Can simulate last two with first method by inserting appropriate control characters

6 11.6 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

7 11.7 File Operations Create Allocate space, add entry in directory Write (Append) Find file in directory, find end-of-file, add information from memory Read Find file in directory, go to current file position pointer, add information to memory, update pointer Reposition within file (seek) Find file in directory, find desired position, update pointer Delete Find file in directory, mark all allocated space as empty, remove file from directory Truncate (delete all content) Find file in directory, mark all allocated space as empty

8 11.8 File Operations Operations implemented by system calls Open(F) Find F in directory, move contents from allocated space on disk to memory Close(F) Move the content F in memory to allocated space on disk, mark memory space as free Create(F) Delete(F) Both work on closed files on disk rather than opened files in memory System call implementation trickier if OS allows multiple processes to use files at once

9 11.9 File Tables OS typically maintains two levels of file information in two file tables Per-Process File Table Which files does this process have open The process’ current file position pointer Process’ access rights System-Wide File Table Which files are currently opened File-Open Count: how many processes have opened each file File’s location in directory and on disk Accounting information

10 11.10 Open File Locking Provided by some operating systems and file systems to control access to a file Shared or exclusive: Shared – concurrent access by multiple processes is allowed (reader lock) Exclusive – one process has exclusive access (writer lock) Mandatory or advisory: Mandatory – lock is enforced by operating system Advisory – processes can find status of locks and decide what to do

11 11.11 File Types Different types of file (text, object, binary) have different contents and require different actions OS should recognise file types and take reasonable default action (i.e. open file with correct program) Implemented in different ways MS-DOS/Windows: File extension after name specifies type and program information Mac OS X: Basic types (text, appl), program information is “creator” file attribute Unix: Magic number at beginning of file represents rough file type, no program information stored

12 11.12 File Types

13 11.13 File Structure Different file types have different internal structures Content must be interpreted differently Internal file structures may or may not be supported by OS User-program-specific structures are not supported  OS reads file byte by byte, sends to user process without interpreting There must be a minimal number of system-supported structures the OS can interpret (ex.: executable code, text)  More supported types = more support and functionality in OS, bigger and more cumbersome OS

14 11.14 Access Methods Sequential Access Simplest, most common method Operations: Read next, write next, reset, optional forward & rewind I Direct (Relative) Access Access relative block number Operations: Read n, write n, position to n Can simulate sequential access (n += 1) Indexed Access Extension of direct access Blocks have ID numbers, operations access ID in index Multilevel indexes (index of index values) allow management of larger indexes

15 11.15 Disk Structure Non-volatile secondary memory of the system Disk can be subdivided into partitions Disk or partition can be used raw – without a file system, or formatted with a file system 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

16 11.16 Operations Performed on Directory Search for a file Find directory entry that matches desired name Create a file Add entry to directory Delete a file Remove entry from directory Rename a file Modify the directory entry of a specific file File name should be unique List a directory Cycle through all entries in directory, listing information from each entry Traverse the file system Access every directory in the computer system and its content Can be useful for automated system backups, for example

17 11.17 Single-Level Directory A single directory for the system Limitations No multi-user support Enforcing unique names for files becomes problematic with thousands of files

18 11.18 Two-Level Directory Separate directory for each user Improvements & limitations Unique file names enforced at UFD level Each user isolated from others: no sharing System files stored in special user directory: multi-step search for file looks in user directory then in system directories in search path

19 11.19 Generalization of two-level directory to arbitrary levels Tree-Structured Directory

20 11.20 File and subdirectory are identical directory entries, differentiated by a single binary flag Improvements & limitations Unique file name requirement enforced at subdirectory level Users can access some subdirectories belonging to other users Needs new system calls to create & delete subdirectories and change the current directory Need support for path names (absolute and relative paths) Tree-Structured Directory

21 11.21 Acyclic-Graph Directory Shared files and subdirectories appear in each user’s subdirectory Only one copy of a shared file exists Appears in two places in the directory graph Changes done by one user are immediately visible to everyone

22 11.22 Acyclic-Graph Directory Sharing implementation methods Link  Requires a new directory entry type  Pointer to an existing file or subdirectory  Can contain the absolute or relative path (symbolic links) or the disk address (hard links)  Resolve the link by following path/address to locate the file  Most popular approach (Unix & Windows) Duplication  Identical entries in all directories  Need to maintain consistency in all directories Sharing problems Any file might now have multiple paths After files are deleted, pointers lead to nonexistent paths/disk address of other files

23 11.23 General Graph Directory Adding and deleting subdirectories and pointers to subdirectories will eventually lead to cycles in the graph!

24 11.24 Acyclic Graph vs. General Graph IssueAcyclicGeneral SearchingSearch each directory and its subdirectories Need loop detection otherwise algorithm can be stuck in infinite loop Self-referencingImpossiblePossible, and can falsely increase the file’s reference count, making it “undeletable” Adding linksNeed to prevent cycles, with cycle detection algorithm or special policy Always allowed

25 11.25 File System Mounting A file system must be mounted before it becomes part of the system’s namespace and can be accessed by processes in the system An unmounted file system is mounted at a mount point (a location in the existing directory hierarchy, typically an empty directory)

26 11.26 File System Mounting An unmounted file system is a volume on disk Needs to be mounted into the existing file system before it can be used Mount to specified directory in subsystem (will overwrite existing directory structure)

27 11.27 File System Mounting Macintosh When the system encounters a new disk, it automatically checks the file system and, if valid, mounts it at the root level Unix Devices can be mounted to any subfolder Mount can be commanded explicitly by user OS keeps track of devices and mount points Mac OS X / BSD Unix All file systems are mounted in the /Volumes directory Mac OS X hides this fact and shows them mounted at root level Windows Two-level system directory Devices and volumes automatically mounted to second level and get drive letters Each drive letter then has a general graph directory structure

28 11.28 Protection In multi-user system, we need to protect files from inappropriate access by unauthorized users File system usually gives control over these operations Read Write Execute Append Delete List Other operations (rename, copy, edit, etc.) can be implemented by operating system

29 11.29 Access Control Most common approach to protection Each file & directory has an access control list Contains user + access rights OS checks list before granting a user access to a file Problems: Giving access to a file to everyone involves listing each individual user in the access control list Building a list may be impossible if we do not know in advance the users of the system The list is stored in the directory entry, making is unpredictable in size (and potentially very large)

30 11.30 Access Control Can solve the list problems by creating three user classifications Owner  The creator of the file, has full access by default Group  A group of users who all have the same level of access Universe  Anyone who’s not the owner or in the group, have this (normally lower) level of access An access control list can be added to the file if you need to define access for specific individual users

31 11.31 Windows XP Access Control

32 11.32 UNIX Access Control

33 11.33 Review What is a file table and what is it used for? How many are there in the system? How does a two-level file system alleviate the problems of a single-level file system?

34 11.34 Exercises Read everything but skip 11.5 (File Sharing) If you have the “with Java” textbook, skip the Java sections and subtract 1 to the following section numbers 11.1 11.2 11.3 11.5 11.6 11.8 11.9 11.10 11.12 11.13 11.14 11.15 11.16

35 Silberschatz, Galvin and Gagne ©2009 Edited by Khoury, 2015 Operating System Concepts – 9 th Edition, End of Chapter 11


Download ppt "Silberschatz, Galvin and Gagne ©2009 Edited by Khoury, 2015 Operating System Concepts – 9 th Edition, Chapter 11: File-System Interface."

Similar presentations


Ads by Google