SlideShare a Scribd company logo
Lab 10: File system – Inodes and beyond
Advanced Operating Systems

Zubair Nabi
zubair.nabi@itu.edu.pk

April 10, 2013
Recap of Lab 9: xv6 FS layers

File descriptors

System calls

Recursive lookup Pathnames
Directory inodes
Inodes and
block allocator
Logging
Buffer cache

Directories
Files
Transactions
Blocks
Recap of Lab 9: xv6 FS layers (2)

1

Buffer cache: Reads and writes blocks on the IDE disk via the
buffer cache, which synchronizes access to disk blocks
Recap of Lab 9: xv6 FS layers (2)

1

Buffer cache: Reads and writes blocks on the IDE disk via the
buffer cache, which synchronizes access to disk blocks
• Ensures that only one kernel process can edit any particular block
at a time
Recap of Lab 9: xv6 FS layers (2)

1

Buffer cache: Reads and writes blocks on the IDE disk via the
buffer cache, which synchronizes access to disk blocks
• Ensures that only one kernel process can edit any particular block
at a time

2

Logging: Ensures atomicity by enabling higher layers to wrap
updates to several blocks in a transaction
Recap of Lab 9: xv6 FS layers (2)

1

Buffer cache: Reads and writes blocks on the IDE disk via the
buffer cache, which synchronizes access to disk blocks
• Ensures that only one kernel process can edit any particular block
at a time

2

Logging: Ensures atomicity by enabling higher layers to wrap
updates to several blocks in a transaction

3

Inodes and block allocator: Provides unnamed files, each
unnamed file is represented by an inode and a sequence of
blocks holding the file content
Recap of Lab 9: xv6 FS layers (3)

4

Directory inodes: Implements directories as a special kind of
inode
Recap of Lab 9: xv6 FS layers (3)

4

Directory inodes: Implements directories as a special kind of
inode
• The content of this inode is a sequence of directory entries, each
of which contains a name and a reference to the named file’s
inode
Recap of Lab 9: xv6 FS layers (3)

4

Directory inodes: Implements directories as a special kind of
inode
• The content of this inode is a sequence of directory entries, each
of which contains a name and a reference to the named file’s
inode

5

Recursive lookup: Provides hierarchical path names such as
/foo/bar/baz.txt, via recursive lookup
Recap of Lab 9: xv6 FS layers (3)

4

Directory inodes: Implements directories as a special kind of
inode
• The content of this inode is a sequence of directory entries, each
of which contains a name and a reference to the named file’s
inode

5

Recursive lookup: Provides hierarchical path names such as
/foo/bar/baz.txt, via recursive lookup

6

File descriptors: Abstracts many Unix resources, such as pipes,
devices, file, etc., using the file system interface
Recap of Lab 9: File system layout

• xv6 lays out inodes and content blocks on the disk by dividing the
disk into several sections
Recap of Lab 9: File system layout

• xv6 lays out inodes and content blocks on the disk by dividing the
disk into several sections
boot super
0

1

inodes...
2

• Block 0 holds the boot sector

bitmap...
…..

data...

log...
Recap of Lab 9: File system layout

• xv6 lays out inodes and content blocks on the disk by dividing the
disk into several sections
boot super
0

1

inodes...
2

bitmap...

data...

log...

…..

• Block 0 holds the boot sector
• Block 1 (called the superblock) contains metadata about the file
system
Recap of Lab 9: File system layout

• xv6 lays out inodes and content blocks on the disk by dividing the
disk into several sections
boot super
0

1

inodes...
2

bitmap...

data...

log...

…..

• Block 0 holds the boot sector
• Block 1 (called the superblock) contains metadata about the file
system
• File system size in blocks, the number of data blocks, the number
of inodes, and the number of blocks in the log
Recap of Lab 9: File system layout

• xv6 lays out inodes and content blocks on the disk by dividing the
disk into several sections
boot super
0

1

inodes...
2

bitmap...

data...

log...

…..

• Block 0 holds the boot sector
• Block 1 (called the superblock) contains metadata about the file
system
• File system size in blocks, the number of data blocks, the number
of inodes, and the number of blocks in the log

• Blocks starting at 2 hold inodes, with multiple inodes per block
Recap of Lab 9: File system layout

boot super
0

1

inodes...
2

bitmap...

data...

log...

…..

• inode blocks are followed by bitmap blocks which keep track of
data blocks in use
Recap of Lab 9: File system layout

boot super
0

1

inodes...
2

bitmap...

data...

log...

…..

• inode blocks are followed by bitmap blocks which keep track of
data blocks in use
• Bitmap blocks are followed by data blocks which hold file and
directory contents
Recap of Lab 9: File system layout

boot super
0

1

inodes...
2

bitmap...

data...

log...

…..

• inode blocks are followed by bitmap blocks which keep track of
data blocks in use
• Bitmap blocks are followed by data blocks which hold file and
directory contents
• Finally at the end, the blocks hold a log which is required by the
transaction layer
Inodes

• Have two variants:
1

On-disk data structure containing a file’s size and list of data block
numbers
Inodes

• Have two variants:
On-disk data structure containing a file’s size and list of data block
numbers
2 In-memory version of the on-disk inode, along with extra
information needed within the kernel
1
Inodes

• Have two variants:
On-disk data structure containing a file’s size and list of data block
numbers
2 In-memory version of the on-disk inode, along with extra
information needed within the kernel
1

• All on-disk inodes are stored in a contiguous area of disk,
between the superblock and the bitmap block
Inodes

• Have two variants:
On-disk data structure containing a file’s size and list of data block
numbers
2 In-memory version of the on-disk inode, along with extra
information needed within the kernel
1

• All on-disk inodes are stored in a contiguous area of disk,
between the superblock and the bitmap block
• Each inode has the same size, so given a number n (called the
inode number or i-number), it is simple to locate the
corresponding inode
On-disk inodes

• Represented by struct dinode
On-disk inodes

• Represented by struct dinode
• Contains a type field to distinguish between files, directories, and
special files (devices)
On-disk inodes

• Represented by struct dinode
• Contains a type field to distinguish between files, directories, and
special files (devices)
• Zero indicates that the dinode is free
On-disk inodes

• Represented by struct dinode
• Contains a type field to distinguish between files, directories, and
special files (devices)
• Zero indicates that the dinode is free
• Also keeps track of the number of directory entries that refer to
this inode
On-disk inodes

• Represented by struct dinode
• Contains a type field to distinguish between files, directories, and
special files (devices)
• Zero indicates that the dinode is free
• Also keeps track of the number of directory entries that refer to
this inode
• This reference count dictates when the inode should be freed
On-disk inodes

• Represented by struct dinode
• Contains a type field to distinguish between files, directories, and
special files (devices)
• Zero indicates that the dinode is free
• Also keeps track of the number of directory entries that refer to
this inode
• This reference count dictates when the inode should be freed

• Also has fields to hold number of bytes of content and the block
numbers of disk blocks
Code: dinode

struct dinode {
short type; // File type
short major; // Major device number (T_DEV only)
short minor; // Minor device number (T_DEV only)
short nlink; // Number of links to inode in file s
uint size; // Size of file (bytes)
uint addrs[NDIRECT+1]; // Data block addresses
};
#define T_DIR 1 // Directory
#define T_FILE 2 // File
#define T_DEV 3 // Device
In-memory inodes

• Represented by struct inode
In-memory inodes

• Represented by struct inode
• An inode is kept in memory if there are C pointers referring to it
In-memory inodes

• Represented by struct inode
• An inode is kept in memory if there are C pointers referring to it
• These pointers come from file descriptors, current working
directories, and kernel code
In-memory inodes

• Represented by struct inode
• An inode is kept in memory if there are C pointers referring to it
• These pointers come from file descriptors, current working
directories, and kernel code
• iget and iput functions are used to acquire and release
pointers to/from an inode
In-memory inodes

• Represented by struct inode
• An inode is kept in memory if there are C pointers referring to it
• These pointers come from file descriptors, current working
directories, and kernel code
• iget and iput functions are used to acquire and release
pointers to/from an inode
• A pointer via an iget() call implements a weak form of a lock by
ensuring that the inode will stay in the cache till the reference
count goes down to zero
In-memory inodes

• Represented by struct inode
• An inode is kept in memory if there are C pointers referring to it
• These pointers come from file descriptors, current working
directories, and kernel code
• iget and iput functions are used to acquire and release
pointers to/from an inode
• A pointer via an iget() call implements a weak form of a lock by
ensuring that the inode will stay in the cache till the reference
count goes down to zero
• These pointers enable long-term references (open files and
current directory) and to prevent deadlock in code that
manipulates multiple inodes (pathname lookup)
Code: inode
struct inode {
uint dev; // Device number
uint inum; // Inode number
int ref; // Reference count
int flags; // I_BUSY, I_VALID
short type; // copy of disk inode
short major;
short minor;
short nlink;
uint size;
uint addrs[NDIRECT+1];
};
#define I_BUSY 0x1
#define I_VALID 0x2
Inode locks and allocation

• To ensure that an inode has valid content, the code must read it
from disk
Inode locks and allocation

