Upload
kirtidhamija16
View
67
Download
2
Tags:
Embed Size (px)
DESCRIPTION
this ppt gives an intro to files.
Citation preview
FILES
WHAT ARE FILES?
In general, a file is a sequence of bits, bytes, lines or records whose meaning is defined by the files creator and user.
The file can be indexed, structured, etc. The file is an entry in a directory. The file may have attributes (name, creator,
date, type, permissions).
FILE STRUCTURE File structure is a structure, which is
according to a required format that operating system can understand.
A file has a certain defined structure according to its type.
A text file is a sequence of characters organized into lines.
A source file is a sequence of procedures and functions.
An object file is a sequence of bytes organized into blocks that are understandable by the machine.
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 Create Write Read Reposition within file Delete Truncate
FILE TYPES
FUNCTIONS OF FILE SYSTEM
File system in OS provide the way to create and access the files.
How the memory is allocated to files and how the addresses are saved regarding to each file.
FILE ACCESS METHODS
File access refers to the manner in which the records of a file may be accessed.
There are several ways to access files Sequential access Direct/Random access Indexed sequential access
SEQUENTIAL ACCESS A sequential access is that in which the records
are accessed in some sequence i.e the information in the file is processed in order, one record after the other.
This access method is the most common one. Example: Compilers usually access files in this
fashion. Retrieving from sequential file:
To access records, it is necessary to read the file from beginning to examine each record in sequence until the desired record is located.
Appending a sequential file:The append operation refers to adding more records to an existing file. The following operations are done for the purpose of appending a file. Open the file. Read the file till EOF is encountered. Read the data to be added. Write the data on the file. Close the file.
DIRECT / RANDOM ACCESS Random access file organization provides,
accessing the records directly.
Each record has its own address on the file with by the help of which it can be directly accessed for reading or writing.
The records need not be in any sequence within the file and they need not be in adjacent locations on the storage medium.
Method useful for disks. There are no restrictions on which blocks are
read/written in any order. User now says "read n" rather than "read next".
INDEXED SEQUENTIAL ACCESS
This approach combines the advantages of both sequential and direct file access.
An index is created for each file which contains pointers to various blocks.
Index is searched sequentially and its pointer is used to access the file directly.
Example to understand Indexed Sequential Access
(Prime Area)
FILE ALLOCATION METHODS
Files are allocated disk spaces by operating system.
Allocation methods are for Effective disk space utilization Allow fast file access
Operating systems deploy following three main ways to allocate disk space to files. Contiguous Allocation Linked Allocation Indexed Allocation
CONTIGUOUS ALLOCATION
Each file occupies a set of contiguous blocks on the disk.
Simple – only starting location (block ) and length (number of blocks) are required.
Random access. Can be used for both sequential and
direct files.
Example: If file is n block long and starts at location b, then, the blocks
occupied are b, b+1, b+2…..b+n-1 . The directory entry for file has
Name Starting address Length
PROBLEMS Finding space for a new file or a resized file.
Determining size requirements.
External fragmentation of the hard disk.
LINKED ALLOCATION
Each file is a linked list of disk blocks, scattered anywhere on the disk.
Directory contains link / pointer to first block of a file.
There's no external fragmentation since each request is for one block.
Method can only be effectively used for sequential files.
This method is inefficient for direct files.
EXAMPLE
INDEXED ALLOCATION
Provides solutions to problems of contiguous and linked allocation.
A index block is created having all pointers to files.
Each file has its own index block which stores the addresses of disk space occupied by the file.
Directory contains the addresses of index blocks of files.
EXAMPLE
Method suffers from wasted space since, for small files, most of the index block is wasted
If the index block is too small, we can: Link several together Use a multilevel index Combined scheme
PROTECTION We want to keep our information safe from
physical damage(reliability) and improper access(protection).
We can protect our information by controlled access.
Types of access Read Write Execute Delete etc.
ACCESS CONTROL This is the most common approach. ALCs(access control lists) are maintained. The main problem of ALCs is their length. The technique has two undesirable
consequences: Construction of list is tedious. Size of the directory once defined cannot
be changed
This problem can be resolved by using condense access list.
Three classifications of users is defined: OWNER: the user who creates the file. GROUP: a set of user who are sharing the file
and need similar access. UNIVERSE: all other users in the system.
Eg. UNIX system defines three fields i.e. rwx r- controls read access w- controls write access x- controls execution
DIFFICULTY: assigning the precedence when permission and ACLs conflict.
OTHER METHODS OF PROTECTION
PROTECTION THROUGH PASSWORD: To associate password with each file. Use a separate password for each file. But it would
be a tedious job for the user to remember all the passwords.
Solution to this is to choose same password but if the password is once known to someone else than all the data will be revealed.
Hence, the security in this method is on all or nothing basis.
THANK YOU