kObb,
};
- enum Flags {
+ enum MountFlags {
/* Flag that volume is primary external storage */
kPrimary = 1 << 0,
/* Flag that volume is visible to normal apps */
};
enum class State {
- /* Next states: mounting, formatting */
kUnmounted = 0,
- /* Next states: mounted, unmountable */
- kMounting,
- /* Next states: unmounting */
+ kChecking,
kMounted,
- /* Next states: unmounted */
+ kMountedReadOnly,
kFormatting,
- /* Next states: unmounted */
- kUnmounting,
- /* Next states: mounting, formatting */
+ kEjecting,
kUnmountable,
+ kRemoved,
+ kBadRemoval,
};
const std::string& getId() { return mId; }
+ const std::string& getDiskId() { return mDiskId; }
+ const std::string& getPartGuid() { return mPartGuid; }
Type getType() { return mType; }
- int getFlags() { return mFlags; }
- userid_t getUser() { return mUser; }
+ int getMountFlags() { return mMountFlags; }
+ userid_t getMountUserId() { return mMountUserId; }
State getState() { return mState; }
const std::string& getPath() { return mPath; }
+ const std::string& getInternalPath() { return mInternalPath; }
- status_t setFlags(int flags);
- status_t setUser(userid_t user);
+ status_t setDiskId(const std::string& diskId);
+ status_t setPartGuid(const std::string& partGuid);
+ status_t setMountFlags(int mountFlags);
+ status_t setMountUserId(userid_t mountUserId);
+ status_t setSilent(bool silent);
void addVolume(const std::shared_ptr<VolumeBase>& volume);
void removeVolume(const std::shared_ptr<VolumeBase>& volume);
status_t destroy();
status_t mount();
status_t unmount();
- status_t format();
+ status_t format(const std::string& fsType);
protected:
explicit VolumeBase(Type type);
virtual status_t doDestroy();
virtual status_t doMount() = 0;
virtual status_t doUnmount() = 0;
- virtual status_t doFormat();
+ virtual status_t doFormat(const std::string& fsType);
status_t setId(const std::string& id);
status_t setPath(const std::string& path);
+ status_t setInternalPath(const std::string& internalPath);
+
+ void notifyEvent(int msg);
+ void notifyEvent(int msg, const std::string& value);
private:
/* ID that uniquely references volume while alive */
std::string mId;
+ /* ID that uniquely references parent disk while alive */
+ std::string mDiskId;
+ /* Partition GUID of this volume */
+ std::string mPartGuid;
/* Volume type */
Type mType;
- /* Flags applicable to volume */
- int mFlags;
+ /* Flags used when mounting this volume */
+ int mMountFlags;
/* User that owns this volume, otherwise -1 */
- userid_t mUser;
+ userid_t mMountUserId;
/* Flag indicating object is created */
bool mCreated;
/* Current state of volume */
State mState;
/* Path to mounted volume */
std::string mPath;
+ /* Path to internal backing storage */
+ std::string mInternalPath;
+ /* Flag indicating that volume should emit no events */
+ bool mSilent;
/* Volumes stacked on top of this volume */
std::list<std::shared_ptr<VolumeBase>> mVolumes;