SlideShare a Scribd company logo
1 of 69
Download to read offline
1
Virtual Filesystem
8/12
Bob.Fu
別上傳公司網站
2
● FIlesystems
● VFS
● Rootfs
● Dir/File Operations
4
Filesystems
msdos
disk
vfat
ntfs
ext4
cd-rom
iso9660
usb
vfat
emmc
ext4
ram network
cifs
nfs
procfs
sysfs
pipefs
sockfs
ramfs
tmpfs
*. meta/data layout
*. file name length
*. date/time
*. max partition/file size
*. journal
*. block allocation
*. fragmentation
*. ...
storage
5
vfs
emmc
ext4
file
directory
link
char
block
fifo
sock
usb
vfat
file
directory
ram
tmpfs
file
directory
link
char
block
fifo
sock
sysfs
file(attr)
directory
link
bin_attr
sockfs
file
VFS
app
libc
6
vfs
emmc
ext4
file
directory
link
char
block
fifo
sock
usb
vfat
file
directory
ram
tmpfs
file
directory
link
char
block
fifo
sock
sysfs
file(attr)
directory
link
bin_attr
sockfs
file
VFS
fop
iop
inode
dentry file name
ext4mount address
space
p pp p p p p p
meta
data
7
VFS
/
dev init proc system sysdata
bbb cccaaa
C
eee fffddd
D
linux
windows
8
VFS
“/”d
rootfsm
d “dev” d “init” d “proc” d “system” d “sys”d “data
9
VFS
“/”d
rootfsm
d “dev” d “init” d “proc” d “system” d “sys”
d “console”
d “/”
tmpfsm
d “pts”
d “data
d “/”
ext4m
d “/”
procm
d “/”
ext4m
d “/”
sysfsm
d “/”
devptsm
d “bin”
d “sh”
10
VFS
d “init”
fop
iop
i
getattr( )
setattr( )
mmap( )
aio_write( )
write( )
aio_read( )
fsync( )
llseek( )
read( )
file@rootfs
filesystem + file type
11
VFS
d “init”
fop
iop
i
symlink( )
unlink( )
link( )
lookup( )
mkdir( )
rmdir( )
create( )
fsync( )
read( )
llseek( )
release( )
open( )
dir@rootfs
filesystem + file type
mknod( )
rename( )
14
Rootfs
kernel
rootfs
uImage
initramfs
partition b
partition a
SN
kernel
ramdisk
boot.img
initramfs
partition a
ANAN
kernel
rootfs
uImage
initramfs
dram
bring up
SN: 各自產生 , 各佔一個 partition
AN: 各自產生 , 合併檔案 & 佔一個 partition
bring up: 同時產生 ( 單一檔案 ), 載入 dram
15
Rootfs
kernel
ramdisk
boot.img
initramfs
ANAN
Image, 沒壓縮
cpio, gzip 壓縮
16
Rootfs
kernel
ramdisk
boot.img
initramfs
data
init
init.rc
proc
sys
system
sbin
adbd
healthd
root
devconsole first userspace process
standard in
standard out
standard err
root mount run commands
AN
17
Rootfs
fopiopi
“/”d
rootfsm
1. 掛載 rootfs
18
Rootfs
fopiopi
“/”d
rootfsm
fopiopi
d “dev”
fopiopi
d “console”
1. 掛載 rootfs
2. 根據 initramfs 建檔
19
Rootfs
fopiopi
“/”d
rootfsm
fopiopi
d “dev”
fopiopi
d “init”
fopiopi
d “proc”
fopiopi
d “system”
fopiopi
d “sys”
fopiopi
d “console”
fopiopi
d “data
1. 掛載 rootfs
2. 根據 initramfs 建檔
3. 根據 ramdisk 建檔
20
Rootfs
fopiopi
“/”d
rootfsm
fopiopi
d “dev”
fopiopi
d “init”
fopiopi
d “proc”
fopiopi
d “system”
fopiopi
d “sys”
fopiopi
d “console”
fopiopi
d “data
1. 掛載 rootfs
2. 根據 initramfs 建檔
3. 根據 ramdisk 建檔
4. init 預設行為
21
Rootfs
fopiopi
“/”d
rootfsm
fopiopi
d “dev”
fopiopi
d “init”
fopiopi
d “proc”
fopiopi
d “system”
fopiopi
d “sys”
fopiopi
d “console”
fopiopi
d “/”
tmpfsm
fopiopi
d “data
1. 掛載 rootfs
2. 根據 initramfs 建檔
3. 根據 ramdisk 建檔
4. init 預設行為
a. mount tmpfs
23
Rootfs
fopiopi
“/”d
rootfsm
fopiopi
d “dev”
fopiopi
d “init”
fopiopi
d “proc”
fopiopi
d “system”
fopiopi
d “sys”
fopiopi
d “console”
fopiopi
d “/”
tmpfsm
fopiopi
d “pts”
fopiopi
d “data
1. 掛載 rootfs
2. 根據 initramfs 建檔
3. 根據 ramdisk 建檔
4. init 預設行為
a. mount tmpfs
b. mkdir pts
24
Rootfs
fopiopi
“/”d
rootfsm
fopiopi
d “dev”
fopiopi
d “init”
fopiopi
d “proc”
fopiopi
d “system”
fopiopi
d “sys”
fopiopi
d “console”
fopiopi
d “/”
tmpfsm
fopiopi
d “pts”
fopiopi
d “data
fopiopi
d “/”
devptsm
1. 掛載 rootfs
2. 根據 initramfs 建檔
3. 根據 ramdisk 建檔
4. init 預設行為
a. mount tmpfs
b. mkdir pts
c. mount devpts
25
Rootfs
fopiopi
“/”d
rootfsm
fopiopi
d “dev”
fopiopi
d “init”
fopiopi
d “proc”
fopiopi
d “system”
fopiopi
d “sys”
fopiopi
d “console”
fopiopi
d “/”
tmpfsm
fopiopi
d “pts”
fopiopi
d “data
fopiopi
d “/”
procm
fopiopi
d “/”
devptsm
1. 掛載 rootfs
2. 根據 initramfs 建檔
3. 根據 ramdisk 建檔
4. init 預設行為
a. mount tmpfs
b. mkdir pts
c. mount devpts
d. mount proc
26
Rootfs
fopiopi
“/”d
rootfsm
fopiopi
d “dev”
fopiopi
d “init”
fopiopi
d “proc”
fopiopi
d “system”
fopiopi
d “sys”
fopiopi
d “console”
fopiopi
d “/”
tmpfsm
fopiopi
d “pts”
fopiopi
d “data
fopiopi
d “/”
procm
fopiopi
d “/”
sysfsm
fopiopi
d “/”
devptsm
1. 掛載 rootfs
2. 根據 initramfs 建檔
3. 根據 ramdisk 建檔
4. init 預設行為
a. mount tmpfs
b. mkdir pts
c. mount devpts
d. mount proc
e. mount sysfs
27
Rootfs
fopiopi
“/”d
rootfsm
fopiopi
d “dev”
fopiopi
d “init”
fopiopi
d “proc”
fopiopi
d “system”
fopiopi
d “sys”
fopiopi
d “console”
fopiopi
d “/”
tmpfsm
fopiopi
d “pts”
fopiopi
d “data
fopiopi
d “/”
procm
fopiopi
d “/”
sysfsm
fopiopi
d “/”
devptsm
1. 掛載 rootfs
2. 根據 initramfs 建檔
3. 根據 ramdisk 建檔
4. init 預設行為
a. mount tmpfs
b. mkdir pts
c. mount devpts
d. mount proc
e. mount sysfs
5. init 根據 init.rc 行為
“init.rc”
28
Rootfs
fopiopi
“/”d
rootfsm
fopiopi
d “dev”
fopiopi
d “init”
fopiopi
d “proc”
fopiopi
d “system”
fopiopi
d “sys”
fopiopi
d “console”
fopiopi
d “/”
tmpfsm
fopiopi
d “pts”
fopiopi
d “data
fopiopi
d “/”
ext4m
fopiopi
d “/”
procm
fopiopi
d “/”
sysfsm
fopiopi
d “/”
devptsm
1. 掛載 rootfs
2. 根據 initramfs 建檔
3. 根據 ramdisk 建檔
4. init 預設行為
a. mount tmpfs
b. mkdir pts
c. mount devpts
d. mount proc
e. mount sysfs
5. init 根據 init.rc 行為
a. mount data
29
Rootfs
fopiopi
“/”d
rootfsm
fopiopi
d “dev”
fopiopi
d “init”
fopiopi
d “proc”
fopiopi
d “system”
fopiopi
d “sys”
fopiopi
d “console”
fopiopi
d “/”
tmpfsm
fopiopi
d “pts”
fopiopi
d “data
fopiopi
d “/”
ext4m
fopiopi
d “/”
procm
fopiopi
d “/”
ext4m
fopiopi
d “/”
sysfsm
fopiopi
d “/”
devptsm
1. 掛載 rootfs
2. 根據 initramfs 建檔
3. 根據 ramdisk 建檔
4. init 預設行為
a. mount tmpfs
b. mkdir pts
c. mount devpts
d. mount proc
e. mount sysfs
5. init 根據 init.rc 行為
a. mount data
b. mount system
30
Rootfs
fopiopi
“/”d
rootfsm
fopiopi
d “dev”
fopiopi
d “init”
fopiopi
d “proc”
fopiopi
d “system”
fopiopi
d “sys”
fopiopi
d “console”
fopiopi
d “/”
tmpfsm
fopiopi
d “pts”
fopiopi
d “data
fopiopi
d “/”
ext4m
fopiopi
d “/”
procm
fopiopi
d “/”
ext4m
fopiopi
d “/”
sysfsm
fopiopi
d “/”
devptsm
app bin xbin
sh su
1. 掛載 rootfs
2. 根據 initramfs 建檔
3. 根據 ramdisk 建檔
4. init 預設行為
a. mount tmpfs
b. mkdir pts
c. mount devpts
d. mount proc
e. mount sysfs
5. init 根據 init.rc 行為
a. mount data
b. mount system
31
Rootfs
fopiopi
“/”d
rootfsm
fopiopi
d “dev”
fopiopi
d “init”
fopiopi
d “proc”
fopiopi
d “system”
fopiopi
d “sys”
fopiopi
d “console”
fopiopi
d “/”
tmpfsm
fopiopi
d “pts”
fopiopi
d “data
fopiopi
d “/”
ext4m
fopiopi
d “/”
procm
fopiopi
d “/”
ext4m
fopiopi
d “/”
sysfsm
fopiopi
d “/”
devptsm
fopiopi
d “bin”
fopiopi
d “sh”
app xbin
1. 掛載 rootfs
2. 根據 initramfs 建檔
3. 根據 ramdisk 建檔
4. init 預設行為
a. mount tmpfs
b. mkdir pts
c. mount devpts
d. mount proc
e. mount sysfs
5. init 根據 init.rc 行為
a. mount data
b. mount system
c. /bin/sh
su
kernel 行為
userspace 行為
32
Rootfs
fopiopi
“/”d
rootfsm
fopiopi
d “dev”
fopiopi
d “init”
fopiopi
d “proc”
fopiopi
d “system”
fopiopi
d “sys”
fopiopi
d “console”
fopiopi
d “/”
tmpfsm
fopiopi
d “pts”
fopiopi
d “data
fopiopi
d “/”
ext4m
fopiopi
d “/”
procm
fopiopi
d “/”
ext4m
fopiopi
d “/”
sysfsm
fopiopi
d “/”
devptsm
fopiopi
d “bin”
fopiopi
d “sh”
app xbin
1. 掛載 rootfs
2. 根據 initramfs 建檔
3. 根據 ramdisk 建檔
4. init 預設行為
a. mount tmpfs
b. mkdir pts
c. mount devpts
d. mount proc
e. mount sysfs
5. init 根據 init.rc 行為
a. mount data
b. mount system
c. /bin/sh
su
fopiopi
d “/”
debugfsm
fopiopi
d “/”
devtmpfsm
fopiopi
d “/”
sockfsm
fopiopi
d “/”
pipefsm
33
Mount
fopiopi
“/”d
rootfsm
fopiopi
d “dev”
tmpfsm
1. 建立 mount
34
Mount
fopiopi
“/”d
rootfsm
fopiopi
d “dev”
tmpfsm
1. 建立 mount
2. 建立 root inode
fopiopi
35
Mount
fopiopi
“/”d
rootfsm
fopiopi
d “dev”
tmpfsm
1. 建立 mount
2. 建立 root inode
3. 建立 root dentry “/”
fopiopi
d “/”
36
Mount
fopiopi
“/”d
rootfsm
fopiopi
d “dev”
tmpfsm
1. 建立 mount
2. 建立 root inode
3. 建立 root dentry “/”
4. 紀錄 parent mount & mount point(dentry)
fopiopi
d “/”
37
Lookup
fopiopi
“/”d
rootfsm
fopiopi
d “console”
fopiopi
d “dev”
*. task pwd 初始指向 root dentry
*. cd dev/console/../..
pwd
38
Lookup
fopiopi
“/”d
rootfsm
fopiopi
d “console”
fopiopi
d “dev”
*. task pwd 初始指向 root dentry
*. cd dev/console/../..
1. 往下 , 查表 , “/” dentry + child string “dev”
獲取” dev” dentry
pwd
dentry
hashtable dev/
“dev”
39
Lookup
fopiopi
“/”d
rootfsm
fopiopi
d “console”
fopiopi
d “dev”
pwd
*. task pwd 初始指向 root dentry
*. cd dev/console/../..
1. 往下 , 查表 , “/” dentry + child string “dev”
獲取” dev” dentry
2. 往下 , 查表 , “dev” dentry + child string “console”
獲取” console” dentry
dentry
hashtable
dev
“console”
console
40
Lookup
fopiopi
“/”d
rootfsm
fopiopi
d “console”
fopiopi
d “dev”
pwd
*. task pwd 初始指向 root dentry
*. cd dev/console/../..
1. 往下 , 查表 , “/” dentry + child string “dev”
獲取” dev” dentry
2. 往下 , 查表 , “dev” dentry + child string “console”
獲取” console” dentry
3. 往上 , 指標
41
Lookup
fopiopi
“/”d
rootfsm
fopiopi
d “console”
fopiopi
d “dev”
pwd
*. task pwd 初始指向 root dentry
*. cd dev/console/../..
1. 往下 , 查表 , “/” dentry + child string “dev”
獲取” dev” dentry
2. 往下 , 查表 , “dev” dentry + child string “console”
獲取” console” dentry
3. 往上 , 指標
4. 往上 , 指標
42
Lookup
fopiopi
“/”d
rootfsm
fopiopi
d “console”
fopiopi
d “dev”
fopiopi
d “/”
tmpfsm
fopiopi
d “pts”
fopiopi
d “/”
devptsm
*. task pwd 初始指向 root dentry
*. cd dev/pts/../..
pwd
43
Lookup
fopiopi
“/”d
rootfsm
fopiopi
d “console”
fopiopi
d “dev”
fopiopi
d “/”
tmpfsm
fopiopi
d “pts”
fopiopi
d “/”
devptsm
*. task pwd 初始指向 root dentry
*. cd dev/pts/../..
1.1. 往下 , 查表 , 獲取” dev” dentry
pwd
dentry
hashtable dev/
“dev”
44
Lookup
fopiopi
“/”d
rootfsm
fopiopi
d “console”
fopiopi
d “dev”
fopiopi
d “/”
tmpfsm
fopiopi
d “pts”
fopiopi
d “/”
devptsm
*. task pwd 初始指向 root dentry
*. cd dev/pts/../..
1.1. 往下 , 查表 , 獲取” dev” dentry
1.2. follow mount, 查表 , rootfs mount + “dev” dentry
獲取 tmpfs mount( 獲取 root dentry)
pwd
dentry
hashtable dev
mount
hashtable
dev
rootfs
tmpfs
/
“dev”
45
Lookup
fopiopi
“/”d
rootfsm
fopiopi
d “console”
fopiopi
d “dev”
fopiopi
d “/”
tmpfsm
fopiopi
d “pts”
fopiopi
d “/”
devptsm
*. task pwd 初始指向 root dentry
*. cd dev/pts/../..
1.1. 往下 , 查表 , 獲取” dev” dentry
1.2. follow mount, 查表 , rootfs mount + “dev” dentry
獲取 tmpfs mount( 獲取 root dentry)
2.1. 往下 , 查表 , 獲取” pts” dentry
pwd
dentry
hashtable pts/
“pts”
46
Lookup
fopiopi
“/”d
rootfsm
fopiopi
d “console”
fopiopi
d “dev”
fopiopi
d “/”
tmpfsm
fopiopi
d “pts”
fopiopi
d “/”
devptsm
*. task pwd 初始指向 root dentry
*. cd dev/pts/../..
1.1. 往下 , 查表 , 獲取” dev” dentry
1.2. follow mount, 查表 , rootfs mount + “dev” dentry
獲取 tmpfs mount( 獲取 root dentry)
2.1. 往下 , 查表 , 獲取” pts” dentry
2.2. follow mount, 查表 , tmpfs mount + “pts” dentry
獲取 devpts mount( 獲取 root dentry)
pwd
mount
hashtable
pts
tmpfs
devpts
dentry
hashtable pts/
“pts”
47
Lookup
fopiopi
“/”d
rootfsm
fopiopi
d “console”
fopiopi
d “dev”
fopiopi
d “/”
tmpfsm
fopiopi
d “pts”
fopiopi
d “/”
devptsm
*. task pwd 初始指向 root dentry
*. cd dev/pts/../..
1.1. 往下 , 查表 , 獲取” dev” dentry
1.2. follow mount, 查表 , rootfs mount + “dev” dentry
獲取 tmpfs mount( 獲取 root dentry)
2.1. 往下 , 查表 , 獲取” pts” dentry
2.2. follow mount, 查表 , tmpfs mount + “pts” dentry
獲取 devpts mount( 獲取 root dentry)
3.1. follow up, 指標 (to mount point)
pwd
48
Lookup
fopiopi
“/”d
rootfsm
fopiopi
d “console”
fopiopi
d “dev”
fopiopi
d “/”
tmpfsm
fopiopi
d “pts”
fopiopi
d “/”
devptsm
*. task pwd 初始指向 root dentry
*. cd dev/pts/../..
1.1. 往下 , 查表 , 獲取” dev” dentry
1.2. follow mount, 查表 , rootfs mount + “dev” dentry
獲取 tmpfs mount( 獲取 root dentry)
2.1. 往下 , 查表 , 獲取” pts” dentry
2.2. follow mount, 查表 , tmpfs mount + “pts” dentry
獲取 devpts mount( 獲取 root dentry)
3.1. follow up, 指標 (to mount point)
3.2. 往上 , 指標 (to parent dentry)
pwd
49
Lookup
fopiopi
“/”d
rootfsm
fopiopi
d “console”
fopiopi
d “dev”
fopiopi
d “/”
tmpfsm
fopiopi
d “pts”
fopiopi
d “/”
devptsm
*. task pwd 初始指向 root dentry
*. cd dev/pts/../..
1.1. 往下 , 查表 , 獲取” dev” dentry
1.2. follow mount, 查表 , rootfs mount + “dev” dentry
獲取 tmpfs mount( 獲取 root dentry)
2.1. 往下 , 查表 , 獲取” pts” dentry
2.2. follow mount, 查表 , tmpfs mount + “pts” dentry
獲取 devpts mount( 獲取 root dentry)
3.1. follow up, 指標 (to mount point)
3.2. 往上 , 指標 (to parent dentry)
4.1. follow up, 指標 (to mount point)
pwd
50
Lookup
fopiopi
“/”d
rootfsm
fopiopi
d “console”
fopiopi
d “dev”
fopiopi
d “/”
tmpfsm
fopiopi
d “pts”
fopiopi
d “/”
devptsm
*. task pwd 初始指向 root dentry
*. cd dev/pts/../..
1.1. 往下 , 查表 , 獲取” dev” dentry
1.2. follow mount, 查表 , rootfs mount + “dev” dentry
獲取 tmpfs mount( 獲取 root dentry)
2.1. 往下 , 查表 , 獲取” pts” dentry
2.2. follow mount, 查表 , tmpfs mount + “pts” dentry
獲取 devpts mount( 獲取 root dentry)
3.1. follow up, 指標 (to mount point)
3.2. 往上 , 指標 (to parent dentry)
4.1. follow up, 指標 (to mount point)
4.2. 往上 , 指標 (to parent dentry)
pwd
51
Create
parent
fop
iop
i
d “parent”
memory storage
d “child”
1. 查找 path & 建立 dentry
52
Create
parent
fop
iop
i
d “parent”
memory storage
d “child”
1. 查找 path & 建立 dentry
2. 執行 dir 自帶 create( )/mkdir( )/symlink( )/mknod( )
mknod( )
symlink( ) for link
for dirmkdir( )
create( ) for file
for char/block
53
Create
parent
fop
iop
i
d “parent”
memory storage
1. 查找 path & 建立 dentry
2. 執行 dir 自帶 create( )/mkdir( )/symlink( )/mknod( )
a. 建立 inode, 安裝 ops
mknod( )
symlink( ) for link
for dirmkdir( )
create( ) for file
for char/block
fop
iop
i
d “child”
54
Create
parent
fop
iop
i
d “parent”
memory storage
1. 查找 path & 建立 dentry
2. 執行 dir 自帶 create( )/mkdir( )/symlink( )/mknod( )
a. 建立 inode, 安裝 ops
b. 找地方放” target path”, if symlink
mknod( )
symlink( ) for link
for dirmkdir( )
create( ) for file
for char/block
fop
iop
i
d “child”
55
Create
parent
fop
iop
i
d “parent”
memory storage
1. 查找 path & 建立 dentry
2. 執行 dir 自帶 create( )/mkdir( )/symlink( )/mknod( )
a. 建立 inode, 安裝 ops
b. 找地方放” target path”, if symlink
c. 建立 dirent
mknod( )
symlink( ) for link
for dirmkdir( )
create( ) for file
for char/block
fop
iop
i
d “child” child
56
Create
parent
fop
iop
i
d “parent”
memory storage
1. 查找 path & 建立 dentry
2. 執行 dir 自帶 create( )/mkdir( )/symlink( )/mknod( )
a. 建立 inode, 安裝 ops
b. 找地方 (e.g. page) 放” target path”, if symlink
c. 建立 dirent
d. 關聯 dentry/inode
mknod( )
symlink( ) for link
for dirmkdir( )
create( ) for file
for char/block
fop
iop
i
d “child” child
57
Delete
parent
fop
iop
i
d “parent”
child
memory storage
fop
iop
i
d “child”
1. 查找 path
58
Delete
parent
rmdir( )
fop
iop
i
d “parent”
child
memory storage
unlink( ) for file/link/char/block
for dir
fop
iop
i
d “child”
1. 查找 path
2. 執行 parent inode 自帶 unlink( ) 或 rmdir( )
59
Delete
parent
rmdir( )
fop
iop
i
d “parent”
memory storage
unlink( ) for file/link/char/block
for dir
fop
iop
i
d “child”
1. 查找 path
2. 執行 parent inode 自帶 unlink( ) 或 rmdir( )
a. 移除 dirent
60
Delete
parent
rmdir( )
fop
iop
i
d “parent”
memory storage
unlink( ) for file/link/char/block
for dir
fop
iop
i
d “child”
1. 查找 path
2. 執行 parent inode 自帶 unlink( ) 或 rmdir( )
a. 移除 dirent
b. inode nlink--
61
Delete
1. 查找 path
2. 執行 parent inode 自帶 unlink( ) 或 rmdir( )
a. 移除 dirent
b. inode nlink--
c. 移除 child dentry
parent
rmdir( )
fop
iop
i
d “parent”
memory storage
unlink( ) for file/link/char/block
for dir
fop
iop
i
68
File Open/Close
file file
file
descriptor
table
task 1
file
descriptor
table
task 2
file
file
i
d
i
d
i
d
i
d file@vfs
file file@task
69
File Open/Close
file file
file
descriptor
table
task 1
file
descriptor
table
task 2
file
file
open:
i
d
i
d
i
d
70
File Open/Close
file file
file
descriptor
table
task 1
file
descriptor
table
task 2
file
file
open:
1. 準備可用 fd(array index)
i
d
i
d
i
d
71
File Open/Close
file file
file
descriptor
table
task 1
file
descriptor
table
task 2
file
file
open:
1. 準備可用 fd(array index)
2. 準備空 struct file
file
i
d
i
d
i
d
72
File Open/Close
file file
file
descriptor
table
task 1
file
descriptor
table
task 2
file
file
open:
1. 準備可用 fd(array index)
2. 準備空 struct file
3. 查找目標 (dentry/inode)
file
i
d
i
d
i
d
73
File Open/Close
file file
file
descriptor
table
task 1
file
descriptor
table
task 2
file
file
open:
1. 準備可用 fd(array index)
2. 準備空 struct file
3. 查找目標 (dentry/inode)
4. 建立 file 到 dentry/inode 關係
file
i
d
i
d
i
d
74
File Open/Close
file file
file
descriptor
table
task 1
file
descriptor
table
task 2
file
file
open:
1. 準備可用 fd(array index)
2. 準備空 struct file
3. 查找目標 (dentry/inode)
4. 建立 file 到 dentry/inode 關係
5. 安裝 file 到 fd table
file
i
d
i
d
i
d
75
File Open/Close
file file
file
descriptor
table
task 1
file
descriptor
table
task 2
file
file
close:
file
i
d
i
d
i
d
76
File Open/Close
file file
file
descriptor
table
task 1
file
descriptor
table
task 2
file
file
close:
1. 歸還 fd
file
i
d
i
d
i
d
77
File Open/Close
file file
file
descriptor
table
task 1
file
descriptor
table
task 2
file
file
close:
1. 歸還 fd
2. 歸還 file( 移除 )
i
d
i
d
i
d
78
File Open/Close
file file
file
descriptor
table
task 1
file
descriptor
table
task 2
file
file
close:
1. 歸還 fd
2. 歸還 file( 移除 )
3. 歸還 dentry/inode(count--)
i
d
i
d
i
d
79
Read/Write
fop
iop
address
space
p pp p p p p p
file
descriptor
table
file ino
file ino
read( )
aio_read( )
write( )
aio_write( )
userspace
buffer
storage
write read

