diff options
Diffstat (limited to 'vold')
-rw-r--r-- | vold/blkdev.c | 8 | ||||
-rwxr-xr-x | vold/format.c | 22 | ||||
-rw-r--r-- | vold/media.h | 6 | ||||
-rw-r--r-- | vold/mmc.c | 2 | ||||
-rw-r--r-- | vold/uevent.c | 5 | ||||
-rw-r--r-- | vold/volmgr.c | 22 | ||||
-rw-r--r-- | vold/volmgr_vfat.c | 30 |
7 files changed, 70 insertions, 25 deletions
diff --git a/vold/blkdev.c b/vold/blkdev.c index 2c5681a..33fed1b 100644 --- a/vold/blkdev.c +++ b/vold/blkdev.c @@ -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 < NDOSPART) { dos_partition_dec(block + DOSPARTOFF + part_no * sizeof(struct dos_partition), &part); diff --git a/vold/format.c b/vold/format.c index cd40197..c67b358 100755 --- a/vold/format.c +++ b/vold/format.c @@ -33,21 +33,23 @@ int format_partition(blkdev_t *part, char *type) { char *devpath; int rc = -EINVAL; - + devpath = blkdev_get_devpath(part); if (!strcmp(type, FORMAT_TYPE_FAT32)) { - char *args[9]; + char *args[7]; args[0] = MKDOSFS_PATH; args[1] = "-F"; - args[2] = "32"; - args[3] = "-c"; - args[4] = "16"; - args[5] = "-O"; - args[6] = "android"; - args[7] = devpath; - args[8] = NULL; - rc = logwrap(8, args, 1); + if ((part->nr_sec * 512) <= (unsigned int) (1024*1024*1024*2)) + args[2] = "16"; + else + args[2] = "32"; + + args[3] = "-O"; + args[4] = "android"; + args[5] = devpath; + args[6] = NULL; + rc = logwrap(7, args, 1); } else { char *args[7]; args[0] = MKE2FS_PATH; diff --git a/vold/media.h b/vold/media.h index 567ce04..6fd8b84 100644 --- a/vold/media.h +++ b/vold/media.h @@ -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; @@ -258,7 +258,7 @@ static int mmc_bootstrap_mmcblk_partition(char *devpath) char filename[255]; char *uevent_buffer; ssize_t sz; - char *uevent_params[4]; + char *uevent_params[5]; char tmp[255]; FILE *fp; char line[255]; diff --git a/vold/uevent.c b/vold/uevent.c index dffe817..dc15d80 100644 --- a/vold/uevent.c +++ b/vold/uevent.c @@ -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, diff --git a/vold/volmgr.c b/vold/volmgr.c index 3c34a9c..deb680e 100644 --- a/vold/volmgr.c +++ b/vold/volmgr.c @@ -460,7 +460,7 @@ int volmgr_enable_ums(boolean enable) pthread_mutex_lock(&v->lock); if (v->state == volstate_mounted) volmgr_send_eject_request(v); - else if (v->state == volstate_ums) { + else if (v->state == volstate_ums || v->state == volstate_nomedia) { pthread_mutex_unlock(&v->lock); goto next_vol; } @@ -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); diff --git a/vold/volmgr_vfat.c b/vold/volmgr_vfat.c index 22e2dcf..4c695e4 100644 --- a/vold/volmgr_vfat.c +++ b/vold/volmgr_vfat.c @@ -18,6 +18,7 @@ #include <errno.h> #include <sys/mount.h> +#include <cutils/properties.h> #include "vold.h" #include "volmgr.h" @@ -108,14 +109,29 @@ int vfat_mount(blkdev_t *dev, volume_t *vol, boolean safe_mode) } /* - * The mount masks restrict access so that: - * 1. The 'system' user cannot access the SD card at all - - * (protects system_server from grabbing file references) - * 2. Group users can RWX - * 3. Others can only RX + * Note: This is a temporary hack. If the sampling profiler is enabled, + * we make the SD card world-writable so any process can write snapshots. + * + * TODO: Remove this code once we have a drop box in system_server. */ - rc = mount(devpath, vol->mount_point, "vfat", flags, - "utf8,uid=1000,gid=1015,fmask=702,dmask=702,shortname=mixed"); + char value[PROPERTY_VALUE_MAX]; + property_get("persist.sampling_profiler", value, ""); + if (value[0] == '1') { + LOGW("The SD card is world-writable because the" + " 'persist.sampling_profiler' system property is set to '1'."); + rc = mount(devpath, vol->mount_point, "vfat", flags, + "utf8,uid=1000,gid=1015,fmask=000,dmask=000,shortname=mixed"); + } else { + /* + * The mount masks restrict access so that: + * 1. The 'system' user cannot access the SD card at all - + * (protects system_server from grabbing file references) + * 2. Group users can RWX + * 3. Others can only RX + */ + rc = mount(devpath, vol->mount_point, "vfat", flags, + "utf8,uid=1000,gid=1015,fmask=702,dmask=702,shortname=mixed"); + } if (rc && errno == EROFS) { LOGE("vfat_mount(%d:%d, %s): Read only filesystem - retrying mount RO", |