SlideShare a Scribd company logo
Android Storage
- Vold (Honeycomb 3.2)
William.L
wiliwe@gmail.com
2011-11-25
Outline
What is Vold?
Components
Communication
Vold Init Flow
Volume State Machine
Example : SD Card Insert
Appendix A- An issue in Google original code
Appendix B- How to read Microsoft NTFS format
storage?
Reference
What is Vold?
Volume daemon
The same as Mountd before Donut (Android 1.7)
Vold 2.0 since Froyo (Android 2.2)
As the role of Udev in the desktop Linux distro
Lisenting Netlink socket for volume changing Uevent
Ineteract with MountService (Java layer)
As a slave to MountService which is the decision maker
Notify volume status changing events to MountService
Execute commands issued from MountService
Communicates with MountService through unix domain(POSIX
Local IPC) socket
Folder : AndroidSrc/system/vold
Main Entry
main.c : main()
Components (1/12)
Vold is composed of
VolumeManager
NetlinkManager
NetlinkHandler
NetlinkEvent
CommandListener
Volume / DirectVolume
vold.fstab file
Fat
fsck_msdos , newfs_msdos executables
Components (2/12)
MountService
vold
(local socket )
CommandListener
VolumeManager
Send
command
Notify volume
events
Netlink socket
Notify volume events
Dispatch
Command
Notify volume
events
NetlinkManager
NetlinkHandler
Linux Kernel
Notify UEVENT
Vold
VolumeCollection <List>
DirectVolume-USB
DirectVolume-
External SD Card
.
.
.
After parsing
vold.fstab,
add
DirectVolume
to
VolumeCollecti
on list
Vold Architecture
(Java layer)
(C/C++ app layer)
Components (3/12)
VolumeManager
VolumeManager.cpp/.h
Provides corresponding command handlers called by
CommandListener for ASEC/OBB/MountService
commands
Store volume informations retrieved from vold.fstab
Notify MountService status changing of volumes
Components (4/12)
NetlinkManager
NetlinkManager.cpp/.h
Open the socket listening to kernel Netlink Kobject
Uevent
Create a NetlinkHandler instance with the opened
socket and activate it to start to listen to the Netlink
socket
Components (5/12)
NetlinkHandler
NetlinkHandler.cpp/.h
Wait for Netlink Kobject Uevent
Process Uevent in NetlinkHandler::onEvent()
Call proper command handlers(defined in VolumeManager)
corresponding to the “action” type of uevent
Components (6/12)
NetlinkEvent
AndroidSrc/system/core/include/sysutils/NetlinkEvent.h
Encapsulate Uevent information
Passed to NetlinkHandler::onEvent()
Components (7/12)
CommandListener
CommandListener.cpp/.h
Using socket(vold) to communicate with MountService
Wait for commands from MountService
Dispatch received MountService commands to
corresponding executor
CommandListener::VolumeCmd::runCommand()
Components (8/12)
Volume / DirectVolume
Volume.cpp/.h , DirectVolume.cpp/.h
DirectVolume is a subclass of Volume
To store volume informations retreiving from vold.fstab
Volume do the actual actions(mount, unmount, etc)
corresponding to the commands(doMount, doUnmount, etc)
from MountService
Components (9/12)
vold.fstab
AndroidSrc/device/nvidia/ventana [nVidia solution]
Describe what storages will be added into system
Processed by process_config()
AndroidSrc/system/vold/main.cpp
Example:
dev_mount usbdrive /mnt/usbdrive auto /devices/platform/tegra-ehci.2/usb2
dev_mount - Means mounting devices
usbdrive - Label for the USB volume
/mnt/usbdrive - Where the USB volume will be mounted
auto - Partition number (1 based). 'auto' for first usable partition
/devices/platform/tegra-ehci.2/usb2 - The sysfs path to external USB device
Components (10/12)
Fat
Fat.cpp/.h
Validate if the filesystem of the new added volume is FAT
Mount the new volume whose filesystem type is FAT
Format specified volume’s filesystem to FAT
Components (11/12)
fsck_msdos exectutable
AndroidSrc/external/fsck_msdos/main.c
To validate if the filesystem in new adding volume is MS-
DOS FAT 16 or 32
Called by Fat::check()
Components (12/12)
newfs_msdos exectutable
AndroidSrc/system/core/toolbox/newfs_msdos.c
To format a specified volume to MS-DOS FAT 32 type
filesystem
Called by Fat::format()
Communication
Netlink Socket
Passes informations between Kernel space and User
space
Protocol : NETLINK_KOBJECT_UEVENT
Defined in KernelSrc/include/linux/netlink.h
KernelSrc/lib/kobject_uevent.c : kobject_uevent_env()
Unix Domain/POSIX Local IPC Socket
For the communication between Vold & MountService
Created in init.rc
socket vold stream 0660 root mount
mount is MountService process
AndroidSrc/system/core/rootdir/init.rc
Vold Init Flow
Init.rc invoke “/system/bin/vold” &
create local socket “vold”
vold/main()
Create instance of
VolumeManager, CommandListener,
NetlinkManager separately
Set CommandLisener instance
to be the broadcaster of
VolumeManager/NetlinkManager to notify
volume changing event to MountService
through local socket
Activate the VolumeManager instance to run
Create the folder “/dev/block/vold” for device
node of new added volume
Acitvate the NetlinkManager instance to
listen to netlink uevent
Call coldboot() to monitor if there has
any volume(insternal/external storage)
has existed before booting
start
Activate CommandLinstener instance to
to listen “vold” local socket
Loop forever
Parse vold.fstab and store possible adding
storages’ Information using DirectVolume
Volume State Machine (1/4)
10 volume states (enum-value)
Init (-1)
NoMedia/Removed (0)
Idle/Unmounted (1)
Pending (2)
Waiting for the report of the number of volume partition
Chencking (3)
Checking filesystem type
Mounted (4)
Unmounting (5)
Formatting (6)
Shared(Unmounted) (7)
ShareMnt (8)
Volume State Machine (2/4)
Init NoMediaInitial
System initialize done
Attach storage to the device
NoMedia
Idle(Unmounted)
Pending
CheckingMounted
Initial
Volume State Machine (3/4)
NoMedia Idle(Unmounted)
Initial
Deattach storage from the device
Mounted Unmounting
Formatting
Idle(Unmounted)
Initial
Format the storage
Mounted Unmounting
(1)
(2) (3)
(4)(5)
CheckingMounted
(6)
Volume State Machine (4/4)
Idle(Unmounted)
Initial
Storage(SD card) Unsharing
SharedMnt Shared-Unmounted
CheckingMounted
Shared-Unmounted
Initial
Storage(SD card) Sharing
Mounted Unmounting
Idle(Unmounted)
SharedMnt
From Honeycomb with
MTP, these two cases
will not happen!
When access USB
mass-storage through
MTP, it need not to
unmount SD card.
Example: SD Card Insert (1/3)
[Honeycomb MR2]
Volume information for SD card in vold.fstab :
dev_mount sdcard /sdcard2 auto /devices/platform/sdhci-tegra.2/mmc_host/mmc1
When Vold init, a DirectVolume instance will be created to store SD card volume
informations
The stored informations are:
Label : sdcard
MountPoint : /sdcard2
DevPath(sysfs) : /devices/platform/sdhci-tegra.2/mmc_host/mmc1
Example: SD Card Insert (2/3)
Kernel detect a mmc
medium (sd card) insert
Kernel send Netlink Kobject Uevent :
ACTION : add
DEVPATH : /devices/platform/sdhci-
tegra.2/mmc_host/mmc1/mmc1:e624/block/mmcblk1
DEVTYPE : disk
SUBSYS : block
ACTION : add
DEVPATH : /devices/platform/sdhci-
tegra.2/mmc_host/mmc1/mmc1:e624/block/mmcblk1/mmcblk1p1
DEVTYPE : partition
SUBSYS : block
NetlinkHanlder detect Uevent with “block” subsys type,
then call VolumeManager::handleBlockEvent()
In VolumeManager::handleBlockEvent(), it iterate all
stored DirectVolume instances and call their
handleBolckEvent() method
In DirectVolume::handleBolckEvent(), it compares
passed in devPath with the one retrieved from vold.fstab.
In this example, if it found the string
“/devices/platform/sdhci-tegra.2/mmc_host/mmc1” in
devPath, it will create a device node under
/dev/block/vold/MajrID:MinrID for the new added volume
and then send notification,
“ResponseCode::VolumeDiskInserted”, to
MountService with Label & MountPoint (from vold.fstab)
as parameters
Continued to the
next slide
Insert
Android Device
Example: SD Card Insert (3/3)
On MountService receiving notification from
Vold, “ResponseCode::VolumeDiskInserted”,
it send “volume mount” command back to Vold
with “MountPoint” as the parameter named
Label
Continued from the previous slide
In Vold, CommandListener receive ”volume
mount” command, it execute
VolumeManager::mountVolume() with
parameter, Label, from MountService
In VolumeManager::mountVolume(), it
compare parameter, Label, with “Label” or
“MountPoint” informations retrieved from
vold.fstab.
If it match one of two information, it will call
Volume::mountVol() to subsequtial operations
for mounting
In Volume::mountVol(), it does FAT filesystem
checking operation by calling Fat::check().
If the new added volume is FAT filesystem, it
will try to mount new volume with VFAT type
using Fat::doMount() and
Volume::doMoveMount()
The new added volume has been mounted,
and the user can use this new
volume/storage (^o^)
Appendix A-
An issue in Google original code:
video/image files in external storage will be deleted
when un-mounting external storage
2011-10-14
Problem Description
After user pressing “Unmount” button in
Settings>Storage menu to unmount an
external storage, all video/image files on that
external storage will be deleted immediately
without any warning message
This problem will shock users!!!
Root Cause (1/2)
After user pressing “Unmount” button in
Settings>Storage menu, the system will send
ACTION_MEDIA_EJECT and
ACTION_MEDIA_UNMOUNTED Intents (events)
in sequence
When the member "mUnmountReceiver“
(BroadcastReceiver) of the class MediaProvider
(MediaProvider.java) receiving the
ACTION_MEDIA_EJECT Intent, it will call
delete() of SQLiteDatabase class to
prune/remove invalid entries in thumbnail table
representing video/image files on the
unmounted external storage
Root Cause (2/2)
delete() of SQLiteDatabase class will delete the
(video/image) files corresponding to invalid
entries in the thumbnail table eventually
Please refer to the Google Android issue
http://code.google.com/p/android/issues/detail?id=3692
Search the keyword “delete()”
Solution
To change the Intent type the member
"mUnmountReceiver“ monitors to
ACTION_MEDIA_UNMOUNTED and
ACTION_MEDIA_BAD_REMOVAL
So MediaProvider will prune/remove invalid
entries in thumbnail table only when it receives
Unmounted or Bad-Removal events
e.g. the external storage has been detached from the
file system actually!
Appendix B-
How to read Microsoft NTFS
format storage?
2011-12-27
Problem Description
Originally, Google Android only supports
Microsoft FAT format storage
Android Vold (Volume.cpp) checks the format
of a new inserted storage when trying to do
mounting. If it is not FAT format, it will skip this
storage and check the next found storage
Storages in NTFS format are so common, so it is
better for an Android device to be capable of
reading NTFS format storage
Solution (1/2)
TuxEra’s NTFS-3G is a stable, full-featured
solution to address the requirement of reading
NTFS format storage
This is a file system driver for NTFS format
After installing this into Linux system, it will add a file
system type option “ntfs” of “mount” system command
and “mount()” API
NTFS-3G official site
http://www.tuxera.com/community/ntfs-3g-download/
Solution (2/2)
In the method mountVol() of Volume class
(Volume.cpp)
“if ( Fat::check(devicePath) )” block will enter when the
checking status is non-zero, e.g. the current storage is
NOT FAT format
It could add codes to calling mount() with “ntfs” option
in this block to try to mount current storage and to see if
it is NTFS format through the return value of mount()
Also, it needs to check the storage is in Read-Only
mode
Reference
Kobject Uevent socket – Chapter 17, Linux 核
心開發指南 (Linux Kernel Development, 2/e)
Robert Love 著, 沈中庸、沈彥男 譯, 維科出版社
Unix Domain Socket – Chapter 15, Unix
Network Programming, Volume 1: The Sockets
Networking API, 3/e W. Richard Stevens
Netlink in Kernel –
http://www.linuxjournal.com/article/7356
Ad

More Related Content

What's hot (20)

Android booting sequece and setup and debugging
Android booting sequece and setup and debuggingAndroid booting sequece and setup and debugging
Android booting sequece and setup and debugging
Utkarsh Mankad
 
Android Boot Time Optimization
Android Boot Time OptimizationAndroid Boot Time Optimization
Android Boot Time Optimization
Kan-Ru Chen
 
Embedded Android : System Development - Part II (HAL)
Embedded Android : System Development - Part II (HAL)Embedded Android : System Development - Part II (HAL)
Embedded Android : System Development - Part II (HAL)
Emertxe Information Technologies Pvt Ltd
 
Q4.11: Porting Android to new Platforms
Q4.11: Porting Android to new PlatformsQ4.11: Porting Android to new Platforms
Q4.11: Porting Android to new Platforms
Linaro
 
Embedded Android : System Development - Part I
Embedded Android : System Development - Part IEmbedded Android : System Development - Part I
Embedded Android : System Development - Part I
Emertxe Information Technologies Pvt Ltd
 
Learning AOSP - Android Booting Process
Learning AOSP - Android Booting ProcessLearning AOSP - Android Booting Process
Learning AOSP - Android Booting Process
Nanik Tolaram
 
Low Level View of Android System Architecture
Low Level View of Android System ArchitectureLow Level View of Android System Architecture
Low Level View of Android System Architecture
National Cheng Kung University
 
