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: |
| 30 | static const int MAX_PARTITIONS = 4; |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 31 | protected: |
| 32 | PathCollection *mPaths; |
| 33 | int mPartIdx; |
San Mehat | dd9b8e9 | 2009-10-21 11:06:52 -0700 | [diff] [blame] | 34 | int mDiskMajor; |
| 35 | int mDiskMinor; |
| 36 | int mPartMinors[MAX_PARTITIONS]; |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 37 | int mDiskNumParts; |
San Mehat | fd7f587 | 2009-10-12 11:32:47 -0700 | [diff] [blame] | 38 | unsigned char mPendingPartMap; |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 39 | |
| 40 | public: |
San Mehat | a2677e4 | 2009-12-13 10:40:18 -0800 | [diff] [blame] | 41 | DirectVolume(VolumeManager *vm, const char *label, const char *mount_point, int partIdx); |
San Mehat | ae10b91 | 2009-10-12 14:57:05 -0700 | [diff] [blame] | 42 | virtual ~DirectVolume(); |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 43 | |
| 44 | int addPath(const char *path); |
| 45 | |
San Mehat | fd7f587 | 2009-10-12 11:32:47 -0700 | [diff] [blame] | 46 | int handleBlockEvent(NetlinkEvent *evt); |
San Mehat | a2677e4 | 2009-12-13 10:40:18 -0800 | [diff] [blame] | 47 | dev_t getDiskDevice(); |
| 48 | void handleVolumeShared(); |
| 49 | void handleVolumeUnshared(); |
| 50 | |
San Mehat | 49e2bce | 2009-10-12 16:29:01 -0700 | [diff] [blame] | 51 | protected: |
San Mehat | a2677e4 | 2009-12-13 10:40:18 -0800 | [diff] [blame] | 52 | int getDeviceNodes(dev_t *devs, int max); |
San Mehat | fd7f587 | 2009-10-12 11:32:47 -0700 | [diff] [blame] | 53 | |
| 54 | private: |
| 55 | void handleDiskAdded(const char *devpath, NetlinkEvent *evt); |
| 56 | void handleDiskRemoved(const char *devpath, NetlinkEvent *evt); |
San Mehat | a2677e4 | 2009-12-13 10:40:18 -0800 | [diff] [blame] | 57 | void handleDiskChanged(const char *devpath, NetlinkEvent *evt); |
San Mehat | fd7f587 | 2009-10-12 11:32:47 -0700 | [diff] [blame] | 58 | void handlePartitionAdded(const char *devpath, NetlinkEvent *evt); |
| 59 | void handlePartitionRemoved(const char *devpath, NetlinkEvent *evt); |
San Mehat | a2677e4 | 2009-12-13 10:40:18 -0800 | [diff] [blame] | 60 | void handlePartitionChanged(const char *devpath, NetlinkEvent *evt); |
| 61 | |
| 62 | int doMountVfat(const char *deviceNode, const char *mountPoint); |
San Mehat | 49e2bce | 2009-10-12 16:29:01 -0700 | [diff] [blame] | 63 | |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 64 | }; |
| 65 | |
San Mehat | ae10b91 | 2009-10-12 14:57:05 -0700 | [diff] [blame] | 66 | typedef android::List<DirectVolume *> DirectVolumeCollection; |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 67 | |
| 68 | #endif |