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 "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);
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -325,7 +325,10 @@ 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
|
||||||
*/
|
*/
|
||||||
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,
|
if (!(blkdev = blkdev_create(disk,
|
||||||
event->path,
|
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),
|
* 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) {
|
||||||
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) {
|
if (!part) {
|
||||||
LOGE("Unable to find device to format");
|
LOGE("Unable to find device to format");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue