vold: Add support for /dev/block/mmcblk1
Signed-off-by: Ethan.Du <a7233c@motorola.com> Signed-off-by: San Mehat <san@google.com>
This commit is contained in:
parent
ff7d5835d9
commit
3afe20b0be
4 changed files with 33 additions and 6 deletions
|
@ -32,6 +32,7 @@
|
|||
#include "vold.h"
|
||||
#include "blkdev.h"
|
||||
#include "diskmbr.h"
|
||||
#include "media.h"
|
||||
|
||||
#define DEBUG_BLKDEV 0
|
||||
|
||||
|
@ -132,7 +133,12 @@ int blkdev_refresh(blkdev_t *blk)
|
|||
}
|
||||
} else if (blk->type == blkdev_partition) {
|
||||
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) {
|
||||
dos_partition_dec(block + DOSPARTOFF + part_no * sizeof(struct dos_partition), &part);
|
||||
|
|
|
@ -28,6 +28,12 @@ typedef enum media_type {
|
|||
media_devmapper,
|
||||
} 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 {
|
||||
char *devpath;
|
||||
char *name;
|
||||
|
|
|
@ -325,7 +325,10 @@ static int handle_block_event(struct uevent *event)
|
|||
* If there isn't a disk already its because *we*
|
||||
* are the disk
|
||||
*/
|
||||
disk = blkdev_lookup_by_devno(maj, 0);
|
||||
if (media->media_type == media_mmc)
|
||||
disk = blkdev_lookup_by_devno(maj, ALIGN_MMC_MINOR(min));
|
||||
else
|
||||
disk = blkdev_lookup_by_devno(maj, 0);
|
||||
|
||||
if (!(blkdev = blkdev_create(disk,
|
||||
event->path,
|
||||
|
|
|
@ -536,9 +536,16 @@ static int _volmgr_consider_disk_and_vol(volume_t *vol, blkdev_t *dev)
|
|||
* Since we only support creating 1 partition (right now),
|
||||
* 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) {
|
||||
part = blkdev_lookup_by_devno(dev->major, 0);
|
||||
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);
|
||||
if (!part) {
|
||||
LOGE("Unable to find device to format");
|
||||
return -ENODEV;
|
||||
|
@ -573,9 +580,14 @@ static int _volmgr_consider_disk_and_vol(volume_t *vol, blkdev_t *dev)
|
|||
rc = -ENODEV;
|
||||
int 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) {
|
||||
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;
|
||||
}
|
||||
rc = _volmgr_start(vol, part);
|
||||
|
|
Loading…
Reference in a new issue