More Related Content

What's hot

Linux Capabilities - eng - v2.1.5, compact
Linux Capabilities - eng - v2.1.5, compactLinux Capabilities - eng - v2.1.5, compact
Linux Capabilities - eng - v2.1.5, compactAlessandro Selli
 
File formats for Next Generation Sequencing
File formats for Next Generation SequencingFile formats for Next Generation Sequencing
File formats for Next Generation SequencingPierre Lindenbaum
 
A Stealthy Stealers - Spyware Toolkit and What They Do
A Stealthy Stealers - Spyware Toolkit and What They DoA Stealthy Stealers - Spyware Toolkit and What They Do
A Stealthy Stealers - Spyware Toolkit and What They Dosanghwan ahn
 
Kernel Recipes 2019 - Faster IO through io_uring
Kernel Recipes 2019 - Faster IO through io_uringKernel Recipes 2019 - Faster IO through io_uring
Kernel Recipes 2019 - Faster IO through io_uringAnne Nicolas
 
SANS @Night There's Gold in Them Thar Package Management Databases
SANS @Night There's Gold in Them Thar Package Management DatabasesSANS @Night There's Gold in Them Thar Package Management Databases
SANS @Night There's Gold in Them Thar Package Management DatabasesPhil Hagen
 
System Hacking Tutorial #1 - Introduction to Vulnerability and Type of Vulner...
System Hacking Tutorial #1 - Introduction to Vulnerability and Type of Vulner...System Hacking Tutorial #1 - Introduction to Vulnerability and Type of Vulner...
System Hacking Tutorial #1 - Introduction to Vulnerability and Type of Vulner...sanghwan ahn
 
