Presentation is loading. Please wait.

Presentation is loading. Please wait.

Module 4.0: File Systems File is a contiguous logical address space.

Similar presentations


Presentation on theme: "Module 4.0: File Systems File is a contiguous logical address space."— Presentation transcript:

1 Module 4.0: File Systems File is a contiguous logical address space.
Access Methods Directory Structure Protection File System implementation File-system structure Allocation Methods Free-space Management Directory Implementation Recovery, Efficiency, and Performance K. Salah

2 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. K. Salah

3 File Operations 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. K. Salah

4 File Types – name, extension
K. Salah

5 File Structure None - sequence of words, bytes Simple record structure
Lines Fixed length Variable length Tree of fixed or variable records with a key for each record. Who decides: Operating system Program K. Salah

6 Access Methods read next write next reset read n write n position to n
Sequential Access Tape Model. Reading records in order. read next write next reset Direct or Random Access Disk Model. Reading records in order and out of order. read n write n position to n Most files in modern OS are direct access. K. Salah

7 Memory-Mapped Files Some OS provides map and unmap system calls.
map will map the file into the address space at the virtual address. System calls like open, read, seek are not applicable. Eliminates the need for I/O, thus making it easier to program. Problems Hard to know the size of the file in advance Conflicts arise when sharing files between processes How to deal with huge files that are bigger than a segment or the whole virtual address space. K. Salah

8 Directory Structure Directory Files F 1 F 2 F 4 F 3 F n
A collection of nodes containing information about all files. Both the directory structure and the files reside on disk. Directory Files F 1 F 2 F 3 F 4 F n K. Salah

9 Information in a Device Directory
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) K. Salah

10 Operations Performed on Directory
Search for a file Create a file Delete a file List a directory Rename a file Traverse the file system K. Salah

11 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, …) Directory structure: Single-level: A single directory of all users Two-level: Separate directory for each user Tree-structured: Most common K. Salah

12 Tree-Structured Directories
Efficient searching Grouping Capability Absolute or relative path name Current directory (working directory) cd /spell/mail/prog type list Deleting “mail”  deleting the entire subtree rooted by “mail”. K. Salah

13 Shared Files/Directories
Symbolic or soft link A file/directory is a pointer (contains the pathname) to another file/directory, e.g., softclass /etc/classes/ics431/class Takes longer to lookup as the path is traversed The file pointed to can be deleted or changed Backup might do multiple copies Good for linking files on other machines Hard link The file/directory points to the same file/directory-structure or I-node of the other file/directory. Faster for lookup Has an owner issue Need to keep a count in the structure for file deletion. K. Salah

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

15 Access Lists and Groups
Mode of access: read, write, execute Three classes of users RWX a) owner access 7  RWX b) groups access 6  1 1 0 c) public access 1  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. owner group public chmod 761 game Attach a group to a file chgrp G game K. Salah

16 File-System Implementation
Contiguous Allocation Each file occupies a set of contiguous blocks on the disk. Simple – only starting location (block #) and length (number of blocks) are required. Random access. Wasteful of space (dynamic allocation problem). Files cannot grow. Linked Allocation Indexed Allocation K. Salah

17 Linked Allocation Simple – need only starting address
Each file is a linked list of disk blocks: blocks may be scattered anywhere on the disk. Simple – need only starting address Free-space management system – no waste of space except for pointers No random access File-allocation table (FAT) – disk-space allocation used by MS-DOS and OS/2. A table used as a linked list keeping track of all available and used blocks. See Fig K. Salah

18 Indexed Allocation Brings all pointers together into the index block. In Unix called (i-node). Random access Dynamic allocation without external fragmentation, but have overhead of index block. Wasted space for index block. Worse than linked allocation. How big should the index block should be? K. Salah

19 Use of Multi-level Index – Unix i-node
K. Salah

20 Directory Implementation
Linear list of file names with pointer to the data blocks. simple to program time-consuming to execute Hash Table – linear list with hash data structure. decreases directory search time collisions – situations where two file names hash to the same location fixed size K. Salah

21 Efficiency and Performance
Efficiency dependent on: disk allocation and directory algorithms types of data kept in file’s directory entry Performance disk cache – separate section of main memory for frequently used blocks free-behind and read-ahead – techniques to optimize sequential access improve PC performance by dedicating section of memory as virtual disk, or RAM disk. K. Salah

22 Caching and Recovery Various Disk-Caching Locations:
Consistency checker – compares data in directory structure with data blocks on disk, and tries to fix inconsistencies. Use system programs to back up data from disk to another storage device (floppy disk, magnetic tape). Recover lost file or disk by restoring data from backup. NTFS Features: Logging, Encryption, Compression, Larger sizes than FAT, but more overhead (space and time). K. Salah


Download ppt "Module 4.0: File Systems File is a contiguous logical address space."

Similar presentations


Ads by Google