10 File System
10 File System
File Concept
A file is a named collection of related information that is
recorded on secondary storage.
From a user's perspective, a file is the smallest allotment
of logical secondary storage; that is, data cannot be
written to secondary storage unless they are within a file.
Commonly, files represent programs (both source and
object forms) and data.
Data files may be numeric, alphabetic, alphanumeric, or
binary.
Files may be free form, such as text files, or may be
formatted rigidly.
In general, a file is a sequence of bits, bytes, lines, or
records, the meaning of which is defined by the file's
creator and user.
File Structure
A file has a certain defined structure, which depends on
its type.
A text file is a sequence of characters organized into
lines (and possibly pages).
A source file is a sequence of subroutines and functions,
each of which is further organized as declarations
followed by executable statements.
An object file is a sequence of bytes organized into
blocks understandable by the system's linker.
An executable file is a series of code sections that the
loader can bring into memory and execute.
File Attributes
Name – only information kept in human-readable form
Identifier – unique tag (number) identifies file within
file system
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
File Operations
File is an abstract data type
Create
Write
Read
Reposition within file
Delete
Truncate
Open(Fi) – search the directory structure on disk for
entry Fi, and move the content of entry to memory
Close (Fi) – move the content of entry Fi in memory to
directory structure on disk
File Types – Name, Extension
Access Methods
Sequential Access
read next
write next
reset
no read after last write
(rewrite)
Direct Access
read n
write n
position to n
read next
write next
rewrite n
n = relative block number
Sequential-access File
Example of Index and Relative
Files
Directory Structure
Directory
Files
F1 F2 F4
F3
Fn
The simplest directory structure is the single-level directory. All files are
contained in the same directory, which is easy to support and understand
Naming problem
Grouping problem
Single-Level Directory
Types of access
Read
Write
Execute
Append
Delete
List
Access Lists and Groups
Mode of access: read, write, execute
Three classes of users
RWX
a) owner access 7 11
1
RWX
b) group access 6 110
RWX
c) public access 1 001
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.