Pry at the Ruby Drink-up of Sophia, February 2012
Pry at the Ruby Drink-up of Sophia, February 2012Pry at the Ruby Drink-up of Sophia, February 2012
Pry at the Ruby Drink-up of Sophia, February 2012rivierarb
 
도커 없이 컨테이너 만들기 5편 마운트 네임스페이스와 오버레이 파일시스템
도커 없이 컨테이너 만들기 5편 마운트 네임스페이스와 오버레이 파일시스템도커 없이 컨테이너 만들기 5편 마운트 네임스페이스와 오버레이 파일시스템
도커 없이 컨테이너 만들기 5편 마운트 네임스페이스와 오버레이 파일시스템Sam Kim
 
FFMPEG on android
FFMPEG on androidFFMPEG on android
FFMPEG on androidYoss Cohen
 
Cisco IOS shellcode: All-in-one
Cisco IOS shellcode: All-in-oneCisco IOS shellcode: All-in-one
Cisco IOS shellcode: All-in-oneDefconRussia
 
start_printf: dev/ic/com.c comstart()
start_printf: dev/ic/com.c comstart()start_printf: dev/ic/com.c comstart()
start_printf: dev/ic/com.c comstart()Kiwamu Okabe
 
NUMOSS 4th Week - Commandline Tutorial
NUMOSS 4th Week - Commandline TutorialNUMOSS 4th Week - Commandline Tutorial
NUMOSS 4th Week - Commandline TutorialGagah Arifianto
 