• To ensure that an inode has valid content, the code must read it
from disk
• This read call must be wrapped around ilock and iunlock
Inode locks and allocation

• To ensure that an inode has valid content, the code must read it
from disk
• This read call must be wrapped around ilock and iunlock
• This allows multiple processes to hold a C pointer to an inode but
only one process can lock it at a time
Inode locks and allocation

• To ensure that an inode has valid content, the code must read it
from disk
• This read call must be wrapped around ilock and iunlock
• This allows multiple processes to hold a C pointer to an inode but
only one process can lock it at a time
• Inodes are allocated via ialloc which works similar to balloc
Inode data

• Data is found in the blocks pointed to by the addrs fields
Inode data

• Data is found in the blocks pointed to by the addrs fields
• Size of addrs is NDIRECT+1 where NDIRECT is 12
Inode data

• Data is found in the blocks pointed to by the addrs fields
• Size of addrs is NDIRECT+1 where NDIRECT is 12
• addrs can refer to 6KB of data
Inode data

• Data is found in the blocks pointed to by the addrs fields
• Size of addrs is NDIRECT+1 where NDIRECT is 12
• addrs can refer to 6KB of data
• The 13th location in addrs field points to the indirect block
(NINDIRECT) which points to 64KB of data
Inode data

• Data is found in the blocks pointed to by the addrs fields
• Size of addrs is NDIRECT+1 where NDIRECT is 12
• addrs can refer to 6KB of data
• The 13th location in addrs field points to the indirect block
(NINDIRECT) which points to 64KB of data
• Therefore, while fixed-sized blocks simplify look up, the maximum
size of a file in xv6 can be 70KB
Inodes content

• bmap(struct inode *ip, uint bn) returns the disk
address of the nth block within inode ip, masking away the
complexity of direct and indirect blocks
Inodes content

• bmap(struct inode *ip, uint bn) returns the disk
address of the nth block within inode ip, masking away the
complexity of direct and indirect blocks
• If the data block does not exist, it is created
Inodes content

• bmap(struct inode *ip, uint bn) returns the disk
address of the nth block within inode ip, masking away the
complexity of direct and indirect blocks
• If the data block does not exist, it is created

• itrunc(struct inode *ip) frees inode ip by setting its
reference count to zero and freeing up blocks, both direct and
indirect
Inodes content

• bmap(struct inode *ip, uint bn) returns the disk
address of the nth block within inode ip, masking away the
complexity of direct and indirect blocks
• If the data block does not exist, it is created

• itrunc(struct inode *ip) frees inode ip by setting its
reference count to zero and freeing up blocks, both direct and
indirect
• readi(struct inode *ip, char *dst, uint
off, uint n) reads n blocks in inode ip starting from off
into dst
Inodes content (2)

• writei(struct inode *ip, char *src, uint
off, uint n) works similar to readi but it:
Inodes content (2)

• writei(struct inode *ip, char *src, uint
off, uint n) works similar to readi but it:
1

Copies data in instead of out
Inodes content (2)

• writei(struct inode *ip, char *src, uint
off, uint n) works similar to readi but it:
1
2

Copies data in instead of out
Extends the file if the write increases its size
Inodes content (2)

• writei(struct inode *ip, char *src, uint
off, uint n) works similar to readi but it:
Copies data in instead of out
Extends the file if the write increases its size
3 Updates the size in the inode

1

2
Inodes content (2)

• writei(struct inode *ip, char *src, uint
off, uint n) works similar to readi but it:
Copies data in instead of out
Extends the file if the write increases its size
3 Updates the size in the inode

1

2

• stati(struct inode *ip, struct stat *st)
copies metadata of inode ip into st which is exposed to
userspace via the stat system call
Directory layer

• A directory is a file with an inode type T_DIR and data in the
form of a sequence of directory entries
Directory layer

• A directory is a file with an inode type T_DIR and data in the
form of a sequence of directory entries
• Each entry is a struct dirent
Directory layer

• A directory is a file with an inode type T_DIR and data in the
form of a sequence of directory entries
• Each entry is a struct dirent

struct dirent {
ushort inum; // free, if zero
char name[DIRSIZ];
};
#define DIRSIZ 14
dirlookup

• Searches a directory for an entry with the given name
dirlookup

• Searches a directory for an entry with the given name
• Signature: struct inode* dirlookup(struct inode

*dp, char *name, uint *poff)
dirlookup

• Searches a directory for an entry with the given name
• Signature: struct inode* dirlookup(struct inode

*dp, char *name, uint *poff)
• If it finds it, it returns a pointer to the corresponding inode via
iget, unlocked, and returns the offset of the entry within the
directory
dirlink

• Writes a new directory entry with the given name and inode
number into dp
dirlink

• Writes a new directory entry with the given name and inode
number into dp
• Signature: int dirlink(struct inode *dp, char

*name, uint inum)
Path names

• Path name look up is enabled by multiple calls – one for each
path component – to dirlookup
Path names

• Path name look up is enabled by multiple calls – one for each
path component – to dirlookup
• namei takes a path and returns the corresponding inode
Path names

• Path name look up is enabled by multiple calls – one for each
path component – to dirlookup
• namei takes a path and returns the corresponding inode
• nameiparent is similar but returns the inode of the parent
directory
Path names

• Path name look up is enabled by multiple calls – one for each
path component – to dirlookup
• namei takes a path and returns the corresponding inode
• nameiparent is similar but returns the inode of the parent
directory
• Both make a call to namex internally
namex

• Starts by deciding where the path evaluation begins
namex

• Starts by deciding where the path evaluation begins
• If the path begins with /, evaluation starts at the root
namex

• Starts by deciding where the path evaluation begins
• If the path begins with /, evaluation starts at the root
• Otherwise, the current directory
namex

• Starts by deciding where the path evaluation begins
• If the path begins with /, evaluation starts at the root
• Otherwise, the current directory

• Uses skipelem to parse the path into path elements
namex

• Starts by deciding where the path evaluation begins
• If the path begins with /, evaluation starts at the root
• Otherwise, the current directory

• Uses skipelem to parse the path into path elements
• For each iteration (depending on the number of path elements),
looks up name within the current path element inode till it finds
the required inode and returns it
File descriptor layer

• Everything in Unix is a file and this interface is enabled by the file
descriptor layer
File descriptor layer

• Everything in Unix is a file and this interface is enabled by the file
descriptor layer
• Each process has its own open files (or file descriptor) table
File descriptor layer

• Everything in Unix is a file and this interface is enabled by the file
descriptor layer
• Each process has its own open files (or file descriptor) table
• Each open file is represented by struct file
Code: struct file

struct file {
enum { FD_NONE, FD_PIPE, FD_INODE } type;
int ref; // reference count
char readable;
char writable;
struct pipe *pipe;
struct inode *ip;
uint off;
};
file
• struct file is simply a wrapper around an inode or a pipe;
plus an I/O offset
file
• struct file is simply a wrapper around an inode or a pipe;
plus an I/O offset
• Each call to open creates a new struct file
file
• struct file is simply a wrapper around an inode or a pipe;
plus an I/O offset
• Each call to open creates a new struct file
• If multiple processes open the same independently, they will have
their own struct file for it with a local I/O offset
file
• struct file is simply a wrapper around an inode or a pipe;
plus an I/O offset
• Each call to open creates a new struct file
• If multiple processes open the same independently, they will have
their own struct file for it with a local I/O offset
• The same struct file can appear multiple times within a) A
process’s file table, and b) Across multiple processes
file
• struct file is simply a wrapper around an inode or a pipe;
plus an I/O offset
• Each call to open creates a new struct file
• If multiple processes open the same independently, they will have
their own struct file for it with a local I/O offset
• The same struct file can appear multiple times within a) A
process’s file table, and b) Across multiple processes
• When would this happen?
file
• struct file is simply a wrapper around an inode or a pipe;
plus an I/O offset
• Each call to open creates a new struct file
• If multiple processes open the same independently, they will have
their own struct file for it with a local I/O offset
• The same struct file can appear multiple times within a) A
process’s file table, and b) Across multiple processes
• When would this happen?
• a happens when a process opens a file and then dups it and b
takes place when it makes a call to fork
file
• struct file is simply a wrapper around an inode or a pipe;
plus an I/O offset
• Each call to open creates a new struct file
• If multiple processes open the same independently, they will have
their own struct file for it with a local I/O offset
• The same struct file can appear multiple times within a) A
process’s file table, and b) Across multiple processes
• When would this happen?
• a happens when a process opens a file and then dups it and b
takes place when it makes a call to fork

• Reference count tracks the number of references to a particular
open file
file
• struct file is simply a wrapper around an inode or a pipe;
plus an I/O offset
• Each call to open creates a new struct file
• If multiple processes open the same independently, they will have
their own struct file for it with a local I/O offset
• The same struct file can appear multiple times within a) A
process’s file table, and b) Across multiple processes
• When would this happen?
• a happens when a process opens a file and then dups it and b
takes place when it makes a call to fork

• Reference count tracks the number of references to a particular
open file
• Read/write access is tracked by readable/writable fields
Global file table

