1 / 66

Operating Systems

Operating Systems. Prof. Navneet Goyal Department of Computer Science & Information Systems BITS, Pilani. Topics. Files Access Methods Directory Structure File System mounting File sharing Protection. Files. Most visible aspect of an OS

aneko
Download Presentation

Operating Systems

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. Operating Systems Prof. Navneet Goyal Department of Computer Science & Information Systems BITS, Pilani

  2. Topics • Files • Access Methods • Directory Structure • File System mounting • File sharing • Protection

  3. Files • Most visible aspect of an OS • Files provide mechanism for online storage of and access to both data and programs of the OS and all the users • A typical file system consists of: • Files (each storing related data) • Metadata (directory structure)

  4. Files • Information can be stored on various storage media • OS provides a uniform logical view of information storage • OS abstracts from the physical properties of its storage devices to define a logical storage unit, FILE! • Files are mapped by the OS onto physical devices

  5. Files • File is a named collection of related information that is recorded on a secondary storage • Smallest allotment of logical secondary storage • Data cannot be written on secondary storage unless it is written on a file • File is a very general concept

  6. File System • Collection of Files File contains related data • Directory Structure Organizes & provides information about all files in the system • Partitions Separates physically or logically large collections of directories

  7. Typical File System

  8. File Attributes • Name • Identifier (generally a number) • Type • Location (device: location) • Size (bytes, words or blocks) • Protection (rwx) • Time, date, & user identification (creation, last modification, last use)

  9. File Operations • File is an ADT • Must define operations on files • File Operations • Creating • Writing • Reading • Repositioning within file (file seek) • Deleting • Truncating • OS provides system calls for each operation

  10. File Operations • Creating • Space in the file system must be found for the file • Entry for the new file must be made in the directory • Writing a file • System call specifying the name of the file and the information to be written. System keeps a pointer to the location where the next write is to take place

  11. File Operations • Reading • System call specifying the name of the file and where the next block of the file should be put. • A process is either reading from a file or writing to a file, the current operation location can be kept as per process “current-file-position” pointer • Both read and write ops. Use this same pointer to save space & system complexity • Repositioning within a file • Current file position pointer is repositioned to a given value. Need not involve an actual I/O. Also called as file seek

  12. File Operations • Deleting a file • Search the directory for the names file, release all file space, and erase the directory entry • Truncating a file • Erases the content of a file but keeps its attributes

  13. File Operations • Other Operations • Appending • Renaming • Copy • Move • open() system call • Must be invoked before a file is used • Open file table is maintained by OS • Create & Delete work with closed files

  14. File Types

  15. Access Methods • Files contain information • Information must be accessed and read into memory for processing • Information in files can be accessed in several ways • Most systems provide only one method • Some systems provide many

  16. Access Methods • Choosing the right one for a particular application is a typical design issue • Sequential Access • Direct Access • Indexes (IBMs ISAM)

  17. Directory Structure • Stores information about all files • Resides on secondary storage • Contains file’s name & Identifier • Identifier in turn locates other file attributes • More than 1KB of information for each file • Directory structure size in MBs • Backups of files and directory structure kept on tapes

  18. Directory Structure • Disks are split into one or more partitions • Minidisks or Volumes • Each disk contains atleast one partition • Partitions can be larger than a disk • Partitions are “virtual disks” • Partition maintains information about files in “Device Directory”

  19. Directory Structure A collection of nodes containing information about all files. Both the directory structure and the files reside on disk Backups of these two structures are kept on tapes

  20. Information in a Directory • Name • Type • Address • Current length • Maximum length • Date last accessed • Date last updated • Owner ID • Protection information

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

  22. How to Organize a Directory? Issues • 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, …) Schemes for defining the logical structure of a directory: • Single level directory • Two level directory • Tree structured directory • Acyclic graph directory • General graph directory

  23. Single-Level Directory Single directory for all users: easy to support & understand • All files in a single directory • Naming problem (unique names) • Grouping Problem

  24. Two-Level Directory Separate directory for each user • each user has its own UFD (user file dir) • UFDs have similar structure • When a user logs in, the MFD (master file dir) is searched • MFD is indexed by user name or accnt no. • Each entry in MFD points to a UFD • User name & a file name define a path name

  25. Two-Level Directory Separate directory for each user • When a user refers to a file, only his own UFD is searched • File names can be shared among users • Solves the name-collision problem • Disadvantages? • System files?

  26. Two-Level Directory Separate directory for each user • File name would be searched in the current UFD only • Copy system files to each UFD!! • Standard solution: special user directory is defined to contain system files: say user 0 • Search procedure?

  27. Tree-Structured Directory

  28. Tree-Structured Directory • Generalization of two-level directory (with arbitrary height) • Each user has a current directory (working directory) • Can change current directory via cd command or system call • Path names can be absolute or relative Operations • Creating a new file is done in current directory • Delete a file • rm <file-name> • Creating a new subdirectory is done in current directory • mkdir <dir-name> Advantages • Efficient searching • Grouping Capability

  29. Acyclic-Graph Directory • 2 programmers working on a joint project • File pertaining to project stored in a subdirectory of each user • Shared subdirectory! • Tree structure prohibits the sharing of files or directories! • A shared file or dir will exist in the file system in two or more places at once • AGD allows files & dirs to be shared

  30. Acyclic-Graph Directory • Shared file is not the same as two copies of the file • With a shared file, only one actual file exists • Shared subdirectories • Files created in this SD will auto. appear in all the shared SDs • LINKS!!

  31. Acyclic-Graph Directory • A link is a pointer to another file or subdirectory • Link may be implemented as an absolute or a relative path • When a reference to a file is made • directory is searched • If directory entry is marked as a link, name of the real file is included in the link information • Link is resolved using the path name to locate the real file • Tree traversal is used to traverse directories

  32. Acyclic-Graph Directory Duplication • Duplicate all information in both the sharing directories • Original & copy indistinguishable • Maintaining consistency when a file is modified is a problem

  33. Acyclic-Graph Directory Problems • AGD is more flexible but more complex • File may have multiple absolute path names. Different file names refer to the same file!!

  34. Acyclic-Graph Directory • Have shared subdirectories • and files using acyclic graph • Two different names exist • (aliasing problem) • If ‘dict’ deletes list ⇒ • dangling pointer (UNIX case) • Solutions: • Preserve file until all references to it are deleted • Reference count solution

  35. General-Graph Directory • Add links to an existing tree structured directory, resulting in a simple graph structure • Want to avoid searching any shared components twice • Reference count solution does not hold due to self-reference • => use garbage collection • Acyclic structure is much easier to work with • How do we guarantee no cycle? • Allow links only to file not subdirectories • Every time a new link is added use a cycle detection algorithm

  36. General Graph Directory • Problem with AGD: ensuring no cycles • Allowing users to create files & directories to an existing tree structure preserves the tree-structured nature • But, when we allow links to be added to an existing tree structure, the tree structure is destroyed, resulting in a simple graph structure

  37. File System Mounting • Just as a file must be opened before it is used, a file system must be mounted before it can be accessed • Procedure?

  38. File System Mounting Procedure • The OS is given the name of the device, and the location within the file structure at which to attach the file system (or mount point) • Typically, a mount point is an empty directory • The OS verifies that the device contains a valid file system by asking the device driver to read the directory • Finally, the OS notes in its directory structure that a file system is mounted at the specified mount point; This scheme enables the OS to traverse its directory structure, switching among file systems as appropriate

  39. File System Mounting

  40. 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

  41. File Sharing: Multiple Users • User IDs identify users, allowing permissions and protections to be per-user • Group IDs allow users to be in groups, permitting group access rights

  42. File Sharing: Remote File Systems • Uses networking to allow file system access between systems • Manually via programs like FTP • Automatically, seamlessly using distributed file systems • Semi automatically via the world wide web • Client-server model allows clients to mount remote file systems from servers • Server can serve multiple clients • Client and user-on-client identification is insecure or complicated • NFS is standard UNIX client-server file sharing protocol • CIFS is standard Windows protocol • Standard operating system file calls are translated into remote calls • Distributed Information Systems (distributed naming services) such as LDAP, DNS, NIS, Active Directory implement unified access to information needed for remote computing

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

  44. Access Control List (ACL) • Various users may need different types of access to a file or directory • The most general scheme is to associate with each file & directory an access-control list (ACL) specifying the user name & the types of access allowed for each user • Advantages • Enable complex access methodology • Disadvantages • Constructing such a list may be a tedious and unrewarding task, especially if we do not know in advance the list of users in the system • The directory entry, previously of fixed size, now needs to be of variable size, resulting in more complicated space management

  45. Access Lists & Groups (UNIX) • Various users may need different types of access to a file or directory • The most general scheme is to associate with each file & directory an access-control list (ACL) specifying the user name & the types of access allowed for each user • Advantages • Enable complex access methodology • Disadvantages • Constructing such a list may be a tedious and unrewarding task, especially if we do not know in advance the list of users in the system • The directory entry, previously of fixed size, now needs to be of variable size, resulting in more complicated space management

  46. Access Lists & Groups (UNIX)

  47. Sample Directory Listing (UNIX)

  48. Windows XP Access-control List Management

  49. UNIX File System

  50. Working Directory

More Related