Make container without_docker_6-overlay-network_1
Make container without_docker_6-overlay-network_1 Make container without_docker_6-overlay-network_1
Make container without_docker_6-overlay-network_1 Sam Kim
 
도커 없이 컨테이너 만들기 4편 네트워크네임스페이스 (2)
도커 없이 컨테이너 만들기 4편 네트워크네임스페이스 (2)도커 없이 컨테이너 만들기 4편 네트워크네임스페이스 (2)
도커 없이 컨테이너 만들기 4편 네트워크네임스페이스 (2)Sam Kim
 
Next Generation Sequencing file Formats ( 2017 )
Next Generation Sequencing file Formats ( 2017 )Next Generation Sequencing file Formats ( 2017 )
Next Generation Sequencing file Formats ( 2017 )Pierre Lindenbaum
 
Confraria Security & IT - Lisbon Set 29, 2011
Confraria Security & IT - Lisbon Set 29, 2011Confraria Security & IT - Lisbon Set 29, 2011
Confraria Security & IT - Lisbon Set 29, 2011ricardomcm
 

What's hot (20)

Linux Capabilities - eng - v2.1.5, compact
Linux Capabilities - eng - v2.1.5, compactLinux Capabilities - eng - v2.1.5, compact
Linux Capabilities - eng - v2.1.5, compact
 
