This document discusses file management concepts including files, file attributes, file operations, file types, file structure, and access methods. Key points include:
- Files represent named collections of related information stored on secondary storage.
- File attributes include name, identifier, type, location, size, protection, and time/date information.
- Basic file operations are creating, writing, reading, repositioning, deleting, and truncating files.
- File types include ordinary files, directory files, and special files which represent devices.
- File structure and access methods like sequential, direct, and indexed access determine how information is organized and retrieved from files.
2. File Concept
Computer store information in various storage media
OS provides a uniform logical view of information storage.
These storage devises are nonvolatile.
Physical properties of storage devices are mapped into logical view by OS called as
file.
File is named collection of related information that is recorded on secondary
storage.
Commonly files represent programs and data.
Information in file defined by creator of file.
In general file is sequence of bits, bytes, lines or records defined by user or creator.
3. File Attributes
File attributes varies from one OS to another but typically consists of:
1. Name: string of character and symbolic file name is the only information kept in
human readable form.
2. Identifier : unique tag, usually a number identifies a file within a file system. It is
non human readable name for file.
3. Type: this information is needed for system to support different types of files.
4. Location: pointer to device and location of file on device.
5. Size: current size of file (bytes, words or blocks) and possibly maximum allowed
size is included in this attribute.
6. Protection: access control information determines who can do reading, writing,
executing and so on.
7. Time, Date and User identification: this information kept for creation, last
modification and last use. Useful for protection security and usage monitoring.
4. File Operations
Six basic operations on files:
1. Creating a file: Two steps necessary for file creation. First find space for file in file
system. Second entry for a new file must be made in a directory.
2. Writing a file: To write into a file we make a system call specifying both file name
and content to write. Write pointer must be updated when write occurs.
3. Reading a file: To read from a file we make a system call specifying both file name
and where the block of the file should be put.
4. Repositioning within file: directory searched for the appropriate entry and the
current file-position-pointer is repositioned to given value. Need not any actual IO.
Also known as file seek.
5. File Operations
5. Deleting a File: To delete a file, we search directory for named entry. Having found
associated directory entry, we release all file space, so that it can be used by others.
6. Truncating a file: The user may want to erase content of file but keep its attributes.
Rater than deletion and recreation.
Other common operations are
1. Appending
2. Renaming
3. copy
6. File Types
Operating System recognize type of file and then operate on file in reasonable
ways.
Technique for implement file types is to include the types as part of file name.
Filename is divided into two parts file name and extension separated by period
character.
example: data.txt, add.c, server.java
System uses extension to indicate type of file and type of operation that can be
done on that file.
7. File Types
1. Ordinary files
These are the files that contain user information.
These may have text, databases or executable program.
The user can apply various operations on such files like add, modify, delete or even remove the
entire file.
2. Directory files
These files contain list of file names and other information related to these files.
3. Special files
These files are also known as device files.
These files represent physical device like disks, terminals, printers, networks, tape drive etc.
These files are of two types −
1. Character special files − data is handled character by character as in case of terminals or
printers.
2. Block special files − data is handled in blocks as in the case of disks and tapes.
8.
9. File Structure
File types can also be used to indicate internal structure of file.
A File Structure should be according to a required format that the operating
system can understand and read.
1. A text file is a sequence of characters organized into lines.
2. A source file is a sequence of procedures and functions.
3. An object file is a sequence of bytes organized into blocks that are understandable
by the machine.
4. When operating system defines different file structures, it also contains the code to
support these file structure. Unix, MS-DOS support minimum number of file
structure.
10. Access Methods
File store information
Information must be accessed as needed and read into computer memory in
several ways
1. Sequential Access
Simplest method.
Information in the file is processed in order, one record after another.
Editors and compilers usually access files in this fashion.
Read command cause a pointer to be moved a head by one.
Write command allocate space for the record and move the pointer to the new End
Of File.
read next : reads next portion of file
write next : writes to next portion of file
11. Access Methods
2. Direct Access (Relative Access)
File is made up of fixed length of logical records that allow programs to read and
write records rapidly in no particular order.
Based on disk model of a file.
File is viewed as numbered sequence of blocks or records.
Then we read block 14, then 34 and then block 5.
No restriction on order of reading and writing of blocks.
Used to immediate access of large amount of information.
Databases.
File operations as modified including block number as a parameter. Read n, write n
Block number is provided by user to OS is a relative block number.
12.
13. Access Methods
3. Other access Methods
Built on top of the direct access method
Involve index for a file.
Index contains pointers to various blocks.
To find a record in a file, we first search the index, then use pointer to access file
directly and to find desired record.
With large file index file becomes too large to kept in memory. Solution is to create
index for index.