Академический Документы
Профессиональный Документы
Культура Документы
FILE CONCEPT
It provides the mechanism for online storage of
FILE CONCEPT
A file is a named collection of related information
files
may
be
numeric,
alphabetic,
alphanumeric or binary.
Files may be free form such as text files or may be
formatted rigidly.
File Attributes
A file is referred to by its name. A name is usually a string of
characters.
A files attributes vary from one OS to another but consist of these
Name: symbolic file name is the only information kept in human
readable form.
Identifier: number which identifies the file within the file system; it is
the non human readable name for the file.
Type: information is needed for systems that support different types
of files.
File Attributes
Location: this information is a pointer to a device and
to the location of the file on that device.
Size: the current size of the file
Protection: Access control information determines who
can do reading, writing, executing etc.
Time, date and user identification: This information
may be kept for creation, last modification and last
use.
File Attributes
The information about all files is kept in the directory
unique identifier.
The identifier in turn locates the other file attributes.
File Operations
A file is an abstract data type.
OS can provide system calls to create, write, read,
found for the file. Second, an entry for the new file
must be made in the directory.
File Operations
Writing a file To write a file, specify both the name
File Operations
Because a process is either reading from or writing to a file,
named file. When found, release all file space and erase the
directory entry.
File Operations
Truncating a file User may want to erase the
contents of a file but keep its attributes. This function
allows all attributes to remain unchanged except for file
length.
OS keeps a small table called the open file table
containing information about all open files.
The open () call can also accept access mode
information create, read only, read write, append
only, etc. This mode is checked against files
permissions
File Operations
File Operations
Each entry in the per process table points to a
system wide open file table.
The system wide table contains process
independent information.
Once a file has been opened by one process, the
system wide table includes an entry for the file.
The open file table also has an open count
associated with each file to indicate how many
processes have the file open.
File Operations
File pointer System must keep track of the last read
FileofOperations
Disk location
the file The information
needed to locate the file on disk is kept in
memory so that the system does not have to read
it from disk for each operation.
Access rights Each process opens a file a
file in an access mode. This information is stored
on the per process table so the OS can allow or
deny subsequent I/O requests.
FILE OPERATIONS
File locks allow one process to lock a file and
prevent other processes from gaining access to it.
File locks are useful for files that are shared by
several processes.
A shared lock is where several processes can
acquire the lock concurrently.
An exclusive lock is where only one process at a
time can acquire such a lock.
File types
A common technique for implementing file types is
a name and
type
File Structure
File types also can be used to indicate the internal
structures.
structures.
the user.
directories.
called a link.
directory.
File Concept
Contiguous logical address space
Types:
Data
numeric
character
binary
Program
File Structure
None - sequence of words, bytes
Simple record structure
Lines
Fixed length
Variable length
Complex Structures
Formatted document
Can simulate last two with first method by inserting appropriate control
characters
Who decides:
Operating system
Program
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
Open Files
Several pieces of data are needed to manage open files:
File pointer: pointer to last read/write location, per process that has
the file open
File-open count: counter of number of times a file is open to allow
removal of data from open-file table when last processes closes it
Disk location of the file: cache of data access information
Access rights: per-process access mode information
Access Methods
Sequential Access
Direct Access
read next
write next
reset
no read after last write
(rewrite)
read n
write n
position to n
read next
write next
rewrite n
Sequential-access File
Directory Structure
A collection of nodes containing information about all files
Directory
Files
F1
F2
F3
F4
Fn
Disk Structure
Disk can be subdivided into partitions
Disks or partitions can be RAID protected against failure
Disk or partition can be used raw without a file system, or formatted
purpose file systems, frequently all within the same operating system
or computer
Single-Level Directory
A single directory for all users
Naming problem
Grouping problem
Two-Level Directory
Separate directory for each user
Path name
Can have the same file name for different user
Efficient searching
No grouping capability
Tree-Structured Directories
cd /spell/mail/prog
type list
rm <file-name>
Creating a new subdirectory is done in current directory
mkdir <dir-name>
Example: if in current directory /mail
mkdir count
mail
prog
Acyclic-Graph Directories
Have shared subdirectories and files
Solutions:
Entry-hold-count solution
Garbage collection
mount point
Mount Point
File Sharing
File sharing is desirable for users who want to
collaborate and to reduce the effort required to
achieve a computing goal.
Multiple users: When an OS accommodates
multiple users, the issues of file sharing, file
naming and file protection become preeminent.
System mediates file sharing.
The system can either allow a user to access the
files of other users by default or require that a user
specifically grant access to the files.
File Sharing
Sharing of files on multi-user systems is desirable
Sharing may be done through a protection scheme
On distributed systems, files may be shared across a network
Network File System (NFS) is a common distributed file-sharing method
per-user
rights
servers
Standard operating system file calls are translated into remote calls
server failure
Protection
When information is stored in a computer
Types of Access
Complete protection to files can be provided by
prohibiting access.
Systems that do not permit access to the files of
ii. Write
iii. Execute
iv. Append
controlled.
Access Control
The most common approach to the protection problem
Access Control
The main problem with access lists is their
length.
each file:
a)
b)
c)
b) group access
c) public access
RWX
111
RWX
110
RWX
001
appropriate access.
owner
chmod
group
761
public
game
game
Access Control
If only one password is used for all the files, then once it is
discovered, all files are accessible.
End of Chapter 10