Download
file systems n.
Skip this Video
Loading SlideShow in 5 Seconds..
File Systems PowerPoint Presentation
Download Presentation
File Systems

File Systems

1551 Vues Download Presentation
Télécharger la présentation

File Systems

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. 10 File Systems Kai Bu kaibu@zju.edu.cn http://list.zju.edu.cn/kaibu/cmpt300

  2. File Systems the most visible aspect of an OS

  3. File Systems the most visible aspect of an OS storage and access to data & programs of the OS and all the users

  4. File Systems files: each stores related data directory: organizes & provides info about all the files

  5. File • A logical storage unit • abstracted by OS from the physical properties of its storage devices • A named collection of related information that is recorded on secondary storage

  6. File • Text file a sequence of characters organized into lines (and possibly pages) • Source file a sequence of functions, each of which is further organized as declarations followed by executable statements • Executable file a series of code sections that the loader can bring into memory and execute

  7. what’s special about files?

  8. File Attributes • Name the symbolic file name is the only info kept in human-readable form • Identifier a unique tag, usually a number, identifies the file within the file system • Type for systems to differentiate diff file types cont.

  9. File Types name.extension

  10. File Attributes • Location a pointer to a device and to the location of the file on that device • Size current file size (in bytes, words, blocks) and possibly the maximum allowed size cont.

  11. File Attributes • Protection access-control information, who can read, write, execute, and so on • Time, date, and user identification may be kept for creation, last modification, and last use; useful for protection, security, and usage monitoring

  12. what to do with files?

  13. File Operations • Create allocate space in the file system make an entry in the directory cont.

  14. File Operations • Write via a system call specifying file name and the info to be written to the file; locate the file using its name to search directory; keep a write pointer to the location in the file where the next write is to take place cont.

  15. File Operations • Read via a system call specifying file name and where (in memory) the next block of the file should be put; keep a read pointer to the location in the file where the next read is to take place; r&w share current-file-position pointer cont.

  16. File Operations • Reposition within a file reposition current-file-position pointer to a given value; also known as file seek cont.

  17. File Operations • Delete search the directory for the named file, release the space of the file; erase the directory entry; so the released space can be reused; cont.

  18. File Operations • Truncate erase the contents of a file but keep its attributes; reset file length as zero; release its file space;

  19. always search directory?

  20. always search directory? not if record the search history

  21. Open-File Table • Contain information of all open files • Each entry has an open count that indicates how many processes have the file open • File pointer to track the last read-write location • Disk location for locating a file on disk • Access rights

  22. how to access a file?

  23. Sequential Access • Process information in the file in order one record after another • read_next(): reads the next portion of the file and advances a file pointer • write_next(): appends to the end of the file and advances to the end of the newly written material • Pointer can be reset to the beginning

  24. Direct Access • Organize a file as fixed-length logical records • number the records/blocks • Allow program to read and write records rapidly in no particular order • Enable immediate access to large amounts of information • read(n), write(n)

  25. how is file-system organized?

  26. devices partitioned into volumes; each volume maintains a directory, which records file name, location, size, type, etc.

  27. Operations over Directory • Search for a file • Create a file • Delete a file • List a directory • Rename a file • Traverse the file system

  28. Single-Level Directory • Contain all files in the same directory • Require unique file names

  29. Two-Level Directory • Create a separate directory per user UFD: user file directory • Unique file names for the same user • Diff users may have same-name files • Maintain a master file directory (MFD) to index the UFD of each user

  30. Two-Level Directory • Resembles a tree with MFD as the root and UFDs as leaves • Path name: user name + file name; for each file in the system

  31. Tree-Structured Directory • Allow users to create subdirectories • Treat directory as a special file in each directory entry: bit 0 for file: bit 1 for subdirectory:

  32. Tree-Structured Directory • Allow users to create subdirectories • Treat directory as a special file absolute path name: from the root to the specified file:

  33. Tree-Structured Directory • Allow users to create subdirectories • Treat directory as a special file relative path name: a path from the current directory:

  34. Tree-Structured Directory • Allow users to create subdirectories • Treat directory as a special file Example: current directory root/spell/mail: prt/first = root/spell/mail/prt/first:

  35. Acyclic-Graph Directory • Allow directories to share subdirectories and files • Share file/directory among users

  36. General Graph Directory unwanted; cycles need to be avoided; run cycle detection alg upon adding links in acyclic G

  37. how to mount a file system?

  38. how to mount a file system? so that a volume is available within the file-system name space

  39. File-System Mounting • The OS is given the following info: name of the device; mount point – the location within the file structure where the file system is to be attached; and file system type for some OS • OS then verifies that the device contains a valid file system and updates directory

  40. File-System Mounting /device/dsk Existing System Unmounted Volume

  41. File-System Mounting accessible files /device/dsk Existing System Unmounted Volume

  42. File-System Mounting /device/dsk mounted over /users its files become accessible; original mounted files are obscured untill /device/dsk is unmounted;

  43. how to share files?

  44. how to share files? owner: the user with the most control over the file; change file attributes and grant access; group: users who can share access to the file;

  45. how to share files? owner ID compared with the user ID when that user requests an operation on a file; group ID(s) compared with that user’s group ID(s)

  46. how to share files remotely? in a network

  47. The Client-Server Model • Server the machine containing the files to share • Client the machine seeking access to the files • Server specifies exactly which resource to share with exactly which users

  48. The Client-Server Model • Server the machine containing the files to share • Client the machine seeking access to the files • Server specifies exactly which resource to share with exactly which users • Server checks user credentials before granting access

  49. Consistency Semantics • Specify how multiple users to access a shared file simultaneously • UNIX Semantics writes to an open file by a user are visible immediately to other users who have this file open;

  50. Consistency Semantics • Specify how multiple users to access a shared file simultaneously • Session Semantics writes to an open file by a user are not visible immediately to other users that have the same file open; once a file is closed, the changes are visible only in later sessions*; *the series of accesses between open() and close()