SlideShare a Scribd company logo
1 of 11
Download to read offline
Unit VIII
FILE SYSTEM
1. File Concept
Computers can store information on various storage media, such as magnetic disks, magnetic tapes,
and optical disks. So that the computer system will be convenient to use, the operating system
provides a uniform logical view of information storage. The operating system abstracts from the
physical properties of its storage devices to define a logical storage unit, the file. Files are mapped
by the operating system onto physical devices. These storage devices are usually nonvolatile, so the
contents are persistent through power failures and system reboots.
A file is a named collection of related information that is recorded on secondary storage. The
information in a file is defined by its creator. Many different types of information may be stored in a
file- such as source programs, object programs, executable programs, numeric data, text, payroll
records, graphic images, sound recordings, and so on. 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 management system is the software which empowers users and applications to organize and
manage the data that resides on secondary storage. The file management system is supposed to hide
all device-specific aspects of file manipulation from users. The organization and management of
files may involve access, updates and several other file operations. The common responsibilities of
the file-management system include the following:
• Mapping of access requests from logical to physical file-address apace
• Transmission of file elements between main and secondary storage
• Management of the secondary storage, such as keeping track of the status, allocation, and
deallocation of space
• Support for protection and sharing of files and the recovery and possible restoration of files
after system crashes
A file's attributes consist of the following:
• Name. The symbolic file name is the only information kept in human-readable form.
• Identifier. This unique tag, usually a number, identifies the file within the file system; it is
the non-human-readable name for the file.
• Type. This information is needed for systems that support different types of files.
• 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 (in bytes, words, or blocks) and possibly the maximum
allowed size are included in this attribute.
• Protection. Access-control information determines who can do reading, writing, executing,
and so on.
• Time, date, and user identification. This information may be kept for creation, last
modification, and last use. These data can be useful for protection, security, and usage
monitoring.
A generalization of file services.
File operations are the functions that can be carried out on a file. For handling these operations,
operating system provides some services in the form of system calls. The various operations and the
related system calls are given below:
• Create a file. Two steps are necessary to create a file. First, space in the file system must be
found for the file. Second, an entry for the new file must be made in the directory, which
contains name, location and other such pieces of information. The system call used for this
operation is create.
• Open a file. The system call open, accepts the file name and the access mode (read, write
and execute) as parameters. The OS searches the directory entry table for the file name and
checks if access mode is allowed. It then copies the directory entry of the file to the open-
file table (this table stores information about the files that are open at a particular time).
• Write to a file. To write a file, write system call is uded which requires both the name of the
file and the information to be written to the file. Given the name of the file, the system
searches the directory to find the file's location. The system must keep a write pointer to the
location in the file where the next write is to take place. The write pointer must be updated
whenever a write occurs.
• Read a file. To read from a file, we use system call read that specifies the name of the file
and where (in memory) the next block of the file should be put. Again, the directory is
searched for the associated entry, and the system needs to keep a read pointer to the location
in the file where the next read is to take place. Once the read has taken place, the read
pointer is updated.
• Repositioning within a file/Seek file. To position the pointer to a specific position in a file,
the seek system call is used. Once the pointer is positioned, data can be read from and
written to that position.
• Close a file. When all operations on a file are completed, it must be closed using the close
system call. The OS searches and erase the file entry from the open-file table.
• Delete a file. When a file is not required, the delete system call searches the directory for the
named file. Having found the associated directory entry, all file space is released, so that it
can be reused by other files, and erase the directory entry.
• Append a file. To add data at the end of an existing file, append system call is used. It
works similar to the write system call, except that it positions the pointer at the end of the
file and then performs the write operation.
• Rename file. To change the name of existing file, rename system call is used. This system
call changes the existing entry for the file name in the directory to the new file name.
Listing of some file types commonly used:
Ques. What is a file? Define File Management System.
Ques. List file attributes. Which operations are performed on files? List some file types
commonly used.
2. Access Methods
Information stored in files are accessed and read into computer memory in several ways:
1. Sequential Access: In simplest access method information in the file is processed in order,
one record after the other. A read operation-read next-reads the next portion of the file and
automatically advances a file pointer, which tracks the I/O location. Similarly, the write
operation-write next-appends to the end of the file and advances to the end of the newly
written material (the new end of file). For example, editors and compilers usually access
files in this fashion. Such a file can be reset to the beginning by rewind operation.
2. Direct Access: For direct access, a file is viewed as a numbered sequence of fixed-length
blocks or records, that allow programs to read and write records rapidly in no particular
order. Thus, we may read block 14, then read block 53, and then write block 7. Direct-access
files are of great use for immediate access to large amounts of information. Databases are
often of this type.
For the direct-access method, the file operations must be modified to include the block
number as a parameter. Thus, we have read n, where n is the block number, rather than read
next, and write n rather than write next.
3. Other Access Methods (Indexed sequential access): This method involves the
construction of an index for the file. The index contains pointers to the various blocks. To
find a record in the file, we first search the index and then use the pointer to access the file
directly and to find the desired record.
Following figure shows an example of indexed sequential-access method, where the file is
kept sorted on a defined key (last name). To find a particular item, we first make a search of
the index file, which provides the block number of the secondary index. This block
containing the desired record is read in and thus sequential search on index is performed.
With large files, the index file itself may become too large to be kept in memory. One
solution is to create an index for the index file. The primary index file would contain
pointers to secondary index files, which would point to the actual data items.
3. Directory structure
A computer system stores numerous data on disks. To manage this data, the disk is divided into one
or more partitions (also known as volumes) and each partition contains information about the files
stored in it. This information is stored in a directory. In simplest terms, directory is a flat file that
stores information about the files and subdirectories and organizes files hierarchically. The system
views them differently from ordinary files.
Directory operations include:
• Create a file – new files can be created and added to the directory as new directory entry.
• Search for a file – when a file is required, corresponding entry is serached in the directory.
• Delete a file – a file erase from the directory, when it is no longer required.
• List a directory – contents of the directory entry is listed.
• Rename a file – a file may be renamed, wchich may change its position in the directory.
• Traverse the file system – every file in the directory can be accessed.
Following are the commonly used directory structure:
1. Single-Level Directory
It is the simplest form of directory structure, in which a single directory contains all files for all
users. Sometimes this directory is referred to as root directory. It is simple to implement, but the
drawback is that no two files have the same name.
2. Two-Level Directory
In this directory structure, each user gets their own directory space called user file directory
(UFD). File names only need to be unique within a given user's directory.
A master file directory (MFD) is used to keep track of each users directory, and must be
maintained when users are added to or removed from the system.
3. Hierarchical-Level Directory/Tree-Structured Directories
The two-level hierarchy eliminates file name conflicts between users. But another problem is that
users with many files may want to group them in smaller subgroups. So, two-tiered directory
structure is extended for new directory structure called Hierarchical Directory Structure.
Here each user / process has the concept of a current directory from which all ( relative ) searches
take place. Files may be accessed using either absolute pathnames (relative to the root of the tree)
or relative pathnames (relative to the current directory).
All these three directory structures are shown as (a), (b) and (c) respectively in the above figure. A,
B and C represents three different users. Enclosing rectangles represent directories of corresponding
users and enclosing circles represent files of those users.
4. Acyclic-Graph Directories:
A tree structure prohibits the sharing of files or directories. An acyclic graph( a graph with no
cycles) allows directories to share subdirectories and files. The acyclic graph is a natural
generalization of the tree-structured directory scheme.
Shared files and subdirectories can be implemented in several ways: 1) A common way, used by
many of the UNIX systems, is to create a new directory entry called a link. A link is effectively a
pointer to another file or subdirectory. 2) Another common approach to implement shared files is
simply to duplicate all information. Thus, both entries are identical and equal.
5. General Graph Directory
The primary advantage of an acyclic graph is the relative simplicity of the algorithms to traverse the
graph and to determine when there are no more references to a file. We want to avoid traversing
shared sections of an acyclic graph twice, mainly for performance reasons. With acyclic-graph
directory structures, a value of 0 in the reference count means that there are no more references to
the file or directory, and the file can be deleted. However, when cycles exist, the reference count
may not be 0 even when it is no longer possible to refer to a directory or file, because of self-
referencing concept.
So, A serious problem with using an acyclic-graph structure is ensuring that there are no cycles. If
we start with a two-level directory and allow users to create subdirectories, a tree-structured
directory results. It should be fairly easy to see that simply adding new files and subdirectories to an
existing tree-structured directory preserves the tree-structured nature. However when we add links,
the tree structure is destroyed, resulting in a simple graph structure.
Ques: What is a Directory? What are the commonly used directory structure?
Ques: Differentiate between a file and a directory.
Ques: Justify the need of file system.
Ans: File systems provide efficient and convenient access to the disk by allowing data to be stored,
located, and retrieved easily. A file system provides solution to following design problems:
1. To define how the file system should look to the user. This task involves defining a file and
its attributes, the operations allowed on a file, and the directory structure for organizing
files.
2. To create algorithms and data structures to map the logical file system onto the physical
secondary-storage devices.
The file system itself is generally composed of many different levels as shown in following figure.
Each level uses the features of lower levels to create new features for use by higher levels.
The lowest level, the I/O control, consists of device drivers and interrupt handlers to transfer
information between the main memory and the disk system.
The basic file system needs only to issue generic commands to the appropriate device driver to read
and write physical blocks on the disk. Each physical block is identified by its numeric disk address
(for example, drive 1, cylinder 73, track 2, sector 10).
The file-organization module knows about files and their logical blocks, as well as physical blocks.
It also includes the free-space manager, which tracks unallocated blocks and provides these blocks
to the file-organization module when requested.
Finally, the logical file system manages metadata information, which includes all of the file-system
structure except the actual data (or contents of the files). It is also responsible for protection and
security.
To create a new file, an application program calls the logical file system. The logical file system
knows the format of the directory structures. To create a new file, it allocates a new FCB. The
system then reads the appropriate directory into memory, updates it with the new file name and
FCB, and writes it back to the disk.
Ques: What are the structures used in file-system implementation?
File system provide efficient and convenient access to the disk by allowing data to be stored,
located, and retrieved easily. On disk, the file system may contain information about the total
number of blocks, the number and location of free blocks, the directory structure, and individual
files. Several on-disk and in-memory structures are used to implement a file system.
Important data structures stored on disk are briefly explained here:
• A boot-control block, ( per volume ) can contain information needed by the system to boot
an operating system from that volume. If the disk does not contain an operating system, this
block will be left empty.
• A volume control block, (per volume) contains volume (or partition) details such number of
blocks in the partition, size of blocks, free-block counts, and free-block pointers.
• A directory structure (per file system), containing file names and pointers to corresponding
FCBs. UNIX uses inode numbers, and windows uses a master file table.
• The File Control Block, FCB, (per file) contains many details about the file. It has a unique
identifier number to allow association with a directory entry. UNIX stores this information
in inodes, and windows maintains a relational database structure within the master file table.
There are also several key data structures stored in memory:
• An in-memory mount table, contains information about each mounted volumes. (Before
you can access the files on a file system, you need to mount the file system. Mounting a file
system attaches that file system to a directory (mount point) and makes it available to the
system.)
• An in-memory directory cache holds the directory information of recently accessed
directories.
• A system-wide open file table, contains a copy of the FCB of each open file, as well as
some other related information.
• A per-process open file table, contains a pointer to the appropriate entry in the system-wide
open-file table, as well as other information.
Ques: Explain allocation strategies: Contoguous, linked and indexed.
Files are allocated disk spaces by operating system. The main problem is how to allocate space to
these files so that disk space is utilized effectively and files can be accessed quickly. Three major
methods of allocating disk space are in wide use:
1. Contiguous Allocation: It requires that each file occupy a set of contiguous blocks on disk.
Disk addresses define a linear ordering on the disk. Contiguous allocation of a file is defined
by the disk address and length (in block units) of the first block. If the file is n blocks long
and starts at location b, then it occupies blocks b, b + 1, b + 2, ... , b + n – 1.
Advantage:
1. Accessing a file that has been allocated contiguously is easy.
2. Both sequential and direct access can be supported by contiguous allocation.
Drawbacks:
1. difficulty in finding space for a new file.
2. As files are allocated and deleted, the free disk space is broken into little pieces
resulting into external fragmentation.
2. Linked Allocation: With this linked allocation, each file is a linked list of disk blocks; the
disk blocks may be scattered anywhere on the disk. The directory contains a pointer to the
first and last blocks of the file. Each block contains a pointer to the next block. These
pointers are not made available to the user. For example, linked allocation for a file of five
blocks might start at block 9 and continue at block 16, then block 1, then block 10, and
finally block 25 can be done in following way:
To create a new file, we simply create a new entry in the directory. With linked allocation,
each directory entry has a pointer to the first disk block of the file. The size of a file need not
be declared when that file is created. A file can continue to grow as long as free blocks are
available. To read a file, we simply read blocks by following the pointers from block to
block.
Advantage: There is no external fragmentation with linked allocation, and any free block on
the free-space list can be used to satisfy a request.
Drawbacks:
1. The major problem is that it can be used effectively only for sequential-access files.
To find the ith block of a file, we must start at the begining of that file and follow the
pointers until we get to the ith block. So, it is inefficient to support a direct-access
capability for linked-allocation files.
2. Each file requires slightly more space because it stores pointers to next block
3. Indexed Allocation: Linked allocation solves the external-fragmentation and size-
declaration problems of contiguous allocation. However, linked allocation cannot support
efficient direct access, since the pointers to the blocks are scattered all over the disk and
must be retrieved in order. Indexed allocation solves this problem by bringing all the
pointers together into one location: the index block.
Each file has its own index block, which is an array of disk-block addresses. The directory
contains the address of the index block only. When the file is created, all pointers in the
index block are set to nil. When the ith block is first written, a block is obtained from the
free-space manager and its address is put in the ith index-block entry. To find and read the
ith block, we use the pointer in the ith index-block entry.
Advantage: Indexed allocation supports direct access, without suffering from external
fragmentation, because any free block on the disk can satisfy a request for more space.
Drawback: Indexed allocation does suffer from wasted space because with indexed
allocation, an entire index block must be allocated, even if only one or two pointers will be
non-nil. However, the pointer overhead of the index block is generally greater than the
pointer overhead of linked allocation.
This point raises the questions of how big the index block should be, and how it should be
implemented. There are several approaches:
1. Linked scheme. An index block is normally one disk block. Thus, it can be read and
written directly by itself. To allow for large files, we can link together several index
blocks.
2. Multilevel index. A variant of linked representation uses a first-level index block to
point to a set of second-level index blocks, which in turn point to the file blocks. To
access a block, the operating system uses the first-level index to find a second-level
index block and then uses that block to find the desired data block. This approach
could be continued to a third or fourth level, depending on the desired maximum file
size.
3. Combined scheme. Another alternative, used in the Unix File Systetm, is to keep the
first, say, 15 pointers of the index block in the file's inode. The first 12 of these
pointers point to direct blocks (data blocks). Thus, the data for small files (of no
more than 12 blocks) do not need a separate index block. If the block size is 4 KB,
then up to 48 KB of data can be accessed directly. The next three pointers point to
indirect blocks. The first points to a single indirect block, which is an index block
containing not data but the addresses of blocks that do contain data. The second
points to a double indirect block, which contains the address of a block that
contains the addresses of blocks that contain pointers to the actual data blocks. The
last pointer contains the address of a triple indirect block.

