Download presentation
Presentation is loading. Please wait.
Published byCurtis Stafford Modified over 9 years ago
1
CHAPTER 11: FILE-SYSTEM INTERFACE File Concept File Concept File Access File Access Directory Structure Directory Structure File System Mounting File System Mounting File Sharing File Sharing File Protection File Protection
2
FILE CONCEPT Introduction Introduction File attributes File attributes File types File types File structures File structures File operations File operations
3
File concept What is a file What is a file A file is named collection of related information that is recorded on secondary storage. Content types: Content types: Data numeric alphabetic alphanumeric binary Program source programs Object forms
4
File concept: Attributes File attributes Name: The symbolic file name in human-readable form Name: The symbolic file name in human-readable form Identifier: to identify the file within the file system (Internal) Identifier: to identify the file within the file system (Internal) Type: to support different types. Type: to support different types. Location: the location on the secondary storage device. Location: the location on the secondary storage device. Size: the current size (and/or its maximum size) Size: the current size (and/or its maximum size) Protection: who can do reading, writing, executing, and so on. Protection: who can do reading, writing, executing, and so on. Time, date, and user identification: This information may be kept for creation, last modification, and usage monitoring. Time, date, and user identification: This information may be kept for creation, last modification, and usage monitoring. Typically, the directory entry consists of the file ’ s name and its unique identifier. The identifier in turn locates the other file attributes. One of the file attributes is the location of file.
5
File concept : Types If an OS recognizes the type of a file, it can then operate on the file in reasonable ways. If an OS recognizes the type of a file, it can then operate on the file in reasonable ways. Some common file types (See the next slide) Some common file types (See the next slide) The TOPS-20 OS: If the user tries to execute an object program whose source file has been modified (or edited) since the object file was produced, the source file will be recompiled automatically. The TOPS-20 OS: If the user tries to execute an object program whose source file has been modified (or edited) since the object file was produced, the source file will be recompiled automatically. The Apple Macintosh OS: Each file has a type and also has a creator attribute containing the name of the program that created it. The Apple Macintosh OS: Each file has a type and also has a creator attribute containing the name of the program that created it. The Linux: File types are just hints. How to determine a file type on the Linux. The Linux: File types are just hints. How to determine a file type on the Linux.
6
File concept: Types
7
File concept: Structure File structures File structures None - sequence of words, bytes Simple record structure Lines, Fixed length, Variable length Complex Structures Formatted document Relocatable load file Can be implemented by inserting appropriate control characters. Who decides: Operating system and Program Who decides: Operating system and Program Conclusion: Too few structures make programming inconvenient, whereas too many cause OS bloat and programmer confusion. Conclusion: Too few structures make programming inconvenient, whereas too many cause OS bloat and programmer confusion.
8
File concept: Operations Create: to allocate the file space and allocate the directory entry Create: to allocate the file space and allocate the directory entry Read/Write/Seek: to find the directory entry and keep a read/write pointer or seek to a new position. Read/Write/Seek: to find the directory entry and keep a read/write pointer or seek to a new position. Delete: to find the directory entry and release all file space and erase the directory entry Delete: to find the directory entry and release all file space and erase the directory entry Truncate: to find the directory entry and release some file space Truncate: to find the directory entry and release some file space Open(F) – to search the directory structure on disk for entry F, and copy the directory entry into the open-file table and allocate a file descriptor. Open(F) – to search the directory structure on disk for entry F, and copy the directory entry into the open-file table and allocate a file descriptor. Close (F) – to copy the directory entry in the open-file table to the directory structure on disk and free the file descriptor Close (F) – to copy the directory entry in the open-file table to the directory structure on disk and free the file descriptor
9
File concept: Operations File tables File tables Single user: Per-process file table secondary storage Multiple-users: Per-process file table system- wide table secondary storage Several pieces of information are associated with an open file File pointerFile pointer File open countFile open count Disk location of the fileDisk location of the file Access rightsAccess rights
10
FILE ACCESS Sequential Access Sequential Access read next write next reset Direct Access Direct Access read n write/rewrite n position to n read next write next n = relative block number To simulate sequential access by direct access is easy To simulate sequential access by direct access is easy (To simulate direct access by sequential access is NOT easy) (To simulate direct access by sequential access is NOT easy)
11
File access: Sequential-access
12
File access: Direct-access
13
File access: Other access Index file Index file Master index Master index index file file data (ISAM: Indexed Sequential-Access Method from IBM)
14
File access: Other access
15
DIRECTORY STRUCTURE Disks partitions/minidisks/volumes FS Directories Files Disks partitions/minidisks/volumes FS Directories Files The directory is used to organize files (and directories) The directory is used to organize files (and directories) The directory can be viewed as a symbol table that translates file names into their directory entries. The directory can be viewed as a symbol table that translates file names into their directory entries. The operations on directories The operations on directories Search a file Create a file Delete a file List a directory Rename a file Traverse the file system
16
Directory structure A Typical File-system Organization
17
Directory structure: Criteria Efficiency – locating a file quickly. Efficiency – locating a file quickly. Naming – convenient to users. 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 Grouping – logical grouping of files by properties all Java programs all games …
18
Directory structures Single-level directory Single-level directory Two-level directory Two-level directory Tree-structured directory Tree-structured directory Acyclic graph directory Acyclic graph directory General graph directory General graph directory
19
Directory structure: Single-Level Directory A single directory for all users. A single directory for all users. Naming problem Grouping problem
20
Directory structure: Two-Level Directory Separate directory for each user. Separate directory for each user. MFD/UFD/FileName (Path name) Can have the same file name for different user Efficient searching No grouping capability
21
Directory structure: Tree-Structured Directories
22
Efficient searching Efficient searching Grouping Capability Grouping Capability Current directory (working directory) Current directory (working directory) cd /spell/mail/prog type list Absolute or relative path name Absolute or relative path name Creating a new file is done in current directory. Creating a new file is done in current directory. Delete a file Delete a file rm rm Creating a new subdirectory is done in current directory. Creating a new subdirectory is done in current directory. mkdir mkdir Example: if in current directory /mail mkdir count
23
Directory structure: Acyclic-graph directories
24
Tree-structured directory + sharing Acyclic-Graph Directories Tree-structured directory + sharing Acyclic-Graph Directories Linux ln: Linux ln: hard link soft link Potential problems Potential problems To traverse the FS To delete a file (for symbolic link and hard link)
25
Directory structure: General graph directory
26
Potential problems Potential problems To traverse the FS (maybe looping forever) To determine when a file can be deleted. Garbage collection
27
FILE SYSTEM MOUNTING A file system must be mounted before it can be accessed. 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. A unmounted file system (I.e. Fig. 11-11(b)) is mounted at a mount point.
28
(a) Existing. (b) Unmounted Partition
29
File System Mounting /etc/fstab /etc/fstab 1. Device 2. Mount point 3. File system type 4. Mount options 5. For dump 6. For fsck Mount/umount, swapon/swapoff /proc
30
FILE SHARING For multi-user OS For multi-user OS Sharing of files on multi-user systems is desirable. Sharing may be done through a protection scheme. File sharing over the network File sharing over the network FTP WWW NFS
31
File Sharing: Remote file systems The C/S Model The C/S Model The server: To declare that a resource is available to clients To specify exactly which resource and exactly which clients. The client: To access the remote files. The protocol: Authentication Operations.
32
File Sharing: Remote file systems How to use NFS How to use NFS Startup nfs /etc/rc.d/init.d/nfs setup or ntsysv /etc/exports Mount NFS mount server_machine:/exported_fs mount_point /etc/fstab
33
File Sharing: Remote file systems Distributed Information Systems Distributed Information Systems To provide a unified access to the information needed for remote computing. DNS: domain name to IP address Yellow pages: to centralize storage of user name, hostnames, printer information, and the like. Yellow pages NIS NIS+ (Sun Microsystems) Domains Active directory (Microsoft) LDAP (Lightweight directory-access protocol)
34
File Sharing: Remote file systems Failure Modes Failure Modes For one machine, to use RAID (Redundant Arrays of Inexpensive Disks) to prevent data loss For networked machines, Stateful mode: Too many problems can cause operation to fail.Too many problems can cause operation to fail. not good enough.not good enough. Stateless The protocol carries all the information needed to locate the appropriate file and perform the requested operation on a file.The protocol carries all the information needed to locate the appropriate file and perform the requested operation on a file.
35
File Sharing : Consistency semantics Consistency semantics: Consistency semantics: specifies the the semantics of multiple users accessing a shared file simultaneously. In particular, these semantics should specify when modifications of data by one user are observable by other users. UNIX semantics UNIX semantics Writes to an open file by a user are visible immediately to other users that have this file open at the same time One mode of sharing allows users to share the pointer of current location into the file
36
File Sharing : Consistency semantics AFS (Andrew File System) Semantics AFS (Andrew File System) Semantics Writes to an open file by a user are not visible immediately to other users that have the same file open simultaneously. Once a file is closed, the changes made to it are visible only in sessions starting later. Already open instances of the file do not reflect these changes. Immutable-shared file semantics Immutable-shared file semantics Once a file is declared as shared by its creator, it cannot be modified. An immutable file has two key properties. Its name may not be reused and its contents may not be altered.
37
FILE PROTECTION File owner/creator should be able to control: File owner/creator should be able to control: what can be done by whom No access some controlled access full access Types of access Types of access Read Write Execute Append Delete List
38
File protection Access control lists Access control lists Mode of access: read, write, execute Mode of access: read, write, execute Three classes of users Three classes of usersRWX a) owner access 7 1 1 1 RWX b) group access 6 1 1 0 RWX c) public access1 0 0 1 Ask manager to create a group (unique name), say G, and add some users to the group. 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. For a particular file (say game) or subdirectory, define an appropriate access.
39
File protection Chmod Chmod Find Find Ls, cd, mkdir, cat, more, less, cmp, diff, sort, merge, tee, touch, Ls, cd, mkdir, cat, more, less, cmp, diff, sort, merge, tee, touch,
40
Homework 3, 6, 7, 10, 11 3, 6, 7, 10, 11
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.