SlideShare una empresa de Scribd logo
1 de 34
Descargar para leer sin conexión
INTERNAL REPRESENTATION OF FILE
MRS.SOWMYAJYOTHI
FACULTY
MANGALORE
References: The Design of the Unix Operating System- Maurice J. Bach
INODES:- (Index Node)
Inode contains the information necessary for a process to
access a file.
Inodes exist in a static form on disk, and the kernel reads
them into an in-core inode to manipulate them.
An INODE is a data structure on a file system on a Unix-like
operating system that stores all the information about a
file except its name and its actual data.
All UNIX files have its description stored in a structure
called 'inode'.
Directories are also represented as files and have an
associated inode. In addition to descriptions about the file,
the inode contains pointers to the data blocks of the file.
Inodes are of two types
1. Disk Inode : store the i-node information when file is
not in use.
2. Memory Inode or In-core Inode: record the
information about active files.
For every file there is an unique inode.
DISK INODE consists of the following fields:
1. File owner identifier:- Ownership is divided between an
individual owner and a “group” owner and defines the set of
users who have access rights to a file. The super-user has
access rights to all files in the system.
2. File type :- Files may be of type regular, directory,
character or block special or FIFO (pipes).
3. File access permissions:- The system protects files
according to 3 classes: the owner and the group owner of
the file, and other users; each class has access rights to read,
write and execute the file, which can be set individually.
Because directories cannot be executed, execution permission
for a directory gives the right to search the directory for a file
name.
4. File access times:- giving the time the file was last
modified, when it was last accessed and when the inode
was last modified.
5. Number of links to the file, representing the number of
names the file has in the directory hierarchy.
6. File size:- Data in a file is addressable by the number of
bytes from the beginning of the file.
7. Location of the file data: The table of contents for the
disk addresses of data in a file. Although the users treat the
data in a file as a logical stream of bytes, the kernel saves
the data in discontiguous disk blocks. The inode identifies
the disk blocks that contain the file’s data.
Sample Disk Inode:
This inode is that of a regular file owned
by “mjb”, which contains 6030 bytes.
The system permits “mjb” to read, write
or execute the file; members of the
group “os” and all other users can only
read or execute the file, not write it. The
last time anyone read the file was on
October 23, 1984 at 1:45 in the
afternoon and the last time anyone
wrote the file was on October 22, 1984
at 10:30 in the morning. The inode was
last changed on October 23, 1984 at
1:30 in the afternoon, although the data
in the file was not written at that time.
2. Incore inode:- An entry in the kernel table describing the
status of a filesystem inode that is being accessed by
processes.
In-core copy : record the information about active files.
The Incore copy/ Memory inode of the inode contains
the following fields in addition to the fields of the disk
inode.
A file system is a logical collection of files on a partition or
disk. A partition is a container for information and can span
an entire hard drive if desired.
A Unix file system is a collection of files and directories that
has the following properties −
i. It has a root directory (/) that contains other files and
directories.
ii. Each file or directory is uniquely identified by its name,
the directory in which it resides, and a unique identifier,
typically called an inode.
iii. By convention, the root directory has an inode number
of 2 and the lost+found directory has an inode number
of 3.
iv. Inode numbers 0 and 1 are not used.
SUPERBLOCK
•A superblock is a record of the characteristics of a file
system including its size, the block size, the empty and the
filled blocks and their respective counts, the size and
location of the inode tables, the disk block map and usage
information, and the size of the block groups.
•The term filesystem refers to an entire hierarchy of
directories or directory tree, that is used to organize files on
a computer system.
•A file system is a logical collection of files on a partition or
disk. A partition is a container for information and can
span an entire hard drive if desired.
The Super block contains the following information, to keep
track of the entire file system.
1. Size of the file system : Size of the file system represents the
actual no of blocks (used + unused) present in the file system.
2. Number of free blocks on the system
3. A list of free blocks
4. Index to next free block on the list : Index indexes to the next
free disk block in the free disk block list.
5. Size of the inode list
6. Number of free the inodes
7. A list of free inodes
8. Index to next free inode on the list
9. Lock fields for free block and free inode lists
10.Flag to indicate modification of super block
Super block consist of
The size of the file system
The number of free blocks in the file system
A list of free blocks available on the file system
The index of the next free block in the free block list
The size of the inode list
The number of free inodes in the file system
A list of free inodes in the file system
The index of the next free inode in the free inode list
Lock fields for the free block and free inode lists
A flag indicating that the super block has been modified
File Types
1. Ordinary files / Regular File–
An ordinary file is a file on the system that contains data,
text, or program instructions.
Used to store your information, such as some text you
have written or an image you have drawn. This is the type
of file that you usually work with.
Always located within/under a directory file.
Do not contain other files.
In long-format output of ls -l, this type of file is specified by
the “-” symbol.
Structure of the regular file
The inode contains the TABLE OF CONTENT (TOC) to locate
a file data
TOC consist of set of disk block numbers
Kernel stores file data a block at a time
Following Diagram shows the problems of continuous
allocation of file data
Structure of Regular file (TOC)
The TOC consist of a list of block
numbers such that the blocks contain
the data belonging to the file
The System V UNIX system runs with
13 entries in the inode TOC, but the
principles are independent of the
number of entries
The blocks marked “direct” in the
figure contain the number of disk blocks
that contains real data
The block marked “single indirect”
refers to a block that contains a list of
direct block numbers, to access the
data via the indirect block, the kernel
must read the indirect block, find the
appropriate direct block entry, and then
read the direct block to find the data
The block marked “double indirect”
contains a list of single indirect block
numbers
The block marked “triple indirect”
contains the list of double indirect blocks
STRUCTURE OF A REGULAR FILE
If the data in a file were stored in a contiguous section of
the disk (that is, the file occupied a linear sequence of
disk blocks), then storing the start block address and the
file size in the inode would suffice to access all the data in
the file.
However, such an allocation strategy would not allow for
simple expansion and contraction of files in the file
system without running the risk of fragmenting free
storage area on the disk. Furthermore, the kernel would
have to allocate and reserve contiguous space in the file
system before allowing operations that would increase the
file size.
Allocationof ContiguousFilesandFragmentationof FreeSpace
40 50 60 70 Block Addresses
40 50 60 70 81 Block Addresses
…………….. File A Free File C File B ………….
For example:- Suppose a user creates three files. A, B and C. each
consisting of 10 disk blocks of storage, and suppose the system
allocated storage for the three files contiguously. If the user then
wishes to add 5 block of data to the middle file B, the kernel would have
to copy file B to a place in the file system that had room for 15 blocks
of storage.
The System V UNIX system runs with 13 entries in the inode
table of contents, but the principles are independent of the
number of entries.
The blocks marked “direct" in the figure contain the numbers of
disk blocks that contain real data.
The block marked "single indirect” refers to a block that
contains a list of direct block numbers.
To access the data via the indirect block, the kernel must read the
indirect block, find the appropriate direct block entry, and then
read the direct block to find the data.
The block marked "double indirect" contains a list of indirect
block numbers, and
The block marked "triple indirect" contains a list of double
indirect block numbers.
Directories
Directory
 Directory contains a list of other files (the contents
of a directory). Directory files act as a container for other
files, of any category. Thus we can have a directory file
contained within a directory file (this is commonly referred
to as a subdirectory).
A directory is a file whose data is a sequence of entries,
each consisting of an INODE NUMBER and the NAME OF A
FILE contained in the directory.
 A path name is a null terminated character string