File formats for Next Generation Sequencing
File formats for Next Generation SequencingFile formats for Next Generation Sequencing
File formats for Next Generation Sequencing
 
Sp ch05
Sp ch05Sp ch05
Sp ch05
 
A Stealthy Stealers - Spyware Toolkit and What They Do
A Stealthy Stealers - Spyware Toolkit and What They DoA Stealthy Stealers - Spyware Toolkit and What They Do
A Stealthy Stealers - Spyware Toolkit and What They Do
 
Kernel Recipes 2019 - Faster IO through io_uring
Kernel Recipes 2019 - Faster IO through io_uringKernel Recipes 2019 - Faster IO through io_uring
Kernel Recipes 2019 - Faster IO through io_uring
 
SANS @Night There's Gold in Them Thar Package Management Databases
SANS @Night There's Gold in Them Thar Package Management DatabasesSANS @Night There's Gold in Them Thar Package Management Databases
SANS @Night There's Gold in Them Thar Package Management Databases
 
System Hacking Tutorial #1 - Introduction to Vulnerability and Type of Vulner...
System Hacking Tutorial #1 - Introduction to Vulnerability and Type of Vulner...System Hacking Tutorial #1 - Introduction to Vulnerability and Type of Vulner...
System Hacking Tutorial #1 - Introduction to Vulnerability and Type of Vulner...
 
