2. Introduction
All computer applications need to store and retrieve
information.
Things to be consider
Store a very large amount of information.
Information must survive after the termination of
process.
Multiple processes must be able to access the
information concurrently.
3. solution
Need to store the information on disks and other
external media in units called files.
Process can read and write whenever needed.
Information stored in units is persistent.
information disappear when its owner explicitly
removes it.
4. File
It is a uniform logical storage unit.
Its a abstract mechanism.
Named collection of related information, which is
stored on secondary storage.
Managed by operating system.
5. File Naming
It provides a way to store and retrieve the information
later.
Used to shield the user from details of information
storage and disk working.
Rules for file naming
String of 1 to 8 letters
Digits and special characters
Some allow string from 1 to 255 characters
Case sensitivity
Extensions
6. File Naming
Rules for UNIX Operating System
Allows string from 1 to 255 characters
Name String is case sensitive
Varying size Extensions to separate file names
Example
PROGRAM1, Program1, program1
program1.java.bz2 , program1.c
7. File Naming
Rules for MS-DOS Operating System and Windows
Allows string from 1 to 255 characters
Name String is non -case sensitive
1 to 3 character Extensions to separate file names
Example
PROGRAM1, Program1, program1 {same}
program1.java
8. File Extensions
Extensions Meaning
File.bak Backup File
File.c C source program
File.gif Graphical Interchange Format Image
File.html Web document
File.iso ISO image of a CD-ROM
File.jpg Joint Photographic Expert Group encoded still pictures
File.mp3 Music encoded in MPEG layer3
File.mpg Movie encoded with MPEG standard
File.o Object file
File.pdf Portable Document Format File
File.txt General Text File
File.zip Compressed File
9. File Structure
Ways of File Structure
Unstructured Sequence of Bytes
Collection of bytes
Operating System does not know or care what is in the
File
Handled by user
Used in UNIX and WIN 98
Advantages:
Provides maximum flexibility.
User can save anything in it.
Disadvantage:
No simultaneous read and write operation .
11. File Structure
Ways of File Structure
Sequence of Fixed length Records
Collection of fixed length records.
Used in older systems.
Advantages:
Read and write operation on different record done
simultaneously.
Disadvantage:
Sequential search so time consuming
13. File Structure
Ways of File Structure
Tree Structure
File consists of a tree of records with varying size.
Each record contains a key Field.
Tree is sorted based on key fields.
Used in large mainframe systems
Advantages:
Less time to search a record.
14. File Structure
Tree Structure
Ant Fox Pig
Cat Cow Dog Goat Lion Owl Pony Rat Worm
Hen Horse Lamb
16. File Structure
Four Terms
Fields
Basic elements of data
Has 3 sub fields
Example emp_name
Records
Collection of related fields.
Has sub fields like name and length
Example emp_record
17. File Structure
Four Terms
File
Collection of similar records.
Treated as a single entity by user.
Has sub fields like name, creation date ,length.
Example : payroll system.
Database
Collection of related data ( one or more files).
Has sub fields like name and length
Example: organizations data or project
18. File Types
Operating system supports several types of files
Regular File
Character special File
Block Special File
Metadata File
Directories
19. File Types
Regular Files: Two types
ASCII Files
Consists lines of text
Uses carriage return or line feed character
Display or print as it is
Edited by any editor
Easy to link
Binary Files
Consists of bytes
Difficult to link
20. File Types
UNIX executable binary file
Magic Number
Text Size
Data Size
BSS Size
Symbol Table Size
Entry Point
Flag
text
Data
Relocation Bit
Symbol Table
Header
21. File Type
Unix Binary archive File
Header
Object module
Header
Object module
Header
Object module
Header
Object module
Module name
Date
Owner
Protection
Size
22. File Attribute
Every file has a name and additional information
List of Attributes
Name
Protection
password
Identifier
Type
Location
Creator
owner
Size
Time and Date of creation
Hidden flag
Read-only flag
Binary or ASCII file
Lock flag
System flag
23. File Access Methods
Types of File Access Methods
Sequential Access Method
Random or Direct Access Method
Other Access Methods
24. File Access Methods
Sequential access method
Simple access method.
Information of the file is processed in order.
Supports following operations
read_next()
write_next()
rewind()
Skip(n) records Current position
Rewind read/write
start end
25. File Access Methods
Random or Direct access method
It is based on disk model.
Allows random access.
File is viewed as a numbered sequence of records.
Used to access large amount of data.
Supports following operations
read(n)
write(n)
jump to record n
Query current record
26. File Access Methods
Other Access method(Indexed)
Build on top of direct access method
To search the record
Search index for file pointer
Search file in directory
Search a required record
Key Field Pointer
radha ----
raj -----
Radha Social-security age --
Index Relative File
27. File Operations
Operations required to define a file properly.
Operations are nothing but OS system calls.
List of operations
Creating a file
Writing a file
Reading a file
Append a file
Seek operation / repositioning within a file
Deleting a file
Get attribute
Set attribute
Rename
Truncating a File
28. File System Implementation
Why to use disk
Deals with
How the files and directories are stored
How they are managed
How it work efficiently
File system layout
MBR pt partition1 partition2 partition3 -----
Entire disk space
Boot
block
Super
block
Free space
mgmt
I-nodes Root dir Files &
directory
Unix file system
Editor's Notes
Query current record – used to return back to this record later
Query current record – used to return back to this record later