1 / 30

Chapter 11 File-System Interface

Chapter 11 File-System Interface. Outline. File Concept Access Methods Directory Structure File System Mounting File Sharing Protection. File Concept. Contiguous logical address space Types: Data numeric character binary Program. File Structure. None - sequence of words, bytes

derick
Download Presentation

Chapter 11 File-System Interface

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 11 File-System Interface os11

  2. Outline • File Concept • Access Methods • Directory Structure • File System Mounting • File Sharing • Protection os11

  3. File Concept • Contiguous logical address space • Types: • Data • numeric • character • binary • Program os11

  4. File Structure • None - sequence of words, bytes • Simple record structure • Lines • Fixed length • Variable length • Complex Structures • Formatted document • Relocatable load file • Can simulate last two with first method by inserting appropriate control characters. • Who decides: • Operating system • Program os11

  5. 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. os11

  6. 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. os11

  7. File Types – Name, Extension os11

  8. Open a File • A file is openwhen it is first used. No search on directory is required for later usage. • Two levels of tables • A table for each process (information dependent on the process) • index to system table • current position pointer • A system open-file table (information independent from a process) • open count (for shared files) • disk location • access date • file size os11

  9. OS and Disk I/O • Advantages for OS to know the file type • avoid some mistakes (e.g., print a binary-object) • TOPS-20: if source program has been modified, running an old .obj file causes re-compiling automatically • Windows: doubling clicking a .doc file invokes MS Words • Disk I/O performs in units of one block • logical records  packing a physical block • all file systems have internal fragmentation • larger block  larger internal fragmentation os11

  10. Access Methods • Sequential access: records are processed in order, e.g., tapes • read/write (next) • reset to beginning, skip forward/backword • Direct access (disks) • position (seek) to the n-th record • read/write • Other (direct access+index) • an index table (can be put into memory); the index, like an index in the back of a book, contains pointers to the various blocks. • file in disk J: reduce I/O for searching on a large file os11

  11. Sequential-access current position end beginning read/write rewind Index and relative files adams smith, john id age address arthur asher smith index file relative file os11

  12. Directory Structure (1) • A collection of nodes containing information about all files. Directory Files F 1 F 2 F 3 F 4 F n Both the directory structure and the files reside on disk. Backups of these two structures are kept on tapes. os11

  13. directory directory partition A partition C directory partition B disk 1 disk 2 Directory Structure (2) • Typical file-system organization • disk  partitions (IBM: minidisk, PC: volume) files (including directories) os11

  14. Directory Structure (3) flexible complicated • Directory structures • Single-level directory • Two-level directory • Tree-structured directory (more common) • Acyclic-graph directory (cycle-detection is expensive) • General graph directory (garbage collection is expensive) os11

  15. Operations Performed on Directory • Search for a file • Create a file • Delete a file • List a directory • Rename a file • Traverse the file system os11

  16. 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 Java programs, all games, …) os11

  17. Single-Level Directory • A single directory for all users. Naming problem L:1. difficult to remember all names 2. not easy to give a new name 3. confusion between different users Grouping problem os11

  18. Two-Level Directory • Separate directory for each user. • Path name: user name + file name • Can have the same file name for different user • Efficient searching • No grouping capability os11

  19. Tree-Structured Directories os11

  20. Tree-structured directory • each user has a current directory • absolute path name vs. relative path name • search path root spell obj program current directory stat mail dist test pe2 cc pas a mail\jaja, or \spell\mail\jaja cat bo a test jaja ab os11

  21. Acyclic-graph directory J: 1.share subdirectory (file): the same file or directory may be in two different directories. 2. relative simplicity of the algorithms to traverse the graph and to determine when there are no more reference to a file. L: • Search/traverse the file system should be careful • Deletion is complicated: • Dangling pointers to a deleted file. • Solution: Keep a count of the number of references • Detection of cycles is expensive os11

  22. Acyclic-graph directory root spell obj program cat mail dist pe2 pe2 cc pasc a cat bo a test os11

  23. General graph directory L: How do we guarantee no cycle? • Searching/traversing is difficult • search a directory twice limit # of directories that can be accessed • infinite loop • Deletion is more complicated • Self-reference: a set of files with nonzero reference-count that are impossible to refer, the possibility of self-referencing (a cycle) in the directory structure. • Solution: garbage collection (very expensive) os11

  24. General graph directory root spell obj program cat mail dist pe2 pe2 cc pasc a root bo a test os11

  25. File System Mounting • 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. os11

  26. (a) Existing. (b) Unmounted Partition os11

  27. Mount Point os11

  28. File Sharing • 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. os11

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

  30. owner group public chmod 761 game Access Lists and Groups • Mode of access: read, write, execute • Three classes of users RWX a) owner access 7  1 1 1 RWX b) group access 6  1 1 0 RWX 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. os11

More Related