Embedded Android : System Development - Part III
Embedded Android : System Development - Part IIIEmbedded Android : System Development - Part III
Embedded Android : System Development - Part III
Emertxe Information Technologies Pvt Ltd
 
Android Booting Sequence
Android Booting SequenceAndroid Booting Sequence
Android Booting Sequence
Jayanta Ghoshal
 
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Opersys inc.
 
Embedded Android Workshop with Pie
Embedded Android Workshop with PieEmbedded Android Workshop with Pie
Embedded Android Workshop with Pie
Opersys inc.
 
Learning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device DriverLearning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device Driver
Nanik Tolaram
 
Embedded Android Workshop
Embedded Android WorkshopEmbedded Android Workshop
Embedded Android Workshop
Opersys inc.
 
Embedded Android : System Development - Part II (Linux device drivers)
Embedded Android : System Development - Part II (Linux device drivers)Embedded Android : System Development - Part II (Linux device drivers)
Embedded Android : System Development - Part II (Linux device drivers)
Emertxe Information Technologies Pvt Ltd
 
Introduction to Android Window System
Introduction to Android Window SystemIntroduction to Android Window System
Introduction to Android Window System
National Cheng Kung University
 
Android Treble: Blessing or Trouble?
Android Treble: Blessing or Trouble?Android Treble: Blessing or Trouble?
Android Treble: Blessing or Trouble?
Opersys inc.
 
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Opersys inc.
 
Embedded Android : System Development - Part IV (Android System Services)
Embedded Android : System Development - Part IV (Android System Services)Embedded Android : System Development - Part IV (Android System Services)
Embedded Android : System Development - Part IV (Android System Services)
Emertxe Information Technologies Pvt Ltd
 
Design and Concepts of Android Graphics
Design and Concepts of Android GraphicsDesign and Concepts of Android Graphics
Design and Concepts of Android Graphics
National Cheng Kung University
 
Android Internals
Android InternalsAndroid Internals
Android Internals
Opersys inc.
 
Android booting sequece and setup and debugging
Android booting sequece and setup and debuggingAndroid booting sequece and setup and debugging
Android booting sequece and setup and debugging
Utkarsh Mankad
 
Android Boot Time Optimization
Android Boot Time OptimizationAndroid Boot Time Optimization
Android Boot Time Optimization
Kan-Ru Chen
 
