Android vold 2.0 source code (1)

Source: Internet
Author: User

From android2.2 (froyo), Android has changed vold code.C Language, Changed to C ++, and fully inherits the framework, netlinklistener, and other general classes. Although the structure of the submitted vold is large, it can be inherited and scalable, but it also increasesCodeComplexity.

 

This article is a good introduction to vold Analysis in Android.

 

But this articleArticleMore focused on the structure, lack of practicality, some elegance, and lack of simplicity

 

This article first introduces the main functions of each file and class, and then introduces the vold operation process in detail, hoping to help. If you have any questions, you can leave a message to ask questions.

 

1. Main functions of various files and classes:

Main. cpp

: You can see the main () function. One important point is that vold has changed to a new configuration file. Changed to/etc/vold. fstab. Your vold is not working properly. First, check whether the configuration has been changed.

 

Volume. h/CPP, Volume

Class: a very important class, but there is no direct instance, provides the main operation functions of the SD card, including Mount, unmout, format, another important structure Android :: list <volume *> volumecollection; explained in the next section

 

Directvolume. h/CPP, directvolume

Class, inherited from volume, is definitely the most important class in Vold, in Main. in the CPP file, when the vold (in the main function) is initialized, A directvolume instance is created by calling process_config to parse each row of information in the config file, and the instance is stored in the volumecollection, directvolume mainly implements four virtual functions in the middle of volume, handleblockevent (handling events from various blocks), getdiskdevice (Returning Device numbers), handlevolumeshared, and handlevolumeunshared (changing the status ). Handleblockevent parses the event information and calls the corresponding processing details: handledisk and handlepartition ***.

 

Volumemanager. h/CPP, volumemanager

Class: volume management function. The main class member mvolumes stores the directvolume pointer. It is mainly responsible for calling various implementation functions of volume and directvolume, and is only an encapsulated class. Basically, handleblockevent and handleswitchevent are used to process different netlinkevents received. The other is to find the corresponding volume through the const char * label, and then call the implementation function of this volume. Single class.

 

Fat. h/CPP, fat class

SD adopts a FAT file system based on its compatibility with common PCs. vold adopts a vfat file system compatible with fat16 and FAT32. Fat implements check, mount, format: Check, call fsck_msdos_path (/system/bin/fsck_msdos) Check SD information; mount, mainly set some mount parameters; format, call mkdosfs_path (/system/bin/newfs_msdos) and format SD to vfat file mode. All three functions in the fat class are called in functions of the volume class.

 

Voldcommand. h/CPP, voldcommand class

: Inherited from frameworkcommand, without specific implementation

Commandlistener. h/CPP, commandlistener class:

Inherited from frameworklistener, implements a function similar to the socket listening interface. Is the upper-layer, or framework interface in vold. It mainly implements dumpcmd, volumecmd, sharecmd, aseccmd, storagecmd, xwarpcmd, and six internal classes inherited from voldcommand, the commandlistener class registers the above internal class as command in the constructor. Each internal class mainly implements the runcommand function to process the specific processing method after receiving data packets.

1. dumpcmd. You can dump the information of the loop, devmapper, and file system that can be mounted.

2. volumecmd handles various SD operations. Generally, it calls various volumemanager functions to implement mount, unmount, share, unshare, format, and other information.

3. sharecmd: Call the volume available function of volumemanager to implement share.

4. storagecmd: some operations related to switching to the storage mode, mainly calling some operations of the Process class.

5, aseccmd, ASEC related

6, xwarpcmd, xwarp related

 

Netlinkhandler. h/CPP, netlinkhandler class
It inherits from netlinklistener and implements the functions of starting, ending, and information processing.

Netlinkmanager. h/CPP, netlinkmanager class
, Same as above. It is created in the main function. The function is the same as above. In fact, it is only an encapsulation of the upper class.

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.