More Related Content

What's hot

Allocation methods continuous method.47
Allocation methods continuous method.47 Allocation methods continuous method.47
Allocation methods continuous method.47 myrajendra
 
File System Interface
File System InterfaceFile System Interface
File System Interfacechandinisanz
 
Linked allocation 48
Linked  allocation 48Linked  allocation 48
Linked allocation 48myrajendra
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OSvampugani
 
Memory management
Memory managementMemory management
Memory managementcpjcollege
 
Paging and Segmentation in Operating System
Paging and Segmentation in Operating SystemPaging and Segmentation in Operating System
Paging and Segmentation in Operating SystemRaj Mohan
 
Shell and its types in LINUX
Shell and its types in LINUXShell and its types in LINUX
Shell and its types in LINUXSHUBHA CHATURVEDI
 
Database backup and recovery
Database backup and recoveryDatabase backup and recovery
Database backup and recoveryAnne Lee
 
file system in operating system
file system in operating systemfile system in operating system
file system in operating systemtittuajay
 
File Management in Operating System
File Management in Operating SystemFile Management in Operating System
File Management in Operating SystemJanki Shah
 
11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMSkoolkampus
 
File Management in Operating Systems
File Management in Operating SystemsFile Management in Operating Systems
File Management in Operating Systemsvampugani
 

