Operating System Lecture 15 File Systems Manoj Kumar

  • Slides: 32
Download presentation
Operating System Lecture 15: File Systems Manoj Kumar Jain M. L. Sukhadia University Udaipur

Operating System Lecture 15: File Systems Manoj Kumar Jain M. L. Sukhadia University Udaipur

Outline n n n File Concept Access Methods Directory Structure File System Mounting File

Outline n n n File Concept Access Methods Directory Structure File System Mounting File Sharing Protection Manoj Kumar Jain Professor Computer Science MLSU Udaipur 2

File Concept n Contiguous logical address space n Types: n Data n n numeric

File Concept n Contiguous logical address space n Types: n Data n n numeric character binary Program Manoj Kumar Jain Professor Computer Science MLSU Udaipur 3

File Structure n n None - sequence of words, bytes Simple record structure n

File Structure n n None - sequence of words, bytes Simple record structure n n Complex Structures n n Lines Fixed length Variable length Formatted document Relocatable load file Can simulate last two with first method by inserting appropriate control characters. Who decides: n n Operating system Program Manoj Kumar Jain Professor Computer Science MLSU Udaipur 4

File Attributes n n n n Name – only information kept in human-readable form.

File Attributes n n n n 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. Manoj Kumar Jain Professor Computer Science MLSU Udaipur 5

File Operations n n n n Create Write Read Reposition within file – file

File Operations n n n n Create Write Read Reposition within file – file seek 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. Manoj Kumar Jain Professor Computer Science MLSU Udaipur 6

File Types – Name, Extension Manoj Kumar Jain Professor Computer Science MLSU Udaipur 7

File Types – Name, Extension Manoj Kumar Jain Professor Computer Science MLSU Udaipur 7

Access Methods n Sequential Access n Direct Access read next write next reset no

Access Methods n Sequential Access n Direct Access read next write next reset no read after last write (rewrite) read n write n position to n read next write next rewrite n n = relative block number Manoj Kumar Jain Professor Computer Science MLSU Udaipur 8

Sequential-access File Manoj Kumar Jain Professor Computer Science MLSU Udaipur 9

Sequential-access File Manoj Kumar Jain Professor Computer Science MLSU Udaipur 9

Simulation of Sequential Access on a Direct-access File Manoj Kumar Jain Professor Computer Science

Simulation of Sequential Access on a Direct-access File Manoj Kumar Jain Professor Computer Science MLSU Udaipur 10

Example of Index and Relative Files Manoj Kumar Jain Professor Computer Science MLSU Udaipur

Example of Index and Relative Files Manoj Kumar Jain Professor Computer Science MLSU Udaipur 11

Directory Structure n A collection of nodes containing information about all files. Directory Files

Directory Structure n A collection of nodes containing information about all files. Directory Files F 1 F 2 F 3 F 4 Fn Both the directory structure and the files reside on disk. Backups of these two structures are kept on tapes. Manoj Kumar Jain Professor Computer Science MLSU Udaipur 12

A Typical File-system Organization Manoj Kumar Jain Professor Computer Science MLSU Udaipur 13

A Typical File-system Organization Manoj Kumar Jain Professor Computer Science MLSU Udaipur 13

Information in a Device Directory n n n n n Name Type Address Current

Information in a Device Directory n n n n n Name Type Address Current length Maximum length Date last accessed (for archival) Date last updated (for dump) Owner ID (who pays) Protection information (discuss later) Manoj Kumar Jain Professor Computer Science MLSU Udaipur 14

Operations Performed on Directory n n n Search for a file Create a file

Operations Performed on Directory n n n Search for a file Create a file Delete a file List a directory Rename a file Traverse the file system Manoj Kumar Jain Professor Computer Science MLSU Udaipur 15

Organize the Directory (Logically) to Obtain n n Efficiency – locating a file quickly.

Organize the Directory (Logically) to Obtain n n Efficiency – locating a file quickly. Naming – convenient to users. n n n 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, …) Manoj Kumar Jain Professor Computer Science MLSU Udaipur 16

Single-Level Directory n A single directory for all users. Naming problem Grouping problem Manoj

Single-Level Directory n A single directory for all users. Naming problem Grouping problem Manoj Kumar Jain Professor Computer Science MLSU Udaipur 17

