DirectVolume.h revision a2677e4ad01f250b0765f04adf0acfa6627efc98
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            mPartIdx;
34    int            mDiskMajor;
35    int            mDiskMinor;
36    int            mPartMinors[MAX_PARTITIONS];
37    int            mDiskNumParts;
38    unsigned char  mPendingPartMap;
39
40public:
41    DirectVolume(VolumeManager *vm, const char *label, const char *mount_point, int partIdx);
42    virtual ~DirectVolume();
43
44    int addPath(const char *path);
45
46    int handleBlockEvent(NetlinkEvent *evt);
47    dev_t getDiskDevice();
48    void handleVolumeShared();
49    void handleVolumeUnshared();
50
51protected:
52    int getDeviceNodes(dev_t *devs, int max);
53
54private:
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
66typedef android::List<DirectVolume *> DirectVolumeCollection;
67
68#endif
69