Transcript mount point

File System Interface
Rahul Ajit
Khin Zayar Htay
File Concept


Files are logical storage units mapped on
to physical secondary storage, usually
nonvolatile such as magnetic disks,
magnetic tapes and optical disks.
Types:
Data
 Numeric, alphabetic, alphanumeric,
or binary
Program
 Source and object forms
File Attributes




Name - Only information kept in humanreadable form.
Identifier – Unique tag, usually a number
that identifies the file within the file
system.
Type – Needed for systems that support
different types.
Location – Pointer to file location on
device.
File Attributes (Cont’d)




Size – Current file size.
Protection – Access-control who can write,
read, execute and so on.
Time, date and user identification – Data
for protection, security and usage
monitoring.
Volatility – Frequency with which additions
and deletions are made to the file.
File Operations



A file is an abstract data type. To define a
file, we need to consider the operations
that can be performed on the file.
Creating a file - Allocate space for the file,
entry for the file in the directory.
Writing a file - Make a system call
specifying both the name of the file and
the information to be written to the file.
System keeps a write pointer.
File Operations (Cont’d)


Reading a file - Make a system call
specifying both the name of the file and
where the next block of file should be put.
System keeps a read pointer.
Repositioning within a file – Also known as
file seek. The directory is searched for the
appropriate entry, and the current fileposition-pointer is repositioned to a given
value.
File Operations (Cont’d)



Deleting a file – Release all file space
and erase the directory entry.
Truncating a file – Deletes contents and
resets length to 0 but directory entry
and all file attributes except file length
remains unchanged.
Opening/closing a file - When a file
operation is requested, the file is
specified via an index into open-file table
usually after an open() system call.
File Operations (Cont’d)

Information associated with open file
File pointer - If no file offset in
read()/write() system calls are included.
File-open count - The number of
processes have opened the file. When
the count reaches 0 the entry is deleted
from open-file table.
Disk location of the file
Access rights - Per process access mode
information.
File Locks



File locks allow one process to lock a file
and prevent other processes from gaining
access to it.
Mandatory file locks - Once a process
acquires an exclusive lock, the operating
system will prevent any other process
from accessing the locked file.
Advisory file locks – Is up to software
developers to ensure that locks are
appropriately acquired and released.
Common file types
File Structure




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.
Operating system or program can
establish file structure.
File Structure (Cont’d)



File type may indicate internal structure of
file (e.g., source or object).
IBM mainframe systems, for example,
support a very wide range of access
methods.
UNIX, MS-DOS, others, support only a
minimal number of file structures. (UNIX
files are sequence of 8-bit bytes)
File Structure (Cont’d)


Macintosh resource fork and data fork.
The logical record size, physical block size,
and packing technique determine how
many logical records are in each physical
block. The packing can be done either by
the user's application program or by the
operating system.
Access Methods

Sequential access – Information in the file
is processed in order, one record after the
other.
read next
Write next
Reset or skip n
Access Methods (Cont’d)

Direct access – Or relative access is based
on a disk model of a file, since disks allow
random access to any file block.
Read n, write n
Read next, write next, position file to n
where n is the relative block number.
Access Methods (Cont’d)

Other access methods – Index and
relative files.
Directory Structure

Storage structure – A collection of nodes
containing information of all files. Resides
on disk, along with the files.
Directory Operations






Search for a file.
Create a file.
Delete a file.
List a directory.
Rename a file.
Traverse the file system usually for back
up purposes.
Single-Level Directory

All files are contained in the same
directory. Simple to support and use. But
difficult when the number of files increase
and system has more than one user.
Two-Level Directory



Each user has own user file directory
(UFD).
Master file directory (MFD) holds pointers
to UFDs.
Disadvantage: Isolation.
Tree-Structured Directory




Natural generalization of two-level
directories. Contains a set of files and subdirectories with the same internal format.
The current directory should contain most
of the files that are of current interest to
the process.
Special system calls are used to create
and delete directories. To change
directories a system call that takes a
directory name as a parameter and uses it
to redefine current directory.
Efficient searching and group capability.
Tree-Structured Directory (Cont’d)
Acyclic-Graph Directory

A graph with no cycles, allows directories
to share subdirectories and files.
Acyclic-Graph Directory (Cont’d)



One way of implementation is by creating
a new directory called link, which is a
pointer to another file or sub directory.
An alternative approach is to duplicate all
information in both sharing directories.
Deleting a file could involve the approach
of leaving the links dangling or the
approach where file is preserved until all
references to it are deleted.
General Graph Directory

We have to guarantee no cycles are
formed by making sure that
We allow only links to files and not sub
directories
Garbage collection
Every time a new link is added use a
cycle detection algorithm to determine if
it is okay.
General Graph Directory (Cont’d)
File-System Mounting



The process of incorporating a file
system into the existing directory
structure.
A file system must be mounted
before it can be accessible to system
processes.
A file system is mounted at mount
point (empty directory).
mount -t iso9660 /dev/hdc /cdrom
File-System Mounting (Cont’d)

Mounting Process, OS
Name of device
Mount point
File system type
Verify device contains valid file system.
File system is mounted at specified
mount point.
File-System Mounting (Cont’d)



Unix
Mount /dev/dsk/c1t4d0s0 under Solaris
UNIX at /data2, enter:
mkdir /data2
mount /dev/dsk/c1t4d0s0 /data2
To remove mount point run:
umount /data2
File-System Mounting (Cont’d)
File-System Mounting (Cont’d)

