Module 4 0 File Systems File is a
- Slides: 24
Module 4. 0: File Systems ØFile is a contiguous logical address space (of related records) ØAccess Methods ØDirectory Structure ØProtection ØFile System implementation Ø Ø Ø K. Salah File-system structure Allocation Methods Free-space Management Directory Implementation Recovery, Efficiency, and Performance 1 Operating Systems
File Attributes • • • Name – only information kept in human-readable form. • Information about files are kept in the directory structure, which is maintained on the disk. 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. K. Salah 2 Operating Systems
File Operations • • create • close (Fi) – move the content of entry Fi in memory to directory structure/descriptor on disk. write read reposition within file – file seek delete truncate open(Fi) – search the directory structure/descriptor on disk for entry Fi, and move the content of entry to memory. K. Salah 3 Operating Systems
File Types – name, extension K. Salah 4 Operating Systems
File Structure of Data within Data Blocks Ø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 5 Operating Systems
Access Methods 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 read next write next Most files in modern OS are direct access. K. Salah 6 Operating Systems
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 Ø Example: one process uses map and another uses open, read, write. Ø How to deal with huge files that are bigger than a segment or the whole virtual address space. K. Salah 7 Operating Systems
Directory Structure Ø Ø 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 Fn K. Salah 8 Operating Systems
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 9 Operating Systems
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 10 Operating Systems
Actual File Size • • In Windows, disk block is 4 KB • “Size” of file reflects the actual size of data. • “Size on disk” which is multiple of data blocks. • Ex, if you create a text file with “xyz” with notepad, size of file will show 3, while “Size on disk” will show 4 KB. In Unix, disk block is 512 B K. Salah 11 Operating Systems
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 Operating Systems
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 Operating Systems
Shared Files/Directories Ø Symbolic or soft link Ø A file/directory is a pointer (contains the pathname) to another file/directory, Ø e. g. , ln –s /etc/classes/ics 431/class softclass Ø A new i-node is created for softclass Ø Ø Ø 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. Ø e. g. , ln /etc/classes/ics 431/class hardclass Ø No i-node is created. Only entry in the i-node of directory which hardclass is under Ø Faster for lookup Ø Has an owner issue Ø Need to keep a count in the structure for file deletion Ø K. Salah 14 Operating Systems
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 Operating Systems
Access Lists and Groups • • Mode of access: read, write, execute Three classes of users RWX a) owner access 7 b) groups access 6 c) public access 1 110 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 K. Salah G 16 game Operating Systems
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 Operating Systems
Linked Allocation Ø 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. 12 -6. K. Salah 18 Operating Systems
Indexed Allocation Ø Brings all pointers together into the index block. In Unix called (inode). Ø 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 be? K. Salah 19 Operating Systems
Use of Multi-level Index – Unix i-node K. Salah 20 Operating Systems
• • Where is the path stored in the inode of a softlink file? Where is list of file names in a directory inode is stored? K. Salah 21 Operating Systems
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 22 Operating Systems
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 23 Operating Systems
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 (USB disks, tapes, or Cloud Computing dropbox). Ø Recover lost file or disk by restoring data from backup. Ø NTFS Features: Logging or journaling, Encryption, Compression, Larger sizes than FAT, but more overhead (space and time). K. Salah 24 Operating Systems
- Module 4 operating systems and file management
- File-file yang dibuat oleh user pada jenis file di linux
- C device module module 1
- Curriculum guide for driver education in virginia module 10
- Module 10 the nervous and endocrine systems
- Physical image vs logical image
- File sharing management system
- Distributed file system definition
- An html file is a text file containing small markup tags.
- In a file-oriented information system, a transaction file
- Rolling file systems
- Distributed file system
- Allows the replication of only immutable files.
- Decision support systems and intelligent systems
- Engineering elegant systems: theory of systems engineering
- Embedded systems vs cyber physical systems
- Engineering elegant systems: theory of systems engineering
- Scratch modules
- Grade 9 english module
- Gestalt psychology illusions
- Module 3 topic 1
- Drivers ed module 7 topic 3
- Why are most roadways crowned?
- Module 11 topic 1 insuring a vehicle
- Curriculum guide for driver education in virginia module 8