divided into separate components by the slash (“/")
character. Each component except the last must be the
name of a directory, but the last component may be a non-
directory file.
Directories
Other File Types
Pipe: Allow processes to communicate with each other.
◦ FIFO(FIRST-IN-FIRST-OUT)
◦ Its data is transient: once data is read from a pipe, it
cannot be read again
◦ Use only direct block (not the indirect block)
2020-12-28
26
Special file
◦ BLOCK DEVICE, CHARACTER DEVICE
◦ The inode contains the major and minor device number
◦ Major number indicates a device type such as terminal
or disk
◦ Minor number indicates the unit number of the device
Other File Types:-
The UNIX system supports 2 other file types: pipes and special files.
A pipe, sometimes called a FIFO (“First In first Out”), differs from a
regular file in that its data is transient: Once data is read from a
pipe, it cannot be read again. Also, the data is read in the order that
it was written to the pipe, and the system allows no deviation from
that order.
 The kernel stores the data in a pipe the same way it stores data in
an ordinary file, except that it uses only the direct blocks, not the
indirect blocks.
 The last file types in the UNIX system are special files, including
block device special files and character device special files. Both
types specify devices, and therefore the file inodes do not reference
any data. The inode contains two numbers known as the major and
minor device numbers.The major number indicates a device type
such as terminal or disk.
 The minor number indicates the unit number of the device.
iput releasing inode from in-core inode
Steps for iput Algorithm
The kernel locks the inode if it
has not been already locked
The kernel decrements inode
reference count
The kernel checks if reference
count is 0 or not
If the reference count is 0 and the
number of links to the file is 0,
then the kernel releases disk
blocks for file(algorithm free),
free the inode(algorithm ifree)
If the file was accessed or the
inode was changed or the file
was changed , then the kernel
updates the disk inode
The kernel puts the inode on
free list
If the reference count is not 0, the
kernel releases the inode lock
Releasing Inodes: When the kernel releases an inode
(algorithm iput),
It decrements its in-core reference count.
If the count drops to 0, the kernel writes the inode to disk if
the in-core copy differs from the disk copy.
They differ if the file data has changed, if the file access time
has changed, or if the file owner or access permissions have
changed.
The kernel places the inode on the free list of inodes,
effectively caching the inode in case it is needed again soon.
The kernel may also release all data blocks associated with
the file and free the inode if the number of links to the file is
0.
Path Conversion to an inode
The kernel works internally with inodes rather than
with path names, it converts the path name to
inodes to access files.
The algorithm namei parses the path name one component at a time
if (path name starts with root)
◦ working inode= root inode
else
◦ working inode= current directory inode
while (there is more path name)
◦ read next component from input
◦ read directory content
◦ if (component matches an entry in directory)
◦ get inode number for matched component
◦ release working inode
◦ working inode=inode of matched component
◦ Else
◦ return no inode
return (working inode)

Más contenido relacionado

La actualidad más candente

Unix file systems 2 in unix internal systems
Unix file systems 2 in unix internal systems Unix file systems 2 in unix internal systems
Unix file systems 2 in unix internal systems senthilamul
 
File System Implementation - Part1
File System Implementation - Part1File System Implementation - Part1
File System Implementation - Part1Amir Payberah
 
Disk and File System Management in Linux
Disk and File System Management in LinuxDisk and File System Management in Linux
Disk and File System Management in LinuxHenry Osborne
 
Mca ii os u-5 unix linux file system
Mca  ii  os u-5 unix linux file systemMca  ii  os u-5 unix linux file system
Mca ii os u-5 unix linux file systemRai University
 
File systemimplementationfinal
File systemimplementationfinalFile systemimplementationfinal
File systemimplementationfinalmarangburu42
 
Intro to linux systems administration
Intro to linux systems administrationIntro to linux systems administration
Intro to linux systems administrationPadam Banthia
 
Operating Systems - Implementing File Systems
Operating Systems - Implementing File SystemsOperating Systems - Implementing File Systems
Operating Systems - Implementing File SystemsMukesh Chinta
 
File Management in Operating Systems
File Management in Operating SystemsFile Management in Operating Systems
File Management in Operating Systemsvampugani
 
file system in operating system
file system in operating systemfile system in operating system
file system in operating systemtittuajay
 
The unix file system
The unix file systemThe unix file system
The unix file systemgsandeepmenon
 
Chapter 10 - File System Interface
Chapter 10 - File System InterfaceChapter 10 - File System Interface
Chapter 10 - File System InterfaceWayne Jones Jnr
 
linux file sysytem& input and output
linux file sysytem& input and outputlinux file sysytem& input and output
linux file sysytem& input and outputMythiliA5
 
File System Interface
File System InterfaceFile System Interface
File System Interfacechandinisanz
 

La actualidad más candente (20)

Unix file systems 2 in unix internal systems
Unix file systems 2 in unix internal systems Unix file systems 2 in unix internal systems
Unix file systems 2 in unix internal systems
 
File System Implementation - Part1
File System Implementation - Part1File System Implementation - Part1
File System Implementation - Part1
 
OSCh11
OSCh11OSCh11
OSCh11
 
File management
File managementFile management
File management
 
File System Implementation
File System ImplementationFile System Implementation
File System Implementation
 
Disk and File System Management in Linux
Disk and File System Management in LinuxDisk and File System Management in Linux
Disk and File System Management in Linux
 
Mca ii os u-5 unix linux file system
Mca  ii  os u-5 unix linux file systemMca  ii  os u-5 unix linux file system
Mca ii os u-5 unix linux file system
 
File systemimplementationfinal
File systemimplementationfinalFile systemimplementationfinal
File systemimplementationfinal
 
Intro to linux systems administration
Intro to linux systems administrationIntro to linux systems administration
Intro to linux systems administration
 
Operating Systems - Implementing File Systems
Operating Systems - Implementing File SystemsOperating Systems - Implementing File Systems
Operating Systems - Implementing File Systems
 
File Management in Operating Systems
File Management in Operating SystemsFile Management in Operating Systems
File Management in Operating Systems
 
file system in operating system
file system in operating systemfile system in operating system
file system in operating system
 
The unix file system
The unix file systemThe unix file system
The unix file system
 
Chapter 10 - File System Interface
Chapter 10 - File System InterfaceChapter 10 - File System Interface
Chapter 10 - File System Interface
 
File system
File systemFile system
File system
 
Unix File System
Unix File SystemUnix File System
Unix File System
 
linux file sysytem& input and output
linux file sysytem& input and outputlinux file sysytem& input and output
linux file sysytem& input and output
 
File System Interface
File System InterfaceFile System Interface
File System Interface
 
File system implementation
File system implementationFile system implementation
File system implementation
 
Ch11
Ch11Ch11
Ch11
 

Similar a Internal representation of file chapter 4 Sowmya Jyothi

Internal representation of files ppt
Internal representation of files pptInternal representation of files ppt
Internal representation of files pptAbhaysinh Surve
 
Root file system
Root file systemRoot file system
Root file systemBindu U
 
Unit ivos - file systems
Unit ivos - file systemsUnit ivos - file systems
Unit ivos - file systemsdonny101
 
File management
File managementFile management
File managementMohd Arif
 
MODULE 3.1 updated-18cs56.pptx
MODULE 3.1 updated-18cs56.pptxMODULE 3.1 updated-18cs56.pptx
MODULE 3.1 updated-18cs56.pptxManasaPJ1
 
Filesystemimplementationpre final-160919095849
Filesystemimplementationpre final-160919095849Filesystemimplementationpre final-160919095849
Filesystemimplementationpre final-160919095849marangburu42
 
File system interfacefinal
File system interfacefinalFile system interfacefinal
File system interfacefinalmarangburu42
 
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
 
AOS Lab 10: File system -- Inodes and beyond
AOS Lab 10: File system -- Inodes and beyondAOS Lab 10: File system -- Inodes and beyond
AOS Lab 10: File system -- Inodes and beyondZubair Nabi
 
file management_part2_os_notes.ppt
file management_part2_os_notes.pptfile management_part2_os_notes.ppt
file management_part2_os_notes.pptHelalMirzad
 
Glusterfs session #1 disk filesystems
Glusterfs session #1   disk filesystemsGlusterfs session #1   disk filesystems
Glusterfs session #1 disk filesystemsPranith Karampuri
 
Ch 17 disk storage, basic files structure, and hashing
Ch 17 disk storage, basic files structure, and hashingCh 17 disk storage, basic files structure, and hashing
Ch 17 disk storage, basic files structure, and hashingZainab Almugbel
 
Linux fundamentals
Linux fundamentalsLinux fundamentals
Linux fundamentalsRaghu nath
 
2nd unit part 1
2nd unit  part 12nd unit  part 1
2nd unit part 1Pavan Illa
 
Disk and file operation
Disk and file operationDisk and file operation
Disk and file operationJaveria Yaqoob
 

Similar a Internal representation of file chapter 4 Sowmya Jyothi (20)

Internal representation of files ppt
Internal representation of files pptInternal representation of files ppt
Internal representation of files ppt
 
Unix Administration
Unix AdministrationUnix Administration
Unix Administration
 
Root file system
Root file systemRoot file system
Root file system
 
Windowsforensics
WindowsforensicsWindowsforensics
Windowsforensics
 
osd - co1 session7.pptx
osd - co1 session7.pptxosd - co1 session7.pptx
osd - co1 session7.pptx
 
Unit ivos - file systems
Unit ivos - file systemsUnit ivos - file systems
Unit ivos - file systems
 
File management
File managementFile management
File management
 
UNIT III.pptx
UNIT III.pptxUNIT III.pptx
UNIT III.pptx
 
MODULE 3.1 updated-18cs56.pptx
MODULE 3.1 updated-18cs56.pptxMODULE 3.1 updated-18cs56.pptx
MODULE 3.1 updated-18cs56.pptx
 
Filesystemimplementationpre final-160919095849
Filesystemimplementationpre final-160919095849Filesystemimplementationpre final-160919095849
Filesystemimplementationpre final-160919095849
 
File system interfacefinal
File system interfacefinalFile system interfacefinal
File system interfacefinal
 
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
 
AOS Lab 10: File system -- Inodes and beyond
AOS Lab 10: File system -- Inodes and beyondAOS Lab 10: File system -- Inodes and beyond
AOS Lab 10: File system -- Inodes and beyond
 
file management_part2_os_notes.ppt
file management_part2_os_notes.pptfile management_part2_os_notes.ppt
file management_part2_os_notes.ppt
 
Glusterfs session #1 disk filesystems
Glusterfs session #1   disk filesystemsGlusterfs session #1   disk filesystems
Glusterfs session #1 disk filesystems
 
Ch 17 disk storage, basic files structure, and hashing
Ch 17 disk storage, basic files structure, and hashingCh 17 disk storage, basic files structure, and hashing
Ch 17 disk storage, basic files structure, and hashing
 
Linux fundamentals
Linux fundamentalsLinux fundamentals
Linux fundamentals
 
2nd unit part 1
2nd unit  part 12nd unit  part 1
2nd unit part 1
 
Disk and file operation
Disk and file operationDisk and file operation
Disk and file operation
 
Linux file system
Linux file systemLinux file system
Linux file system
 

Más de Sowmya Jyothi

Stacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURESStacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURESSowmya Jyothi
 
Functions in c mrs.sowmya jyothi
Functions in c mrs.sowmya jyothiFunctions in c mrs.sowmya jyothi
Functions in c mrs.sowmya jyothiSowmya Jyothi
 
Strings in c mrs.sowmya jyothi
Strings in c mrs.sowmya jyothiStrings in c mrs.sowmya jyothi
Strings in c mrs.sowmya jyothiSowmya Jyothi
 
Arrays in c unit iii chapter 1 mrs.sowmya jyothi
Arrays in c unit iii chapter 1 mrs.sowmya jyothiArrays in c unit iii chapter 1 mrs.sowmya jyothi
Arrays in c unit iii chapter 1 mrs.sowmya jyothiSowmya Jyothi
 
Bca data structures linked list mrs.sowmya jyothi
Bca data structures linked list mrs.sowmya jyothiBca data structures linked list mrs.sowmya jyothi
Bca data structures linked list mrs.sowmya jyothiSowmya Jyothi
 
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHIBCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHISowmya Jyothi
 
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHIBCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHISowmya Jyothi
 
BCA DATA STRUCTURES ALGORITHMS AND PRELIMINARIES MRS SOWMYA JYOTHI
BCA DATA STRUCTURES ALGORITHMS AND PRELIMINARIES MRS SOWMYA JYOTHIBCA DATA STRUCTURES ALGORITHMS AND PRELIMINARIES MRS SOWMYA JYOTHI
BCA DATA STRUCTURES ALGORITHMS AND PRELIMINARIES MRS SOWMYA JYOTHISowmya Jyothi
 
BCA DATA STRUCTURES INTRODUCTION AND OVERVIEW SOWMYA JYOTHI
BCA DATA STRUCTURES INTRODUCTION AND OVERVIEW SOWMYA JYOTHIBCA DATA STRUCTURES INTRODUCTION AND OVERVIEW SOWMYA JYOTHI
BCA DATA STRUCTURES INTRODUCTION AND OVERVIEW SOWMYA JYOTHISowmya Jyothi
 
HARDWARE AND PC MAINTENANCE -THE COMPLETE PC-MRS SOWMYA JYOTHI REFERENCE-MIKE...
HARDWARE AND PC MAINTENANCE -THE COMPLETE PC-MRS SOWMYA JYOTHI REFERENCE-MIKE...HARDWARE AND PC MAINTENANCE -THE COMPLETE PC-MRS SOWMYA JYOTHI REFERENCE-MIKE...
HARDWARE AND PC MAINTENANCE -THE COMPLETE PC-MRS SOWMYA JYOTHI REFERENCE-MIKE...Sowmya Jyothi
 
Unit II chapter 4 Loops in C
Unit II chapter 4 Loops in CUnit II chapter 4 Loops in C
Unit II chapter 4 Loops in CSowmya Jyothi
 
Unit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in CUnit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in CSowmya Jyothi
 
Unit ii chapter 1 operator and expressions in c
Unit ii chapter 1 operator and expressions in cUnit ii chapter 1 operator and expressions in c
Unit ii chapter 1 operator and expressions in cSowmya Jyothi
 
Overview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya JyothiOverview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya JyothiSowmya Jyothi
 
NETWORK AND DATABASE CONCEPTS UNIT 1 CHAPTER 2 MRS.SOWMYA JYOTHI
NETWORK AND DATABASE CONCEPTS UNIT 1 CHAPTER 2 MRS.SOWMYA JYOTHINETWORK AND DATABASE CONCEPTS UNIT 1 CHAPTER 2 MRS.SOWMYA JYOTHI
NETWORK AND DATABASE CONCEPTS UNIT 1 CHAPTER 2 MRS.SOWMYA JYOTHISowmya Jyothi
 
Introduction to computers MRS. SOWMYA JYOTHI
Introduction to computers MRS. SOWMYA JYOTHIIntroduction to computers MRS. SOWMYA JYOTHI
Introduction to computers MRS. SOWMYA JYOTHISowmya Jyothi
 
Introduction to graphics
Introduction to graphicsIntroduction to graphics
Introduction to graphicsSowmya Jyothi
 

Más de Sowmya Jyothi (17)

Stacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURESStacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURES
 
Functions in c mrs.sowmya jyothi
Functions in c mrs.sowmya jyothiFunctions in c mrs.sowmya jyothi
Functions in c mrs.sowmya jyothi
 
Strings in c mrs.sowmya jyothi
Strings in c mrs.sowmya jyothiStrings in c mrs.sowmya jyothi
Strings in c mrs.sowmya jyothi
 
Arrays in c unit iii chapter 1 mrs.sowmya jyothi
Arrays in c unit iii chapter 1 mrs.sowmya jyothiArrays in c unit iii chapter 1 mrs.sowmya jyothi
Arrays in c unit iii chapter 1 mrs.sowmya jyothi
 
Bca data structures linked list mrs.sowmya jyothi
Bca data structures linked list mrs.sowmya jyothiBca data structures linked list mrs.sowmya jyothi
Bca data structures linked list mrs.sowmya jyothi
 
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHIBCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
 
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHIBCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
 
BCA DATA STRUCTURES ALGORITHMS AND PRELIMINARIES MRS SOWMYA JYOTHI
BCA DATA STRUCTURES ALGORITHMS AND PRELIMINARIES MRS SOWMYA JYOTHIBCA DATA STRUCTURES ALGORITHMS AND PRELIMINARIES MRS SOWMYA JYOTHI
BCA DATA STRUCTURES ALGORITHMS AND PRELIMINARIES MRS SOWMYA JYOTHI
 
BCA DATA STRUCTURES INTRODUCTION AND OVERVIEW SOWMYA JYOTHI
BCA DATA STRUCTURES INTRODUCTION AND OVERVIEW SOWMYA JYOTHIBCA DATA STRUCTURES INTRODUCTION AND OVERVIEW SOWMYA JYOTHI
BCA DATA STRUCTURES INTRODUCTION AND OVERVIEW SOWMYA JYOTHI
 
HARDWARE AND PC MAINTENANCE -THE COMPLETE PC-MRS SOWMYA JYOTHI REFERENCE-MIKE...
HARDWARE AND PC MAINTENANCE -THE COMPLETE PC-MRS SOWMYA JYOTHI REFERENCE-MIKE...HARDWARE AND PC MAINTENANCE -THE COMPLETE PC-MRS SOWMYA JYOTHI REFERENCE-MIKE...
HARDWARE AND PC MAINTENANCE -THE COMPLETE PC-MRS SOWMYA JYOTHI REFERENCE-MIKE...
 
Unit II chapter 4 Loops in C
Unit II chapter 4 Loops in CUnit II chapter 4 Loops in C
Unit II chapter 4 Loops in C
 
Unit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in CUnit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in C
 
Unit ii chapter 1 operator and expressions in c
Unit ii chapter 1 operator and expressions in cUnit ii chapter 1 operator and expressions in c
Unit ii chapter 1 operator and expressions in c
 
Overview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya JyothiOverview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya Jyothi
 
NETWORK AND DATABASE CONCEPTS UNIT 1 CHAPTER 2 MRS.SOWMYA JYOTHI
NETWORK AND DATABASE CONCEPTS UNIT 1 CHAPTER 2 MRS.SOWMYA JYOTHINETWORK AND DATABASE CONCEPTS UNIT 1 CHAPTER 2 MRS.SOWMYA JYOTHI
NETWORK AND DATABASE CONCEPTS UNIT 1 CHAPTER 2 MRS.SOWMYA JYOTHI
 
Introduction to computers MRS. SOWMYA JYOTHI
Introduction to computers MRS. SOWMYA JYOTHIIntroduction to computers MRS. SOWMYA JYOTHI
Introduction to computers MRS. SOWMYA JYOTHI
 
Introduction to graphics
Introduction to graphicsIntroduction to graphics
Introduction to graphics
 

Último

ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxdhanalakshmis0310
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxAmita Gupta
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 

Último (20)

ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 

Internal representation of file chapter 4 Sowmya Jyothi

  • 1. INTERNAL REPRESENTATION OF FILE MRS.SOWMYAJYOTHI FACULTY MANGALORE References: The Design of the Unix Operating System- Maurice J. Bach
  • 2. INODES:- (Index Node) Inode contains the information necessary for a process to access a file. Inodes exist in a static form on disk, and the kernel reads them into an in-core inode to manipulate them. An INODE is a data structure on a file system on a Unix-like operating system that stores all the information about a file except its name and its actual data. All UNIX files have its description stored in a structure called 'inode'. Directories are also represented as files and have an associated inode. In addition to descriptions about the file, the inode contains pointers to the data blocks of the file.
  • 3. Inodes are of two types 1. Disk Inode : store the i-node information when file is not in use. 2. Memory Inode or In-core Inode: record the information about active files. For every file there is an unique inode.
  • 4. DISK INODE consists of the following fields: 1. File owner identifier:- Ownership is divided between an individual owner and a “group” owner and defines the set of users who have access rights to a file. The super-user has access rights to all files in the system. 2. File type :- Files may be of type regular, directory, character or block special or FIFO (pipes). 3. File access permissions:- The system protects files according to 3 classes: the owner and the group owner of the file, and other users; each class has access rights to read, write and execute the file, which can be set individually. Because directories cannot be executed, execution permission for a directory gives the right to search the directory for a file name.
  • 5. 4. File access times:- giving the time the file was last modified, when it was last accessed and when the inode was last modified. 5. Number of links to the file, representing the number of names the file has in the directory hierarchy. 6. File size:- Data in a file is addressable by the number of bytes from the beginning of the file. 7. Location of the file data: The table of contents for the disk addresses of data in a file. Although the users treat the data in a file as a logical stream of bytes, the kernel saves the data in discontiguous disk blocks. The inode identifies the disk blocks that contain the file’s data.
  • 6.
  • 7. Sample Disk Inode: This inode is that of a regular file owned by “mjb”, which contains 6030 bytes. The system permits “mjb” to read, write or execute the file; members of the group “os” and all other users can only read or execute the file, not write it. The last time anyone read the file was on October 23, 1984 at 1:45 in the afternoon and the last time anyone wrote the file was on October 22, 1984 at 10:30 in the morning. The inode was last changed on October 23, 1984 at 1:30 in the afternoon, although the data in the file was not written at that time.
  • 8. 2. Incore inode:- An entry in the kernel table describing the status of a filesystem inode that is being accessed by processes. In-core copy : record the information about active files. The Incore copy/ Memory inode of the inode contains the following fields in addition to the fields of the disk inode.
  • 9.
  • 10. A file system is a logical collection of files on a partition or disk. A partition is a container for information and can span an entire hard drive if desired. A Unix file system is a collection of files and directories that has the following properties − i. It has a root directory (/) that contains other files and directories. ii. Each file or directory is uniquely identified by its name, the directory in which it resides, and a unique identifier, typically called an inode. iii. By convention, the root directory has an inode number of 2 and the lost+found directory has an inode number of 3. iv. Inode numbers 0 and 1 are not used.
  • 11. SUPERBLOCK •A superblock is a record of the characteristics of a file system including its size, the block size, the empty and the filled blocks and their respective counts, the size and location of the inode tables, the disk block map and usage information, and the size of the block groups. •The term filesystem refers to an entire hierarchy of directories or directory tree, that is used to organize files on a computer system. •A file system is a logical collection of files on a partition or disk. A partition is a container for information and can span an entire hard drive if desired.
  • 12. The Super block contains the following information, to keep track of the entire file system. 1. Size of the file system : Size of the file system represents the actual no of blocks (used + unused) present in the file system. 2. Number of free blocks on the system 3. A list of free blocks 4. Index to next free block on the list : Index indexes to the next free disk block in the free disk block list. 5. Size of the inode list 6. Number of free the inodes 7. A list of free inodes 8. Index to next free inode on the list 9. Lock fields for free block and free inode lists 10.Flag to indicate modification of super block
  • 13. Super block consist of The size of the file system The number of free blocks in the file system A list of free blocks available on the file system The index of the next free block in the free block list The size of the inode list The number of free inodes in the file system A list of free inodes in the file system The index of the next free inode in the free inode list Lock fields for the free block and free inode lists A flag indicating that the super block has been modified
  • 15. 1. Ordinary files / Regular File– An ordinary file is a file on the system that contains data, text, or program instructions. Used to store your information, such as some text you have written or an image you have drawn. This is the type of file that you usually work with. Always located within/under a directory file. Do not contain other files. In long-format output of ls -l, this type of file is specified by the “-” symbol.
  • 16. Structure of the regular file The inode contains the TABLE OF CONTENT (TOC) to locate a file data TOC consist of set of disk block numbers Kernel stores file data a block at a time Following Diagram shows the problems of continuous allocation of file data
  • 17.
  • 18. Structure of Regular file (TOC) The TOC consist of a list of block numbers such that the blocks contain the data belonging to the file The System V UNIX system runs with 13 entries in the inode TOC, but the principles are independent of the number of entries The blocks marked “direct” in the figure contain the number of disk blocks that contains real data The block marked “single indirect” refers to a block that contains a list of direct block numbers, to access the data via the indirect block, the kernel must read the indirect block, find the appropriate direct block entry, and then read the direct block to find the data The block marked “double indirect” contains a list of single indirect block numbers The block marked “triple indirect” contains the list of double indirect blocks
  • 19. STRUCTURE OF A REGULAR FILE If the data in a file were stored in a contiguous section of the disk (that is, the file occupied a linear sequence of disk blocks), then storing the start block address and the file size in the inode would suffice to access all the data in the file. However, such an allocation strategy would not allow for simple expansion and contraction of files in the file system without running the risk of fragmenting free storage area on the disk. Furthermore, the kernel would have to allocate and reserve contiguous space in the file system before allowing operations that would increase the file size.
  • 20. Allocationof ContiguousFilesandFragmentationof FreeSpace 40 50 60 70 Block Addresses 40 50 60 70 81 Block Addresses …………….. File A Free File C File B …………. For example:- Suppose a user creates three files. A, B and C. each consisting of 10 disk blocks of storage, and suppose the system allocated storage for the three files contiguously. If the user then wishes to add 5 block of data to the middle file B, the kernel would have to copy file B to a place in the file system that had room for 15 blocks of storage.
  • 21. The System V UNIX system runs with 13 entries in the inode table of contents, but the principles are independent of the number of entries. The blocks marked “direct" in the figure contain the numbers of disk blocks that contain real data. The block marked "single indirect” refers to a block that contains a list of direct block numbers. To access the data via the indirect block, the kernel must read the indirect block, find the appropriate direct block entry, and then read the direct block to find the data. The block marked "double indirect" contains a list of indirect block numbers, and The block marked "triple indirect" contains a list of double indirect block numbers.
  • 23. Directory  Directory contains a list of other files (the contents of a directory). Directory files act as a container for other files, of any category. Thus we can have a directory file contained within a directory file (this is commonly referred to as a subdirectory). A directory is a file whose data is a sequence of entries, each consisting of an INODE NUMBER and the NAME OF A FILE contained in the directory.  A path name is a null terminated character string divided into separate components by the slash (“/") character. Each component except the last must be the name of a directory, but the last component may be a non- directory file.
  • 25.
  • 26. Other File Types Pipe: Allow processes to communicate with each other. ◦ FIFO(FIRST-IN-FIRST-OUT) ◦ Its data is transient: once data is read from a pipe, it cannot be read again ◦ Use only direct block (not the indirect block) 2020-12-28 26
  • 27. Special file ◦ BLOCK DEVICE, CHARACTER DEVICE ◦ The inode contains the major and minor device number ◦ Major number indicates a device type such as terminal or disk ◦ Minor number indicates the unit number of the device
  • 28. Other File Types:- The UNIX system supports 2 other file types: pipes and special files. A pipe, sometimes called a FIFO (“First In first Out”), differs from a regular file in that its data is transient: Once data is read from a pipe, it cannot be read again. Also, the data is read in the order that it was written to the pipe, and the system allows no deviation from that order.  The kernel stores the data in a pipe the same way it stores data in an ordinary file, except that it uses only the direct blocks, not the indirect blocks.  The last file types in the UNIX system are special files, including block device special files and character device special files. Both types specify devices, and therefore the file inodes do not reference any data. The inode contains two numbers known as the major and minor device numbers.The major number indicates a device type such as terminal or disk.  The minor number indicates the unit number of the device.
  • 29.
  • 30. iput releasing inode from in-core inode Steps for iput Algorithm The kernel locks the inode if it has not been already locked The kernel decrements inode reference count The kernel checks if reference count is 0 or not If the reference count is 0 and the number of links to the file is 0, then the kernel releases disk blocks for file(algorithm free), free the inode(algorithm ifree) If the file was accessed or the inode was changed or the file was changed , then the kernel updates the disk inode The kernel puts the inode on free list If the reference count is not 0, the kernel releases the inode lock
  • 31. Releasing Inodes: When the kernel releases an inode (algorithm iput), It decrements its in-core reference count. If the count drops to 0, the kernel writes the inode to disk if the in-core copy differs from the disk copy. They differ if the file data has changed, if the file access time has changed, or if the file owner or access permissions have changed. The kernel places the inode on the free list of inodes, effectively caching the inode in case it is needed again soon. The kernel may also release all data blocks associated with the file and free the inode if the number of links to the file is 0.
  • 32.
  • 33. Path Conversion to an inode The kernel works internally with inodes rather than with path names, it converts the path name to inodes to access files.
  • 34. The algorithm namei parses the path name one component at a time if (path name starts with root) ◦ working inode= root inode else ◦ working inode= current directory inode while (there is more path name) ◦ read next component from input ◦ read directory content ◦ if (component matches an entry in directory) ◦ get inode number for matched component ◦ release working inode ◦ working inode=inode of matched component ◦ Else ◦ return no inode return (working inode)