diff options
| author | Mike Lockwood <lockwood@android.com> | 2010-09-17 18:50:51 -0400 |
|---|---|---|
| committer | Mike Lockwood <lockwood@android.com> | 2010-09-17 18:50:51 -0400 |
| commit | 2dfe297ec47559dbe2297a72bea71cf515c03797 (patch) | |
| tree | 6e450b33108c9e9937a93603ca3656542b975a74 | |
| parent | a3e06084564c86ff618c40f185f3676b8b629b94 (diff) | |
| download | android_system_vold-2dfe297ec47559dbe2297a72bea71cf515c03797.tar.gz android_system_vold-2dfe297ec47559dbe2297a72bea71cf515c03797.tar.bz2 android_system_vold-2dfe297ec47559dbe2297a72bea71cf515c03797.zip | |
Fixes for devices with internal FAT file system:
Only share a single partition via UMS if a specific partition
is specified in vold.fstab (rather than "auto")
Do not fail to reformat if MBR cannot be found.
Change-Id: I544ca2ee325c308af656ab9f4732c788a964c156
Signed-off-by: Mike Lockwood <lockwood@android.com>
| -rw-r--r-- | DirectVolume.cpp | 8 | ||||
| -rw-r--r-- | DirectVolume.h | 1 | ||||
| -rw-r--r-- | Volume.cpp | 8 | ||||
| -rw-r--r-- | Volume.h | 1 | ||||
| -rw-r--r-- | VolumeManager.cpp | 9 |
5 files changed, 18 insertions, 9 deletions
diff --git a/DirectVolume.cpp b/DirectVolume.cpp index 1f9f084..ce5b892 100644 --- a/DirectVolume.cpp +++ b/DirectVolume.cpp @@ -65,6 +65,14 @@ dev_t DirectVolume::getDiskDevice() { return MKDEV(mDiskMajor, mDiskMinor); } +dev_t DirectVolume::getShareDevice() { + if (mPartIdx != -1) { + return MKDEV(mDiskMajor, mPartIdx); + } else { + return MKDEV(mDiskMajor, mDiskMinor); + } +} + void DirectVolume::handleVolumeShared() { setState(Volume::State_Shared); } diff --git a/DirectVolume.h b/DirectVolume.h index 2a78236..bf50891 100644 --- a/DirectVolume.h +++ b/DirectVolume.h @@ -45,6 +45,7 @@ public: int handleBlockEvent(NetlinkEvent *evt); dev_t getDiskDevice(); + dev_t getShareDevice(); void handleVolumeShared(); void handleVolumeUnshared(); @@ -144,6 +144,10 @@ dev_t Volume::getDiskDevice() { return MKDEV(0, 0); }; +dev_t Volume::getShareDevice() { + return getDiskDevice(); +} + void Volume::handleVolumeShared() { } @@ -220,7 +224,9 @@ int Volume::formatVol() { if (initializeMbr(devicePath)) { SLOGE("Failed to initialize MBR (%s)", strerror(errno)); - goto err; +// goto err; +// don't treat this as a fatal error +// lets continue on and format the partition } sprintf(devicePath, "/dev/block/vold/%d:%d", @@ -71,6 +71,7 @@ public: virtual int handleBlockEvent(NetlinkEvent *evt); virtual dev_t getDiskDevice(); + virtual dev_t getShareDevice(); virtual void handleVolumeShared(); virtual void handleVolumeUnshared(); diff --git a/VolumeManager.cpp b/VolumeManager.cpp index 231b308..b53e7b1 100644 --- a/VolumeManager.cpp +++ b/VolumeManager.cpp @@ -1036,7 +1036,7 @@ int VolumeManager::shareVolume(const char *label, const char *method) { return -1; } - dev_t d = v->getDiskDevice(); + dev_t d = v->getShareDevice(); if ((MAJOR(d) == 0) && (MINOR(d) == 0)) { // This volume does not support raw disk access errno = EINVAL; @@ -1084,14 +1084,7 @@ int VolumeManager::unshareVolume(const char *label, const char *method) { return -1; } - dev_t d = v->getDiskDevice(); - int fd; - char nodepath[255]; - snprintf(nodepath, - sizeof(nodepath), "/dev/block/vold/%d:%d", - MAJOR(d), MINOR(d)); - if ((fd = open("/sys/devices/platform/usb_mass_storage/lun0/file", O_WRONLY)) < 0) { SLOGE("Unable to open ums lunfile (%s)", strerror(errno)); return -1; |