What's hot (20)

Data warehousing
Data warehousingData warehousing
Data warehousing
 
Allocation methods continuous method.47
Allocation methods continuous method.47 Allocation methods continuous method.47
Allocation methods continuous method.47
 
File System Interface
File System InterfaceFile System Interface
File System Interface
 
RAID
RAIDRAID
RAID
 
File Management
File ManagementFile Management
File Management
 
Disk structure
Disk structureDisk structure
Disk structure
 
File allocation methods (1)
File allocation methods (1)File allocation methods (1)
File allocation methods (1)
 
Linked allocation 48
Linked  allocation 48Linked  allocation 48
Linked allocation 48
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
 
Disk management
Disk managementDisk management
Disk management
 
Paging and segmentation
Paging and segmentationPaging and segmentation
Paging and segmentation
 
Memory management
Memory managementMemory management
Memory management
 
Paging and Segmentation in Operating System
Paging and Segmentation in Operating SystemPaging and Segmentation in Operating System
Paging and Segmentation in Operating System
 
Shell and its types in LINUX
Shell and its types in LINUXShell and its types in LINUX
Shell and its types in LINUX
 
Database backup and recovery
Database backup and recoveryDatabase backup and recovery
Database backup and recovery
 
file system in operating system
file system in operating systemfile system in operating system
file system in operating system
 
