Title: FileSystem Interface
1File-System Interface
2Chapter 11 File-System Interface
- 11.1 File Concept
- 11.2 Access Methods
- 11.3 Directory Structure
- 11.4 File System Mounting
- 11.5 File Sharing
- 11.6 Protection
3Chapter 11 Summary
- File Concept File definition, structure,
attributes - Access Methods direct, sequential access
- Directory Structure levels, tree, acyclic
- File System Mounting multi-partition directory
- File Sharing permissions, client-server, DNS
- Protection access levels, access control
4File Concept
- Contiguous logical address space
- File Types
- Data
- numeric
- character
- binary
- Program
- A file is a sequence of bit, bytes, lines or
records, the meaning of which is defined by the
files creator and user.
11.1
5File Structure
- None - sequence of words, bytes
- Simple record structure
- Lines
- Fixed length
- Variable length
- Complex Structures
- Formatted document
- Relocatable load file
- Can simulate structures by inserting appropriate
control characters.
11.1
6File Structure
Text size
Data size
Module name
bss size
Date
Header
Symbol table size
Owner
Entry point
Protection
. . .
Size
Flags
Text
Archive
Data
Relocation bits
Symbol table
Executable
7File 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 is kept in the directory
structure, which is maintained on the disk. - File name, unique file identifier
11.1.1
8File Operations
- Create space in file system, entry in
directory - Write search directory, write, update write
pointer - Read search directory, read, update read
pointer - Seek reposition pointer within a random access
file - Delete release file space, erase directory
entry - Truncate erase contents, keep attributes
- Open place entry in open file table, with file
attributes - Close erase entry from open file table
- Append write data to the end of a file
- Rename change name of an existing file
- Copy copy file to another directory or I/O
device
11.1.2
9Open-File Tables
- Per process table for each process
- File pointer position within file
- Access rights
- System-wide table entry made for any file open
- Location of file on disk
- Access date
- File size
- Open count number of processes accessing file
- File open count re-use open file entry
- (Tracks opens and closes, reaches zero on last
close)
11.1.2
10File Types Name, Extension
Win32 uses extensions UNIX extensions for apps
only
11.1.3, Figure 11.1
11Access Methods
- Direct Access
- read n
- write n
- position to n
- read next
- write next
- rewrite n
- where n relative block number (an index
relative to the beginning of the file).
Used for databases
11.2.2
12Sequential-access File
- Sequential Access
- read next
- write next
- reset
- skip n
Used for editors and compilers
11.2.1, Figure 11.2
13Simulation of Sequential Access on a
Direct-access File
where cp current position
11.2.2, Figure 11.3
14Index and Relative Files
Index contains pointers to various blocks to
find a record, search the index, use pointer to
access file
11.2.3, Figure 11.4
15Directory Structure
- 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.
16Typical File-system Organization
Partitions are like virtual disks.
11.3, Figure 11.5
17Information in a Device Directory
- Name
- Type
- Address
- Current length
- Maximum length
- Date last accessed (for archival info)
- Date last updated (for dump information)
- Owner ID (who owns it)
- Protection information (who accesses)
18Operations Performed on Directory
- Search for a file name pattern searches
- Create a file add to the directory
- Delete a file remove from the directory
- List a directory file names and attributes
- Rename a file
- Traverse the file system access every directory
11.3
19Benefits of Organized Directory
- 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, )
11.3.1
20Single-Level Directory
- A single directory for all users.
Naming problem Grouping problem Useful for
small embedded systems
11.3.1, Figure 11.6
21Two-Level Directory
- Separate directory for each user.
- Path name
- Can have the same file name for different user
- Efficient searching
- No grouping capability
Windows \usr\ast\mailbox UNIX /usr/ast/mailbox MU
LTICS gtusrgtastgtmailbox
11.3.2, Figure 11.7
22Tree-Structured Directories
11.3.3, Figure 11.8
23Tree-Structured Directories
- Efficient searching
- Grouping Capability
- Current directory (working directory)
- cd /spell/mail/prog
- type list
11.3.3
24Tree-Structured Directories
- Absolute or relative path name
- Creating a new file is done in current directory.
- Delete a file
- rm ltfile-namegt
- Creating a new subdirectory is done in current
directory. - mkdir ltdir-namegt
- Example if in current directory /mail
- mkdir count
mail
prog
copy
prt
exp
count
Deleting mail ? deleting the entire subtree
rooted by mail.
11.3.3
25Acyclic-Graph Directories
- Have shared subdirectories and files.
11.3.4, Figure 11.9
26Acyclic-Graph Directories
- Implementing shared files and directories
- Use symbolic links, pointers to other directory
entries - (Links are indirect pointers)
- Or use duplicate entries (but consistency a
problem) - If a file is deleted, a link can be left dangling
- Search for links and de-allocate, but takes time
- Leave the link until an attempt to use it, then
delete - (but be careful, it could point to a new file)
(Win32) - Keep a record of all links and directory entries,
delete file only when the file-reference list is
empty - (UNIX does this, but just keeps a count of links)
11.3.4
27General Graph Directory
11.3.5, Figure 11.10
28General Graph Directory
- How do we guarantee no cycles?
- Allow only links to files, not subdirectories.
- Garbage collection to find cycles, and
- delete file if the only reference is to itself.
- Every time a new link is added,
- use a cycle detection algorithm to
- determine whether it is cyclic.
- Or use algorithm to bypass cycle in directory
traversals.
11.3.5
29File System Mounting
- A file system must be mounted before it can be
accessed. - The directory structure can be built out of
multiple partitions. - An unmounted file system is attached to a file
system (mounted) at a mount point. - Typically, a mount point is an empty directory
- A system may disallow mounting over non-empy
directories - A system may allow the same file system to be
mounted repeatedly, at different points - Win32 discovers and mounts devices at boot time
- UNIX has both automatic and manual execution of
mounting
11.4
30Mounting Point Example
Unmounted Partition
Existing File System
11.5, Figure 11.11
31Mounting Point Example
File System mounted over /users
11.5, Figure 11.12
32Remote File Systems
- Evolution of Network file sharing
- File transfer protocol (ftp)
- Anonymous access
- Authenticated access
- Distributed file system (DFS)
- Remote directories visible
- World Wide Web
- Browser gains access to the remote files
- ftp with a wrapper accesses the files
11.5.2
33Remote File Systems
- Client-server systems
- Clients are identified by network name or IP
address - Encryption algorithms counter spoofing
- Require a secure exchange of keys
- UNIX Network File System (NFS) is
- a common distributed file-sharing method.
- Allows many clients to connect to many servers
- Domain Name System (DNS) for Internet
- A type of distributed naming service
- Host name to network address translations
11.5.2
34Remote File Systems
- Network Information Service (NIS) from Sun
- Centralized storage of user names, host names
- Insecure, clear text system
- Common Internet File System (CIFS)
- Network information plus user authentication
- Domains distributed naming structure (older)
- Active directory (Windows 2000 and later)
- Lightweight Directory Access Protocol (LDAP)
- Efforts to create industry agreement on this
standard - Secure single log-in across multiple computer
types
11.5.2
35Domain Name System
- DNS is a mechanism to resolve the host name into
a host-id that describes the destination system
to the networking hardware - DNS specifies the naming structure of the hosts
- The system resolves addresses by examining the
host name components in reverse order - Each component has a name server that accepts a
name and returns the address of the name server
responsible for that name - bob.cs.brown.edu turns into 128.148.31.100, after
edu name server has returned server address for
brown.edu, etc.
11.5.2.2
36Failure Modes
- Local file systems
- Failure of the disk or network hardware
- Corruption of the directory structure
- Corruption of metadata (disk management info)
- (RAID systems have redundancy for secure data)
- (Redundant Arrays of Inexpensive Disks)
- Remote file systems
- Network interruptions
- Server crash
- Scheduled server downtimes
11.5.2.3
37Failure Recovery
- DFS protocols allow for delay of operations
- So remote server can come back into operation
- State information preserved at client and server
- Export status of file
- Mounting status of file systems
- NFS implements a stateless DFS
- Assumes legitimacy of interrupted client
- Assumes remote mounting of the file system
- Locates appropriate file, completes operation
11.5.2.3
38File Consistency
- Consistency Semantics
- determine when modifications of data by one user
are observable by another - Defined over a file session, a series of accesses
between open and close operations - UNIX
- A file has a single, shareable image
- Writes to an open file are immediately visible to
other users of the file - Movement of pointer to current location within a
file is shared among all users of the file
11.5.3
39File Consistency
- Andrew File System (AFS)
- Can span over 5000 workstations
- A file may have many different images at the same
time - Atomic read and write operations ensure
consistency between local and remote data - Writes are not immediately visible to other users
- File changes are seen by other users only after
they close and reopen the file - Results in rapid, concurrent access
11.5.3
40Protection
- File owner/creator should be able to control
- what can be done
- by whom
- Types of controlled access
- Read
- Write
- Execute
- Append
- Delete
- List
11.6.1
41Access Lists and Groups
- Associate with each file and directory an access
list user name and access level - Enables complex access methodology
- But access lists get long
- Condense the access list to three classifications
of user - Owner the one who created the file
- Group a set of users needing similar access
- Universe all other users
- May also have specific users in an access list
11.6.2
42Access 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
- Manager creates group G comprised of some users
- For a particular file or subdirectory, define an
appropriate access.
11.6.4
43Access Lists and Groups
Access by Owner, Group, Public
Directory?
Owner Size Date File Name
- -rw-rw-r-- 1 staff 31200 Sep 3 intro.ps
- drwx------ 5 staff 512 Jul 8 private/
- drwxrwxr-x 2 staff 512 Jul 8 doc/
- drwxrwx--- 2 student 512 Aug 3 student-proj/
- -rw-r--r-- 1 staff 9423 Feb 24 program.c
- -rwxr-xr-x 1 staff 20471 Feb 24 program
Number of links
Attach a group to a file chgrp G game
11.6.4, Figure 11.13