Q4.11: Porting Android to new Platforms
Q4.11: Porting Android to new PlatformsQ4.11: Porting Android to new Platforms
Q4.11: Porting Android to new Platforms
Linaro
 
Learning AOSP - Android Booting Process
Learning AOSP - Android Booting ProcessLearning AOSP - Android Booting Process
Learning AOSP - Android Booting Process
Nanik Tolaram
 
Android Booting Sequence
Android Booting SequenceAndroid Booting Sequence
Android Booting Sequence
Jayanta Ghoshal
 
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Opersys inc.
 
Embedded Android Workshop with Pie
Embedded Android Workshop with PieEmbedded Android Workshop with Pie
Embedded Android Workshop with Pie
Opersys inc.
 
Learning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device DriverLearning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device Driver
Nanik Tolaram
 
Embedded Android Workshop
Embedded Android WorkshopEmbedded Android Workshop
Embedded Android Workshop
Opersys inc.
 
Android Treble: Blessing or Trouble?
Android Treble: Blessing or Trouble?Android Treble: Blessing or Trouble?
Android Treble: Blessing or Trouble?
Opersys inc.
 
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Opersys inc.
 

Similar to Android Storage - Vold (20)

Ch12 system administration
Ch12 system administration Ch12 system administration
Ch12 system administration
Raja Waseem Akhtar
 
Ch04
Ch04Ch04
Ch04
Raja Waseem Akhtar
 
Ch04 system administration
Ch04 system administration Ch04 system administration
Ch04 system administration
Raja Waseem Akhtar
 
Monky vold extension
Monky vold extensionMonky vold extension
Monky vold extension
mamahow
 
Let’s talk virtualization
Let’s talk virtualizationLet’s talk virtualization
Let’s talk virtualization
Etienne Tremblay
 
Mirroring the root_disk under solaris SVM
Mirroring the root_disk under solaris SVMMirroring the root_disk under solaris SVM
Mirroring the root_disk under solaris SVM
Kazimal Abed Mohammed
 
Bootloaders (U-Boot)
Bootloaders (U-Boot) Bootloaders (U-Boot)
Bootloaders (U-Boot)
Omkar Rane
 
The Holy Grail of Deployment
The Holy Grail of DeploymentThe Holy Grail of Deployment
The Holy Grail of Deployment
Stuart King
 
I/O, You Own: Regaining Control of Your Disk in the Presence of Bootkits
I/O, You Own: Regaining Control of Your Disk in the Presence of BootkitsI/O, You Own: Regaining Control of Your Disk in the Presence of Bootkits
I/O, You Own: Regaining Control of Your Disk in the Presence of Bootkits
CrowdStrike
 
Ch12
Ch12Ch12
Ch12
Raja Waseem Akhtar
 
Bootkits: Past, Present & Future - Virus Bulletin
Bootkits: Past, Present & Future - Virus BulletinBootkits: Past, Present & Future - Virus Bulletin
Bootkits: Past, Present & Future - Virus Bulletin
ESET
 
R12 d49656 gc10-apps dba 01
R12 d49656 gc10-apps dba 01R12 d49656 gc10-apps dba 01
R12 d49656 gc10-apps dba 01
zeesniper
 
WinFE: The (Almost) Perfect Triage Tool
WinFE: The (Almost) Perfect Triage ToolWinFE: The (Almost) Perfect Triage Tool
WinFE: The (Almost) Perfect Triage Tool
Brent Muir
 
dokumen.tips_aix-presentation.ppt
dokumen.tips_aix-presentation.pptdokumen.tips_aix-presentation.ppt
dokumen.tips_aix-presentation.ppt
AhmedFawzy916524
 
Logical volume manager xfs
Logical volume manager xfsLogical volume manager xfs
Logical volume manager xfs
Sarwar Javaid
 
Red Hat Training
Red Hat   TrainingRed Hat   Training
Red Hat Training
Open Source Group
 
1 04 rao
1 04 rao1 04 rao
1 04 rao
dimitar9
 
VDCF Overview
VDCF OverviewVDCF Overview
VDCF Overview
JomaSoft
 
Basic Linux Internals
Basic Linux InternalsBasic Linux Internals
Basic Linux Internals
mukul bhardwaj
 
X64 Workshop Linux Information Gathering
X64 Workshop Linux Information GatheringX64 Workshop Linux Information Gathering
X64 Workshop Linux Information Gathering
Aero Plane
 
Monky vold extension
Monky vold extensionMonky vold extension
Monky vold extension
mamahow
 
Let’s talk virtualization
Let’s talk virtualizationLet’s talk virtualization
Let’s talk virtualization
Etienne Tremblay
 
Mirroring the root_disk under solaris SVM
Mirroring the root_disk under solaris SVMMirroring the root_disk under solaris SVM
Mirroring the root_disk under solaris SVM
Kazimal Abed Mohammed
 
Bootloaders (U-Boot)
Bootloaders (U-Boot) Bootloaders (U-Boot)
Bootloaders (U-Boot)
Omkar Rane
 
The Holy Grail of Deployment
The Holy Grail of DeploymentThe Holy Grail of Deployment
The Holy Grail of Deployment
Stuart King
 
I/O, You Own: Regaining Control of Your Disk in the Presence of Bootkits
I/O, You Own: Regaining Control of Your Disk in the Presence of BootkitsI/O, You Own: Regaining Control of Your Disk in the Presence of Bootkits
I/O, You Own: Regaining Control of Your Disk in the Presence of Bootkits
CrowdStrike
 