50 most frequently used unix
50 most frequently used unix50 most frequently used unix
50 most frequently used unix
 
Pry at the Ruby Drink-up of Sophia, February 2012
Pry at the Ruby Drink-up of Sophia, February 2012Pry at the Ruby Drink-up of Sophia, February 2012
Pry at the Ruby Drink-up of Sophia, February 2012
 
도커 없이 컨테이너 만들기 5편 마운트 네임스페이스와 오버레이 파일시스템
도커 없이 컨테이너 만들기 5편 마운트 네임스페이스와 오버레이 파일시스템도커 없이 컨테이너 만들기 5편 마운트 네임스페이스와 오버레이 파일시스템
도커 없이 컨테이너 만들기 5편 마운트 네임스페이스와 오버레이 파일시스템
 
FFMPEG on android
FFMPEG on androidFFMPEG on android
FFMPEG on android
 
Cisco IOS shellcode: All-in-one
Cisco IOS shellcode: All-in-oneCisco IOS shellcode: All-in-one
Cisco IOS shellcode: All-in-one
 
Linux Command Line
Linux Command LineLinux Command Line
Linux Command Line
 
start_printf: dev/ic/com.c comstart()
start_printf: dev/ic/com.c comstart()start_printf: dev/ic/com.c comstart()
start_printf: dev/ic/com.c comstart()
 
