1/* 2 * Copyright (C) 2008 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#ifndef _DEVICEVOLUME_H 18#define _DEVICEVOLUME_H 19 20#include <utils/List.h> 21 22#include "Volume.h" 23 24#define MAX_PARTS 4 25 26typedef android::List<char *> PathCollection; 27 28class DirectVolume : public Volume { 29public: 30 static const int MAX_PARTITIONS = 4; 31protected: 32 PathCollection *mPaths; 33 int mDiskMajor; 34 int mDiskMinor; 35 int mPartMinors[MAX_PARTITIONS]; 36 int mOrigDiskMajor; 37 int mOrigDiskMinor; 38 int mOrigPartMinors[MAX_PARTITIONS]; 39 int mDiskNumParts; 40 unsigned char mPendingPartMap; 41 int mIsDecrypted; 42 int mFlags; 43 44public: 45 DirectVolume(VolumeManager *vm, const char *label, const char *mount_point, int partIdx); 46 virtual ~DirectVolume(); 47 48 int addPath(const char *path); 49 50 int handleBlockEvent(NetlinkEvent *evt); 51 dev_t getDiskDevice(); 52 dev_t getShareDevice(); 53 void handleVolumeShared(); 54 void handleVolumeUnshared(); 55 int getVolInfo(struct volume_info *v); 56 void setFlags(int flags); 57 58protected: 59 int getDeviceNodes(dev_t *devs, int max); 60 int updateDeviceInfo(char *new_path, int new_major, int new_minor); 61 virtual void revertDeviceInfo(void); 62 int isDecrypted() { return mIsDecrypted; } 63 int getFlags() { return mFlags; } 64 65private: 66 void handleDiskAdded(const char *devpath, NetlinkEvent *evt); 67 void handleDiskRemoved(const char *devpath, NetlinkEvent *evt); 68 void handleDiskChanged(const char *devpath, NetlinkEvent *evt); 69 void handlePartitionAdded(const char *devpath, NetlinkEvent *evt); 70 void handlePartitionRemoved(const char *devpath, NetlinkEvent *evt); 71 void handlePartitionChanged(const char *devpath, NetlinkEvent *evt); 72 73 int doMountVfat(const char *deviceNode, const char *mountPoint); 74 75}; 76 77typedef android::List<DirectVolume *> DirectVolumeCollection; 78 79#endif 80