Presentation is loading. Please wait.

Presentation is loading. Please wait.

10.1 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Chapter 10: File-System Objectives To discuss file-system design tradeoffs, including.

Similar presentations


Presentation on theme: "10.1 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Chapter 10: File-System Objectives To discuss file-system design tradeoffs, including."— Presentation transcript:

1 10.1 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Chapter 10: File-System Objectives To discuss file-system design tradeoffs, including access methods, file sharing, file locking, and directory structures To explore file-system protection Skip10.2, 10.4, 10.5

2 10.2 Silberschatz, Galvin and Gagne ©2005 Operating System Principles 10.1 File Concept The operating system abstracts from the physical properties of its storage to define a logical storage unit, the file. Files are mapped by the OS onto physical, usually nonvolatile, devices. The OS normally maintains two-level open-file tables, per-process and system-wide

3 10.3 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Open and Close 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

4 10.4 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Internal File Structure All disks is performed in units of one block (physical record) Logical records may vary in length Packing a number of logical records into physical blocks is the common solution Example: UNIX defines all files to be streams of bytes. Its logical record size is 1 byte. Packing can be done either by user’s application or by the operating system Internal fragmentation problem

5 10.5 Silberschatz, Galvin and Gagne ©2005 Operating System Principles 10.3 Directory Structure A disk may have several partitions. A partition may be with a file system. Several partitions, maybe from many disks, could form a volume that holds a file system. A collection of nodes containing information about all files F 1 F 2 F 3 F 4 F n Directory Files Both the directory structure and the files reside on disk Backups of these two structures are kept on tapes

6 10.6 Silberschatz, Galvin and Gagne ©2005 Operating System Principles A Typical File-system Organization

7 10.7 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Operations Performed on Directory Search for a file Create a file Delete a file List a directory Rename a file Traverse the file system for backup (to tape)

8 10.8 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Organize the Directory (Logically) to Obtain: Efficiency – locating a file quickly Naming – convenient to users Two users can have same name for different files The same file can have several different names Grouping – logical grouping of files by properties e.g., all Java programs, all games, …

9 10.9 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Single-Level Directory A single directory for all users Naming problem Grouping problem

10 10.10 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Two-Level Directory Separate directory for each user Can have the same file name for different user Isolation or Allow access to other’s files? If allowed, then use path name Efficient searching Use environment variable: search path No grouping capability

11 10.11 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Tree-Structured Directories

12 10.12 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Tree-Structured Directories Efficient searching Grouping Capability Current directory (working directory) cd /spell/mail/prog type list Absolute or relative path name Creating a new file is done in current directory Delete a file rm Delete a directory MS-DOS will not delete a directory unless it is empty Unix provides an option to delete all files and sub-directories under a directory

13 10.13 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Tree-Structured Directories Creating a new subdirectory is done in current directory mkdir Example: if current directory is /mail mkdir count mail progcopyprtexpcount In Unix “rm –f mail”  deleting the entire subtree rooted by “mail”

14 10.14 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Acyclic-Graph Directories Use link to have shared subdirectories and files Another approach: duplicate all information about subdirectories and files in both sharing directories. But it is hard to maintain consistency when a shared file is modified.

15 10.15 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Acyclic-Graph Directories New directory entry type Link – another name (pointer) to an existing file Resolve the link – follow pointer to locate the file Two different names (aliasing) A file could have multiple absolute path names. Traverse problem. If dict deletes all  dangling pointer. Solutions: Just wait for users to find out. It is used with symbolic links: Preserve the file until all references to it are deleted. Unix uses this approach for hard links by keeping a reference count in the file information block. Acyclic-graph could be maintained by prohibiting multiple references to directories SKIP: 10.3.7

16 10.16 Silberschatz, Galvin and Gagne ©2005 Operating System Principles 10.6 Protection Reliability is to keep the computer system from physical damage. (Chapter 12) Protection is to keep it from improper access. File owner/creator should be able to control: what can be done by whom Basic types of controlled access Read Write Execute Append Delete List Other high-level functions, like copying and editing files may be implemented by making lower-level system calls

17 10.17 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Access Control Lists Mode of access: read, write, execute Three classes of users r w x a) owner access 7  1 1 1 r w x b) group access 6  1 1 0 r w x c) public access1  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. ownergrouppublic chmod761game Attach a group to a file chgrp G game

18 10.18 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Windows XP Access-control List Management

19 10.19 Silberschatz, Galvin and Gagne ©2005 Operating System Principles A Sample UNIX Directory Listing

20 10.20 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Other Protection Approaches Associate a password with each file Disadvantages  The number of passwords that a user needs to remember  If only one password is used for all the files, then protection is on an all-or-none basis – Some system allow the user to associate a password with a directory Adding protection mechanisms to single-user OS is difficult Directory protection Control the creation and deletion of files in a directory Control whether a user could check the existence of a file in a directory. (Listing the contents of a directory)


Download ppt "10.1 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Chapter 10: File-System Objectives To discuss file-system design tradeoffs, including."

Similar presentations


Ads by Google