50 Most Frequently Used UNIX Linux Commands -hmftj
50 Most Frequently Used UNIX  Linux Commands -hmftj50 Most Frequently Used UNIX  Linux Commands -hmftj
50 Most Frequently Used UNIX Linux Commands -hmftj
 
NUMOSS 4th Week - Commandline Tutorial
NUMOSS 4th Week - Commandline TutorialNUMOSS 4th Week - Commandline Tutorial
NUMOSS 4th Week - Commandline Tutorial
 
Make container without_docker_6-overlay-network_1
Make container without_docker_6-overlay-network_1 Make container without_docker_6-overlay-network_1
Make container without_docker_6-overlay-network_1
 
도커 없이 컨테이너 만들기 4편 네트워크네임스페이스 (2)
도커 없이 컨테이너 만들기 4편 네트워크네임스페이스 (2)도커 없이 컨테이너 만들기 4편 네트워크네임스페이스 (2)
도커 없이 컨테이너 만들기 4편 네트워크네임스페이스 (2)
 
Next Generation Sequencing file Formats ( 2017 )
Next Generation Sequencing file Formats ( 2017 )Next Generation Sequencing file Formats ( 2017 )
Next Generation Sequencing file Formats ( 2017 )
 
Confraria Security & IT - Lisbon Set 29, 2011
Confraria Security & IT - Lisbon Set 29, 2011Confraria Security & IT - Lisbon Set 29, 2011
Confraria Security & IT - Lisbon Set 29, 2011
 

Similar to ch8-pv1-the-virtual-filesystem

Cd rom mounting cdro-ms on solaris
Cd rom mounting cdro-ms on solarisCd rom mounting cdro-ms on solaris
Cd rom mounting cdro-ms on solarisBui Van Cuong
 
(120513) #fitalk an introduction to linux memory forensics
(120513) #fitalk   an introduction to linux memory forensics(120513) #fitalk   an introduction to linux memory forensics
(120513) #fitalk an introduction to linux memory forensicsINSIGHT FORENSIC
 
(120513) #fitalk an introduction to linux memory forensics
(120513) #fitalk   an introduction to linux memory forensics(120513) #fitalk   an introduction to linux memory forensics
(120513) #fitalk an introduction to linux memory forensicsINSIGHT FORENSIC
 
Simplest-Ownage-Human-Observed… - Routers
 Simplest-Ownage-Human-Observed… - Routers Simplest-Ownage-Human-Observed… - Routers
Simplest-Ownage-Human-Observed… - RoutersLogicaltrust pl
 
Filip palian mateuszkocielski. simplest ownage human observed… routers
Filip palian mateuszkocielski. simplest ownage human observed… routersFilip palian mateuszkocielski. simplest ownage human observed… routers
Filip palian mateuszkocielski. simplest ownage human observed… routersYury Chemerkin
 
Virtualization and automation of library software/machines + Puppet
Virtualization and automation of library software/machines + PuppetVirtualization and automation of library software/machines + Puppet
Virtualization and automation of library software/machines + PuppetOmar Reygaert
 
Linux Troubleshooting
Linux TroubleshootingLinux Troubleshooting
Linux TroubleshootingKeith Wright
 
Security Walls in Linux Environment: Practice, Experience, and Results
Security Walls in Linux Environment: Practice, Experience, and ResultsSecurity Walls in Linux Environment: Practice, Experience, and Results
Security Walls in Linux Environment: Practice, Experience, and ResultsIgor Beliaiev
 
Part 4 of 'Introduction to Linux for bioinformatics': Managing data
Part 4 of 'Introduction to Linux for bioinformatics': Managing data Part 4 of 'Introduction to Linux for bioinformatics': Managing data
Part 4 of 'Introduction to Linux for bioinformatics': Managing data Joachim Jacob
 
MINCS - containers in the shell script (Eng. ver.)
MINCS - containers in the shell script (Eng. ver.)MINCS - containers in the shell script (Eng. ver.)
MINCS - containers in the shell script (Eng. ver.)Masami Hiramatsu
 
Andresen 8 21 02
Andresen 8 21 02Andresen 8 21 02
Andresen 8 21 02FNian
 
Writing Character driver (loadable module) in linux
Writing Character driver (loadable module) in linuxWriting Character driver (loadable module) in linux
Writing Character driver (loadable module) in linuxRajKumar Rampelli
 
What is-a-computer-process-os
What is-a-computer-process-osWhat is-a-computer-process-os
What is-a-computer-process-osManish Singh
 
Unmasking Careto through Memory Forensics (video in description)
Unmasking Careto through Memory Forensics (video in description)Unmasking Careto through Memory Forensics (video in description)
Unmasking Careto through Memory Forensics (video in description)Andrew Case
 
Advanced Level Training on Koha / TLS (ToT)
Advanced Level Training on Koha / TLS (ToT)Advanced Level Training on Koha / TLS (ToT)
Advanced Level Training on Koha / TLS (ToT)Ata Rehman
 