Bootkits: Past, Present & Future - Virus Bulletin
Bootkits: Past, Present & Future - Virus BulletinBootkits: Past, Present & Future - Virus Bulletin
Bootkits: Past, Present & Future - Virus Bulletin
ESET
 
R12 d49656 gc10-apps dba 01
R12 d49656 gc10-apps dba 01R12 d49656 gc10-apps dba 01
R12 d49656 gc10-apps dba 01
zeesniper
 
WinFE: The (Almost) Perfect Triage Tool
WinFE: The (Almost) Perfect Triage ToolWinFE: The (Almost) Perfect Triage Tool
WinFE: The (Almost) Perfect Triage Tool
Brent Muir
 
dokumen.tips_aix-presentation.ppt
dokumen.tips_aix-presentation.pptdokumen.tips_aix-presentation.ppt
dokumen.tips_aix-presentation.ppt
AhmedFawzy916524
 
Logical volume manager xfs
Logical volume manager xfsLogical volume manager xfs
Logical volume manager xfs
Sarwar Javaid
 
VDCF Overview
VDCF OverviewVDCF Overview
VDCF Overview
JomaSoft
 
X64 Workshop Linux Information Gathering
X64 Workshop Linux Information GatheringX64 Workshop Linux Information Gathering
X64 Workshop Linux Information Gathering
Aero Plane
 
Ad

More from William Lee (20)

Usage Note of Apache Thrift for C++ Java PHP Languages
Usage Note of Apache Thrift for C++ Java PHP LanguagesUsage Note of Apache Thrift for C++ Java PHP Languages
Usage Note of Apache Thrift for C++ Java PHP Languages
William Lee
 
Usage Note of Qt ODBC Database Access on Linux
Usage Note of Qt ODBC Database Access on LinuxUsage Note of Qt ODBC Database Access on Linux
Usage Note of Qt ODBC Database Access on Linux
William Lee
 
Usage Note of SWIG for PHP
Usage Note of SWIG for PHPUsage Note of SWIG for PHP
Usage Note of SWIG for PHP
William Lee
 
Upgrade GCC & Install Qt 5.4 on CentOS 6.5
Upgrade GCC & Install Qt 5.4 on CentOS 6.5 Upgrade GCC & Install Qt 5.4 on CentOS 6.5
Upgrade GCC & Install Qt 5.4 on CentOS 6.5
William Lee
 
Usage Notes of The Bro 2.2 / 2.3
Usage Notes of The Bro 2.2 / 2.3Usage Notes of The Bro 2.2 / 2.3
Usage Notes of The Bro 2.2 / 2.3
William Lee
 
Viewing Android Source Files in Eclipse (Chinese)
Viewing Android Source Files in Eclipse  (Chinese)Viewing Android Source Files in Eclipse  (Chinese)
Viewing Android Source Files in Eclipse (Chinese)
William Lee
 
Usage Note of Microsoft Dependency Walker
Usage Note of Microsoft Dependency WalkerUsage Note of Microsoft Dependency Walker
Usage Note of Microsoft Dependency Walker
William Lee
 
Usage Note of PlayCap
Usage Note of PlayCapUsage Note of PlayCap
Usage Note of PlayCap
William Lee
 
Qt4 App - Sliding Window
Qt4 App - Sliding WindowQt4 App - Sliding Window
Qt4 App - Sliding Window
William Lee
 
GTK+ 2.0 App - Desktop App Chooser
GTK+ 2.0 App - Desktop App ChooserGTK+ 2.0 App - Desktop App Chooser
GTK+ 2.0 App - Desktop App Chooser
William Lee
 
GTK+ 2.0 App - Icon Chooser
GTK+ 2.0 App - Icon ChooserGTK+ 2.0 App - Icon Chooser
GTK+ 2.0 App - Icon Chooser
William Lee
 
Note of CGI and ASP
Note of CGI and ASPNote of CGI and ASP
Note of CGI and ASP
William Lee
 
Moblin2 - Window Manager(Mutter) Plugin
Moblin2 - Window Manager(Mutter) PluginMoblin2 - Window Manager(Mutter) Plugin
Moblin2 - Window Manager(Mutter) Plugin
William Lee
 
MGCP Overview
MGCP OverviewMGCP Overview
MGCP Overview
William Lee
 
Asterisk (IP-PBX) CDR Log Rotation
Asterisk (IP-PBX) CDR Log RotationAsterisk (IP-PBX) CDR Log Rotation
Asterisk (IP-PBX) CDR Log Rotation
William Lee
 
L.A.M.P Installation Note --- CentOS 6.5
L.A.M.P Installation Note --- CentOS 6.5L.A.M.P Installation Note --- CentOS 6.5
L.A.M.P Installation Note --- CentOS 6.5
William Lee
 
C Program Runs on Wrong Target Platform(CPU Architecture)
C Program Runs on Wrong Target Platform(CPU Architecture)C Program Runs on Wrong Target Platform(CPU Architecture)
C Program Runs on Wrong Target Platform(CPU Architecture)
William Lee
 
Internationalization(i18n) of Web Page
Internationalization(i18n) of Web PageInternationalization(i18n) of Web Page
Internationalization(i18n) of Web Page
William Lee
 
Notes for SQLite3 Usage
Notes for SQLite3 UsageNotes for SQLite3 Usage
Notes for SQLite3 Usage
William Lee
 
