Chapter - 6
Chapter - 6
File System
Outline
• Introduction
• File system concepts and definition
• File attributes
• File access methods
• File operation, organization
• Directories
• File allocation
• File permission
Introduction
• Secondary storage is the non-volatile repository
for (both user and system) data and programs.
Directory
Files F2 F4
F1 F3
Fn
Naming problem
Grouping problem
Here the directory contains four files.
Disadvantage:
– Different users may accidentally use the same names for
their files.
• Path name
• Can have the same file name for different user
• Efficient searching
• No grouping capability
Tree (Hierarchical directory system)
• Arbitrary (sub)-tree for each user.
• It is used for large number of files.
• Each user can have as many directories as possible.
Tree-Structured Directories…
• Efficient
searching
• Grouping
Capability
• Current directory
(working
directory)
– cd
/spell/mail/pro
g
– type list
Tree-Structured Directories (Cont)
• Absolute or relative path name
• 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
Solutions:
– Backpointers, so we can delete
all pointers
Variable size records a problem
– Backpointers using a daisy
chain organization
– Entry-hold-count solution
General Graph Directory
• 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
Directory operation
• Each file is a
linked list of disk
blocks:
• blocks may be
scattered
anywhere on the
disk.
block = pointer
File-Allocation Table
• File-allocation
table (FAT) –
disk-space
allocation used
by MS-DOS and
OS/2.
Indexed Allocation
• Brings all pointers together into the index block.
• Logical view.
index table
Indexed allocation…
• Allocate an array of pointers
during file creation.
• Fill the array as new disk
blocks are assigned.
• Advantages
– Small internal fragmentation
– Easy sequential and direct
access
• Disadvantages
– Lots of seeks if the file is big
– Maximum file size is limited to
the size of the block
• Example
– Unix file system
Example of Indexed Allocation
File Permissions
• Read, write, and execute privileges
• In Windows:
– Change permission on the Security tab on a file’s
Properties dialog box
– Allow indicates grant;
– Deny indicates revoke
• In UNIX/Linux
– Three permission settings:
• owner; group to which owner belongs; all other users
– Each setting consist of rwx
• r for reading, w for writing, and x for executing
– CHMOD command used to change file permissions
File Permissions
• One can easily view the permissions for a file by invoking a long
format listing using the command ls -l.