Similar to ch8-pv1-the-virtual-filesystem (20)

Cd rom mounting cdro-ms on solaris
Cd rom mounting cdro-ms on solarisCd rom mounting cdro-ms on solaris
Cd rom mounting cdro-ms on solaris
 
Ch12 system administration
Ch12 system administration Ch12 system administration
Ch12 system administration
 
(120513) #fitalk an introduction to linux memory forensics
(120513) #fitalk   an introduction to linux memory forensics(120513) #fitalk   an introduction to linux memory forensics
(120513) #fitalk an introduction to linux memory forensics
 
(120513) #fitalk an introduction to linux memory forensics
(120513) #fitalk   an introduction to linux memory forensics(120513) #fitalk   an introduction to linux memory forensics
(120513) #fitalk an introduction to linux memory forensics
 
Linux filesystemhierarchy
Linux filesystemhierarchyLinux filesystemhierarchy
Linux filesystemhierarchy
 
Simplest-Ownage-Human-Observed… - Routers
 Simplest-Ownage-Human-Observed… - Routers Simplest-Ownage-Human-Observed… - Routers
Simplest-Ownage-Human-Observed… - Routers
 
Filip palian mateuszkocielski. simplest ownage human observed… routers
Filip palian mateuszkocielski. simplest ownage human observed… routersFilip palian mateuszkocielski. simplest ownage human observed… routers
Filip palian mateuszkocielski. simplest ownage human observed… routers
 
Aix commands
Aix commandsAix commands
Aix commands
 
sift_cheat_sheet.pdf
sift_cheat_sheet.pdfsift_cheat_sheet.pdf
sift_cheat_sheet.pdf
 
Virtualization and automation of library software/machines + Puppet
Virtualization and automation of library software/machines + PuppetVirtualization and automation of library software/machines + Puppet
Virtualization and automation of library software/machines + Puppet
 
Ch12
Ch12Ch12
Ch12
 
Linux Troubleshooting
Linux TroubleshootingLinux Troubleshooting
Linux Troubleshooting
 
Security Walls in Linux Environment: Practice, Experience, and Results
Security Walls in Linux Environment: Practice, Experience, and ResultsSecurity Walls in Linux Environment: Practice, Experience, and Results
Security Walls in Linux Environment: Practice, Experience, and Results
 
Part 4 of 'Introduction to Linux for bioinformatics': Managing data
Part 4 of 'Introduction to Linux for bioinformatics': Managing data Part 4 of 'Introduction to Linux for bioinformatics': Managing data
Part 4 of 'Introduction to Linux for bioinformatics': Managing data
 
MINCS - containers in the shell script (Eng. ver.)
MINCS - containers in the shell script (Eng. ver.)MINCS - containers in the shell script (Eng. ver.)
MINCS - containers in the shell script (Eng. ver.)
 
Andresen 8 21 02
Andresen 8 21 02Andresen 8 21 02
Andresen 8 21 02
 
Writing Character driver (loadable module) in linux
Writing Character driver (loadable module) in linuxWriting Character driver (loadable module) in linux
Writing Character driver (loadable module) in linux
 
What is-a-computer-process-os
What is-a-computer-process-osWhat is-a-computer-process-os
What is-a-computer-process-os
 
Unmasking Careto through Memory Forensics (video in description)
Unmasking Careto through Memory Forensics (video in description)Unmasking Careto through Memory Forensics (video in description)
Unmasking Careto through Memory Forensics (video in description)
 
Advanced Level Training on Koha / TLS (ToT)
Advanced Level Training on Koha / TLS (ToT)Advanced Level Training on Koha / TLS (ToT)
Advanced Level Training on Koha / TLS (ToT)
 

More from yushiang fu

ch15-pv1-time-management
ch15-pv1-time-managementch15-pv1-time-management
ch15-pv1-time-managementyushiang fu
 
ch13-pv1-system-calls
ch13-pv1-system-callsch13-pv1-system-calls
ch13-pv1-system-callsyushiang fu
 
ch9-pv1-the-extended-filesystem-family
ch9-pv1-the-extended-filesystem-familych9-pv1-the-extended-filesystem-family
ch9-pv1-the-extended-filesystem-familyyushiang fu
 
ch3-pv1-memory-management
ch3-pv1-memory-managementch3-pv1-memory-management
ch3-pv1-memory-managementyushiang fu
 
ch4-pv2-virtual-process-memory
ch4-pv2-virtual-process-memorych4-pv2-virtual-process-memory
ch4-pv2-virtual-process-memoryyushiang fu
 

More from yushiang fu (6)

ch15-pv1-time-management
ch15-pv1-time-managementch15-pv1-time-management
ch15-pv1-time-management
 
ch13-pv1-system-calls
ch13-pv1-system-callsch13-pv1-system-calls
ch13-pv1-system-calls
 
ch9-pv1-the-extended-filesystem-family
ch9-pv1-the-extended-filesystem-familych9-pv1-the-extended-filesystem-family
ch9-pv1-the-extended-filesystem-family
 
ch7-pv1-modules
ch7-pv1-modulesch7-pv1-modules
ch7-pv1-modules
 
ch3-pv1-memory-management
ch3-pv1-memory-managementch3-pv1-memory-management
ch3-pv1-memory-management
 
ch4-pv2-virtual-process-memory
ch4-pv2-virtual-process-memorych4-pv2-virtual-process-memory
ch4-pv2-virtual-process-memory
 

ch8-pv1-the-virtual-filesystem