+static void get_internal_storage_number_from_device_mapper(char *root_name)
+{
+ int major, minor;
+ char dev_name[PATH_MAX];
+ struct dm_task *dmt;
+ struct dm_info info;
+ struct dm_deps *deps;
+
+ _D("Searching device mapper root device: %s", DEVICE_MAPPER_ROOT_NODE_PATH);
+
+ if (!root_name)
+ return;
+
+ dmt = dm_task_create(DM_DEVICE_DEPS);
+ if (!dmt)
+ return;
+
+ if (!dm_task_set_name(dmt, root_name))
+ goto out;
+
+ if (!dm_task_run(dmt))
+ goto out;
+
+ if (!dm_task_get_info(dmt, &info) || !info.exists)
+ goto out;
+
+ deps = dm_task_get_deps(dmt);
+ if (!deps || deps->count != 1)
+ goto out;
+
+ major = (int) MAJOR(deps->device[0]);
+ minor = (int) MINOR(deps->device[0]);
+
+ if (!dm_device_get_name(major, minor, 1, dev_name, PATH_MAX))
+ goto out;
+
+ /* Ex: dev_name is mmcblk0p2 */
+ _D("Found actual device associated with root device of device mapper: %s", dev_name);
+
+ if (!is_emulator()) {
+ if (!fnmatch(MMC_PARTITION_PATH, dev_name, 0))
+ sscanf(dev_name, "mmcblk%d", &dev_internal);
+ else if (!fnmatch(SCSI_PARTITION_PATH, dev_name, 0))
+ sscanf(dev_name, "sd%c", &dev_internal_scsi);
+ } else
+ if (!fnmatch(MMC_LINK_PARTITION_PATH, dev_name, 0))
+ sscanf(dev_name, "vd%c", &dev_internal_emul);
+
+out:
+ dm_task_destroy(dmt);
+}
+