Cygwin Install How-To (Chinese)
Cygwin Install How-To (Chinese)Cygwin Install How-To (Chinese)
Cygwin Install How-To (Chinese)
William Lee
 
Usage Note of Apache Thrift for C++ Java PHP Languages
Usage Note of Apache Thrift for C++ Java PHP LanguagesUsage Note of Apache Thrift for C++ Java PHP Languages
Usage Note of Apache Thrift for C++ Java PHP Languages
William Lee
 
Usage Note of Qt ODBC Database Access on Linux
Usage Note of Qt ODBC Database Access on LinuxUsage Note of Qt ODBC Database Access on Linux
Usage Note of Qt ODBC Database Access on Linux
William Lee
 
Usage Note of SWIG for PHP
Usage Note of SWIG for PHPUsage Note of SWIG for PHP
Usage Note of SWIG for PHP
William Lee
 
Upgrade GCC & Install Qt 5.4 on CentOS 6.5
Upgrade GCC & Install Qt 5.4 on CentOS 6.5 Upgrade GCC & Install Qt 5.4 on CentOS 6.5
Upgrade GCC & Install Qt 5.4 on CentOS 6.5
William Lee
 
Usage Notes of The Bro 2.2 / 2.3
Usage Notes of The Bro 2.2 / 2.3Usage Notes of The Bro 2.2 / 2.3
Usage Notes of The Bro 2.2 / 2.3
William Lee
 
Viewing Android Source Files in Eclipse (Chinese)
Viewing Android Source Files in Eclipse  (Chinese)Viewing Android Source Files in Eclipse  (Chinese)
Viewing Android Source Files in Eclipse (Chinese)
William Lee
 
Usage Note of Microsoft Dependency Walker
Usage Note of Microsoft Dependency WalkerUsage Note of Microsoft Dependency Walker
Usage Note of Microsoft Dependency Walker
William Lee
 
Usage Note of PlayCap
Usage Note of PlayCapUsage Note of PlayCap
Usage Note of PlayCap
William Lee
 
Qt4 App - Sliding Window
Qt4 App - Sliding WindowQt4 App - Sliding Window
Qt4 App - Sliding Window
William Lee
 
GTK+ 2.0 App - Desktop App Chooser
GTK+ 2.0 App - Desktop App ChooserGTK+ 2.0 App - Desktop App Chooser
GTK+ 2.0 App - Desktop App Chooser
William Lee
 
GTK+ 2.0 App - Icon Chooser
GTK+ 2.0 App - Icon ChooserGTK+ 2.0 App - Icon Chooser
GTK+ 2.0 App - Icon Chooser
William Lee
 
Note of CGI and ASP
Note of CGI and ASPNote of CGI and ASP
Note of CGI and ASP
William Lee
 
Moblin2 - Window Manager(Mutter) Plugin
Moblin2 - Window Manager(Mutter) PluginMoblin2 - Window Manager(Mutter) Plugin
Moblin2 - Window Manager(Mutter) Plugin
William Lee
 
Asterisk (IP-PBX) CDR Log Rotation
Asterisk (IP-PBX) CDR Log RotationAsterisk (IP-PBX) CDR Log Rotation
Asterisk (IP-PBX) CDR Log Rotation
William Lee
 
L.A.M.P Installation Note --- CentOS 6.5
L.A.M.P Installation Note --- CentOS 6.5L.A.M.P Installation Note --- CentOS 6.5
L.A.M.P Installation Note --- CentOS 6.5
William Lee
 
C Program Runs on Wrong Target Platform(CPU Architecture)
C Program Runs on Wrong Target Platform(CPU Architecture)C Program Runs on Wrong Target Platform(CPU Architecture)
C Program Runs on Wrong Target Platform(CPU Architecture)
William Lee
 
Internationalization(i18n) of Web Page
Internationalization(i18n) of Web PageInternationalization(i18n) of Web Page
Internationalization(i18n) of Web Page
William Lee
 
Notes for SQLite3 Usage
Notes for SQLite3 UsageNotes for SQLite3 Usage
Notes for SQLite3 Usage
William Lee
 
Cygwin Install How-To (Chinese)
Cygwin Install How-To (Chinese)Cygwin Install How-To (Chinese)
Cygwin Install How-To (Chinese)
William Lee
 
Ad

Recently uploaded (20)

Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 