• All open files in the system are kept within a global file table
(ftable)
Global file table

• All open files in the system are kept within a global file table
(ftable)
• ftable has corresponding functions to:
1 Allocate a file: filealloc
Global file table

• All open files in the system are kept within a global file table
(ftable)
• ftable has corresponding functions to:
1 Allocate a file: filealloc
2 Create a duplicate reference: filedup
Global file table

• All open files in the system are kept within a global file table
(ftable)
• ftable has corresponding functions to:
1 Allocate a file: filealloc
2 Create a duplicate reference: filedup
3 Release a reference: fileclose
Global file table

• All open files in the system are kept within a global file table
(ftable)
• ftable has corresponding functions to:
1 Allocate a file: filealloc
2 Create a duplicate reference: filedup
3 Release a reference: fileclose
4 Read from a file: fileread
Global file table

• All open files in the system are kept within a global file table
(ftable)
• ftable has corresponding functions to:
1 Allocate a file: filealloc
2 Create a duplicate reference: filedup
3 Release a reference: fileclose
4 Read from a file: fileread
5 Write to a file: filewrite
File manipulation

• filealloc: Scans the file table for an unreferenced file
(f->ref == 0) and returns a new reference
File manipulation

• filealloc: Scans the file table for an unreferenced file
(f->ref == 0) and returns a new reference
• filedup: Increments the reference count
File manipulation

• filealloc: Scans the file table for an unreferenced file
(f->ref == 0) and returns a new reference
• filedup: Increments the reference count
• fileclose: Decrements the reference count
File manipulation

• filealloc: Scans the file table for an unreferenced file
(f->ref == 0) and returns a new reference
• filedup: Increments the reference count
• fileclose: Decrements the reference count
• If f->ref == 0, underlying pipe or inode is released
File manipulation (2)

• filestat: Invokes stati and ensures that the file represents
an inode
File manipulation (2)

• filestat: Invokes stati and ensures that the file represents
an inode
• fileread and filewrite:
1

Check whether the operation is allowed by the open mode
File manipulation (2)

• filestat: Invokes stati and ensures that the file represents
an inode
• fileread and filewrite:
1
2

Check whether the operation is allowed by the open mode
Patch the call through to either the underlying pipe or inode
implementation
File manipulation (2)

• filestat: Invokes stati and ensures that the file represents
an inode
• fileread and filewrite:
Check whether the operation is allowed by the open mode
Patch the call through to either the underlying pipe or inode
implementation
3 If the wrapper is around an inode, the I/O offset would be used
and then advanced
1

2
File manipulation (2)

• filestat: Invokes stati and ensures that the file represents
an inode
• fileread and filewrite:
Check whether the operation is allowed by the open mode
Patch the call through to either the underlying pipe or inode
implementation
3 If the wrapper is around an inode, the I/O offset would be used
and then advanced
4 Pipes have no concept of offset
1

2
System calls

• sys_link and sys_unlink edit directories by creating or
removing references to inodes
System calls

• sys_link and sys_unlink edit directories by creating or
removing references to inodes
• sys_link creates a new name for an existing inode
System calls

• sys_link and sys_unlink edit directories by creating or
removing references to inodes
• sys_link creates a new name for an existing inode
1 Takes as arguments two strings old and new
System calls

• sys_link and sys_unlink edit directories by creating or
removing references to inodes
• sys_link creates a new name for an existing inode
1 Takes as arguments two strings old and new
2 Increments its nlink field – Number of links
System calls

• sys_link and sys_unlink edit directories by creating or
removing references to inodes
• sys_link creates a new name for an existing inode
1 Takes as arguments two strings old and new
2 Increments its nlink field – Number of links
3

Creates a new directory entry pointing at old’s inode
System calls

• sys_link and sys_unlink edit directories by creating or
removing references to inodes
• sys_link creates a new name for an existing inode
1 Takes as arguments two strings old and new
2 Increments its nlink field – Number of links
3
4

Creates a new directory entry pointing at old’s inode
The new directory entry is on the same inode as the existing one
create

• Creates a new name for a new inode
create

• Creates a new name for a new inode
• Generalizes the creation of three file creation system calls:
create

• Creates a new name for a new inode
• Generalizes the creation of three file creation system calls:
1 open with the O_CREATE flag creates a new file
create

• Creates a new name for a new inode
• Generalizes the creation of three file creation system calls:
1 open with the O_CREATE flag creates a new file
2 mkdir creates a new directory
create

• Creates a new name for a new inode
• Generalizes the creation of three file creation system calls:
1 open with the O_CREATE flag creates a new file
2 mkdir creates a new directory
3 mkdev creates a new device file
create (2)

• Makes a call to dirlookup to check whether the name already
exists
create (2)

• Makes a call to dirlookup to check whether the name already
exists
• If it does not exist, creates a new inode via a call to ialloc
create (2)

• Makes a call to dirlookup to check whether the name already
exists
• If it does not exist, creates a new inode via a call to ialloc
• If create has been invoked by mkdir (T_DIR), it initializes it
with . and .. entries
create (2)

• Makes a call to dirlookup to check whether the name already
exists
• If it does not exist, creates a new inode via a call to ialloc
• If create has been invoked by mkdir (T_DIR), it initializes it
with . and .. entries
• Finally, it links it into the parent directory
Buffer cache eviction policy

• xv6’s buffer cache uses simple LRU eviction
Buffer cache eviction policy

• xv6’s buffer cache uses simple LRU eviction
• A number of different policies can be implemented such as FIFO,
not frequently used, aging, random, etc.
Buffer cache eviction policy

• xv6’s buffer cache uses simple LRU eviction
• A number of different policies can be implemented such as FIFO,
not frequently used, aging, random, etc.
• The buffer cache is currently a linked list but an efficient
implementation can replace it with a hash table and/or a heap
Buffer cache eviction policy

• xv6’s buffer cache uses simple LRU eviction
• A number of different policies can be implemented such as FIFO,
not frequently used, aging, random, etc.
• The buffer cache is currently a linked list but an efficient
implementation can replace it with a hash table and/or a heap
• The buffer cache can also be integrated with the virtual memory
system to enabled memory-mapped files (mmap in Linux)
Today’s task

• xv6 has no support for memory-mapped files
• Come up with a design to implement mmap1

1

http://man7.org/linux/man-pages/man2/mmap.2.html
Reading(s)

• Chapter 6, “File system”, from “Code: directory layer" onwards
from “xv6: a simple, Unix-like teaching operating system”

More Related Content

What's hot

Course 102: Lecture 26: FileSystems in Linux (Part 1)
Course 102: Lecture 26: FileSystems in Linux (Part 1) Course 102: Lecture 26: FileSystems in Linux (Part 1)
Course 102: Lecture 26: FileSystems in Linux (Part 1)
Ahmed El-Arabawy
 
Osdc2011.ext4btrfs.talk
Osdc2011.ext4btrfs.talkOsdc2011.ext4btrfs.talk
Osdc2011.ext4btrfs.talk
Udo Seidel
 
Part 03 File System Implementation in Linux
Part 03 File System Implementation in LinuxPart 03 File System Implementation in Linux
Part 03 File System Implementation in Linux
Tushar B Kute
 
The TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux KernelThe TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux Kernel
Divye Kapoor
 
Course 102: Lecture 28: Virtual FileSystems
Course 102: Lecture 28: Virtual FileSystems Course 102: Lecture 28: Virtual FileSystems
Course 102: Lecture 28: Virtual FileSystems
Ahmed El-Arabawy
 
Course 102: Lecture 14: Users and Permissions
Course 102: Lecture 14: Users and PermissionsCourse 102: Lecture 14: Users and Permissions
Course 102: Lecture 14: Users and Permissions
Ahmed El-Arabawy
 
Course 102: Lecture 5: File Handling Internals
Course 102: Lecture 5: File Handling Internals Course 102: Lecture 5: File Handling Internals
Course 102: Lecture 5: File Handling Internals
Ahmed El-Arabawy
 
Modern Kernel Pool Exploitation: Attacks and Techniques
Modern Kernel Pool Exploitation: Attacks and TechniquesModern Kernel Pool Exploitation: Attacks and Techniques
Modern Kernel Pool Exploitation: Attacks and TechniquesMichael Scovetta
 
Introduction to-linux
Introduction to-linuxIntroduction to-linux
Introduction to-linux
kishore1986
 
Course 102: Lecture 24: Archiving and Compression of Files
Course 102: Lecture 24: Archiving and Compression of Files Course 102: Lecture 24: Archiving and Compression of Files
Course 102: Lecture 24: Archiving and Compression of Files
Ahmed El-Arabawy
 
The basic concept of Linux FIleSystem
The basic concept of Linux FIleSystemThe basic concept of Linux FIleSystem
The basic concept of Linux FIleSystem
HungWei Chiu
 
HES2011 - Tarjei Mandt – Kernel Pool Exploitation on Windows 7
HES2011 - Tarjei Mandt – Kernel Pool Exploitation on Windows 7HES2011 - Tarjei Mandt – Kernel Pool Exploitation on Windows 7
HES2011 - Tarjei Mandt – Kernel Pool Exploitation on Windows 7Hackito Ergo Sum
 