Two-Level Directory n Separate directory for each user. • Path name • Can have

Two-Level Directory n Separate directory for each user. • Path name • Can have the same file name for different user • Efficient searching • No grouping capability Manoj Kumar Jain Professor Computer Science MLSU Udaipur 18

Tree-Structured Directories Manoj Kumar Jain Professor Computer Science MLSU Udaipur 19

Tree-Structured Directories Manoj Kumar Jain Professor Computer Science MLSU Udaipur 19

Tree-Structured Directories (Cont. ) n Efficient searching n Grouping Capability n Current directory (working

Tree-Structured Directories (Cont. ) n Efficient searching n Grouping Capability n Current directory (working directory) n n cd /spell/mail/prog type list Manoj Kumar Jain Professor Computer Science MLSU Udaipur 20

Tree-Structured Directories (Cont. ) n n Absolute or relative path name Creating a new

Tree-Structured Directories (Cont. ) n n Absolute or relative path name Creating a new file is done in current directory. Delete a file rm <file-name> Creating a new subdirectory is done in current directory. mkdir <dir-name> Example: if in current directory /mail mkdir count mail prog copy prt exp count Deleting “mail” deleting the entire subtree rooted by “mail”. Manoj Kumar Jain Professor Computer Science MLSU Udaipur 21

Acyclic-Graph Directories n Have shared subdirectories and files. Manoj Kumar Jain Professor Computer Science

Acyclic-Graph Directories n Have shared subdirectories and files. Manoj Kumar Jain Professor Computer Science MLSU Udaipur 22

Acyclic-Graph Directories (Cont. ) n Two different names (aliasing) n If dict deletes list

Acyclic-Graph Directories (Cont. ) n Two different names (aliasing) n If dict deletes list dangling pointer. Solutions: n n n Backpointers, so we can delete all pointers. Variable size records a problem. Backpointers using a daisy chain organization. Entry-hold-count solution. Manoj Kumar Jain Professor Computer Science MLSU Udaipur 23

General Graph Directory Manoj Kumar Jain Professor Computer Science MLSU Udaipur 24

General Graph Directory Manoj Kumar Jain Professor Computer Science MLSU Udaipur 24

General Graph Directory (Cont. ) n How do we guarantee no cycles? n n

General Graph Directory (Cont. ) n How do we guarantee no cycles? n n n Allow only links to file not subdirectories. Garbage collection. Every time a new link is added use a cycle detection algorithm to determine whether it is OK. Manoj Kumar Jain Professor Computer Science MLSU Udaipur 25

File System Mounting n A file system must be mounted before it can be

File System Mounting n A file system must be mounted before it can be accessed. n A unmounted file system (i. e. Fig. 11 -11(b)) is mounted at a mount point. Manoj Kumar Jain Professor Computer Science MLSU Udaipur 26

(a) Existing. (b) Unmounted Partition Manoj Kumar Jain Professor Computer Science MLSU Udaipur 27

(a) Existing. (b) Unmounted Partition Manoj Kumar Jain Professor Computer Science MLSU Udaipur 27

Mount Point Manoj Kumar Jain Professor Computer Science MLSU Udaipur 28

Mount Point Manoj Kumar Jain Professor Computer Science MLSU Udaipur 28

File Sharing n n Sharing of files on multi-user systems is desirable. Sharing may

File Sharing n n 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. Manoj Kumar Jain Professor Computer Science MLSU Udaipur 29

Protection n File owner/creator should be able to control: n n n what can

Protection n File owner/creator should be able to control: n n n what can be done by whom Types of access n n n Read Write Execute Append Delete List Manoj Kumar Jain Professor Computer Science MLSU Udaipur 30

Access Lists and Groups n n Mode of access: read, write, execute Three classes

Access Lists and Groups n n Mode of access: read, write, execute Three classes of users RWX 111 110 001 name), say G, a) owner access 7 b) group access 6 c) public access 1 Ask manager to create a group (unique and add some users to the group. For a particular file (say game) or subdirectory, define an appropriate access. owner chmod group 761 public game Attach a group to a file chgrp G game Manoj Kumar Jain Professor Computer Science MLSU Udaipur 31

Thanks Manoj Kumar Jain Professor Computer Science MLSU Udaipur 32

Thanks Manoj Kumar Jain Professor Computer Science MLSU Udaipur 32