File Management in Operating System
File Management in Operating SystemFile Management in Operating System
File Management in Operating System
 
11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS
 
File Management in Operating Systems
File Management in Operating SystemsFile Management in Operating Systems
File Management in Operating Systems
 
FIle Management.ppt
FIle Management.pptFIle Management.ppt
FIle Management.ppt
 

Viewers also liked

Ch11: File System Interface
Ch11: File System InterfaceCh11: File System Interface
Ch11: File System InterfaceAhmar Hashmi
 
Os solved question paper
Os solved question paperOs solved question paper
Os solved question paperAnkit Bhatnagar
 
Operating system concepts (notes)
Operating system concepts (notes)Operating system concepts (notes)
Operating system concepts (notes)Sohaib Danish
 
Operating Systems - File Management
Operating Systems -  File ManagementOperating Systems -  File Management
Operating Systems - File ManagementDamian T. Gordon
 
FINAL DEMO TOPIC
FINAL DEMO TOPICFINAL DEMO TOPIC
FINAL DEMO TOPICbunso18
 
TKP notes for Java
TKP notes for JavaTKP notes for Java
TKP notes for JavaLynn Langit
 
java-Unit4 chap2- awt controls and layout managers of applet
java-Unit4 chap2- awt controls and layout managers of appletjava-Unit4 chap2- awt controls and layout managers of applet
java-Unit4 chap2- awt controls and layout managers of appletraksharao
 
Chapter iv(modern gui)
Chapter iv(modern gui)Chapter iv(modern gui)
Chapter iv(modern gui)Chhom Karath
 
Java Swing Custom GUI MVC Component Tutorial
Java Swing Custom GUI MVC Component TutorialJava Swing Custom GUI MVC Component Tutorial
Java Swing Custom GUI MVC Component TutorialSagun Dhakhwa
 
Chapter 10 - File System Interface
Chapter 10 - File System InterfaceChapter 10 - File System Interface
Chapter 10 - File System InterfaceWayne Jones Jnr
 
Virtual memory managment
Virtual memory managmentVirtual memory managment
Virtual memory managmentSantu Kumar
 
Operating system notes
Operating system notesOperating system notes
Operating system notesSANTOSH RATH
 
Teaching demonstration evaluation form
Teaching demonstration evaluation formTeaching demonstration evaluation form
Teaching demonstration evaluation forms junaid
 
GUI Programming In Java
GUI Programming In JavaGUI Programming In Java
GUI Programming In Javayht4ever
 

Viewers also liked (20)

Memory Management
Memory ManagementMemory Management
Memory Management
 
Chapter 1 swings
Chapter 1 swingsChapter 1 swings
Chapter 1 swings
 
Ch11: File System Interface
Ch11: File System InterfaceCh11: File System Interface
Ch11: File System Interface
 
Os solved question paper
Os solved question paperOs solved question paper
Os solved question paper
 
Operating system concepts (notes)
Operating system concepts (notes)Operating system concepts (notes)
Operating system concepts (notes)
 
Operating Systems - File Management
Operating Systems -  File ManagementOperating Systems -  File Management
Operating Systems - File Management
 
FINAL DEMO TOPIC
FINAL DEMO TOPICFINAL DEMO TOPIC
FINAL DEMO TOPIC
 
TKP notes for Java
TKP notes for JavaTKP notes for Java
TKP notes for Java
 
java-Unit4 chap2- awt controls and layout managers of applet
java-Unit4 chap2- awt controls and layout managers of appletjava-Unit4 chap2- awt controls and layout managers of applet
java-Unit4 chap2- awt controls and layout managers of applet
 
Chapter iv(modern gui)
Chapter iv(modern gui)Chapter iv(modern gui)
Chapter iv(modern gui)
 
Java Swing Custom GUI MVC Component Tutorial
Java Swing Custom GUI MVC Component TutorialJava Swing Custom GUI MVC Component Tutorial
Java Swing Custom GUI MVC Component Tutorial
 
Chapter 10 - File System Interface
Chapter 10 - File System InterfaceChapter 10 - File System Interface
Chapter 10 - File System Interface
 
