San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 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 | |
San Mehat | dd9b8e9 | 2009-10-21 11:06:52 -0700 | [diff] [blame] | 24 | #define MAX_PARTS 4 |
| 25 | |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 26 | typedef android::List<char *> PathCollection; |
| 27 | |
San Mehat | ae10b91 | 2009-10-12 14:57:05 -0700 | [diff] [blame] | 28 | class DirectVolume : public Volume { |
San Mehat | dd9b8e9 | 2009-10-21 11:06:52 -0700 | [diff] [blame] | 29 | public: |
Hirofumi Ando | b4a8c9c | 2011-03-08 13:51:22 +0900 | [diff] [blame] | 30 | static const int MAX_PARTITIONS = 32; |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 31 | protected: |
Jeff Sharkey | ba6ae8d | 2013-07-15 18:14:25 -0700 | [diff] [blame] | 32 | const char* mMountpoint; |
| 33 | const char* mFuseMountpoint; |
| 34 | |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 35 | PathCollection *mPaths; |
San Mehat | dd9b8e9 | 2009-10-21 11:06:52 -0700 | [diff] [blame] | 36 | int mDiskMajor; |
| 37 | int mDiskMinor; |
| 38 | int mPartMinors[MAX_PARTITIONS]; |
Ken Sumrall | 0b8b597 | 2011-08-31 16:14:23 -0700 | [diff] [blame] | 39 | int mOrigDiskMajor; |
| 40 | int mOrigDiskMinor; |
| 41 | int mOrigPartMinors[MAX_PARTITIONS]; |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 42 | int mDiskNumParts; |
Hirofumi Ando | b4a8c9c | 2011-03-08 13:51:22 +0900 | [diff] [blame] | 43 | unsigned int mPendingPartMap; |
Ken Sumrall | 29d8da8 | 2011-05-18 17:20:07 -0700 | [diff] [blame] | 44 | int mIsDecrypted; |
| 45 | int mFlags; |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 46 | |
| 47 | public: |
Jeff Sharkey | ba6ae8d | 2013-07-15 18:14:25 -0700 | [diff] [blame] | 48 | DirectVolume(VolumeManager *vm, const fstab_rec* rec, int flags); |
San Mehat | ae10b91 | 2009-10-12 14:57:05 -0700 | [diff] [blame] | 49 | virtual ~DirectVolume(); |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 50 | |
| 51 | int addPath(const char *path); |
| 52 | |
Jeff Sharkey | ba6ae8d | 2013-07-15 18:14:25 -0700 | [diff] [blame] | 53 | const char *getMountpoint() { return mMountpoint; } |
| 54 | const char *getFuseMountpoint() { return mFuseMountpoint; } |
| 55 | |
San Mehat | fd7f587 | 2009-10-12 11:32:47 -0700 | [diff] [blame] | 56 | int handleBlockEvent(NetlinkEvent *evt); |
San Mehat | a2677e4 | 2009-12-13 10:40:18 -0800 | [diff] [blame] | 57 | dev_t getDiskDevice(); |
Mike Lockwood | 2dfe297 | 2010-09-17 18:50:51 -0400 | [diff] [blame] | 58 | dev_t getShareDevice(); |
San Mehat | a2677e4 | 2009-12-13 10:40:18 -0800 | [diff] [blame] | 59 | void handleVolumeShared(); |
| 60 | void handleVolumeUnshared(); |
Ken Sumrall | 29d8da8 | 2011-05-18 17:20:07 -0700 | [diff] [blame] | 61 | int getVolInfo(struct volume_info *v); |
San Mehat | a2677e4 | 2009-12-13 10:40:18 -0800 | [diff] [blame] | 62 | |
San Mehat | 49e2bce | 2009-10-12 16:29:01 -0700 | [diff] [blame] | 63 | protected: |
San Mehat | a2677e4 | 2009-12-13 10:40:18 -0800 | [diff] [blame] | 64 | int getDeviceNodes(dev_t *devs, int max); |
Ken Sumrall | 29d8da8 | 2011-05-18 17:20:07 -0700 | [diff] [blame] | 65 | int updateDeviceInfo(char *new_path, int new_major, int new_minor); |
Ken Sumrall | 0b8b597 | 2011-08-31 16:14:23 -0700 | [diff] [blame] | 66 | virtual void revertDeviceInfo(void); |
Ken Sumrall | 29d8da8 | 2011-05-18 17:20:07 -0700 | [diff] [blame] | 67 | int isDecrypted() { return mIsDecrypted; } |
| 68 | int getFlags() { return mFlags; } |
San Mehat | fd7f587 | 2009-10-12 11:32:47 -0700 | [diff] [blame] | 69 | |
| 70 | private: |
| 71 | void handleDiskAdded(const char *devpath, NetlinkEvent *evt); |
| 72 | void handleDiskRemoved(const char *devpath, NetlinkEvent *evt); |
San Mehat | a2677e4 | 2009-12-13 10:40:18 -0800 | [diff] [blame] | 73 | void handleDiskChanged(const char *devpath, NetlinkEvent *evt); |
San Mehat | fd7f587 | 2009-10-12 11:32:47 -0700 | [diff] [blame] | 74 | void handlePartitionAdded(const char *devpath, NetlinkEvent *evt); |
| 75 | void handlePartitionRemoved(const char *devpath, NetlinkEvent *evt); |
San Mehat | a2677e4 | 2009-12-13 10:40:18 -0800 | [diff] [blame] | 76 | void handlePartitionChanged(const char *devpath, NetlinkEvent *evt); |
| 77 | |
| 78 | int doMountVfat(const char *deviceNode, const char *mountPoint); |
San Mehat | 49e2bce | 2009-10-12 16:29:01 -0700 | [diff] [blame] | 79 | |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 80 | }; |
| 81 | |
San Mehat | ae10b91 | 2009-10-12 14:57:05 -0700 | [diff] [blame] | 82 | typedef android::List<DirectVolume *> DirectVolumeCollection; |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 83 | |
| 84 | #endif |