The Linux Kernel Implementation of Pipes and FIFOs
The Linux Kernel Implementation of Pipes and FIFOsThe Linux Kernel Implementation of Pipes and FIFOs
The Linux Kernel Implementation of Pipes and FIFOs
Divye Kapoor
 
Memory forensics
Memory forensicsMemory forensics
Memory forensicsSunil Kumar
 
Perl Programming - 04 Programming Database
Perl Programming - 04 Programming DatabasePerl Programming - 04 Programming Database
Perl Programming - 04 Programming Database
Danairat Thanabodithammachari
 
Perbedaan antar computer filesystem 5109100164
Perbedaan antar computer filesystem 5109100164Perbedaan antar computer filesystem 5109100164
Perbedaan antar computer filesystem 5109100164Budi Raharjo
 
Programming Embedded linux
Programming Embedded linuxProgramming Embedded linux
Programming Embedded linux
Liran Ben Haim
 
Linux practicals T.Y.B.ScIT
Linux practicals T.Y.B.ScITLinux practicals T.Y.B.ScIT
Linux practicals T.Y.B.ScIT
vignesh0009
 

What's hot (20)

Course 102: Lecture 26: FileSystems in Linux (Part 1)
Course 102: Lecture 26: FileSystems in Linux (Part 1) Course 102: Lecture 26: FileSystems in Linux (Part 1)
Course 102: Lecture 26: FileSystems in Linux (Part 1)
 
Osdc2011.ext4btrfs.talk
Osdc2011.ext4btrfs.talkOsdc2011.ext4btrfs.talk
Osdc2011.ext4btrfs.talk
 
Part 03 File System Implementation in Linux
Part 03 File System Implementation in LinuxPart 03 File System Implementation in Linux
Part 03 File System Implementation in Linux
 
The TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux KernelThe TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux Kernel
 
Course 102: Lecture 28: Virtual FileSystems
Course 102: Lecture 28: Virtual FileSystems Course 102: Lecture 28: Virtual FileSystems
Course 102: Lecture 28: Virtual FileSystems
 
Introduction to UNIX
Introduction to UNIXIntroduction to UNIX
Introduction to UNIX
 
Course 102: Lecture 14: Users and Permissions
Course 102: Lecture 14: Users and PermissionsCourse 102: Lecture 14: Users and Permissions
Course 102: Lecture 14: Users and Permissions
 
Course 102: Lecture 5: File Handling Internals
Course 102: Lecture 5: File Handling Internals Course 102: Lecture 5: File Handling Internals
Course 102: Lecture 5: File Handling Internals
 
Modern Kernel Pool Exploitation: Attacks and Techniques
Modern Kernel Pool Exploitation: Attacks and TechniquesModern Kernel Pool Exploitation: Attacks and Techniques
Modern Kernel Pool Exploitation: Attacks and Techniques
 
Introduction to-linux
Introduction to-linuxIntroduction to-linux
Introduction to-linux
 
Course 102: Lecture 24: Archiving and Compression of Files
Course 102: Lecture 24: Archiving and Compression of Files Course 102: Lecture 24: Archiving and Compression of Files
Course 102: Lecture 24: Archiving and Compression of Files
 
The basic concept of Linux FIleSystem
The basic concept of Linux FIleSystemThe basic concept of Linux FIleSystem
The basic concept of Linux FIleSystem
 
HES2011 - Tarjei Mandt – Kernel Pool Exploitation on Windows 7
HES2011 - Tarjei Mandt – Kernel Pool Exploitation on Windows 7HES2011 - Tarjei Mandt – Kernel Pool Exploitation on Windows 7
HES2011 - Tarjei Mandt – Kernel Pool Exploitation on Windows 7
 
The Linux Kernel Implementation of Pipes and FIFOs
The Linux Kernel Implementation of Pipes and FIFOsThe Linux Kernel Implementation of Pipes and FIFOs
The Linux Kernel Implementation of Pipes and FIFOs
 
Memory forensics
Memory forensicsMemory forensics
Memory forensics
 
Perl Programming - 04 Programming Database
Perl Programming - 04 Programming DatabasePerl Programming - 04 Programming Database
Perl Programming - 04 Programming Database
 
Perbedaan antar computer filesystem 5109100164
Perbedaan antar computer filesystem 5109100164Perbedaan antar computer filesystem 5109100164
Perbedaan antar computer filesystem 5109100164
 
Namespace
NamespaceNamespace
Namespace
 
Programming Embedded linux
Programming Embedded linuxProgramming Embedded linux
Programming Embedded linux
 
Linux practicals T.Y.B.ScIT
Linux practicals T.Y.B.ScITLinux practicals T.Y.B.ScIT
Linux practicals T.Y.B.ScIT
 

Viewers also liked

Topic 13: Cloud Stacks
Topic 13: Cloud StacksTopic 13: Cloud Stacks
Topic 13: Cloud Stacks
Zubair Nabi
 
AOS Lab 4: If you liked it, then you should have put a “lock” on it
AOS Lab 4: If you liked it, then you should have put a “lock” on itAOS Lab 4: If you liked it, then you should have put a “lock” on it
AOS Lab 4: If you liked it, then you should have put a “lock” on itZubair Nabi
 
AOS Lab 1: Hello, Linux!
AOS Lab 1: Hello, Linux!AOS Lab 1: Hello, Linux!
AOS Lab 1: Hello, Linux!Zubair Nabi
 
AOS Lab 8: Interrupts and Device Drivers
AOS Lab 8: Interrupts and Device DriversAOS Lab 8: Interrupts and Device Drivers
AOS Lab 8: Interrupts and Device DriversZubair Nabi
 
AOS Lab 11: Virtualization
AOS Lab 11: VirtualizationAOS Lab 11: Virtualization
AOS Lab 11: VirtualizationZubair Nabi
 
AOS Lab 5: System calls
AOS Lab 5: System callsAOS Lab 5: System calls
AOS Lab 5: System callsZubair Nabi
 
AOS Lab 6: Scheduling
AOS Lab 6: SchedulingAOS Lab 6: Scheduling
AOS Lab 6: SchedulingZubair Nabi
 
Topic 14: Operating Systems and Virtualization
Topic 14: Operating Systems and VirtualizationTopic 14: Operating Systems and Virtualization
Topic 14: Operating Systems and Virtualization
Zubair Nabi
 
Topic 15: Datacenter Design and Networking
Topic 15: Datacenter Design and NetworkingTopic 15: Datacenter Design and Networking
Topic 15: Datacenter Design and Networking
Zubair Nabi
 
The Anatomy of Web Censorship in Pakistan
The Anatomy of Web Censorship in PakistanThe Anatomy of Web Censorship in Pakistan
The Anatomy of Web Censorship in PakistanZubair Nabi
 
Raabta: Low-cost Video Conferencing for the Developing World
Raabta: Low-cost Video Conferencing for the Developing WorldRaabta: Low-cost Video Conferencing for the Developing World
Raabta: Low-cost Video Conferencing for the Developing WorldZubair Nabi
 
MapReduce Application Scripting
MapReduce Application ScriptingMapReduce Application Scripting
MapReduce Application Scripting
Zubair Nabi
 
MapReduce and DBMS Hybrids
MapReduce and DBMS HybridsMapReduce and DBMS Hybrids
MapReduce and DBMS Hybrids
Zubair Nabi
 
The Big Data Stack
The Big Data StackThe Big Data Stack
The Big Data StackZubair Nabi
 

Viewers also liked (14)

Topic 13: Cloud Stacks
Topic 13: Cloud StacksTopic 13: Cloud Stacks
Topic 13: Cloud Stacks
 
AOS Lab 4: If you liked it, then you should have put a “lock” on it
AOS Lab 4: If you liked it, then you should have put a “lock” on itAOS Lab 4: If you liked it, then you should have put a “lock” on it
AOS Lab 4: If you liked it, then you should have put a “lock” on it
 
AOS Lab 1: Hello, Linux!
AOS Lab 1: Hello, Linux!AOS Lab 1: Hello, Linux!
AOS Lab 1: Hello, Linux!
 
AOS Lab 8: Interrupts and Device Drivers
AOS Lab 8: Interrupts and Device DriversAOS Lab 8: Interrupts and Device Drivers
AOS Lab 8: Interrupts and Device Drivers
 
AOS Lab 11: Virtualization
AOS Lab 11: VirtualizationAOS Lab 11: Virtualization
AOS Lab 11: Virtualization
 
AOS Lab 5: System calls
AOS Lab 5: System callsAOS Lab 5: System calls
AOS Lab 5: System calls
 
AOS Lab 6: Scheduling
AOS Lab 6: SchedulingAOS Lab 6: Scheduling
AOS Lab 6: Scheduling
 
Topic 14: Operating Systems and Virtualization
Topic 14: Operating Systems and VirtualizationTopic 14: Operating Systems and Virtualization
Topic 14: Operating Systems and Virtualization
 