Java packages
Java packagesJava packages
Java packages
 
Java swing
Java swingJava swing
Java swing
 
Virtual memory managment
Virtual memory managmentVirtual memory managment
Virtual memory managment
 
Operating system notes
Operating system notesOperating system notes
Operating system notes
 
10 File System
10 File System10 File System
10 File System
 
Teaching demonstration evaluation form
Teaching demonstration evaluation formTeaching demonstration evaluation form
Teaching demonstration evaluation form
 
GUI Programming In Java
GUI Programming In JavaGUI Programming In Java
GUI Programming In Java
 
File management
File managementFile management
File management
 

Similar to File Systems

Learn about the File Concept in operating systems ppt
Learn about the File Concept in operating systems pptLearn about the File Concept in operating systems ppt
Learn about the File Concept in operating systems pptgeethasenthil2706
 
Unit ivos - file systems
Unit ivos - file systemsUnit ivos - file systems
Unit ivos - file systemsdonny101
 
Unit 3 file management
Unit 3 file managementUnit 3 file management
Unit 3 file managementKalai Selvi
 
Unit 3 chapter 1-file management
Unit 3 chapter 1-file managementUnit 3 chapter 1-file management
Unit 3 chapter 1-file managementKalai Selvi
 
File Management & Access Control
File Management & Access Control File Management & Access Control
File Management & Access Control YuvrajWadavale
 
File concept and access method
File concept and access methodFile concept and access method
File concept and access methodrajshreemuthiah
 
file management_osnotes.ppt
file management_osnotes.pptfile management_osnotes.ppt
file management_osnotes.pptHelalMirzad
 
File system in operating system e learning
File system in operating system e learningFile system in operating system e learning
File system in operating system e learningLavanya Sharma
 
File Management – File Concept, access methods, File types and File Operation
File Management – File Concept, access methods,  File types and File OperationFile Management – File Concept, access methods,  File types and File Operation
File Management – File Concept, access methods, File types and File OperationDhrumil Panchal
 
File organization and introduction of DBMS
File organization and introduction of DBMSFile organization and introduction of DBMS
File organization and introduction of DBMSVrushaliSolanke
 

Similar to File Systems (20)

Learn about the File Concept in operating systems ppt
Learn about the File Concept in operating systems pptLearn about the File Concept in operating systems ppt
Learn about the File Concept in operating systems ppt
 
Unit ivos - file systems
Unit ivos - file systemsUnit ivos - file systems
Unit ivos - file systems
 
Chapter 12.pptx
Chapter 12.pptxChapter 12.pptx
Chapter 12.pptx
 
File
FileFile
File
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 
Unit 3 file management
Unit 3 file managementUnit 3 file management
Unit 3 file management
 
Unit 3 chapter 1-file management
Unit 3 chapter 1-file managementUnit 3 chapter 1-file management
Unit 3 chapter 1-file management
 
File Management & Access Control
File Management & Access Control File Management & Access Control
File Management & Access Control
 
File structure
File structureFile structure
File structure
 
File System operating system operating system
File System  operating system operating systemFile System  operating system operating system
File System operating system operating system
 
File concept and access method
File concept and access methodFile concept and access method
File concept and access method
 
Files
FilesFiles
Files
 
file management
 file management file management
file management
 
file management_osnotes.ppt
file management_osnotes.pptfile management_osnotes.ppt
file management_osnotes.ppt
 
File organisation
File organisationFile organisation
File organisation
 
Ch10
Ch10Ch10
Ch10
 
File system in operating system e learning
File system in operating system e learningFile system in operating system e learning
File system in operating system e learning
 
File Management – File Concept, access methods, File types and File Operation
File Management – File Concept, access methods,  File types and File OperationFile Management – File Concept, access methods,  File types and File Operation
File Management – File Concept, access methods, File types and File Operation
 
OS Unit 4.pptx
OS Unit 4.pptxOS Unit 4.pptx
OS Unit 4.pptx
 
File organization and introduction of DBMS
File organization and introduction of DBMSFile organization and introduction of DBMS
File organization and introduction of DBMS
 

More from Shipra Swati

Operating System-Process Scheduling
Operating System-Process SchedulingOperating System-Process Scheduling
Operating System-Process SchedulingShipra Swati
 
Operating System-Concepts of Process
Operating System-Concepts of ProcessOperating System-Concepts of Process
Operating System-Concepts of ProcessShipra Swati
 
Operating System-Introduction
Operating System-IntroductionOperating System-Introduction
Operating System-IntroductionShipra Swati
 
Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8Shipra Swati
 
Fundamental of Information Technology - UNIT 7
Fundamental of Information Technology - UNIT 7Fundamental of Information Technology - UNIT 7
Fundamental of Information Technology - UNIT 7Shipra Swati
 
Fundamental of Information Technology - UNIT 6
Fundamental of Information Technology - UNIT 6Fundamental of Information Technology - UNIT 6
Fundamental of Information Technology - UNIT 6Shipra Swati
 
Fundamental of Information Technology
Fundamental of Information TechnologyFundamental of Information Technology
Fundamental of Information TechnologyShipra Swati
 
Process Synchronization
Process SynchronizationProcess Synchronization
Process SynchronizationShipra Swati
 

More from Shipra Swati (20)

Operating System-Process Scheduling
Operating System-Process SchedulingOperating System-Process Scheduling
Operating System-Process Scheduling
 
Operating System-Concepts of Process
Operating System-Concepts of ProcessOperating System-Concepts of Process
Operating System-Concepts of Process
 
