Add back "unmountable" volume state.

Also automatically unmount when format is requested.

Bug: 19993667
Change-Id: I2c81b7ccc9d69df61d7ae4df1e8224c02f260044
gugelfrei
Jeff Sharkey 9 years ago
parent 9f18fe7807
commit 0fd9535474

@ -145,8 +145,8 @@ status_t VolumeBase::doDestroy() {
} }
status_t VolumeBase::mount() { status_t VolumeBase::mount() {
if (mState != State::kUnmounted) { if ((mState != State::kUnmounted) && (mState != State::kUnmountable)) {
LOG(WARNING) << getId() << " mount requires state unmounted"; LOG(WARNING) << getId() << " mount requires state unmounted or unmountable";
return -EBUSY; return -EBUSY;
} }
@ -155,7 +155,7 @@ status_t VolumeBase::mount() {
if (res == OK) { if (res == OK) {
setState(State::kMounted); setState(State::kMounted);
} else { } else {
setState(State::kUnmounted); setState(State::kUnmountable);
} }
return res; return res;
@ -183,8 +183,12 @@ status_t VolumeBase::unmount() {
} }
status_t VolumeBase::format() { status_t VolumeBase::format() {
if (mState != State::kUnmounted) { if (mState == State::kMounted) {
LOG(WARNING) << getId() << " format requires state unmounted"; unmount();
}
if ((mState != State::kUnmounted) && (mState != State::kUnmountable)) {
LOG(WARNING) << getId() << " format requires state unmounted or unmountable";
return -EBUSY; return -EBUSY;
} }

@ -63,11 +63,18 @@ public:
}; };
enum class State { enum class State {
/* Next states: mounting, formatting */
kUnmounted = 0, kUnmounted = 0,
/* Next states: mounted, unmountable */
kMounting, kMounting,
/* Next states: unmounting */
kMounted, kMounted,
/* Next states: unmounted */
kFormatting, kFormatting,
/* Next states: unmounted */
kUnmounting, kUnmounting,
/* Next states: mounting, formatting */
kUnmountable,
}; };
const std::string& getId() { return mId; } const std::string& getId() { return mId; }

Loading…
Cancel
Save