Android Storage - Vold

  • 1. Android Storage - Vold (Honeycomb 3.2) William.L [email protected] 2011-11-25
  • 2. Outline What is Vold? Components Communication Vold Init Flow Volume State Machine Example : SD Card Insert Appendix A- An issue in Google original code Appendix B- How to read Microsoft NTFS format storage? Reference
  • 3. What is Vold? Volume daemon The same as Mountd before Donut (Android 1.7) Vold 2.0 since Froyo (Android 2.2) As the role of Udev in the desktop Linux distro Lisenting Netlink socket for volume changing Uevent Ineteract with MountService (Java layer) As a slave to MountService which is the decision maker Notify volume status changing events to MountService Execute commands issued from MountService Communicates with MountService through unix domain(POSIX Local IPC) socket Folder : AndroidSrc/system/vold Main Entry main.c : main()
  • 4. Components (1/12) Vold is composed of VolumeManager NetlinkManager NetlinkHandler NetlinkEvent CommandListener Volume / DirectVolume vold.fstab file Fat fsck_msdos , newfs_msdos executables
  • 5. Components (2/12) MountService vold (local socket ) CommandListener VolumeManager Send command Notify volume events Netlink socket Notify volume events Dispatch Command Notify volume events NetlinkManager NetlinkHandler Linux Kernel Notify UEVENT Vold VolumeCollection <List> DirectVolume-USB DirectVolume- External SD Card . . . After parsing vold.fstab, add DirectVolume to VolumeCollecti on list Vold Architecture (Java layer) (C/C++ app layer)
  • 6. Components (3/12) VolumeManager VolumeManager.cpp/.h Provides corresponding command handlers called by CommandListener for ASEC/OBB/MountService commands Store volume informations retrieved from vold.fstab Notify MountService status changing of volumes
  • 7. Components (4/12) NetlinkManager NetlinkManager.cpp/.h Open the socket listening to kernel Netlink Kobject Uevent Create a NetlinkHandler instance with the opened socket and activate it to start to listen to the Netlink socket
  • 8. Components (5/12) NetlinkHandler NetlinkHandler.cpp/.h Wait for Netlink Kobject Uevent Process Uevent in NetlinkHandler::onEvent() Call proper command handlers(defined in VolumeManager) corresponding to the “action” type of uevent
  • 10. Components (7/12) CommandListener CommandListener.cpp/.h Using socket(vold) to communicate with MountService Wait for commands from MountService Dispatch received MountService commands to corresponding executor CommandListener::VolumeCmd::runCommand()
  • 11. Components (8/12) Volume / DirectVolume Volume.cpp/.h , DirectVolume.cpp/.h DirectVolume is a subclass of Volume To store volume informations retreiving from vold.fstab Volume do the actual actions(mount, unmount, etc) corresponding to the commands(doMount, doUnmount, etc) from MountService
  • 12. Components (9/12) vold.fstab AndroidSrc/device/nvidia/ventana [nVidia solution] Describe what storages will be added into system Processed by process_config() AndroidSrc/system/vold/main.cpp Example: dev_mount usbdrive /mnt/usbdrive auto /devices/platform/tegra-ehci.2/usb2 dev_mount - Means mounting devices usbdrive - Label for the USB volume /mnt/usbdrive - Where the USB volume will be mounted auto - Partition number (1 based). 'auto' for first usable partition /devices/platform/tegra-ehci.2/usb2 - The sysfs path to external USB device
  • 13. Components (10/12) Fat Fat.cpp/.h Validate if the filesystem of the new added volume is FAT Mount the new volume whose filesystem type is FAT Format specified volume’s filesystem to FAT
  • 14. Components (11/12) fsck_msdos exectutable AndroidSrc/external/fsck_msdos/main.c To validate if the filesystem in new adding volume is MS- DOS FAT 16 or 32 Called by Fat::check()
  • 15. Components (12/12) newfs_msdos exectutable AndroidSrc/system/core/toolbox/newfs_msdos.c To format a specified volume to MS-DOS FAT 32 type filesystem Called by Fat::format()
  • 16. Communication Netlink Socket Passes informations between Kernel space and User space Protocol : NETLINK_KOBJECT_UEVENT Defined in KernelSrc/include/linux/netlink.h KernelSrc/lib/kobject_uevent.c : kobject_uevent_env() Unix Domain/POSIX Local IPC Socket For the communication between Vold & MountService Created in init.rc socket vold stream 0660 root mount mount is MountService process AndroidSrc/system/core/rootdir/init.rc
  • 17. Vold Init Flow Init.rc invoke “/system/bin/vold” & create local socket “vold” vold/main() Create instance of VolumeManager, CommandListener, NetlinkManager separately Set CommandLisener instance to be the broadcaster of VolumeManager/NetlinkManager to notify volume changing event to MountService through local socket Activate the VolumeManager instance to run Create the folder “/dev/block/vold” for device node of new added volume Acitvate the NetlinkManager instance to listen to netlink uevent Call coldboot() to monitor if there has any volume(insternal/external storage) has existed before booting start Activate CommandLinstener instance to to listen “vold” local socket Loop forever Parse vold.fstab and store possible adding storages’ Information using DirectVolume
  • 18. Volume State Machine (1/4) 10 volume states (enum-value) Init (-1) NoMedia/Removed (0) Idle/Unmounted (1) Pending (2) Waiting for the report of the number of volume partition Chencking (3) Checking filesystem type Mounted (4) Unmounting (5) Formatting (6) Shared(Unmounted) (7) ShareMnt (8)
  • 19. Volume State Machine (2/4) Init NoMediaInitial System initialize done Attach storage to the device NoMedia Idle(Unmounted) Pending CheckingMounted Initial
  • 20. Volume State Machine (3/4) NoMedia Idle(Unmounted) Initial Deattach storage from the device Mounted Unmounting Formatting Idle(Unmounted) Initial Format the storage Mounted Unmounting (1) (2) (3) (4)(5) CheckingMounted (6)
  • 21. Volume State Machine (4/4) Idle(Unmounted) Initial Storage(SD card) Unsharing SharedMnt Shared-Unmounted CheckingMounted Shared-Unmounted Initial Storage(SD card) Sharing Mounted Unmounting Idle(Unmounted) SharedMnt From Honeycomb with MTP, these two cases will not happen! When access USB mass-storage through MTP, it need not to unmount SD card.
  • 22. Example: SD Card Insert (1/3) [Honeycomb MR2] Volume information for SD card in vold.fstab : dev_mount sdcard /sdcard2 auto /devices/platform/sdhci-tegra.2/mmc_host/mmc1 When Vold init, a DirectVolume instance will be created to store SD card volume informations The stored informations are: Label : sdcard MountPoint : /sdcard2 DevPath(sysfs) : /devices/platform/sdhci-tegra.2/mmc_host/mmc1
  • 23. Example: SD Card Insert (2/3) Kernel detect a mmc medium (sd card) insert Kernel send Netlink Kobject Uevent : ACTION : add DEVPATH : /devices/platform/sdhci- tegra.2/mmc_host/mmc1/mmc1:e624/block/mmcblk1 DEVTYPE : disk SUBSYS : block ACTION : add DEVPATH : /devices/platform/sdhci- tegra.2/mmc_host/mmc1/mmc1:e624/block/mmcblk1/mmcblk1p1 DEVTYPE : partition SUBSYS : block NetlinkHanlder detect Uevent with “block” subsys type, then call VolumeManager::handleBlockEvent() In VolumeManager::handleBlockEvent(), it iterate all stored DirectVolume instances and call their handleBolckEvent() method In DirectVolume::handleBolckEvent(), it compares passed in devPath with the one retrieved from vold.fstab. In this example, if it found the string “/devices/platform/sdhci-tegra.2/mmc_host/mmc1” in devPath, it will create a device node under /dev/block/vold/MajrID:MinrID for the new added volume and then send notification, “ResponseCode::VolumeDiskInserted”, to MountService with Label & MountPoint (from vold.fstab) as parameters Continued to the next slide Insert Android Device
  • 24. Example: SD Card Insert (3/3) On MountService receiving notification from Vold, “ResponseCode::VolumeDiskInserted”, it send “volume mount” command back to Vold with “MountPoint” as the parameter named Label Continued from the previous slide In Vold, CommandListener receive ”volume mount” command, it execute VolumeManager::mountVolume() with parameter, Label, from MountService In VolumeManager::mountVolume(), it compare parameter, Label, with “Label” or “MountPoint” informations retrieved from vold.fstab. If it match one of two information, it will call Volume::mountVol() to subsequtial operations for mounting In Volume::mountVol(), it does FAT filesystem checking operation by calling Fat::check(). If the new added volume is FAT filesystem, it will try to mount new volume with VFAT type using Fat::doMount() and Volume::doMoveMount() The new added volume has been mounted, and the user can use this new volume/storage (^o^)
  • 25. Appendix A- An issue in Google original code: video/image files in external storage will be deleted when un-mounting external storage 2011-10-14
  • 26. Problem Description After user pressing “Unmount” button in Settings>Storage menu to unmount an external storage, all video/image files on that external storage will be deleted immediately without any warning message This problem will shock users!!!
  • 27. Root Cause (1/2) After user pressing “Unmount” button in Settings>Storage menu, the system will send ACTION_MEDIA_EJECT and ACTION_MEDIA_UNMOUNTED Intents (events) in sequence When the member "mUnmountReceiver“ (BroadcastReceiver) of the class MediaProvider (MediaProvider.java) receiving the ACTION_MEDIA_EJECT Intent, it will call delete() of SQLiteDatabase class to prune/remove invalid entries in thumbnail table representing video/image files on the unmounted external storage
  • 28. Root Cause (2/2) delete() of SQLiteDatabase class will delete the (video/image) files corresponding to invalid entries in the thumbnail table eventually Please refer to the Google Android issue http://code.google.com/p/android/issues/detail?id=3692 Search the keyword “delete()”
  • 29. Solution To change the Intent type the member "mUnmountReceiver“ monitors to ACTION_MEDIA_UNMOUNTED and ACTION_MEDIA_BAD_REMOVAL So MediaProvider will prune/remove invalid entries in thumbnail table only when it receives Unmounted or Bad-Removal events e.g. the external storage has been detached from the file system actually!
  • 30. Appendix B- How to read Microsoft NTFS format storage? 2011-12-27
  • 31. Problem Description Originally, Google Android only supports Microsoft FAT format storage Android Vold (Volume.cpp) checks the format of a new inserted storage when trying to do mounting. If it is not FAT format, it will skip this storage and check the next found storage Storages in NTFS format are so common, so it is better for an Android device to be capable of reading NTFS format storage
  • 32. Solution (1/2) TuxEra’s NTFS-3G is a stable, full-featured solution to address the requirement of reading NTFS format storage This is a file system driver for NTFS format After installing this into Linux system, it will add a file system type option “ntfs” of “mount” system command and “mount()” API NTFS-3G official site http://www.tuxera.com/community/ntfs-3g-download/
  • 33. Solution (2/2) In the method mountVol() of Volume class (Volume.cpp) “if ( Fat::check(devicePath) )” block will enter when the checking status is non-zero, e.g. the current storage is NOT FAT format It could add codes to calling mount() with “ntfs” option in this block to try to mount current storage and to see if it is NTFS format through the return value of mount() Also, it needs to check the storage is in Read-Only mode
  • 34. Reference Kobject Uevent socket – Chapter 17, Linux 核 心開發指南 (Linux Kernel Development, 2/e) Robert Love 著, 沈中庸、沈彥男 譯, 維科出版社 Unix Domain Socket – Chapter 15, Unix Network Programming, Volume 1: The Sockets Networking API, 3/e W. Richard Stevens Netlink in Kernel – http://www.linuxjournal.com/article/7356