Topic 15: Datacenter Design and Networking
Topic 15: Datacenter Design and NetworkingTopic 15: Datacenter Design and Networking
Topic 15: Datacenter Design and Networking
 
The Anatomy of Web Censorship in Pakistan
The Anatomy of Web Censorship in PakistanThe Anatomy of Web Censorship in Pakistan
The Anatomy of Web Censorship in Pakistan
 
Raabta: Low-cost Video Conferencing for the Developing World
Raabta: Low-cost Video Conferencing for the Developing WorldRaabta: Low-cost Video Conferencing for the Developing World
Raabta: Low-cost Video Conferencing for the Developing World
 
MapReduce Application Scripting
MapReduce Application ScriptingMapReduce Application Scripting
MapReduce Application Scripting
 
MapReduce and DBMS Hybrids
MapReduce and DBMS HybridsMapReduce and DBMS Hybrids
MapReduce and DBMS Hybrids
 
The Big Data Stack
The Big Data StackThe Big Data Stack
The Big Data Stack
 

Similar to AOS Lab 10: File system -- Inodes and beyond

Internal representation of files ppt
Internal representation of files pptInternal representation of files ppt
Internal representation of files ppt
Abhaysinh Surve
 
Internal representation of file chapter 4 Sowmya Jyothi
Internal representation of file chapter 4 Sowmya JyothiInternal representation of file chapter 4 Sowmya Jyothi
Internal representation of file chapter 4 Sowmya Jyothi
Sowmya Jyothi
 
osd - co1 session7.pptx
osd - co1 session7.pptxosd - co1 session7.pptx
osd - co1 session7.pptx
JyothiMedisetty2
 
Systems Programming - File IO
Systems Programming - File IOSystems Programming - File IO
Systems Programming - File IO
HelpWithAssignment.com
 
2nd unit part 1
2nd unit  part 12nd unit  part 1
2nd unit part 1
Pavan Illa
 
Ext filesystem4
Ext filesystem4Ext filesystem4
Ext filesystem4
Neha Kulkarni
 
De-Anonymizing Live CDs through Physical Memory Analysis
De-Anonymizing Live CDs through Physical Memory AnalysisDe-Anonymizing Live CDs through Physical Memory Analysis
De-Anonymizing Live CDs through Physical Memory Analysis
Andrew Case
 
TLPI Chapter 14 File Systems
TLPI Chapter 14 File SystemsTLPI Chapter 14 File Systems
TLPI Chapter 14 File SystemsShu-Yu Fu
 
KMSUnix and Linux.pptx
KMSUnix and Linux.pptxKMSUnix and Linux.pptx
KMSUnix and Linux.pptx
Ganesh Bhosale
 
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
 
Linux System Programming - File I/O
Linux System Programming - File I/O Linux System Programming - File I/O
Linux System Programming - File I/O
YourHelper1
 
operating system File - System Interface
operating system File - System Interfaceoperating system File - System Interface
operating system File - System Interface
Chandrakant Divate
 
Char Drivers And Debugging Techniques
Char Drivers And Debugging TechniquesChar Drivers And Debugging Techniques
Char Drivers And Debugging Techniques
YourHelper1
 
NSLogger - Cocoaheads Paris Presentation - English
NSLogger - Cocoaheads Paris Presentation - EnglishNSLogger - Cocoaheads Paris Presentation - English
NSLogger - Cocoaheads Paris Presentation - English
Florent Pillet
 
CNIT 152 13 Investigating Mac OS X Systems
CNIT 152 13 Investigating Mac OS X SystemsCNIT 152 13 Investigating Mac OS X Systems
CNIT 152 13 Investigating Mac OS X Systems
Sam Bowne
 
CNIT 121: 13 Investigating Mac OS X Systems
CNIT 121: 13 Investigating Mac OS X SystemsCNIT 121: 13 Investigating Mac OS X Systems
CNIT 121: 13 Investigating Mac OS X Systems
Sam Bowne
 
Working of Volatile and Non-Volatile memory
Working of Volatile and Non-Volatile memoryWorking of Volatile and Non-Volatile memory
Working of Volatile and Non-Volatile memory
Don Caeiro
 
UNIT III.pptx
UNIT III.pptxUNIT III.pptx
UNIT III.pptx
YogapriyaJ1
 

Similar to AOS Lab 10: File system -- Inodes and beyond (20)

Internal representation of files ppt
Internal representation of files pptInternal representation of files ppt
Internal representation of files ppt
 
Internal representation of file chapter 4 Sowmya Jyothi
Internal representation of file chapter 4 Sowmya JyothiInternal representation of file chapter 4 Sowmya Jyothi
Internal representation of file chapter 4 Sowmya Jyothi
 
osd - co1 session7.pptx
osd - co1 session7.pptxosd - co1 session7.pptx
osd - co1 session7.pptx
 
Systems Programming - File IO
Systems Programming - File IOSystems Programming - File IO
Systems Programming - File IO
 
2nd unit part 1
2nd unit  part 12nd unit  part 1
2nd unit part 1
 
Ext filesystem4
Ext filesystem4Ext filesystem4
Ext filesystem4
 
De-Anonymizing Live CDs through Physical Memory Analysis
De-Anonymizing Live CDs through Physical Memory AnalysisDe-Anonymizing Live CDs through Physical Memory Analysis
De-Anonymizing Live CDs through Physical Memory Analysis
 
Windowsforensics
WindowsforensicsWindowsforensics
Windowsforensics
 
TLPI Chapter 14 File Systems
TLPI Chapter 14 File SystemsTLPI Chapter 14 File Systems
TLPI Chapter 14 File Systems
 
Unix File System
Unix File SystemUnix File System
Unix File System
 
KMSUnix and Linux.pptx
KMSUnix and Linux.pptxKMSUnix and Linux.pptx
KMSUnix and Linux.pptx
 
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
 
Linux System Programming - File I/O
Linux System Programming - File I/O Linux System Programming - File I/O
Linux System Programming - File I/O
 
operating system File - System Interface
operating system File - System Interfaceoperating system File - System Interface
operating system File - System Interface
 
Char Drivers And Debugging Techniques
Char Drivers And Debugging TechniquesChar Drivers And Debugging Techniques
Char Drivers And Debugging Techniques
 
NSLogger - Cocoaheads Paris Presentation - English
NSLogger - Cocoaheads Paris Presentation - EnglishNSLogger - Cocoaheads Paris Presentation - English
NSLogger - Cocoaheads Paris Presentation - English
 
CNIT 152 13 Investigating Mac OS X Systems
CNIT 152 13 Investigating Mac OS X SystemsCNIT 152 13 Investigating Mac OS X Systems
CNIT 152 13 Investigating Mac OS X Systems
 
CNIT 121: 13 Investigating Mac OS X Systems
CNIT 121: 13 Investigating Mac OS X SystemsCNIT 121: 13 Investigating Mac OS X Systems
CNIT 121: 13 Investigating Mac OS X Systems
 
Working of Volatile and Non-Volatile memory
Working of Volatile and Non-Volatile memoryWorking of Volatile and Non-Volatile memory
Working of Volatile and Non-Volatile memory
 
UNIT III.pptx
UNIT III.pptxUNIT III.pptx
UNIT III.pptx
 

More from Zubair Nabi

Lab 5: Interconnecting a Datacenter using Mininet
Lab 5: Interconnecting a Datacenter using MininetLab 5: Interconnecting a Datacenter using Mininet
Lab 5: Interconnecting a Datacenter using Mininet
Zubair Nabi
 
Topic 12: NoSQL in Action
Topic 12: NoSQL in ActionTopic 12: NoSQL in Action
Topic 12: NoSQL in Action
Zubair Nabi
 
Lab 4: Interfacing with Cassandra
Lab 4: Interfacing with CassandraLab 4: Interfacing with Cassandra
Lab 4: Interfacing with Cassandra
Zubair Nabi
 
Topic 10: Taxonomy of Data and Storage
Topic 10: Taxonomy of Data and StorageTopic 10: Taxonomy of Data and Storage
Topic 10: Taxonomy of Data and Storage
Zubair Nabi
 
Topic 11: Google Filesystem
Topic 11: Google FilesystemTopic 11: Google Filesystem
Topic 11: Google Filesystem
Zubair Nabi
 
Lab 3: Writing a Naiad Application
Lab 3: Writing a Naiad ApplicationLab 3: Writing a Naiad Application
Lab 3: Writing a Naiad Application
Zubair Nabi
 
Topic 9: MR+
Topic 9: MR+Topic 9: MR+
Topic 9: MR+
Zubair Nabi
 
Topic 8: Enhancements and Alternative Architectures
Topic 8: Enhancements and Alternative ArchitecturesTopic 8: Enhancements and Alternative Architectures
Topic 8: Enhancements and Alternative Architectures
Zubair Nabi
 
Topic 7: Shortcomings in the MapReduce Paradigm
Topic 7: Shortcomings in the MapReduce ParadigmTopic 7: Shortcomings in the MapReduce Paradigm
Topic 7: Shortcomings in the MapReduce Paradigm
Zubair Nabi
 
