0% found this document useful (0 votes)
13 views

OS Unit IV File System_Part 1

The document provides an overview of file systems, detailing the concept of files, their types, attributes, and operations. It explains various access methods, including sequential and direct access, and discusses directory structures and disk organization. Additionally, it covers different directory types such as single-level, two-level, tree-structured, acyclic-graph, and general graph directories, highlighting their advantages and disadvantages.

Uploaded by

bhaveshpenneru27
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

OS Unit IV File System_Part 1

The document provides an overview of file systems, detailing the concept of files, their types, attributes, and operations. It explains various access methods, including sequential and direct access, and discusses directory structures and disk organization. Additionally, it covers different directory types such as single-level, two-level, tree-structured, acyclic-graph, and general graph directories, highlighting their advantages and disadvantages.

Uploaded by

bhaveshpenneru27
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 28

File-System

 File Concept
 Access Methods
 Directory and Disk Structure
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 collection of related information that is recorded on
secondary storage.
 From a user’s perspective, a file is the smallest allotment of logical
secondary storage; that is, data cannot be written to secondary storage
unless they are within a file.

 A file is a collection of bits, bytes,lines or records ,defined by its creator or


owner.

 Commonly, files represent programs (both source and object forms) and
data.
 Data files may be numeric, alphabetic, alphanumeric, or binary.
Types of Files
 Many different types of information may be stored in a file—source or executable
programs, numeric or text data, photos, music, video, and soon.
 A file has a certain defined structure, which depends on its type.
 Text file: is a sequence of characters organized into lines (and possibly pages).

 Source file: is a sequence of subroutines and functions, each of which is further


organized as declarations followed by executable statements.

 Object file : is a sequence of bytes organized in to blocks understandable by the


system's linker

 Executable file : is a sequence of code section that the loader can bring into
memory and execute.
File Types – Name, Extension
File Attributes
 A file is named, for the convenience of its human users, and is referred to by
its name.
 A name is usually a string of characters, such as example.c.
 Some systems differentiate between uppercase and lowercase characters
in names, whereas other systems do not.
 When a file is named, it becomes independent of the process, the user, and
even the system that created it.
 For instance, one user might create the file example.c, and another user
might edit that file by specifying its name.
File Attributes
Detailed information about the file stored in directory structure
 Name – only information kept in human-readable form
 Identifier – unique tag (number) identifies file within file system. it is the
non-human-readable name for the file.
 Type – needed for systems that support different types
 Location – pointer to file location on device
 Size – current file size
 Protection – Access-control information determines who can do reading,
writing, executing
 Time, date, and user identification – Information about files are kept in
the directory structure, which is maintained on the disk. This data useful for
protection, security, and usage monitoring
 Some newer file systems also support extended file attributes, including
character encoding of the file and security features such as a file checksum.
File Operations
 Create
 Write
 Read
 Reposition within file
 Delete
 Truncate
 These six basic operations comprise the minimal set of required file
operations.
 Other common operations are
 appending new information to the end of an existing file
 renaming an existing file.
 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
Access Methods
 Files store information. When it is used, this information must be accessed and
read into computer memory.
 The information in the file can be accessed in several ways.
Sequential Access:
This is the simplest access method. Information in the file is processed in order,
one record after the other.
 This mode of access is by far the most common; for example, editors and
compilers usually access files in this fashion.
 Reads and writes make up the bulk of the operations on a file.
read next
write next
reset (or) rewind
no read after last write
(rewrite)
 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).
 Such a file can be reset to the beginning;
• If the file contains 100 records
• Now we are at 50th record.
• We need to access 75th record.
• First 50,then 51,52… 75
• We cannot access it directly.
• Which takes more time.
Direct Access or Relative Access or Random Access:
read n
write n
position to n
read next
write next
rewrite n
n = relative block number
 A File is made up of fixed length logical records that allow programs to read and
write records rapidly in no particular order.
 The direct-access method is based on a disk model of a file, since disks allow
random access to any file block.
 For direct access, the file is viewed as a numbered sequence of blocks or
records. Thus, we may read block 14, then read block 53, and then write block 7.
There are no restrictions on the order of reading or writing for a direct-access file.
 Direct-access files are of great use for immediate access to large amounts of
information.
 Databases are often of this type. When a query concerning a particular subject
arrives, we compute which block contains the answer and then read that block
directly to provide the desired information.
 As a simple example, on an airline-reservation system
Simulation of Sequential Access on
Direct-access File

