Lecture 9 FILE MANAGEMENT SYSTEM I FileSystem Interface

  • Slides: 34
Download presentation
Lecture 9 FILE MANAGEMENT SYSTEM (I) --File-System Interface Operating System Fall 2005 1

Lecture 9 FILE MANAGEMENT SYSTEM (I) --File-System Interface Operating System Fall 2005 1

Contents n n n File Concept Access Methods Directory Structure File-System Mounting File Sharing

Contents n n n File Concept Access Methods Directory Structure File-System Mounting File Sharing Protection 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 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 n Lines Fixed length Variable length Formatted document Relocatable load file Who decides: n n Operating system Program 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 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 5

File Operations n n n n Create Write Read Reposition within file Delete Truncate

File Operations n n n n 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 6

Open Files n Several pieces of data are needed to manage open files: n

Open Files n Several pieces of data are needed to manage open files: n n 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 7

Open File Locking n n n Provided by some operating systems and file systems

Open File Locking n n n Provided by some operating systems and file systems Mediates access to a file Mandatory or advisory: n n Mandatory – access is denied depending on locks held and requested Advisory – processes can find status of locks and decide what to do 8

File Types – Name, Extension 9

File Types – Name, Extension 9

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

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

Sequential-access File 11

Sequential-access File 11

Simulation of Sequential Access on a Direct-access File 12

Simulation of Sequential Access on a Direct-access File 12

Example of Index and Relative Files 13

Example of Index and Relative Files 13

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. 14

A Typical File-system Organization 15

A Typical File-system Organization 15

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 16

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, …) 17

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

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

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

Two-Level Directory n Separate directory for each user n Path name n Can have the same file name for different user n Efficient searching n No grouping capability 19

Tree-Structured Directories 20

Tree-Structured Directories 20

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

Tree-Structured Directories (Cont) n Efficient searching n Grouping Capability n Current directory (working directory) n n cd /spell/mail/prog type list 21

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

Tree-Structured Directories (Cont) n n n Absolute or relative path name Creating a new file is done in current directory Delete a file rm <file-name> n 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” 22

Acyclic-Graph Directories n Have shared subdirectories and files 23

Acyclic-Graph Directories n Have shared subdirectories and files 23

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

Acyclic-Graph Directories (Cont. ) n n Two different names (aliasing) If dict deletes count dangling pointer Solutions: n n n n Search all the links Leave the link there Do nothing, depends on user Backpointers, so we can delete all pointers Variable size records a problem Don’t delete the file, keep a list of all the references Entry-hold-count solution New directory entry type n n Link – another name (pointer) to an existing file Resolve the link – follow pointer to locate the file 24

General Graph Directory 25

General Graph Directory 25

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 26

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

File System Mounting n n 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 (a) Existing. (b) Unmounted Partition Mount Point 27

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

File Sharing n Sharing of files on multi-user systems is desirable n Sharing may be done through a protection scheme n On distributed systems, files may be shared across a network n Network File System (NFS) is a common distributed file-sharing method 28

File Sharing – Multiple Users n n User IDs identify users, allowing permissions and

File Sharing – Multiple Users n n User IDs identify users, allowing permissions and protections to be per-user Group IDs allow users to be in groups, permitting group access rights 29

File Sharing – Remote File Systems n Uses networking to allow file system access

File Sharing – Remote File Systems n Uses networking to allow file system access between systems n Manually via programs like FTP n Automatically, seamlessly using distributed file systems n Semi automatically via the world wide web Client-server model allows clients to mount remote file systems n Server can serve multiple clients n Client and user-on-client identification is insecure or complicated n NFS is standard UNIX client-server file sharing protocol n CIFS is standard Windows protocol n Standard operating system file calls are translated into remote calls Distributed Information Systems (distributed naming services) n from servers n such as LDAP, DNS, NIS, Active Directory implement unified access to information needed for remote computing 30

File Sharing – Failure Modes n n n Remote file systems add new failure

File Sharing – Failure Modes n n n Remote file systems add new failure modes, due to network failure, server failure Recovery from failure can involve state information about status of each remote request Stateless protocols such as NFS include all information in each request, allowing easy recovery but less security 31

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 32

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 a) owner access 7 111 RWX b) group access 6 110 RWX c) public access 1 001 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. owner chmod group 761 public game Attach a group to a file chgrp G game 33

End of lecture 9 Thank you! 34

End of lecture 9 Thank you! 34