Operating System-Introduction
Operating System-IntroductionOperating System-Introduction
Operating System-Introduction
 
Java unit 11
Java unit 11Java unit 11
Java unit 11
 
Java unit 14
Java unit 14Java unit 14
Java unit 14
 
Java unit 12
Java unit 12Java unit 12
Java unit 12
 
Java unit 7
Java unit 7Java unit 7
Java unit 7
 
Java unit 3
Java unit 3Java unit 3
Java unit 3
 
Java unit 2
Java unit 2Java unit 2
Java unit 2
 
Java unit 1
Java unit 1Java unit 1
Java unit 1
 
OOPS_Unit_1
OOPS_Unit_1OOPS_Unit_1
OOPS_Unit_1
 
Ai lab manual
Ai lab manualAi lab manual
Ai lab manual
 
Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8
 
Fundamental of Information Technology - UNIT 7
Fundamental of Information Technology - UNIT 7Fundamental of Information Technology - UNIT 7
Fundamental of Information Technology - UNIT 7
 
Fundamental of Information Technology - UNIT 6
Fundamental of Information Technology - UNIT 6Fundamental of Information Technology - UNIT 6
Fundamental of Information Technology - UNIT 6
 
Fundamental of Information Technology
Fundamental of Information TechnologyFundamental of Information Technology
Fundamental of Information Technology
 
Disk Management
Disk ManagementDisk Management
Disk Management
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
 
Process Synchronization
Process SynchronizationProcess Synchronization
Process Synchronization
 
Avl excercise
Avl excerciseAvl excercise
Avl excercise
 

Recently uploaded

Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 

Recently uploaded (20)

Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 