Examples are Magnetic Disk, Hard Disk, CD.


We may go to any block whatever we want.

Accessing a record takes more amount of time.


Index and Relative Files
• Other access methods can be built on top of a direct-access method.

• These methods generally involve the construction of an index for the file.

• The index like an index in the back of a book contains pointers to the various blocks.

• To find a record in the file, we first search the index and then use the to access the file
directly and to find the desired record.

• For example, IBM's indexed sequential-access method (ISAM) uses a small master index
that points to disk blocks of a secondary index.

• The secondary index blocks point to the actual file blocks. The file is kept sorted on a
defined key.

• To find a particular item, we first make a binary search of the master index, which
provides the block number of the secondary index.

• This block is read in, and again a binary search is used to find the block containing the
desired record. Finally, this block is searched sequentially.
Example of Index and Relative Files
Directory and Disk Structure

 A collection of nodes containing information about all files

Directory

Files
F1 F2 F4
F3
Fn

Both the directory structure and the files reside on disk


Backups of these two structures are kept on tapes
Files are stored on random-access storage devices, including hard disks, optical
disks, and solid state (memory-based) disks.
Disk Structure
 A storage device can be used in its entirety for a file system.
 It can also be subdivided for finer-grained control.
 For example, a disk can be into quarters, and each quarter can hold a
file system.
 Disks or partitions can be RAID protected against failure
 Disk or partition can be used raw – without a file system, or formatted
with a file system
 Partitions also known as minidisks, slices
 Entity containing file system known as a volume
 Each volume containing file system also tracks that file system’s info in
device directory or volume table of contents
 As well as general-purpose file systems there are many special-
purpose file systems, frequently all within the same operating system
or computer
A Typical File-system Organization
Operations Performed on Directory
 The directory can be viewed as a symbol table that translates file names
into their directory entries.
 Search for a file: We need to be able to search a directory structure to find
the entry for a particular file.
 Create a file: New files need to be created and added to the directory.

 Delete a file: When a file is no longer needed, we want to be able to remove


it from the directory
 List a directory: We need to be able to list the files in a directory and the
contents of the directory entry for each file in the list.

 Rename a file
 Traverse the file system
 Efficiency – locating a file quickly
Organize the Directory (Logically) to Obtain

 Naming – convenient to users


 Two users can have same name for different files
 The same file can have several different names

 Grouping – logical grouping of files by properties, (e.g., all Java programs,


all games, …)
Single-Level Directory
 The simplest directory structure is the single-level directory.
 All files are contained in the same directory, which is easy to support
and understand .
 A single directory for all users

DisAdvantages:
Naming problem: Can’t create more than one file with same name

Size increases searching time increases

Grouping problem
Two-Level Directory
 Separate directory for each user

Advantages
 Can have the same file name for different users
 Efficient searching
Dis Advantages
 Path name
 No grouping capability : Sub directories cannot be created
Tree-Structured Directories
Tree-Structured Directories (Cont.)
 We can have directories at More than two levels (Multilevel)

 Root Directory – User Directories – Sub Directories – Sub Directories


etc.

Advantages:
 Efficient searching

 Grouping Capability : We have many sub directories

 Current directory (working directory)


 cd /spell/mail/prog

Dis Advantage: If we want to share a file among different directories


then it is not possible. Then a cycle is formed.
Tree doesn’t contains Cycle.
Tree-Structured Directories (Cont)
 Absolute or relative path name
 An absolute path name begins at the root and follows a path down
to the specified file, giving the directory names on the path.
 A relative path name defines a path from the current directory.
 Creating a new file is done in current directory
 Delete a file
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 copy prt exp count

Deleting “mail”  deleting the entire subtree rooted by “mail”


Acyclic-Graph Directories
 It is useful when some files need to be accessed from more than one
place
 Share files among multiple directories
Acyclic-Graph Directories (Cont.)
Advantages:
 File can be shared
 Searching is easy due to different paths.

Dis Advantages:
 We share the files via links .If we delete a link it creates a problem

 New directory entry type


 Link – another name (pointer) to an existing file
 Resolve the link – follow pointer to locate the file
General Graph Directory
General Graph Directory (Cont.)
 Cycles are allowed within a directory structure where multiple directories
can be derived from more than one parent

Advantages
It allows cycles
It is more flexible than other directories structure.

Dis Advantages
 It is most costlier than others
 Garbage collection
 Every time a new link is added use a cycle detection algorithm to
determine whether it is OK

You might also like