Lab 1: Introduction to Amazon EC2 and MPI
Lab 1: Introduction to Amazon EC2 and MPILab 1: Introduction to Amazon EC2 and MPI
Lab 1: Introduction to Amazon EC2 and MPI
Zubair Nabi
 
Topic 6: MapReduce Applications
Topic 6: MapReduce ApplicationsTopic 6: MapReduce Applications
Topic 6: MapReduce Applications
Zubair Nabi
 

More from Zubair Nabi (11)

Lab 5: Interconnecting a Datacenter using Mininet
Lab 5: Interconnecting a Datacenter using MininetLab 5: Interconnecting a Datacenter using Mininet
Lab 5: Interconnecting a Datacenter using Mininet
 
Topic 12: NoSQL in Action
Topic 12: NoSQL in ActionTopic 12: NoSQL in Action
Topic 12: NoSQL in Action
 
Lab 4: Interfacing with Cassandra
Lab 4: Interfacing with CassandraLab 4: Interfacing with Cassandra
Lab 4: Interfacing with Cassandra
 
Topic 10: Taxonomy of Data and Storage
Topic 10: Taxonomy of Data and StorageTopic 10: Taxonomy of Data and Storage
Topic 10: Taxonomy of Data and Storage
 
Topic 11: Google Filesystem
Topic 11: Google FilesystemTopic 11: Google Filesystem
Topic 11: Google Filesystem
 
Lab 3: Writing a Naiad Application
Lab 3: Writing a Naiad ApplicationLab 3: Writing a Naiad Application
Lab 3: Writing a Naiad Application
 
Topic 9: MR+
Topic 9: MR+Topic 9: MR+
Topic 9: MR+
 
Topic 8: Enhancements and Alternative Architectures
Topic 8: Enhancements and Alternative ArchitecturesTopic 8: Enhancements and Alternative Architectures
Topic 8: Enhancements and Alternative Architectures
 
Topic 7: Shortcomings in the MapReduce Paradigm
Topic 7: Shortcomings in the MapReduce ParadigmTopic 7: Shortcomings in the MapReduce Paradigm
Topic 7: Shortcomings in the MapReduce Paradigm
 
Lab 1: Introduction to Amazon EC2 and MPI
Lab 1: Introduction to Amazon EC2 and MPILab 1: Introduction to Amazon EC2 and MPI
Lab 1: Introduction to Amazon EC2 and MPI
 
Topic 6: MapReduce Applications
Topic 6: MapReduce ApplicationsTopic 6: MapReduce Applications
Topic 6: MapReduce Applications
 

Recently uploaded

Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 

Recently uploaded (20)

Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 

