Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3afe20b0 authored by Ethan.Du's avatar Ethan.Du Committed by San Mehat
Browse files

vold: Add support for /dev/block/mmcblk1



Signed-off-by: default avatarEthan.Du <a7233c@motorola.com>
Signed-off-by: default avatarSan Mehat <san@google.com>
parent ff7d5835
Loading
Loading
Loading
Loading
+7 −1
Original line number Original line Diff line number Diff line
@@ -32,6 +32,7 @@
#include "vold.h"
#include "vold.h"
#include "blkdev.h"
#include "blkdev.h"
#include "diskmbr.h"
#include "diskmbr.h"
#include "media.h"


#define DEBUG_BLKDEV 0
#define DEBUG_BLKDEV 0


@@ -132,7 +133,12 @@ int blkdev_refresh(blkdev_t *blk)
        }
        }
    } else if (blk->type == blkdev_partition) {
    } else if (blk->type == blkdev_partition) {
        struct dos_partition part;
        struct dos_partition part;
        int part_no = blk->minor -1;
	int part_no;

        if (blk->media->media_type == media_mmc)
            part_no = blk->minor % MMC_PARTS_PER_CARD -1;
        else
            part_no = blk->minor -1;


        if (part_no < 4) {
        if (part_no < 4) {
            dos_partition_dec(block + DOSPARTOFF + part_no * sizeof(struct dos_partition), &part);
            dos_partition_dec(block + DOSPARTOFF + part_no * sizeof(struct dos_partition), &part);
+6 −0
Original line number Original line Diff line number Diff line
@@ -28,6 +28,12 @@ typedef enum media_type {
    media_devmapper,
    media_devmapper,
} media_type_t;
} media_type_t;


/*
 * max 8 partitions per card
 */
#define MMC_PARTS_PER_CARD (1<<3)
#define ALIGN_MMC_MINOR(min) (min / MMC_PARTS_PER_CARD * MMC_PARTS_PER_CARD)

typedef struct media {
typedef struct media {
    char           *devpath;
    char           *devpath;
    char           *name;
    char           *name;
+4 −1
Original line number Original line Diff line number Diff line
@@ -325,6 +325,9 @@ static int handle_block_event(struct uevent *event)
         * If there isn't a disk already its because *we*
         * If there isn't a disk already its because *we*
         * are the disk
         * are the disk
         */
         */
        if (media->media_type == media_mmc)
            disk = blkdev_lookup_by_devno(maj, ALIGN_MMC_MINOR(min));
        else
            disk = blkdev_lookup_by_devno(maj, 0);
            disk = blkdev_lookup_by_devno(maj, 0);


        if (!(blkdev = blkdev_create(disk,
        if (!(blkdev = blkdev_create(disk,
+16 −4
Original line number Original line Diff line number Diff line
@@ -536,8 +536,15 @@ static int _volmgr_consider_disk_and_vol(volume_t *vol, blkdev_t *dev)
         * Since we only support creating 1 partition (right now),
         * Since we only support creating 1 partition (right now),
         * we can just lookup the target by devno
         * we can just lookup the target by devno
         */
         */
        blkdev_t *part = blkdev_lookup_by_devno(dev->major, 1);
        blkdev_t *part;
        if (vol->media_type == media_mmc)
            part = blkdev_lookup_by_devno(dev->major, ALIGN_MMC_MINOR(dev->minor) + 1);
        else
            part = blkdev_lookup_by_devno(dev->major, 1);
        if (!part) {
        if (!part) {
            if (vol->media_type == media_mmc)
                part = blkdev_lookup_by_devno(dev->major, ALIGN_MMC_MINOR(dev->minor));
            else
                part = blkdev_lookup_by_devno(dev->major, 0);
                part = blkdev_lookup_by_devno(dev->major, 0);
            if (!part) {
            if (!part) {
                LOGE("Unable to find device to format");
                LOGE("Unable to find device to format");
@@ -573,9 +580,14 @@ static int _volmgr_consider_disk_and_vol(volume_t *vol, blkdev_t *dev)
        rc = -ENODEV;
        rc = -ENODEV;
        int i;
        int i;
        for (i = 0; i < dev->nr_parts; i++) {
        for (i = 0; i < dev->nr_parts; i++) {
            blkdev_t *part = blkdev_lookup_by_devno(dev->major, (i+1));
            blkdev_t *part;
            if (vol->media_type == media_mmc)
                part = blkdev_lookup_by_devno(dev->major, ALIGN_MMC_MINOR(dev->minor) + (i+1));
            else
                part = blkdev_lookup_by_devno(dev->major, (i+1));
            if (!part) {
            if (!part) {
                LOGE("Error - unable to lookup partition for blkdev %d:%d", dev->major, (i+1));
                LOGE("Error - unable to lookup partition for blkdev %d:%d",
                    dev->major, dev->minor);
                continue;
                continue;
            }
            }
            rc = _volmgr_start(vol, part);
            rc = _volmgr_start(vol, part);