Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 11: File-System Interface

Similar presentations


Presentation on theme: "Chapter 11: File-System Interface"— Presentation transcript:

1 Chapter 11: File-System Interface
File Concept Access Methods Directory Structure File System Mounting File Sharing Protection Annotated for use with Silberschatz’s book used during CS350, Fall 03 Instructor's annotation in Blue Last updated 4/25/03, 11/30/03 Operating System Concepts

2 File Concept Type or extension usually indicates meaning of contents:
Collection of related data Contiguous logical address space – mapped onto physical device by OS, but presents a view (interface) to an application which is independent of any device usually non-volatile Users view: smallest allotment of logical secondary storage. From a user viewpoint: data cannot be written to secondary storage unless it is in a file Sequence of bytes, bits, lines, or records … file has a structure defined by file type … interpretation depends on OS and/or application Type or extension usually indicates meaning of contents: Data numeric character, ex: rat.txt - text file binary, ex: rat.xls - spread sheet, application supported Program, ex: rat.exe - executable module, OS supported Operating System Concepts

3 File Structure The internal representation of the data
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 - ex: MS Word documents. Who decides (you mean support? - see previous slide): Operating system Program Operating System Concepts

4 File Attributes Name – only information kept in human-readable form.
Identifier - a machine readable “field” corresponding to the name - typically a number 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. Operating System Concepts

5 File Operations File is an abstract data type - operation are associated with file type, p. 373 Operations (usually from within a program, ie., function calls): 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 - to the open file table, attributes of file is pointed to by a file descriptor or “handle” returned by open call. The open file table is not searched it is directly accessed via the file descriptor. Open file table is like a cache for the directory. Close (Fi) – move the content of entry Fi in memory to directory structure on disk (if modified?). Operating System Concepts

