Presentation is loading. Please wait.

Presentation is loading. Please wait.

Os111 Chapter 11 File-System Interface. os112 Outline File Concept Access Methods Directory Structure File System Mounting File Sharing Protection.

Similar presentations


Presentation on theme: "Os111 Chapter 11 File-System Interface. os112 Outline File Concept Access Methods Directory Structure File System Mounting File Sharing Protection."— Presentation transcript:

1 os111 Chapter 11 File-System Interface

2 os112 Outline File Concept Access Methods Directory Structure File System Mounting File Sharing Protection

3 os113 File Concept Contiguous logical address space Types: Data  numeric  character  binary Program

4 os114 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. Who decides: Operating system Program

5 os115 File Attributes Name – only information kept in human-readable form. 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.

6 os116 File Operations Create Write Read Reposition within file – file seek Delete Truncate Open(F i ) – search the directory structure on disk for entry F i, and move the content of entry to memory. Close (F i ) – move the content of entry F i in memory to directory structure on disk.

7 os117 File Types – Name, Extension

8 os118 Open a File A file is open when it is first used. No search on directory is required for later usage. Two levels of tables  A table for each process (information dependent on the process) index to system table current position pointer  A system open-file table (information independent from a process) open count (for shared files) disk location access date file size

9 os119 OS and Disk I/O Advantages for OS to know the file type avoid some mistakes (e.g., print a binary-object) TOPS-20: if source program has been modified, running an old.obj file causes re-compiling automatically Windows: doubling clicking a.doc file invokes MS Words Disk I/O performs in units of one block logical records  packing  a physical block all file systems have internal fragmentation  larger block  larger internal fragmentation

10 os1110 Access Methods Sequential access: records are processed in order, e.g., tapes read/write (next) reset to beginning, skip forward/backword Direct access (disks) position (seek) to the n-th record read/write Other (direct access+index) an index table (can be put into memory); the index, like an index in the back of a book, contains pointers to the various blocks. file in disk : reduce I/O for searching on a large file

11 os1111 Sequential-access beginning end current position rewind read/write Index and relative files adams asher arthur smith smith, john id age address index file relative file

12 os1112 Directory Structure (1) 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.

13 os1113 Directory Structure (2) Typical file-system organization disk  partitions (IBM: minidisk, PC: volume)  files (including directories) directory partition A partition B disk 1 directory partition C disk 2

14 os1114 Directory Structure (3) Directory structures Single-level directory Two-level directory Tree-structured directory (more common) Acyclic-graph directory (cycle-detection is expensive) General graph directory (garbage collection is expensive) flexible complicated

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

16 os1116 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, … )

17 os1117 Single-Level Directory A single directory for all users. Naming problem  :1. difficult to remember all names 2. not easy to give a new name 3. confusion between different users Grouping problem

18 os1118 Two-Level Directory Separate directory for each user. Path name: user name + file name Can have the same file name for different user Efficient searching No grouping capability

19 os1119 Tree-Structured Directories

20 os1120 Tree-structured directory each user has a current directory absolute path name vs. relative path name search path stat mail dist test rootspell obj program pe2 cc pas a jaja ab cat bo a test current directory mail\jaja, or \spell\mail\jaja

21 os1121 Acyclic-graph directory : 1. share subdirectory (file): the same file or directory may be in two different directories. 2. relative simplicity of the algorithms to traverse the graph and to determine when there are no more reference to a file.  : 1. Search/traverse the file system should be careful 2. Deletion is complicated: Dangling pointers to a deleted file. Solution: Keep a count of the number of references 3. Detection of cycles is expensive

22 os1122 cat mail dist pe2 rootspell obj program pe2 cc pasc a cat bo a test Acyclic-graph directory

23 os1123 General graph directory  : How do we guarantee no cycle? 1. Searching/traversing is difficult search a directory twice limit # of directories that can be accessed infinite loop 2. Deletion is more complicated Self-reference: a set of files with nonzero reference-count that are impossible to refer, the possibility of self-referencing (a cycle) in the directory structure. Solution: garbage collection (very expensive)

24 os1124 cat mail dist pe2 root spell obj program pe2 cc pasc a root bo a test General graph directory

25 os1125 File System Mounting A file system must be mounted before it can be accessed. A unmounted file system (I.e. Fig. 11- 11(b)) is mounted at a mount point.

26 os1126 (a) Existing. (b) Unmounted Partition

27 os1127 Mount Point

28 os1128 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.

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

30 os1130 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 RWX 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


Download ppt "Os111 Chapter 11 File-System Interface. os112 Outline File Concept Access Methods Directory Structure File System Mounting File Sharing Protection."

Similar presentations


Ads by Google