File Systems

  • 1. Unit VIII FILE SYSTEM 1. File Concept Computers can store information on various storage media, such as magnetic disks, magnetic tapes, and optical disks. So that the computer system will be convenient to use, the operating system provides a uniform logical view of information storage. The operating system abstracts from the physical properties of its storage devices to define a logical storage unit, the file. Files are mapped by the operating system onto physical devices. These storage devices are usually nonvolatile, so the contents are persistent through power failures and system reboots. A file is a named collection of related information that is recorded on secondary storage. The information in a file is defined by its creator. Many different types of information may be stored in a file- such as source programs, object programs, executable programs, numeric data, text, payroll records, graphic images, sound recordings, and so on. 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 management system is the software which empowers users and applications to organize and manage the data that resides on secondary storage. The file management system is supposed to hide all device-specific aspects of file manipulation from users. The organization and management of files may involve access, updates and several other file operations. The common responsibilities of the file-management system include the following: • Mapping of access requests from logical to physical file-address apace • Transmission of file elements between main and secondary storage • Management of the secondary storage, such as keeping track of the status, allocation, and deallocation of space • Support for protection and sharing of files and the recovery and possible restoration of files after system crashes A file's attributes consist of the following: • Name. The symbolic file name is the only information kept in human-readable form. • Identifier. This unique tag, usually a number, identifies the file within the file system; it is the non-human-readable name for the file. • Type. This information is needed for systems that support different types of files. • 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 (in bytes, words, or blocks) and possibly the maximum allowed size are included in this attribute. • Protection. Access-control information determines who can do reading, writing, executing, and so on.
  • 2. • Time, date, and user identification. This information may be kept for creation, last modification, and last use. These data can be useful for protection, security, and usage monitoring. A generalization of file services. File operations are the functions that can be carried out on a file. For handling these operations, operating system provides some services in the form of system calls. The various operations and the related system calls are given below: • Create a file. Two steps are necessary to create a file. First, space in the file system must be found for the file. Second, an entry for the new file must be made in the directory, which contains name, location and other such pieces of information. The system call used for this operation is create. • Open a file. The system call open, accepts the file name and the access mode (read, write and execute) as parameters. The OS searches the directory entry table for the file name and checks if access mode is allowed. It then copies the directory entry of the file to the open- file table (this table stores information about the files that are open at a particular time). • Write to a file. To write a file, write system call is uded which requires both the name of the file and the information to be written to the file. Given the name of the file, the system searches the directory to find the file's location. The system must keep a write pointer to the location in the file where the next write is to take place. The write pointer must be updated whenever a write occurs. • Read a file. To read from a file, we use system call read that specifies the name of the file and where (in memory) the next block of the file should be put. Again, the directory is searched for the associated entry, and the system needs to keep a read pointer to the location in the file where the next read is to take place. Once the read has taken place, the read pointer is updated. • Repositioning within a file/Seek file. To position the pointer to a specific position in a file, the seek system call is used. Once the pointer is positioned, data can be read from and written to that position. • Close a file. When all operations on a file are completed, it must be closed using the close system call. The OS searches and erase the file entry from the open-file table. • Delete a file. When a file is not required, the delete system call searches the directory for the named file. Having found the associated directory entry, all file space is released, so that it can be reused by other files, and erase the directory entry. • Append a file. To add data at the end of an existing file, append system call is used. It works similar to the write system call, except that it positions the pointer at the end of the file and then performs the write operation. • Rename file. To change the name of existing file, rename system call is used. This system call changes the existing entry for the file name in the directory to the new file name.
  • 3. Listing of some file types commonly used: Ques. What is a file? Define File Management System. Ques. List file attributes. Which operations are performed on files? List some file types commonly used. 2. Access Methods Information stored in files are accessed and read into computer memory in several ways: 1. Sequential Access: In simplest access method information in the file is processed in order, one record after the other. A read operation-read next-reads the next portion of the file and automatically advances a file pointer, which tracks the I/O location. Similarly, the write operation-write next-appends to the end of the file and advances to the end of the newly written material (the new end of file). For example, editors and compilers usually access files in this fashion. Such a file can be reset to the beginning by rewind operation.
  • 4. 2. Direct Access: For direct access, a file is viewed as a numbered sequence of fixed-length blocks or records, that allow programs to read and write records rapidly in no particular order. Thus, we may read block 14, then read block 53, and then write block 7. Direct-access files are of great use for immediate access to large amounts of information. Databases are often of this type. For the direct-access method, the file operations must be modified to include the block number as a parameter. Thus, we have read n, where n is the block number, rather than read next, and write n rather than write next. 3. Other Access Methods (Indexed sequential access): This method involves the construction of an index for the file. The index contains pointers to the various blocks. To find a record in the file, we first search the index and then use the pointer to access the file directly and to find the desired record. Following figure shows an example of indexed sequential-access method, where the file is kept sorted on a defined key (last name). To find a particular item, we first make a search of the index file, which provides the block number of the secondary index. This block containing the desired record is read in and thus sequential search on index is performed. With large files, the index file itself may become too large to be kept in memory. One solution is to create an index for the index file. The primary index file would contain pointers to secondary index files, which would point to the actual data items. 3. Directory structure A computer system stores numerous data on disks. To manage this data, the disk is divided into one or more partitions (also known as volumes) and each partition contains information about the files stored in it. This information is stored in a directory. In simplest terms, directory is a flat file that stores information about the files and subdirectories and organizes files hierarchically. The system views them differently from ordinary files.
  • 5. Directory operations include: • Create a file – new files can be created and added to the directory as new directory entry. • Search for a file – when a file is required, corresponding entry is serached in the directory. • Delete a file – a file erase from the directory, when it is no longer required. • List a directory – contents of the directory entry is listed. • Rename a file – a file may be renamed, wchich may change its position in the directory. • Traverse the file system – every file in the directory can be accessed. Following are the commonly used directory structure: 1. Single-Level Directory It is the simplest form of directory structure, in which a single directory contains all files for all users. Sometimes this directory is referred to as root directory. It is simple to implement, but the drawback is that no two files have the same name. 2. Two-Level Directory In this directory structure, each user gets their own directory space called user file directory (UFD). File names only need to be unique within a given user's directory. A master file directory (MFD) is used to keep track of each users directory, and must be maintained when users are added to or removed from the system. 3. Hierarchical-Level Directory/Tree-Structured Directories The two-level hierarchy eliminates file name conflicts between users. But another problem is that users with many files may want to group them in smaller subgroups. So, two-tiered directory structure is extended for new directory structure called Hierarchical Directory Structure. Here each user / process has the concept of a current directory from which all ( relative ) searches take place. Files may be accessed using either absolute pathnames (relative to the root of the tree) or relative pathnames (relative to the current directory). All these three directory structures are shown as (a), (b) and (c) respectively in the above figure. A, B and C represents three different users. Enclosing rectangles represent directories of corresponding users and enclosing circles represent files of those users.
  • 6. 4. Acyclic-Graph Directories: A tree structure prohibits the sharing of files or directories. An acyclic graph( a graph with no cycles) allows directories to share subdirectories and files. The acyclic graph is a natural generalization of the tree-structured directory scheme. Shared files and subdirectories can be implemented in several ways: 1) A common way, used by many of the UNIX systems, is to create a new directory entry called a link. A link is effectively a pointer to another file or subdirectory. 2) Another common approach to implement shared files is simply to duplicate all information. Thus, both entries are identical and equal. 5. General Graph Directory The primary advantage of an acyclic graph is the relative simplicity of the algorithms to traverse the graph and to determine when there are no more references to a file. We want to avoid traversing shared sections of an acyclic graph twice, mainly for performance reasons. With acyclic-graph directory structures, a value of 0 in the reference count means that there are no more references to the file or directory, and the file can be deleted. However, when cycles exist, the reference count may not be 0 even when it is no longer possible to refer to a directory or file, because of self- referencing concept. So, A serious problem with using an acyclic-graph structure is ensuring that there are no cycles. If we start with a two-level directory and allow users to create subdirectories, a tree-structured directory results. It should be fairly easy to see that simply adding new files and subdirectories to an existing tree-structured directory preserves the tree-structured nature. However when we add links, the tree structure is destroyed, resulting in a simple graph structure.
  • 7. Ques: What is a Directory? What are the commonly used directory structure? Ques: Differentiate between a file and a directory. Ques: Justify the need of file system. Ans: File systems provide efficient and convenient access to the disk by allowing data to be stored, located, and retrieved easily. A file system provides solution to following design problems: 1. To define how the file system should look to the user. This task involves defining a file and its attributes, the operations allowed on a file, and the directory structure for organizing files. 2. To create algorithms and data structures to map the logical file system onto the physical secondary-storage devices. The file system itself is generally composed of many different levels as shown in following figure. Each level uses the features of lower levels to create new features for use by higher levels. The lowest level, the I/O control, consists of device drivers and interrupt handlers to transfer information between the main memory and the disk system. The basic file system needs only to issue generic commands to the appropriate device driver to read and write physical blocks on the disk. Each physical block is identified by its numeric disk address (for example, drive 1, cylinder 73, track 2, sector 10). The file-organization module knows about files and their logical blocks, as well as physical blocks. It also includes the free-space manager, which tracks unallocated blocks and provides these blocks to the file-organization module when requested. Finally, the logical file system manages metadata information, which includes all of the file-system structure except the actual data (or contents of the files). It is also responsible for protection and security. To create a new file, an application program calls the logical file system. The logical file system knows the format of the directory structures. To create a new file, it allocates a new FCB. The system then reads the appropriate directory into memory, updates it with the new file name and FCB, and writes it back to the disk.
  • 8. Ques: What are the structures used in file-system implementation? File system provide efficient and convenient access to the disk by allowing data to be stored, located, and retrieved easily. On disk, the file system may contain information about the total number of blocks, the number and location of free blocks, the directory structure, and individual files. Several on-disk and in-memory structures are used to implement a file system. Important data structures stored on disk are briefly explained here: • A boot-control block, ( per volume ) can contain information needed by the system to boot an operating system from that volume. If the disk does not contain an operating system, this block will be left empty. • A volume control block, (per volume) contains volume (or partition) details such number of blocks in the partition, size of blocks, free-block counts, and free-block pointers. • A directory structure (per file system), containing file names and pointers to corresponding FCBs. UNIX uses inode numbers, and windows uses a master file table. • The File Control Block, FCB, (per file) contains many details about the file. It has a unique identifier number to allow association with a directory entry. UNIX stores this information in inodes, and windows maintains a relational database structure within the master file table. There are also several key data structures stored in memory: • An in-memory mount table, contains information about each mounted volumes. (Before you can access the files on a file system, you need to mount the file system. Mounting a file system attaches that file system to a directory (mount point) and makes it available to the system.) • An in-memory directory cache holds the directory information of recently accessed directories. • A system-wide open file table, contains a copy of the FCB of each open file, as well as some other related information. • A per-process open file table, contains a pointer to the appropriate entry in the system-wide open-file table, as well as other information. Ques: Explain allocation strategies: Contoguous, linked and indexed. Files are allocated disk spaces by operating system. The main problem is how to allocate space to these files so that disk space is utilized effectively and files can be accessed quickly. Three major methods of allocating disk space are in wide use: 1. Contiguous Allocation: It requires that each file occupy a set of contiguous blocks on disk. Disk addresses define a linear ordering on the disk. Contiguous allocation of a file is defined by the disk address and length (in block units) of the first block. If the file is n blocks long and starts at location b, then it occupies blocks b, b + 1, b + 2, ... , b + n – 1. Advantage: 1. Accessing a file that has been allocated contiguously is easy. 2. Both sequential and direct access can be supported by contiguous allocation.
  • 9. Drawbacks: 1. difficulty in finding space for a new file. 2. As files are allocated and deleted, the free disk space is broken into little pieces resulting into external fragmentation. 2. Linked Allocation: With this linked allocation, each file is a linked list of disk blocks; the disk blocks may be scattered anywhere on the disk. The directory contains a pointer to the first and last blocks of the file. Each block contains a pointer to the next block. These pointers are not made available to the user. For example, linked allocation for a file of five blocks might start at block 9 and continue at block 16, then block 1, then block 10, and finally block 25 can be done in following way: To create a new file, we simply create a new entry in the directory. With linked allocation, each directory entry has a pointer to the first disk block of the file. The size of a file need not be declared when that file is created. A file can continue to grow as long as free blocks are available. To read a file, we simply read blocks by following the pointers from block to block.
  • 10. Advantage: There is no external fragmentation with linked allocation, and any free block on the free-space list can be used to satisfy a request. Drawbacks: 1. The major problem is that it can be used effectively only for sequential-access files. To find the ith block of a file, we must start at the begining of that file and follow the pointers until we get to the ith block. So, it is inefficient to support a direct-access capability for linked-allocation files. 2. Each file requires slightly more space because it stores pointers to next block 3. Indexed Allocation: Linked allocation solves the external-fragmentation and size- declaration problems of contiguous allocation. However, linked allocation cannot support efficient direct access, since the pointers to the blocks are scattered all over the disk and must be retrieved in order. Indexed allocation solves this problem by bringing all the pointers together into one location: the index block. Each file has its own index block, which is an array of disk-block addresses. The directory contains the address of the index block only. When the file is created, all pointers in the index block are set to nil. When the ith block is first written, a block is obtained from the free-space manager and its address is put in the ith index-block entry. To find and read the ith block, we use the pointer in the ith index-block entry. Advantage: Indexed allocation supports direct access, without suffering from external fragmentation, because any free block on the disk can satisfy a request for more space. Drawback: Indexed allocation does suffer from wasted space because with indexed allocation, an entire index block must be allocated, even if only one or two pointers will be non-nil. However, the pointer overhead of the index block is generally greater than the pointer overhead of linked allocation. This point raises the questions of how big the index block should be, and how it should be implemented. There are several approaches:
  • 11. 1. Linked scheme. An index block is normally one disk block. Thus, it can be read and written directly by itself. To allow for large files, we can link together several index blocks. 2. Multilevel index. A variant of linked representation uses a first-level index block to point to a set of second-level index blocks, which in turn point to the file blocks. To access a block, the operating system uses the first-level index to find a second-level index block and then uses that block to find the desired data block. This approach could be continued to a third or fourth level, depending on the desired maximum file size. 3. Combined scheme. Another alternative, used in the Unix File Systetm, is to keep the first, say, 15 pointers of the index block in the file's inode. The first 12 of these pointers point to direct blocks (data blocks). Thus, the data for small files (of no more than 12 blocks) do not need a separate index block. If the block size is 4 KB, then up to 48 KB of data can be accessed directly. The next three pointers point to indirect blocks. The first points to a single indirect block, which is an index block containing not data but the addresses of blocks that do contain data. The second points to a double indirect block, which contains the address of a block that contains the addresses of blocks that contain pointers to the actual data blocks. The last pointer contains the address of a triple indirect block.