• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
26 typedef android::List<char *> PathCollection;
27 
28 class DirectVolume : public Volume {
29 public:
30     static const int MAX_PARTITIONS = 4;
31 protected:
32     PathCollection *mPaths;
33     int            mDiskMajor;
34     int            mDiskMinor;
35     int            mPartMinors[MAX_PARTITIONS];
36     int            mDiskNumParts;
37     unsigned char  mPendingPartMap;
38 
39 public:
40     DirectVolume(VolumeManager *vm, const char *label, const char *mount_point, int partIdx);
41     virtual ~DirectVolume();
42 
43     int addPath(const char *path);
44 
45     int handleBlockEvent(NetlinkEvent *evt);
46     dev_t getDiskDevice();
47     dev_t getShareDevice();
48     void handleVolumeShared();
49     void handleVolumeUnshared();
50 
51 protected:
52     int getDeviceNodes(dev_t *devs, int max);
53 
54 private:
55     void handleDiskAdded(const char *devpath, NetlinkEvent *evt);
56     void handleDiskRemoved(const char *devpath, NetlinkEvent *evt);
57     void handleDiskChanged(const char *devpath, NetlinkEvent *evt);
58     void handlePartitionAdded(const char *devpath, NetlinkEvent *evt);
59     void handlePartitionRemoved(const char *devpath, NetlinkEvent *evt);
60     void handlePartitionChanged(const char *devpath, NetlinkEvent *evt);
61 
62     int doMountVfat(const char *deviceNode, const char *mountPoint);
63 
64 };
65 
66 typedef android::List<DirectVolume *> DirectVolumeCollection;
67 
68 #endif
69