SlideShare ist ein Scribd-Unternehmen logo
1 von 37
© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
File System Modules
2© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
What to Expect?
W's of a File System
Three levels of File Systems
Design a File System
FS relation with a Hard Disk Partition
FS relation with /
Writing a FS module
3© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Why we need a File System?
Preserve Data for Later
Access
Update
Discard
Tag Data for
Categorizing
Easy & Fast Lookup
Fast & Reliable Data Management by
Optimized Operations
4© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
What is a File System?
Three things at three levels
Hardware Space – The Physical Organization of Data
on the Storage Devices
Kernel Space – Drivers to decode & access the data
from the Physical Organization
User Space – All what you see from / - The User View
Which ever it be, it basically does
Organize our data
For easy access by tagging
For fast maintenance by optimizing
5© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
The Three File Systems
Hardware (Space) File System - Storer
Kernel (Space) File System - Decoder
User (Space) File System - Show-er
Storer: Partition for the File System (/dev/*)
Creating the File System (mkfs.*)
Decoder: Driver for the File System (*.ko)
Show-er: Root File System (/xyz)
Connector of the 3: mount
Let's try an example
6© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Recall
7© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Understanding a Hard Disk
Example (Hard Disk)
Heads (or Platters): 0 – 9
Tracks (or Cylinders): 0 – 24
Sectors: 1 – 64
Size of the Hard Disk
10 x 25 x 64 x 512 bytes = 8000KiB
Device independent numbering
(h, t, s) → 64 * (10 * t + h) + s → (1 - 16000)
8© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Partitioning a Hard Disk
First Sector – Master Boot Record (MBR)
Contains Boot Info
Contains Physical Partition Table
Maximum Physical Partitions: 4
At max 1 as Extended Partition
Rest as Primary Partition
Extended could be further partitioned into
Logical Partitions
In each partition
First Sector – Boot Record (BR)
Remaining for File System / Format
Extended Partition BR contains the Logical Partition Table
9© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Placement of a Hardware FS
Each Partition contains a File System
Raw (no FS)
Organized
Organized one is initialized by the corresponding Formating
“Partition Type is to OS”
W95*, DOS*, BSD*, Solaris*, Linux, ...
“Format Type is to File System”
ext2, ext3, vfat, ntfs, jffs2, …
Particular Partition Types support only Particular File
System Types
10© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Design a FS
Let's Take 1 Partition
With 2N blocks of 1 sector each
Size = 2N x 512 bytes = N KiB
Given 3 data pieces
Source Code – 384 bytes
Image – 768 bytes
Document – 500 bytes
Place optimally for further operations
11© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
File System Design
C
384b
Img
768b
Doc
500b
12© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
File System Design
C
384b Img ...
512b
Doc
500b
...Img
256b
Img
768b
Doc
500b
13© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
File System Design
C
384b Img ...
512b
Doc
500b
...Img
256b
C 384 1 1
Img 768 2 3
Doc 500 4 4
XXX X X X
XXX X X X
...
14© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
File System Design
C
384b Img ...
512b
Doc
500b
...Img
256b
C 384 1 1
Img 768 2 3
Doc 500 4 4
0 0 0 0
0 0 0 0
...
15© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
File System Design
C ...
512b
Img ...
512b
Doc
500b
...Img
256b
C 384 1 1
Img 768 2 3
Doc 500 4 4
0 0 0 0
0 0 0 0
... … C
488b
16© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
File System Design
C ...
512b
Img ...
512b
Doc
500b
...Img
256b
C 1000 1 5 0 0 0
Img 768 2 3 0 0 0
Doc 500 4 0 0 0 0
0 0 0 0 0 0 0
...
… C
488b
17© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
File System Design
C ...
512b
Img ...
512b
Doc
500b
...Img
256b
C 1000 4 8 0 0 0
Img 768 5 6 0 0 0
Doc 500 7 0 0 0 0
0 0 0 0 0 0 0
...
… C
488b
18© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
File System Design
C ...
512b
Img ...
512b
Doc
500b
...Img
256b … C
488b4
FST
...
C 1000 5 9 0 0 0
Img 768 6 7 0 0 0
Doc 500 8 0 0 0 0
0 0 0 0 0 0 0
...
19© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
File System Design
C ...
512b
Img ...
512b
Doc
500b
...Img
256b … C
488b4
FST
...
C 1000 5 9 0 0 0TS rw-
Img 768 6 7 0 0 0TS rw-
Doc 500 8 0 0 0 0TS rw-
0 0 0 0 0 0 00 ---
...
20© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Kernel Space File System
Also called the File System modules
Examples: ext2, ext3, vfat, ntfs, jffs2, …, real_sfs, ...
Role: Decode the Hardware FS Layout to Access Data
from the User Space (by implementing the decode logic)
Through the following 2 Interactions:
Interface with the Hardware FS Layout in the hardware partition
Interface with the User Space FS to give a unified view, as at /
First part done through Block Driver
Second part done through VFS
Kernel provides VFS to achieve the virtual user view
21© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
VFS Specifics
Inherited from the Linux specific FS
Promoted to a super set of various FS
Providing a unified view to the User
Default values for various attributes
owner, group, permissions, …
File Types
Same seven types as in ext2/ext3
22© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Virtual File System Interactions
complete
vfat
VFS
ext2
Partition 1
....
Partition 2 ... Partition N ...
User Space File System View @ /
....
Block Driver Block Driver.... ....
real_sfs
Block Driver
23© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Virtual File System Internals
Super Block
Directory Entry Table
Inode Table
d
> File Name
> Inode Number
> File Meta Data
> File Data Block Nos
> FS Meta Data
> Root Inode Number
d
Data Block
r
24© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
VFS Interaction Internals
vfat
VFS
ext2
Buffer
Cache
Block
Drivers
Directory
Cache
Inode
Cache
....
Block
Drivers
25© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
VFS Translation Callbacks
Five categories
File System level
Super Block Operations
Super Block level (Meta Meta Data)
Inode Operations
Inode level (Meta Data)
Directory Entry Operations
File level (Data)
File Operations through the Buffer Cache
Buffer Cache level
Actual Data Operations
26© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
File System Registration
Header: <linux/fs.h>
APIs
int register_filesystem(file_system_type *)
int unregister_filesystem(file_system_type *)
File System Operations
get_sb/mount: (Invoked by mount)
get_sb_bdev/mount_bdev -> Fill the Super Block
kill_sb: (Invoked by umount)
kill_block_super
27© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Fill the Super Block
Block Size & Bits
Magic Number / File System Type
Super Block Operations
Root Inode
Inode Operations
Inode Mode
File Operations
28© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Super Block Operations
Header: <linux/fs.h>
APIs
write_inode: Update File Meta Data
statfs: Get the File Status (Invoked by stat)
simple_statfs (Handler from libfs)
29© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Inode Operations
Header: <linux/fs.h>
APIs
lookup
Search the file name by absolute path
Traverse the inode chain
if found matching inode, then populate the dentry with the inode
information
Inode Information
Size
Mode
File Operations
...
30© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
File Operations
Header: <linux/fs.h>
APIs
open → generic_file_open
read → do_sync_read → generic_file_aio_read →
do_generic_file_read → readpage
write → do_sync_write → generic_file_aio_write →
generic_file_buffered_write → write_begin & write_end
release
readdir: Change Directory (cd). List Directory (ls)
Directory Entry
Fill Function
fsync: Sync the File (sync)
simple_sync_file
31© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Address Space Operations
The Buffer / Page Cache level Operations
Header: <linux/fs.h>
Page Operations
readpage (Invoked by read)
write_begin, write_end (Invoked by write)
writepage (Invoked by pdflush kernel threads)
Page Functions
PageUptodate, PageDirty, PageWriteback, PageLocked
SetPageUptodate, ClearPageDirty, unlock_page, ...
page_address, ...
32© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
ext2/3 Data Block Organization
size ... db10 ib dib tib... db0uidmode
DB0 ... DB10 ...
DB11
... ...
... ...
...
DB...
DB...
DB...
33© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Dive into the Real Driver
© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
File System Pieces – Set 1
Hardware Space
File System Design (Logic) – real_sfs_ds.h
File System Creator (Application) – format_real_sfs.c /
mkfs.sfs.c
Kernel Space
File System Decoder (Driver) – real_sfs_ops.[hc]
File System Translator (Driver) – real_sfs.c
File System Show-er (VFS)
User Space
File System Connector (mount)
© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
File System Pieces – Set 2
Hardware Space
File System Design (Logic) – ddk_fs_ds.h
File System Creator (Application) – mkfs.ddkfs.c
Kernel Space
File System Decoder (Driver) – ddk_fs_ops.[hc]
File System Translator (Driver) – ddk_fs.c
File System Show-er (VFS)
User Space
File System Connector (mount)
36© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
What all have we learnt?
W's of a File System
Three levels of File Systems
And relation between them
Design a File System
FS relation with a Hard Disk Partition
FS relation with /
Role of VFS
Writing a FS module
Simplified Interaction with the Block Driver
5 Operation Sets with VFS
37© 2010-19 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Any Queries?

Weitere ähnliche Inhalte

Was ist angesagt? (20)

Video Drivers
Video DriversVideo Drivers
Video Drivers
 
Character Drivers
Character DriversCharacter Drivers
Character Drivers
 
Introduction to Embedded Systems
Introduction to Embedded SystemsIntroduction to Embedded Systems
Introduction to Embedded Systems
 
Bootloaders
BootloadersBootloaders
Bootloaders
 
I2C Drivers
I2C DriversI2C Drivers
I2C Drivers
 
Embedded Applications
Embedded ApplicationsEmbedded Applications
Embedded Applications
 
Linux Memory Management
Linux Memory ManagementLinux Memory Management
Linux Memory Management
 
BeagleBoard-xM Booting Process
BeagleBoard-xM Booting ProcessBeagleBoard-xM Booting Process
BeagleBoard-xM Booting Process
 
Platform Drivers
Platform DriversPlatform Drivers
Platform Drivers
 
Block Drivers
Block DriversBlock Drivers
Block Drivers
 
Board Bringup
Board BringupBoard Bringup
Board Bringup
 
Toolchain
ToolchainToolchain
Toolchain
 
Low-level Accesses
Low-level AccessesLow-level Accesses
Low-level Accesses
 
Introduction to Linux
Introduction to LinuxIntroduction to Linux
Introduction to Linux
 
Embedded Storage Management
Embedded Storage ManagementEmbedded Storage Management
Embedded Storage Management
 
Kernel Debugging & Profiling
Kernel Debugging & ProfilingKernel Debugging & Profiling
Kernel Debugging & Profiling
 
Introduction to Linux Drivers
Introduction to Linux DriversIntroduction to Linux Drivers
Introduction to Linux Drivers
 
gcc and friends
gcc and friendsgcc and friends
gcc and friends
 
BeagleBone Black Booting Process
BeagleBone Black Booting ProcessBeagleBone Black Booting Process
BeagleBone Black Booting Process
 
SPI Drivers
SPI DriversSPI Drivers
SPI Drivers
 

Ähnlich wie File System Modules

Ähnlich wie File System Modules (20)

File Systems
File SystemsFile Systems
File Systems
 
Introduction to Linux
Introduction to LinuxIntroduction to Linux
Introduction to Linux
 
Linux File System
Linux File SystemLinux File System
Linux File System
 
Linux Kernel Overview
Linux Kernel OverviewLinux Kernel Overview
Linux Kernel Overview
 
Linux_Commands_MT.pdf
Linux_Commands_MT.pdfLinux_Commands_MT.pdf
Linux_Commands_MT.pdf
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
 
File
FileFile
File
 
Linux System
Linux SystemLinux System
Linux System
 
TLPI Chapter 14 File Systems
TLPI Chapter 14 File SystemsTLPI Chapter 14 File Systems
TLPI Chapter 14 File Systems
 
File000128
File000128File000128
File000128
 
Advantages Of SAMBA
Advantages Of SAMBAAdvantages Of SAMBA
Advantages Of SAMBA
 
Let Me Pick Your Brain - Remote Forensics in Hardened Environments
Let Me Pick Your Brain - Remote Forensics in Hardened EnvironmentsLet Me Pick Your Brain - Remote Forensics in Hardened Environments
Let Me Pick Your Brain - Remote Forensics in Hardened Environments
 
System Calls
System CallsSystem Calls
System Calls
 
Ite pc v40_chapter5
Ite pc v40_chapter5Ite pc v40_chapter5
Ite pc v40_chapter5
 
Linux Basics
Linux BasicsLinux Basics
Linux Basics
 
System Calls
System CallsSystem Calls
System Calls
 
Lec9chap8f04
Lec9chap8f04Lec9chap8f04
Lec9chap8f04
 
Linux IO
Linux IOLinux IO
Linux IO
 
101 2.1 design hard disk layout v2
101 2.1 design hard disk layout v2101 2.1 design hard disk layout v2
101 2.1 design hard disk layout v2
 
Windows 7 forensics -overview-r3
Windows 7 forensics -overview-r3Windows 7 forensics -overview-r3
Windows 7 forensics -overview-r3
 

Mehr von Anil Kumar Pugalia (20)

Kernel Debugging & Profiling
Kernel Debugging & ProfilingKernel Debugging & Profiling
Kernel Debugging & Profiling
 
Processes
ProcessesProcesses
Processes
 
Embedded C
Embedded CEmbedded C
Embedded C
 
Embedded Software Design
Embedded Software DesignEmbedded Software Design
Embedded Software Design
 
Playing with R L C Circuits
Playing with R L C CircuitsPlaying with R L C Circuits
Playing with R L C Circuits
 
Audio Drivers
Audio DriversAudio Drivers
Audio Drivers
 
Mobile Hacking using Linux Drivers
Mobile Hacking using Linux DriversMobile Hacking using Linux Drivers
Mobile Hacking using Linux Drivers
 
References
ReferencesReferences
References
 
Functional Programming with LISP
Functional Programming with LISPFunctional Programming with LISP
Functional Programming with LISP
 
Power of vi
Power of viPower of vi
Power of vi
 
"make" system
"make" system"make" system
"make" system
 
Hardware Design for Software Hackers
Hardware Design for Software HackersHardware Design for Software Hackers
Hardware Design for Software Hackers
 
RPM Building
RPM BuildingRPM Building
RPM Building
 
Linux User Space Debugging & Profiling
Linux User Space Debugging & ProfilingLinux User Space Debugging & Profiling
Linux User Space Debugging & Profiling
 
Linux Network Management
Linux Network ManagementLinux Network Management
Linux Network Management
 
Timers
TimersTimers
Timers
 
Threads
ThreadsThreads
Threads
 
Synchronization
SynchronizationSynchronization
Synchronization
 
Processes
ProcessesProcesses
Processes
 
Signals
SignalsSignals
Signals
 

Kürzlich hochgeladen

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 

Kürzlich hochgeladen (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

File System Modules

  • 1. © 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. File System Modules
  • 2. 2© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. What to Expect? W's of a File System Three levels of File Systems Design a File System FS relation with a Hard Disk Partition FS relation with / Writing a FS module
  • 3. 3© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Why we need a File System? Preserve Data for Later Access Update Discard Tag Data for Categorizing Easy & Fast Lookup Fast & Reliable Data Management by Optimized Operations
  • 4. 4© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. What is a File System? Three things at three levels Hardware Space – The Physical Organization of Data on the Storage Devices Kernel Space – Drivers to decode & access the data from the Physical Organization User Space – All what you see from / - The User View Which ever it be, it basically does Organize our data For easy access by tagging For fast maintenance by optimizing
  • 5. 5© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. The Three File Systems Hardware (Space) File System - Storer Kernel (Space) File System - Decoder User (Space) File System - Show-er Storer: Partition for the File System (/dev/*) Creating the File System (mkfs.*) Decoder: Driver for the File System (*.ko) Show-er: Root File System (/xyz) Connector of the 3: mount Let's try an example
  • 6. 6© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Recall
  • 7. 7© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Understanding a Hard Disk Example (Hard Disk) Heads (or Platters): 0 – 9 Tracks (or Cylinders): 0 – 24 Sectors: 1 – 64 Size of the Hard Disk 10 x 25 x 64 x 512 bytes = 8000KiB Device independent numbering (h, t, s) → 64 * (10 * t + h) + s → (1 - 16000)
  • 8. 8© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Partitioning a Hard Disk First Sector – Master Boot Record (MBR) Contains Boot Info Contains Physical Partition Table Maximum Physical Partitions: 4 At max 1 as Extended Partition Rest as Primary Partition Extended could be further partitioned into Logical Partitions In each partition First Sector – Boot Record (BR) Remaining for File System / Format Extended Partition BR contains the Logical Partition Table
  • 9. 9© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Placement of a Hardware FS Each Partition contains a File System Raw (no FS) Organized Organized one is initialized by the corresponding Formating “Partition Type is to OS” W95*, DOS*, BSD*, Solaris*, Linux, ... “Format Type is to File System” ext2, ext3, vfat, ntfs, jffs2, … Particular Partition Types support only Particular File System Types
  • 10. 10© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Design a FS Let's Take 1 Partition With 2N blocks of 1 sector each Size = 2N x 512 bytes = N KiB Given 3 data pieces Source Code – 384 bytes Image – 768 bytes Document – 500 bytes Place optimally for further operations
  • 11. 11© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. File System Design C 384b Img 768b Doc 500b
  • 12. 12© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. File System Design C 384b Img ... 512b Doc 500b ...Img 256b Img 768b Doc 500b
  • 13. 13© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. File System Design C 384b Img ... 512b Doc 500b ...Img 256b C 384 1 1 Img 768 2 3 Doc 500 4 4 XXX X X X XXX X X X ...
  • 14. 14© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. File System Design C 384b Img ... 512b Doc 500b ...Img 256b C 384 1 1 Img 768 2 3 Doc 500 4 4 0 0 0 0 0 0 0 0 ...
  • 15. 15© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. File System Design C ... 512b Img ... 512b Doc 500b ...Img 256b C 384 1 1 Img 768 2 3 Doc 500 4 4 0 0 0 0 0 0 0 0 ... … C 488b
  • 16. 16© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. File System Design C ... 512b Img ... 512b Doc 500b ...Img 256b C 1000 1 5 0 0 0 Img 768 2 3 0 0 0 Doc 500 4 0 0 0 0 0 0 0 0 0 0 0 ... … C 488b
  • 17. 17© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. File System Design C ... 512b Img ... 512b Doc 500b ...Img 256b C 1000 4 8 0 0 0 Img 768 5 6 0 0 0 Doc 500 7 0 0 0 0 0 0 0 0 0 0 0 ... … C 488b
  • 18. 18© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. File System Design C ... 512b Img ... 512b Doc 500b ...Img 256b … C 488b4 FST ... C 1000 5 9 0 0 0 Img 768 6 7 0 0 0 Doc 500 8 0 0 0 0 0 0 0 0 0 0 0 ...
  • 19. 19© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. File System Design C ... 512b Img ... 512b Doc 500b ...Img 256b … C 488b4 FST ... C 1000 5 9 0 0 0TS rw- Img 768 6 7 0 0 0TS rw- Doc 500 8 0 0 0 0TS rw- 0 0 0 0 0 0 00 --- ...
  • 20. 20© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Kernel Space File System Also called the File System modules Examples: ext2, ext3, vfat, ntfs, jffs2, …, real_sfs, ... Role: Decode the Hardware FS Layout to Access Data from the User Space (by implementing the decode logic) Through the following 2 Interactions: Interface with the Hardware FS Layout in the hardware partition Interface with the User Space FS to give a unified view, as at / First part done through Block Driver Second part done through VFS Kernel provides VFS to achieve the virtual user view
  • 21. 21© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. VFS Specifics Inherited from the Linux specific FS Promoted to a super set of various FS Providing a unified view to the User Default values for various attributes owner, group, permissions, … File Types Same seven types as in ext2/ext3
  • 22. 22© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Virtual File System Interactions complete vfat VFS ext2 Partition 1 .... Partition 2 ... Partition N ... User Space File System View @ / .... Block Driver Block Driver.... .... real_sfs Block Driver
  • 23. 23© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Virtual File System Internals Super Block Directory Entry Table Inode Table d > File Name > Inode Number > File Meta Data > File Data Block Nos > FS Meta Data > Root Inode Number d Data Block r
  • 24. 24© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. VFS Interaction Internals vfat VFS ext2 Buffer Cache Block Drivers Directory Cache Inode Cache .... Block Drivers
  • 25. 25© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. VFS Translation Callbacks Five categories File System level Super Block Operations Super Block level (Meta Meta Data) Inode Operations Inode level (Meta Data) Directory Entry Operations File level (Data) File Operations through the Buffer Cache Buffer Cache level Actual Data Operations
  • 26. 26© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. File System Registration Header: <linux/fs.h> APIs int register_filesystem(file_system_type *) int unregister_filesystem(file_system_type *) File System Operations get_sb/mount: (Invoked by mount) get_sb_bdev/mount_bdev -> Fill the Super Block kill_sb: (Invoked by umount) kill_block_super
  • 27. 27© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Fill the Super Block Block Size & Bits Magic Number / File System Type Super Block Operations Root Inode Inode Operations Inode Mode File Operations
  • 28. 28© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Super Block Operations Header: <linux/fs.h> APIs write_inode: Update File Meta Data statfs: Get the File Status (Invoked by stat) simple_statfs (Handler from libfs)
  • 29. 29© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Inode Operations Header: <linux/fs.h> APIs lookup Search the file name by absolute path Traverse the inode chain if found matching inode, then populate the dentry with the inode information Inode Information Size Mode File Operations ...
  • 30. 30© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. File Operations Header: <linux/fs.h> APIs open → generic_file_open read → do_sync_read → generic_file_aio_read → do_generic_file_read → readpage write → do_sync_write → generic_file_aio_write → generic_file_buffered_write → write_begin & write_end release readdir: Change Directory (cd). List Directory (ls) Directory Entry Fill Function fsync: Sync the File (sync) simple_sync_file
  • 31. 31© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Address Space Operations The Buffer / Page Cache level Operations Header: <linux/fs.h> Page Operations readpage (Invoked by read) write_begin, write_end (Invoked by write) writepage (Invoked by pdflush kernel threads) Page Functions PageUptodate, PageDirty, PageWriteback, PageLocked SetPageUptodate, ClearPageDirty, unlock_page, ... page_address, ...
  • 32. 32© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. ext2/3 Data Block Organization size ... db10 ib dib tib... db0uidmode DB0 ... DB10 ... DB11 ... ... ... ... ... DB... DB... DB...
  • 33. 33© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Dive into the Real Driver
  • 34. © 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. File System Pieces – Set 1 Hardware Space File System Design (Logic) – real_sfs_ds.h File System Creator (Application) – format_real_sfs.c / mkfs.sfs.c Kernel Space File System Decoder (Driver) – real_sfs_ops.[hc] File System Translator (Driver) – real_sfs.c File System Show-er (VFS) User Space File System Connector (mount)
  • 35. © 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. File System Pieces – Set 2 Hardware Space File System Design (Logic) – ddk_fs_ds.h File System Creator (Application) – mkfs.ddkfs.c Kernel Space File System Decoder (Driver) – ddk_fs_ops.[hc] File System Translator (Driver) – ddk_fs.c File System Show-er (VFS) User Space File System Connector (mount)
  • 36. 36© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. What all have we learnt? W's of a File System Three levels of File Systems And relation between them Design a File System FS relation with a Hard Disk Partition FS relation with / Role of VFS Writing a FS module Simplified Interaction with the Block Driver 5 Operation Sets with VFS
  • 37. 37© 2010-19 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Any Queries?