FileSystem Interface 1 File Concept Access Methods Directory

  • Slides: 23
Download presentation
File-System Interface • • • 1 File Concept Access : Methods Directory Structure Protection

File-System Interface • • • 1 File Concept Access : Methods Directory Structure Protection File System Structure SLC/VER 1. 0/OS CONCEPTS/OCT'99

File Concept • Contiguous logical address space • Types: – Data • numeric •

File Concept • Contiguous logical address space • Types: – Data • numeric • character • binary – Program 2 SLC/VER 1. 0/OS CONCEPTS/OCT'99

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

File Structure • None - sequence of words, bytes • Simple record structure – Lines – Fixed length – Variable length • Complex Structures – Formatted document – Relocatable load file 3 SLC/VER 1. 0/OS CONCEPTS/OCT'99

File Structure • Can simulate last two with first method by inserting appropriate control

File Structure • Can simulate last two with first method by inserting appropriate control characters. • Who decides: – Operating system – Program 4 SLC/VER 1. 0/OS CONCEPTS/OCT'99

File Attributes • Name – only information kept in humanreadable form. • Type –

File Attributes • Name – only information kept in humanreadable 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. 5 SLC/VER 1. 0/OS CONCEPTS/OCT'99

File Attributes • Time, date, and user identification – data for protection, security, and

File Attributes • 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 SLC/VER 1. 0/OS CONCEPTS/OCT'99

File Operations • • 7 create write read reposition within file – file seek

File Operations • • 7 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. SLC/VER 1. 0/OS CONCEPTS/OCT'99

File Operations • close (Fi) – move the content of entry Fi in memory

File Operations • close (Fi) – move the content of entry Fi in memory to directory structure on disk. 8 SLC/VER 1. 0/OS CONCEPTS/OCT'99

File Types – name, extension 9 SLC/VER 1. 0/OS CONCEPTS/OCT'99

File Types – name, extension 9 SLC/VER 1. 0/OS CONCEPTS/OCT'99

Access Methods • Sequential Access read next write next reset no read after last

Access Methods • Sequential Access read next write next reset no read after last write (rewrite) 10 SLC/VER 1. 0/OS CONCEPTS/OCT'99

Access Methods • Direct Access read n write n position to n read next

Access Methods • Direct Access read n write n position to n read next write next rewrite n n = relative block number 11 SLC/VER 1. 0/OS CONCEPTS/OCT'99

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

Directory Structure • 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. 12 SLC/VER 1. 0/OS CONCEPTS/OCT'99

Information in a Device Directory • • • 13 Name Type Address Current length

Information in a Device Directory • • • 13 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) SLC/VER 1. 0/OS CONCEPTS/OCT'99

Operations Performed on Directory • • • 14 Search for a file Create a

Operations Performed on Directory • • • 14 Search for a file Create a file Delete a file List a directory Rename a file Traverse the file system SLC/VER 1. 0/OS CONCEPTS/OCT'99

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

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 Pascal programs, all games, …) 15 SLC/VER 1. 0/OS CONCEPTS/OCT'99

Single-Level Directory • A single directory for all users. Naming problem Grouping problem 16

Single-Level Directory • A single directory for all users. Naming problem Grouping problem 16 SLC/VER 1. 0/OS CONCEPTS/OCT'99

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

Two-Level Directory • Separate directory for each user. Path name Can have the same file name for different user Efficient searching No grouping capability 17 SLC/VER 1. 0/OS CONCEPTS/OCT'99

Tree-Structured Directories 18 SLC/VER 1. 0/OS CONCEPTS/OCT'99

Tree-Structured Directories 18 SLC/VER 1. 0/OS CONCEPTS/OCT'99

Tree-Structured Directories • Efficient searching • Grouping Capability • Current directory (working directory) –

Tree-Structured Directories • Efficient searching • Grouping Capability • Current directory (working directory) – cd /spell/mail/prog – type list 19 SLC/VER 1. 0/OS CONCEPTS/OCT'99

Tree-Structured Directories • Absolute or relative path name • Creating a new file is

Tree-Structured Directories • Absolute or relative path name • Creating a new file is done in current directory. • Delete a file rm <file-name> mail prog 20 copy prt exp count Deleting “mail” deleting the entire subtree rooted by “mail”. SLC/VER 1. 0/OS CONCEPTS/OCT'99

Tree-Structured Directories • Creating a new subdirectory is done in current directory. mkdir <dir-name>

Tree-Structured Directories • Creating a new subdirectory is done in current directory. mkdir <dir-name> Example: if in current directory /spell/mail mkdir count 21 SLC/VER 1. 0/OS CONCEPTS/OCT'99

Protection • File owner/creator should be able to control: – what can be done

Protection • File owner/creator should be able to control: – what can be done – by whom • Types of access – Read – Write – Execute – Append – Delete and List 22 SLC/VER 1. 0/OS CONCEPTS/OCT'99

File System Structure • File Structure -Logical storage unit -Collection of related information •

File System Structure • File Structure -Logical storage unit -Collection of related information • File system resides on secondary storage (disks) • File system organized into layers. • File control block- storage structure consisting of information about a file 23 SLC/VER 1. 0/OS CONCEPTS/OCT'99