vold2: Get mounting/unmounting/formatting/sharing working

Signed-off-by: San Mehat <san@google.com>
diff --git a/Volume.h b/Volume.h
index 689cd53..838cf1c 100644
--- a/Volume.h
+++ b/Volume.h
@@ -20,6 +20,7 @@
 #include <utils/List.h>
 
 class NetlinkEvent;
+class VolumeManager;
 
 class Volume {
 private:
@@ -27,38 +28,56 @@
 
 public:
     static const int State_Init       = -1;
+    static const int State_NoMedia    = 0;
     static const int State_Idle       = 1;
     static const int State_Pending    = 2;
-    static const int State_Mounted    = 3;
-    static const int State_Checking   = 4;
-    static const int State_Formatting = 5;
+    static const int State_Checking   = 3;
+    static const int State_Mounted    = 4;
+    static const int State_Unmounting = 5;
+    static const int State_Formatting = 6;
+    static const int State_Shared     = 7;
+    static const int State_SharedMnt  = 8;
 
 protected:
     char *mLabel;
     char *mMountpoint;
+    VolumeManager *mVm;
+
+    /*
+     * The major/minor tuple of the currently mounted filesystem.
+     */
+    dev_t mCurrentlyMountedKdev;
 
 public:
-    Volume(const char *label, const char *mount_point);
+    Volume(VolumeManager *vm, const char *label, const char *mount_point);
     virtual ~Volume();
 
-    int mount();
-    int unmount();
+    int mountVol();
+    int unmountVol();
+    int formatVol();
 
     const char *getLabel() { return mLabel; }
     const char *getMountpoint() { return mMountpoint; }
     int getState() { return mState; }
 
     virtual int handleBlockEvent(NetlinkEvent *evt);
+    virtual dev_t getDiskDevice();
+    virtual void handleVolumeShared();
+    virtual void handleVolumeUnshared();
 
 protected:
     void setState(int state);
 
-    virtual int prepareToMount(int *major, int *minor) = 0;
+    virtual int getDeviceNodes(dev_t *devs, int max) = 0;
 
     int createDeviceNode(const char *path, int major, int minor);
 
 private:
     int checkFilesystem(const char *nodepath);
+    int doMountVfat(const char *deviceNode, const char *mountPoint);
+    int doFormatVfat(const char *deviceNode);
+    int initializeMbr(const char *deviceNode);
+    bool isMountpointMounted(const char *path);
 };
 
 typedef android::List<Volume *> VolumeCollection;