AOS Lab 10: File system -- Inodes and beyond

  • 1. Lab 10: File system – Inodes and beyond Advanced Operating Systems Zubair Nabi zubair.nabi@itu.edu.pk April 10, 2013
  • 2. Recap of Lab 9: xv6 FS layers File descriptors System calls Recursive lookup Pathnames Directory inodes Inodes and block allocator Logging Buffer cache Directories Files Transactions Blocks
  • 3. Recap of Lab 9: xv6 FS layers (2) 1 Buffer cache: Reads and writes blocks on the IDE disk via the buffer cache, which synchronizes access to disk blocks
  • 4. Recap of Lab 9: xv6 FS layers (2) 1 Buffer cache: Reads and writes blocks on the IDE disk via the buffer cache, which synchronizes access to disk blocks • Ensures that only one kernel process can edit any particular block at a time
  • 5. Recap of Lab 9: xv6 FS layers (2) 1 Buffer cache: Reads and writes blocks on the IDE disk via the buffer cache, which synchronizes access to disk blocks • Ensures that only one kernel process can edit any particular block at a time 2 Logging: Ensures atomicity by enabling higher layers to wrap updates to several blocks in a transaction
  • 6. Recap of Lab 9: xv6 FS layers (2) 1 Buffer cache: Reads and writes blocks on the IDE disk via the buffer cache, which synchronizes access to disk blocks • Ensures that only one kernel process can edit any particular block at a time 2 Logging: Ensures atomicity by enabling higher layers to wrap updates to several blocks in a transaction 3 Inodes and block allocator: Provides unnamed files, each unnamed file is represented by an inode and a sequence of blocks holding the file content
  • 7. Recap of Lab 9: xv6 FS layers (3) 4 Directory inodes: Implements directories as a special kind of inode
  • 8. Recap of Lab 9: xv6 FS layers (3) 4 Directory inodes: Implements directories as a special kind of inode • The content of this inode is a sequence of directory entries, each of which contains a name and a reference to the named file’s inode
  • 9. Recap of Lab 9: xv6 FS layers (3) 4 Directory inodes: Implements directories as a special kind of inode • The content of this inode is a sequence of directory entries, each of which contains a name and a reference to the named file’s inode 5 Recursive lookup: Provides hierarchical path names such as /foo/bar/baz.txt, via recursive lookup
  • 10. Recap of Lab 9: xv6 FS layers (3) 4 Directory inodes: Implements directories as a special kind of inode • The content of this inode is a sequence of directory entries, each of which contains a name and a reference to the named file’s inode 5 Recursive lookup: Provides hierarchical path names such as /foo/bar/baz.txt, via recursive lookup 6 File descriptors: Abstracts many Unix resources, such as pipes, devices, file, etc., using the file system interface
  • 11. Recap of Lab 9: File system layout • xv6 lays out inodes and content blocks on the disk by dividing the disk into several sections
  • 12. Recap of Lab 9: File system layout • xv6 lays out inodes and content blocks on the disk by dividing the disk into several sections boot super 0 1 inodes... 2 • Block 0 holds the boot sector bitmap... ….. data... log...
  • 13. Recap of Lab 9: File system layout • xv6 lays out inodes and content blocks on the disk by dividing the disk into several sections boot super 0 1 inodes... 2 bitmap... data... log... ….. • Block 0 holds the boot sector • Block 1 (called the superblock) contains metadata about the file system
  • 14. Recap of Lab 9: File system layout • xv6 lays out inodes and content blocks on the disk by dividing the disk into several sections boot super 0 1 inodes... 2 bitmap... data... log... ….. • Block 0 holds the boot sector • Block 1 (called the superblock) contains metadata about the file system • File system size in blocks, the number of data blocks, the number of inodes, and the number of blocks in the log
  • 15. Recap of Lab 9: File system layout • xv6 lays out inodes and content blocks on the disk by dividing the disk into several sections boot super 0 1 inodes... 2 bitmap... data... log... ….. • Block 0 holds the boot sector • Block 1 (called the superblock) contains metadata about the file system • File system size in blocks, the number of data blocks, the number of inodes, and the number of blocks in the log • Blocks starting at 2 hold inodes, with multiple inodes per block
  • 16. Recap of Lab 9: File system layout boot super 0 1 inodes... 2 bitmap... data... log... ….. • inode blocks are followed by bitmap blocks which keep track of data blocks in use
  • 17. Recap of Lab 9: File system layout boot super 0 1 inodes... 2 bitmap... data... log... ….. • inode blocks are followed by bitmap blocks which keep track of data blocks in use • Bitmap blocks are followed by data blocks which hold file and directory contents
  • 18. Recap of Lab 9: File system layout boot super 0 1 inodes... 2 bitmap... data... log... ….. • inode blocks are followed by bitmap blocks which keep track of data blocks in use • Bitmap blocks are followed by data blocks which hold file and directory contents • Finally at the end, the blocks hold a log which is required by the transaction layer
  • 19. Inodes • Have two variants: 1 On-disk data structure containing a file’s size and list of data block numbers
  • 20. Inodes • Have two variants: On-disk data structure containing a file’s size and list of data block numbers 2 In-memory version of the on-disk inode, along with extra information needed within the kernel 1
  • 21. Inodes • Have two variants: On-disk data structure containing a file’s size and list of data block numbers 2 In-memory version of the on-disk inode, along with extra information needed within the kernel 1 • All on-disk inodes are stored in a contiguous area of disk, between the superblock and the bitmap block
  • 22. Inodes • Have two variants: On-disk data structure containing a file’s size and list of data block numbers 2 In-memory version of the on-disk inode, along with extra information needed within the kernel 1 • All on-disk inodes are stored in a contiguous area of disk, between the superblock and the bitmap block • Each inode has the same size, so given a number n (called the inode number or i-number), it is simple to locate the corresponding inode
  • 23. On-disk inodes • Represented by struct dinode
  • 24. On-disk inodes • Represented by struct dinode • Contains a type field to distinguish between files, directories, and special files (devices)
  • 25. On-disk inodes • Represented by struct dinode • Contains a type field to distinguish between files, directories, and special files (devices) • Zero indicates that the dinode is free
  • 26. On-disk inodes • Represented by struct dinode • Contains a type field to distinguish between files, directories, and special files (devices) • Zero indicates that the dinode is free • Also keeps track of the number of directory entries that refer to this inode
  • 27. On-disk inodes • Represented by struct dinode • Contains a type field to distinguish between files, directories, and special files (devices) • Zero indicates that the dinode is free • Also keeps track of the number of directory entries that refer to this inode • This reference count dictates when the inode should be freed
  • 28. On-disk inodes • Represented by struct dinode • Contains a type field to distinguish between files, directories, and special files (devices) • Zero indicates that the dinode is free • Also keeps track of the number of directory entries that refer to this inode • This reference count dictates when the inode should be freed • Also has fields to hold number of bytes of content and the block numbers of disk blocks
  • 29. Code: dinode struct dinode { short type; // File type short major; // Major device number (T_DEV only) short minor; // Minor device number (T_DEV only) short nlink; // Number of links to inode in file s uint size; // Size of file (bytes) uint addrs[NDIRECT+1]; // Data block addresses }; #define T_DIR 1 // Directory #define T_FILE 2 // File #define T_DEV 3 // Device
  • 31. In-memory inodes • Represented by struct inode • An inode is kept in memory if there are C pointers referring to it
  • 32. In-memory inodes • Represented by struct inode • An inode is kept in memory if there are C pointers referring to it • These pointers come from file descriptors, current working directories, and kernel code
  • 33. In-memory inodes • Represented by struct inode • An inode is kept in memory if there are C pointers referring to it • These pointers come from file descriptors, current working directories, and kernel code • iget and iput functions are used to acquire and release pointers to/from an inode
  • 34. In-memory inodes • Represented by struct inode • An inode is kept in memory if there are C pointers referring to it • These pointers come from file descriptors, current working directories, and kernel code • iget and iput functions are used to acquire and release pointers to/from an inode • A pointer via an iget() call implements a weak form of a lock by ensuring that the inode will stay in the cache till the reference count goes down to zero
  • 35. In-memory inodes • Represented by struct inode • An inode is kept in memory if there are C pointers referring to it • These pointers come from file descriptors, current working directories, and kernel code • iget and iput functions are used to acquire and release pointers to/from an inode • A pointer via an iget() call implements a weak form of a lock by ensuring that the inode will stay in the cache till the reference count goes down to zero • These pointers enable long-term references (open files and current directory) and to prevent deadlock in code that manipulates multiple inodes (pathname lookup)
  • 36. Code: inode struct inode { uint dev; // Device number uint inum; // Inode number int ref; // Reference count int flags; // I_BUSY, I_VALID short type; // copy of disk inode short major; short minor; short nlink; uint size; uint addrs[NDIRECT+1]; }; #define I_BUSY 0x1 #define I_VALID 0x2
  • 37. Inode locks and allocation • To ensure that an inode has valid content, the code must read it from disk
  • 38. Inode locks and allocation • To ensure that an inode has valid content, the code must read it from disk • This read call must be wrapped around ilock and iunlock
  • 39. Inode locks and allocation • To ensure that an inode has valid content, the code must read it from disk • This read call must be wrapped around ilock and iunlock • This allows multiple processes to hold a C pointer to an inode but only one process can lock it at a time
  • 40. Inode locks and allocation • To ensure that an inode has valid content, the code must read it from disk • This read call must be wrapped around ilock and iunlock • This allows multiple processes to hold a C pointer to an inode but only one process can lock it at a time • Inodes are allocated via ialloc which works similar to balloc
  • 41. Inode data • Data is found in the blocks pointed to by the addrs fields
  • 42. Inode data • Data is found in the blocks pointed to by the addrs fields • Size of addrs is NDIRECT+1 where NDIRECT is 12
  • 43. Inode data • Data is found in the blocks pointed to by the addrs fields • Size of addrs is NDIRECT+1 where NDIRECT is 12 • addrs can refer to 6KB of data
  • 44. Inode data • Data is found in the blocks pointed to by the addrs fields • Size of addrs is NDIRECT+1 where NDIRECT is 12 • addrs can refer to 6KB of data • The 13th location in addrs field points to the indirect block (NINDIRECT) which points to 64KB of data
  • 45. Inode data • Data is found in the blocks pointed to by the addrs fields • Size of addrs is NDIRECT+1 where NDIRECT is 12 • addrs can refer to 6KB of data • The 13th location in addrs field points to the indirect block (NINDIRECT) which points to 64KB of data • Therefore, while fixed-sized blocks simplify look up, the maximum size of a file in xv6 can be 70KB
  • 46. Inodes content • bmap(struct inode *ip, uint bn) returns the disk address of the nth block within inode ip, masking away the complexity of direct and indirect blocks
  • 47. Inodes content • bmap(struct inode *ip, uint bn) returns the disk address of the nth block within inode ip, masking away the complexity of direct and indirect blocks • If the data block does not exist, it is created
  • 48. Inodes content • bmap(struct inode *ip, uint bn) returns the disk address of the nth block within inode ip, masking away the complexity of direct and indirect blocks • If the data block does not exist, it is created • itrunc(struct inode *ip) frees inode ip by setting its reference count to zero and freeing up blocks, both direct and indirect
  • 49. Inodes content • bmap(struct inode *ip, uint bn) returns the disk address of the nth block within inode ip, masking away the complexity of direct and indirect blocks • If the data block does not exist, it is created • itrunc(struct inode *ip) frees inode ip by setting its reference count to zero and freeing up blocks, both direct and indirect • readi(struct inode *ip, char *dst, uint off, uint n) reads n blocks in inode ip starting from off into dst
  • 50. Inodes content (2) • writei(struct inode *ip, char *src, uint off, uint n) works similar to readi but it:
  • 51. Inodes content (2) • writei(struct inode *ip, char *src, uint off, uint n) works similar to readi but it: 1 Copies data in instead of out
  • 52. Inodes content (2) • writei(struct inode *ip, char *src, uint off, uint n) works similar to readi but it: 1 2 Copies data in instead of out Extends the file if the write increases its size
  • 53. Inodes content (2) • writei(struct inode *ip, char *src, uint off, uint n) works similar to readi but it: Copies data in instead of out Extends the file if the write increases its size 3 Updates the size in the inode 1 2
  • 54. Inodes content (2) • writei(struct inode *ip, char *src, uint off, uint n) works similar to readi but it: Copies data in instead of out Extends the file if the write increases its size 3 Updates the size in the inode 1 2 • stati(struct inode *ip, struct stat *st) copies metadata of inode ip into st which is exposed to userspace via the stat system call
  • 55. Directory layer • A directory is a file with an inode type T_DIR and data in the form of a sequence of directory entries
  • 56. Directory layer • A directory is a file with an inode type T_DIR and data in the form of a sequence of directory entries • Each entry is a struct dirent
  • 57. Directory layer • A directory is a file with an inode type T_DIR and data in the form of a sequence of directory entries • Each entry is a struct dirent struct dirent { ushort inum; // free, if zero char name[DIRSIZ]; }; #define DIRSIZ 14
  • 58. dirlookup • Searches a directory for an entry with the given name
  • 59. dirlookup • Searches a directory for an entry with the given name • Signature: struct inode* dirlookup(struct inode *dp, char *name, uint *poff)
  • 60. dirlookup • Searches a directory for an entry with the given name • Signature: struct inode* dirlookup(struct inode *dp, char *name, uint *poff) • If it finds it, it returns a pointer to the corresponding inode via iget, unlocked, and returns the offset of the entry within the directory
  • 61. dirlink • Writes a new directory entry with the given name and inode number into dp
  • 62. dirlink • Writes a new directory entry with the given name and inode number into dp • Signature: int dirlink(struct inode *dp, char *name, uint inum)
  • 63. Path names • Path name look up is enabled by multiple calls – one for each path component – to dirlookup
  • 64. Path names • Path name look up is enabled by multiple calls – one for each path component – to dirlookup • namei takes a path and returns the corresponding inode
  • 65. Path names • Path name look up is enabled by multiple calls – one for each path component – to dirlookup • namei takes a path and returns the corresponding inode • nameiparent is similar but returns the inode of the parent directory
  • 66. Path names • Path name look up is enabled by multiple calls – one for each path component – to dirlookup • namei takes a path and returns the corresponding inode • nameiparent is similar but returns the inode of the parent directory • Both make a call to namex internally
  • 67. namex • Starts by deciding where the path evaluation begins
  • 68. namex • Starts by deciding where the path evaluation begins • If the path begins with /, evaluation starts at the root
  • 69. namex • Starts by deciding where the path evaluation begins • If the path begins with /, evaluation starts at the root • Otherwise, the current directory
  • 70. namex • Starts by deciding where the path evaluation begins • If the path begins with /, evaluation starts at the root • Otherwise, the current directory • Uses skipelem to parse the path into path elements
  • 71. namex • Starts by deciding where the path evaluation begins • If the path begins with /, evaluation starts at the root • Otherwise, the current directory • Uses skipelem to parse the path into path elements • For each iteration (depending on the number of path elements), looks up name within the current path element inode till it finds the required inode and returns it
  • 72. File descriptor layer • Everything in Unix is a file and this interface is enabled by the file descriptor layer
  • 73. File descriptor layer • Everything in Unix is a file and this interface is enabled by the file descriptor layer • Each process has its own open files (or file descriptor) table
  • 74. File descriptor layer • Everything in Unix is a file and this interface is enabled by the file descriptor layer • Each process has its own open files (or file descriptor) table • Each open file is represented by struct file
  • 75. Code: struct file struct file { enum { FD_NONE, FD_PIPE, FD_INODE } type; int ref; // reference count char readable; char writable; struct pipe *pipe; struct inode *ip; uint off; };
  • 76. file • struct file is simply a wrapper around an inode or a pipe; plus an I/O offset
  • 77. file • struct file is simply a wrapper around an inode or a pipe; plus an I/O offset • Each call to open creates a new struct file
  • 78. file • struct file is simply a wrapper around an inode or a pipe; plus an I/O offset • Each call to open creates a new struct file • If multiple processes open the same independently, they will have their own struct file for it with a local I/O offset
  • 79. file • struct file is simply a wrapper around an inode or a pipe; plus an I/O offset • Each call to open creates a new struct file • If multiple processes open the same independently, they will have their own struct file for it with a local I/O offset • The same struct file can appear multiple times within a) A process’s file table, and b) Across multiple processes
  • 80. file • struct file is simply a wrapper around an inode or a pipe; plus an I/O offset • Each call to open creates a new struct file • If multiple processes open the same independently, they will have their own struct file for it with a local I/O offset • The same struct file can appear multiple times within a) A process’s file table, and b) Across multiple processes • When would this happen?
  • 81. file • struct file is simply a wrapper around an inode or a pipe; plus an I/O offset • Each call to open creates a new struct file • If multiple processes open the same independently, they will have their own struct file for it with a local I/O offset • The same struct file can appear multiple times within a) A process’s file table, and b) Across multiple processes • When would this happen? • a happens when a process opens a file and then dups it and b takes place when it makes a call to fork
  • 82. file • struct file is simply a wrapper around an inode or a pipe; plus an I/O offset • Each call to open creates a new struct file • If multiple processes open the same independently, they will have their own struct file for it with a local I/O offset • The same struct file can appear multiple times within a) A process’s file table, and b) Across multiple processes • When would this happen? • a happens when a process opens a file and then dups it and b takes place when it makes a call to fork • Reference count tracks the number of references to a particular open file
  • 83. file • struct file is simply a wrapper around an inode or a pipe; plus an I/O offset • Each call to open creates a new struct file • If multiple processes open the same independently, they will have their own struct file for it with a local I/O offset • The same struct file can appear multiple times within a) A process’s file table, and b) Across multiple processes • When would this happen? • a happens when a process opens a file and then dups it and b takes place when it makes a call to fork • Reference count tracks the number of references to a particular open file • Read/write access is tracked by readable/writable fields
  • 84. Global file table • All open files in the system are kept within a global file table (ftable)
  • 85. Global file table • All open files in the system are kept within a global file table (ftable) • ftable has corresponding functions to: 1 Allocate a file: filealloc
  • 86. Global file table • All open files in the system are kept within a global file table (ftable) • ftable has corresponding functions to: 1 Allocate a file: filealloc 2 Create a duplicate reference: filedup
  • 87. Global file table • All open files in the system are kept within a global file table (ftable) • ftable has corresponding functions to: 1 Allocate a file: filealloc 2 Create a duplicate reference: filedup 3 Release a reference: fileclose
  • 88. Global file table • All open files in the system are kept within a global file table (ftable) • ftable has corresponding functions to: 1 Allocate a file: filealloc 2 Create a duplicate reference: filedup 3 Release a reference: fileclose 4 Read from a file: fileread
  • 89. Global file table • All open files in the system are kept within a global file table (ftable) • ftable has corresponding functions to: 1 Allocate a file: filealloc 2 Create a duplicate reference: filedup 3 Release a reference: fileclose 4 Read from a file: fileread 5 Write to a file: filewrite
  • 90. File manipulation • filealloc: Scans the file table for an unreferenced file (f->ref == 0) and returns a new reference
  • 91. File manipulation • filealloc: Scans the file table for an unreferenced file (f->ref == 0) and returns a new reference • filedup: Increments the reference count
  • 92. File manipulation • filealloc: Scans the file table for an unreferenced file (f->ref == 0) and returns a new reference • filedup: Increments the reference count • fileclose: Decrements the reference count
  • 93. File manipulation • filealloc: Scans the file table for an unreferenced file (f->ref == 0) and returns a new reference • filedup: Increments the reference count • fileclose: Decrements the reference count • If f->ref == 0, underlying pipe or inode is released
  • 94. File manipulation (2) • filestat: Invokes stati and ensures that the file represents an inode
  • 95. File manipulation (2) • filestat: Invokes stati and ensures that the file represents an inode • fileread and filewrite: 1 Check whether the operation is allowed by the open mode
  • 96. File manipulation (2) • filestat: Invokes stati and ensures that the file represents an inode • fileread and filewrite: 1 2 Check whether the operation is allowed by the open mode Patch the call through to either the underlying pipe or inode implementation
  • 97. File manipulation (2) • filestat: Invokes stati and ensures that the file represents an inode • fileread and filewrite: Check whether the operation is allowed by the open mode Patch the call through to either the underlying pipe or inode implementation 3 If the wrapper is around an inode, the I/O offset would be used and then advanced 1 2
  • 98. File manipulation (2) • filestat: Invokes stati and ensures that the file represents an inode • fileread and filewrite: Check whether the operation is allowed by the open mode Patch the call through to either the underlying pipe or inode implementation 3 If the wrapper is around an inode, the I/O offset would be used and then advanced 4 Pipes have no concept of offset 1 2
  • 99. System calls • sys_link and sys_unlink edit directories by creating or removing references to inodes
  • 100. System calls • sys_link and sys_unlink edit directories by creating or removing references to inodes • sys_link creates a new name for an existing inode
  • 101. System calls • sys_link and sys_unlink edit directories by creating or removing references to inodes • sys_link creates a new name for an existing inode 1 Takes as arguments two strings old and new
  • 102. System calls • sys_link and sys_unlink edit directories by creating or removing references to inodes • sys_link creates a new name for an existing inode 1 Takes as arguments two strings old and new 2 Increments its nlink field – Number of links
  • 103. System calls • sys_link and sys_unlink edit directories by creating or removing references to inodes • sys_link creates a new name for an existing inode 1 Takes as arguments two strings old and new 2 Increments its nlink field – Number of links 3 Creates a new directory entry pointing at old’s inode
  • 104. System calls • sys_link and sys_unlink edit directories by creating or removing references to inodes • sys_link creates a new name for an existing inode 1 Takes as arguments two strings old and new 2 Increments its nlink field – Number of links 3 4 Creates a new directory entry pointing at old’s inode The new directory entry is on the same inode as the existing one
  • 105. create • Creates a new name for a new inode
  • 106. create • Creates a new name for a new inode • Generalizes the creation of three file creation system calls:
  • 107. create • Creates a new name for a new inode • Generalizes the creation of three file creation system calls: 1 open with the O_CREATE flag creates a new file
  • 108. create • Creates a new name for a new inode • Generalizes the creation of three file creation system calls: 1 open with the O_CREATE flag creates a new file 2 mkdir creates a new directory
  • 109. create • Creates a new name for a new inode • Generalizes the creation of three file creation system calls: 1 open with the O_CREATE flag creates a new file 2 mkdir creates a new directory 3 mkdev creates a new device file
  • 110. create (2) • Makes a call to dirlookup to check whether the name already exists
  • 111. create (2) • Makes a call to dirlookup to check whether the name already exists • If it does not exist, creates a new inode via a call to ialloc
  • 112. create (2) • Makes a call to dirlookup to check whether the name already exists • If it does not exist, creates a new inode via a call to ialloc • If create has been invoked by mkdir (T_DIR), it initializes it with . and .. entries
  • 113. create (2) • Makes a call to dirlookup to check whether the name already exists • If it does not exist, creates a new inode via a call to ialloc • If create has been invoked by mkdir (T_DIR), it initializes it with . and .. entries • Finally, it links it into the parent directory
  • 114. Buffer cache eviction policy • xv6’s buffer cache uses simple LRU eviction
  • 115. Buffer cache eviction policy • xv6’s buffer cache uses simple LRU eviction • A number of different policies can be implemented such as FIFO, not frequently used, aging, random, etc.
  • 116. Buffer cache eviction policy • xv6’s buffer cache uses simple LRU eviction • A number of different policies can be implemented such as FIFO, not frequently used, aging, random, etc. • The buffer cache is currently a linked list but an efficient implementation can replace it with a hash table and/or a heap
  • 117. Buffer cache eviction policy • xv6’s buffer cache uses simple LRU eviction • A number of different policies can be implemented such as FIFO, not frequently used, aging, random, etc. • The buffer cache is currently a linked list but an efficient implementation can replace it with a hash table and/or a heap • The buffer cache can also be integrated with the virtual memory system to enabled memory-mapped files (mmap in Linux)
  • 118. Today’s task • xv6 has no support for memory-mapped files • Come up with a design to implement mmap1 1 http://man7.org/linux/man-pages/man2/mmap.2.html
  • 119. Reading(s) • Chapter 6, “File system”, from “Code: directory layer" onwards from “xv6: a simple, Unix-like teaching operating system”