6 File Types – Name, Extension
Big questions: Who supports file extensions (types)? … support is shared by OS and the application … varies according to the OS Also who supports the file structure (internal format, logical records, etc: OS or application? OS minimally supports executable files. UNIX provides only minimal OS support. Internal file structure: Mapping the logical record size to the physical block (sector) is the problem here. See sect Operating System Concepts

7 Access Methods Sequential Access - Tape model: must sequentially move thru file - … no insertion of records, append at end - can read anywhere by searching from beginning for record - Current position (cp) pointer indicates next record to be accessed - write append to end of file read next , cp++ write next , cp++ reset , cp = 0; no read after last write (beyond EOF) Direct Access - Disk model: random access of fixed blocks - File is seen as numbered series of fixed length logical blocks or records that allow programs to read/write records in no particular order. - R/W records in no particular order read n write n position to n read next //simulation of sequential write next rewrite n n = relative block number Operating System Concepts

8 Sequential-access File
Operating System Concepts

9 Simulation of Sequential Access on a Direct-access File … simulation of direct access on sequential more difficult Operating System Concepts

10 Example of Index access methods and Relative Files
- Build on top of direct access - must search index and then directly access via disk pointer (or convert relative block number to a physical disk address) - index written on disk and copied to memory (cache ) - can have multilevel index tables, index the index table - sound familiar? - Index will get you to a physical block containing the logical record (relatively small logical records packed in a larger physical block (ex: sector) - FAT access method (used on PC) related to this idea, and ISAM on IBM mainframes. Operating System Concepts

11 Directory Structure A collection of nodes containing information about all files. A way of locating files on the disk- by name IBM mainframe buzz word: Volume Table of Contents (VTOC) Contains access information about the file such as name, location, size, type, etc. Example: do ls -l -a on UNIX Directory This example shows the one minimal feature of a directory, namely relating file names to their locations. 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. Operating System Concepts

12 A Typical File-system Organization
Organize disk into partitions (minidisks as per IBM mainframes) - Each with its own directory - files and directories stored in partitions - Partitions appear as a logical disk to user - may be larger that a disk for multiple disk systems (Ex: RAID) - Ideally user is oblivious to partition management and sees only disk drives. Typical for PC’s Example for a RAID system Operating System Concepts

13 Information in a Device (say disk) Directory
Name Type Address … pointer to, or indicator of physical location of file – generally not visible to the user – the main guts of the entry. Current length Maximum length Date last accessed (for archival) Date last updated (for dump) Owner ID (who pays) Protection information (discuss later) Check this stuff on UNIX doing ls -l -a Must minimally have name and address Operating System Concepts

14 Operations Performed on Directory
Search for a file Create a file Delete a file List a directory Rename a file Traverse the file system Operating System Concepts

15 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, …) Operating System Concepts

16 Single-Level Directory- some history
Directories originally set up for multi-user systems A single directory for all users. Cat,bo, … are file names <--Actual data for files Naming problem Just a list of all user’s files: names must be unique - problem with duplicate names Grouping problem – difficult to organize files Operating System Concepts

17 Two-Level Directory-some modern history
Separate directory for each user - solves duplicate name problem. Example: IBM VM system - each user (on a different virtual machine) had a single level directory Path name Can have the same file name for different user Efficient searching No grouping capability Operating System Concepts

18 Tree-Structured Directories - what we have today
Does it all: introduces the concept of a “folder” - can have “folders” within “folders” (folders is a Windows buzz word) names in the directory entry are file names OR the names of other directories - the idea is from UNIX Operating System Concepts

19 Tree-Structured Directories (Cont.)
Efficient searching -can quickly skip to desired subdirectory before searching for data files Grouping Capability – easy to organize files Current directory (working directory) cd /spell/mail/prog type list Operating System Concepts

20 Tree-Structured Directories (Cont.)
Absolute (from root) or relative (from current directory) path name suppose your home directory on UNIX is: /u0/users/0/cs350, and inder cs350 you have a subdirctory project containing an executable rw. Executing rw from cs350 can be done as: /u0/users/0/cs350/project/rw - specify absolute path or . /project/rw - use relative path (“.” means current dirctory) 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> Example: if in current directory /mail mkdir count mail prog copy prt exp count Deleting “mail”  deleting the entire subtree rooted by “mail”. In UNIX rm -rf mail … recursively clears all subdirectories - a dangerous command! Operating System Concepts

21 Acyclic-Graph Directories
Have shared subdirectories and files <== key idea. In UNIX this is the symbolic link - powerful method for sharing files among large groups of users over a network. Uses path name to shared file. Can have distinct different file names for same file – alias Must ensure that there are no cycles in the graph Operating System Concepts

22 Acyclic-Graph Directories (Cont.)
Shared file may have two different names (aliasing) When could a shared file be deleted? If dict deletes list  dangling pointer (see prev. slide). Solutions: Backpointers, so we can delete all pointers. Variable size records a problem. Backpointers using a daisy chain organization. Entry-hold-count solution. - remove file only when all references to it are gone - increment/decrement count. Two problems to avoid in acyclic graphs: dangling pointers - UNIX: if shared file deleted, leave all symbolic links - leave it up to the user to handles these links avoid cycles when adding links - cycles detection. Operating System Concepts

23 General Graph Directory >>>omit<<<
Operating System Concepts

24 General Graph Directory (Cont.) >>>omit<<<
How do we guarantee no cycles? Allow only links to file not subdirectories. Garbage collection. Every time a new link is added use a cycle detection algorithm to determine whether it is OK. Operating System Concepts

25 File System Mounting Mounting: Associating data (or file) on a device to a directory to a directory/file system in user space. Make “raw” files on a device part of a directory tree. A file system must be mounted before it can be accessed. The directory structure can be built out of multiple partitions/disks (or from multiple devices, or remote networked machines), which must be “mounted” to make them available within the file system name space A unmounted file system is mounted at a mount point within the directory tree. Operating System Concepts

26 Existing. (b) Unmounted Partition
Operating System Concepts

27 Mount Point New FS mounted over previous directory
subtree at “users” and would obscure previous tree. Better create another subdirectory under users to be the mount point. See pp Operating System Concepts

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. On UNIX - remote file systems would be mounted Operating System Concepts

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 Operating System Concepts

30 Access Lists and Groups
Mode of access: read, write, execute Three classes of users RWX a) owner access 7  RWX b) group 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 Operating System Concepts


Download ppt "Chapter 11: File-System Interface"

Similar presentations


Ads by Google