Don't abort the encryption process if an internal volume is present but unmounted.

It is not a failure if the SD card is not mounted.

Change-Id: If954f77c55ac124b9b7b39c89ffbafb4e5ea9e98
This commit is contained in:
Ken Sumrall 2011-06-14 14:01:55 -07:00
parent 29d8da8cef
commit 319b1043bb
4 changed files with 8 additions and 4 deletions

View file

@ -589,7 +589,7 @@ int Volume::unmountVol(bool force) {
if (getState() != Volume::State_Mounted) {
SLOGE("Volume %s unmount request when not mounted", getLabel());
errno = EINVAL;
return -1;
return UNMOUNT_NOT_MOUNTED_ERR;
}
setState(Volume::State_Unmounting);

View file

@ -1192,7 +1192,7 @@ int VolumeManager::unmountVolume(const char *label, bool force) {
SLOGW("Attempt to unmount volume which isn't mounted (%d)\n",
v->getState());
errno = EBUSY;
return -1;
return UNMOUNT_NOT_MOUNTED_ERR;
}
cleanupAsec(v, force);

View file

@ -137,6 +137,7 @@ private:
extern "C" {
#endif /* __cplusplus */
#define UNMOUNT_NOT_MOUNTED_ERR -2
int vold_unmountVol(const char *label);
int vold_getNumDirectVolumes(void);
int vold_getDirectVolumeList(struct volume_info *v);

View file

@ -1062,7 +1062,7 @@ int cryptfs_enable(char *howarg, char *passwd)
unsigned long mnt_flags, nr_sec;
unsigned char master_key[KEY_LEN_BYTES], decrypted_master_key[KEY_LEN_BYTES];
unsigned char salt[SALT_LEN];
int rc=-1, fd, i;
int rc=-1, fd, i, ret;
struct crypt_mnt_ftr crypt_ftr, sd_crypt_ftr;;
char tmpfs_options[PROPERTY_VALUE_MAX];
char encrypted_state[PROPERTY_VALUE_MAX];
@ -1141,7 +1141,10 @@ int cryptfs_enable(char *howarg, char *passwd)
}
close(fd);
if (vold_unmountVol(vol_list[i].label)) {
ret=vold_unmountVol(vol_list[i].label);
if ((ret < 0) && (ret != UNMOUNT_NOT_MOUNTED_ERR)) {
/* -2 is returned when the device exists but is not currently mounted.
* ignore the error and continue. */
SLOGE("Failed to unmount volume %s\n", vol_list[i].label);
goto error_unencrypted;
}