android--4.2 Vold Mount Management _volumemanager (iii)

Source: Internet
Author: User

In android--4.2 Vold Mount Management _ Main building main (a) in the analysis of the general framework, here to analyze the core volumemanager, re-fill the structure of the framework diagram as follows:


Can see Volumemanager is the entire Android disk Mount Vold mechanism of the core dispatch, up and down connected to the broker!

I have analyzed the sequential structure of the Vold main code, the previous android--4.2 Vold Mount Management _commandlistener (ii) analyzes the function of Commandlistener interacting with the framework layer. .

Here we analyze the roles and functions of volumemanager in the whole system!



Writing is not easy, reproduced please specify the source: http://blog.csdn.net/jscese/article/details/38581521


One: Volumemanager Initial build:

Still in the/system/vold/main.cpp:

    /* Create our Singleton managers * * * *    if (! ( VM = Volumemanager::instance ()) {        Sloge ("Unable to create Volumemanager");        Exit (1);    };    ...    if (Vm->start ()) {        Sloge ("Unable to start Volumemanager (%s)", Strerror (errno));        Exit (1);    }    if (Process_config (VM)) {        Sloge ("Error reading configuration (%s) ... continuing anyways", strerror (errno));    }

First look at the constructor for the VolumeManager.cpp of the sibling directory:

Volumemanager::volumemanager () {    mDebug = false;    Mvolumes = new Volumecollection ();//volume of a container    mactivecontainers = new Asecidcollection ();//Active container, Mount/unmount ASEC Obb record    Mbroadcaster = null;//points to SocketListener for sending mount event    mumssharingcount = 0;    Msaveddirtyratio =-1;    Set dirty ratio to 0 if UMS is active    mumsdirtyratio = 0;    mvolmanagerdisabled = 0;}


The most important of these is the Mvolumes container:

typedef android::list<volume *> Volumecollection;
is a collection of/system/vold/volume.cpp instances!

Vm->start () No action!


Two: Process_config

This function is used to parse the specified configuration file, construct the Directvolume according to the content, and then save the parent class into the Volumemanager container for Volumemanager management of the Mount event.

static int process_config (Volumemanager *vm) {FILE *fp;    int n = 0;    Char line[255]; if (! (    fp = fopen ("/etc/vold.fstab", "R")) {//Open configuration file/etc/vold.fstab return-1; }    while (fgets, sizeof (line), FP)) {        Const char * Delim = "\ t";//\t preceded by a space, with a space or a horizontal tab (tab), to split the read-out line if ( Type = Strtok_r (line, Delim, &save_ptr))) {//split the read line string, one at a time to get the parameters that are specified, using the thread-safe function Strtok_r sloge ("Error p            Arsing type ");        Goto Out_syntax; } if (! (            Label = Strtok_r (NULL, Delim, &save_ptr))) {Sloge ("Error parsing label");        Goto Out_syntax; } if (! (            Mount_point = Strtok_r (NULL, Delim, &save_ptr)) {Sloge ("Error parsing mount point");        Goto Out_syntax;            } if (!strcmp (type, "Dev_mount")) {Directvolume *DV = NULL;            Char *part; if (! (   Part = Strtok_r (NULL, Delim, &save_ptr))) {             Sloge ("Error parsing Partition");            Goto Out_syntax; } if (strcmp (part, "Auto") && atoi (part) = = 0) {sloge ("Partition must either be ' auto '                or 1 based index instead of '%s ', part);            Goto Out_syntax; } if (!STRCMP (part, "Auto")) {//Build Directvolume instance based on the value resolved above DV = new Directvolume (VM, label, MOU            Nt_point,-1);            } else {dv = new Directvolume (VM, label, Mount_point, Atoi (part)); } while ((Sysfs_path = Strtok_r (NULL, Delim, &save_ptr)) ... vm->addvolume (DV);//Add into Volumeman Ager Container ...   }}

You can see the Addvolume function in Volumemanager:

int Volumemanager::addvolume (Volume *v) {    mvolumes->push_back (v);    return 0;}

The inheritance relationship directvolume--> Volume, here casts the
。


Three: Vold.fstab

This configuration file is compiled in the android--4.2 Vold Mount Management _ Main building main (a) in the detailed analysis, first look at this configuration file comments:

######################### Regular device mount#### format:dev_mount <label> <mount_point> <part> <sysfs_path1...> # # Label        -label for the volume## mount_point  -Where The volume would be mounted## part
   
    -Partition # (1 based), or ' auto ' for first usable partition.## <sysfs_path>-List of SYSFS paths to source Devic es######################
   

Each row corresponds to the five parameters above, and each parameter is separated by a space or tab, and Google has an example:

Dev_mount Sdcard/mnt/sdcard AUTO/DEVICES/PLATFORM/GOLDFISH_MMC.0/DEVICES/PLATFORM/MSM_SDCC.2/MMC_HOST/MMC1

This is the configuration of the Mount SDcard, the previous several respectively corresponding to the above comments, the last Sysfs_path is to mount the source device path, this according to the respective platform modification (my is/dev/block/platform/*), the first one will not be the second one



Volumemanager function Implementation functions (mountvolume,handleblockevent, etc.), are called by other function modules, such as the main frame diagram above,

Parsing is not done here, in the back of the Directvolume/volume mount, as well as in the Netlinkevent event processing will be analyzed.






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.