System impose semantics to clarify
functionality. System may
Disallow a mount over a directory that
contain files
A mount over that directory and
directory’s existing files are hidden and
inaccessible
Allow same file system to be mounted
repeatedly at different mount points
Allow one mount per file system
File-System Mounting (Cont’d)

Mac OS
File-System Mounting (Cont’d)

Windows OS
File Sharing



Sharing of file among users and systems
is desirable.
File Sharing through removable media,
computer network, Web and etc
File Sharing through protection such as
access control
File Sharing : Multiple Users




Owner, who can change attributes and
grant access and have most control over
the files
Group, who can share access to the files
or execute one subset of file operations
User ID identifies user and permitting
requested operations on files
Group ID allows user to be in a group and
permitting group access right
File Sharing : Remote File Systems


Network communication among remote
computes now become possible
Networking allows sharing of file system
among different systems
FTP: manually transferring files between
hosts
DFS: accessing files from multiple hosts
via network
WWW: A browser gains access to the
remote files and separate operations for
file transfer.
File Sharing : Remote File Systems (Cont’d)

Client-Server model allows client to
mount one or more file systems from
servers
A server can serve multiple clients.
A client can access multiple servers.
Client identification is complex and
unsecure authentication methods are most
commonly used
UNIX and its NFS, authentication takes
place via client network information by
default
NFS is Unix File Sharing Protocol
CIFS and SMB are Window File Sharing
Protocols
File Sharing : Remote File Systems (Cont’d)

Client-Server model file sharing
Once remote file system is mounted,
client sends file operation requests to
server via DFS
Server applies standard access checks
to see if user has credentials to access
the file in the mode requested
The request is either grant or deny
If access is granted, client performs
requested operations
Client closes the file
File Sharing : Remote File Systems (Cont’d)

Distributed Information Systems provide
unified access to the information needed for
remote computing
DNS provides host-name-to-network-address
translation for internet
Some DIS provides user name, password, user
ID and group ID for distributed facility
UNIX employs a variety of distributedinformation methods.
Sun Microsystems introduced NIS and NIS+
Microsoft CIFS, network information is used
with user authentication for network login
Microsoft uses domain and active directory
naming technology for distributed naming
structures.
Lightweight directory-access protocol (LDAP)
File Sharing : Failure Modes

Local file system can fail for a variety of
reasons
Disk failure, Directory structure or Diskmanagement information corruption, Diskcontroller failure, cable failure, user or
system administrator failure and etc

Remote file system have more failure
modes.
Network interruption and etc



Recover from failure involves some kind of
state information about remote request
NFS, which employs DFS stateless
NFS version 4 is stateful
File Sharing : Consistency Semantics



An important criterion
How modifications of data by one user will
be observable by other users
Andrew file system implemented complex
sharing semantics.
File Sharing : Consistency Semantics (Cont’d)

UNIX Semantics
Writes to an open file by a user are visible
immediately to other users who have this file
open
Supports a mode of sharing where users share
pointer of current location into the file

Session Semantics (eg. AFS)
Writes to an open file by a user are not visible
immediately to other users who have this file
open
Once a file is closed, the changes are visible
only in sessions starting later. Already open file
instances doe not reflect changes.
File Sharing : Consistency Semantics (Cont’d)

Immutable-Shared-Files Semantics
Once a file is declared as shared by its
creator, it cannot be modified.
Two properties: name and content are
immutable
Simple implementation as read-only
sharing
Protection


Keep information stored in system safe
from physical damage and improper or
unauthorized access
Protect files by limiting types of access to
files and by whom
Protection : Access Types

Types of Access
Read
Write
Execute
Append
Delete
List
Protection : Access Control


Common approach is granting access
based on the identity of user
Access-Control List
Specify user names and type of access allowed
for each user
Associate access-control list with each file
Maintenance problems as its length and
unknown size of system users
The variable size directory entry, resulting in
more complicated space management.
Protection : Access Control (Cont’d)

Categories of access
Owner
Group
Universe
Maintenance of groups in the system
are not connected with the specific file
or directory
Each file has owner and group
associated with it. Permissions are
specified to each of them
Protection : Access Control (Cont’d)


Permission and access control lists must
be controlled tightly
Examples in Unix System
File name: book, chapter1
Group name: text, owner
User name: visitor not in groups
-rwxrw-r-- 2 Sara text 2048 Sep 30
2010 book
Chmod text-w book
setfacl -m u:visitor:rx / chapter1
Protection : Access Control (Cont’d)

Windows
Protection : Others

Passwords
Associating a password with each file
Issues
Large number of passwords to
remember
 One password for all files is used,
protection is on all-or-none basis

Some system allow user to associate a
password with subdirectory rather than
individual file.
MS-DOS and early version of Mac OS
provide little in term of file protection.
References






Operating System Concepts 8th Edition by
ABRAHAM SILBERSCHATZ, PETER BAER GALVIN
and GREG GAGNE
http://arstechnica.com/apple/reviews/1999/12/m
acos-x-dp2.ars/6
http://www.dartmouth.edu/~rc/help/faq/permissi
ons.html
http://www-rohan.sdsu.edu/doc/debian/chdisks.html
http://catcode.com/teachmod/index.html
http://www.softpanorama.org/Access_control/acl
.shtml
Thank you