@ -266,6 +266,7 @@ void DirectVolume::handlePartitionRemoved(const char *devpath, NetlinkEvent *evt
int major = atoi ( evt - > findParam ( " MAJOR " ) ) ;
int major = atoi ( evt - > findParam ( " MAJOR " ) ) ;
int minor = atoi ( evt - > findParam ( " MINOR " ) ) ;
int minor = atoi ( evt - > findParam ( " MINOR " ) ) ;
char msg [ 255 ] ;
char msg [ 255 ] ;
int state ;
SLOGD ( " Volume %s %s partition %d:%d removed \n " , getLabel ( ) , getMountpoint ( ) , major , minor ) ;
SLOGD ( " Volume %s %s partition %d:%d removed \n " , getLabel ( ) , getMountpoint ( ) , major , minor ) ;
@ -275,7 +276,8 @@ void DirectVolume::handlePartitionRemoved(const char *devpath, NetlinkEvent *evt
* the removal notification will be sent on the Disk
* the removal notification will be sent on the Disk
* itself
* itself
*/
*/
if ( getState ( ) ! = Volume : : State_Mounted ) {
state = getState ( ) ;
if ( state ! = Volume : : State_Mounted & & state ! = Volume : : State_Shared ) {
return ;
return ;
}
}
@ -300,6 +302,19 @@ void DirectVolume::handlePartitionRemoved(const char *devpath, NetlinkEvent *evt
} else {
} else {
SLOGD ( " Crisis averted " ) ;
SLOGD ( " Crisis averted " ) ;
}
}
} else if ( state = = Volume : : State_Shared ) {
/* removed during mass storage */
snprintf ( msg , sizeof ( msg ) , " Volume %s bad removal (%d:%d) " ,
getLabel ( ) , major , minor ) ;
mVm - > getBroadcaster ( ) - > sendBroadcast ( ResponseCode : : VolumeBadRemoval ,
msg , false ) ;
if ( mVm - > unshareVolume ( getLabel ( ) , " ums " ) ) {
SLOGE ( " Failed to unshare volume on bad removal (%s) " ,
strerror ( errno ) ) ;
} else {
SLOGD ( " Crisis averted " ) ;
}
}
}
}
}