blob: ad1b3864732f168a2cad2f53bb5caa4a84b7babb [file] [log] [blame]
San Mehatf1b736b2009-10-10 17:22:08 -07001/*
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 Mehatdd9b8e92009-10-21 11:06:52 -070024#define MAX_PARTS 4
25
San Mehatf1b736b2009-10-10 17:22:08 -070026typedef android::List<char *> PathCollection;
27
San Mehatae10b912009-10-12 14:57:05 -070028class DirectVolume : public Volume {
San Mehatdd9b8e92009-10-21 11:06:52 -070029public:
30 static const int MAX_PARTITIONS = 4;
San Mehatf1b736b2009-10-10 17:22:08 -070031protected:
32 PathCollection *mPaths;
San Mehatdd9b8e92009-10-21 11:06:52 -070033 int mDiskMajor;
34 int mDiskMinor;
35 int mPartMinors[MAX_PARTITIONS];
San Mehatf1b736b2009-10-10 17:22:08 -070036 int mDiskNumParts;
San Mehatfd7f5872009-10-12 11:32:47 -070037 unsigned char mPendingPartMap;
Ken Sumrall29d8da82011-05-18 17:20:07 -070038 int mIsDecrypted;
39 int mFlags;
San Mehatf1b736b2009-10-10 17:22:08 -070040
41public:
San Mehata2677e42009-12-13 10:40:18 -080042 DirectVolume(VolumeManager *vm, const char *label, const char *mount_point, int partIdx);
San Mehatae10b912009-10-12 14:57:05 -070043 virtual ~DirectVolume();
San Mehatf1b736b2009-10-10 17:22:08 -070044
45 int addPath(const char *path);
46
San Mehatfd7f5872009-10-12 11:32:47 -070047 int handleBlockEvent(NetlinkEvent *evt);
San Mehata2677e42009-12-13 10:40:18 -080048 dev_t getDiskDevice();
Mike Lockwood2dfe2972010-09-17 18:50:51 -040049 dev_t getShareDevice();
San Mehata2677e42009-12-13 10:40:18 -080050 void handleVolumeShared();
51 void handleVolumeUnshared();
Ken Sumrall29d8da82011-05-18 17:20:07 -070052 int getVolInfo(struct volume_info *v);
53 void setFlags(int flags);
San Mehata2677e42009-12-13 10:40:18 -080054
San Mehat49e2bce2009-10-12 16:29:01 -070055protected:
San Mehata2677e42009-12-13 10:40:18 -080056 int getDeviceNodes(dev_t *devs, int max);
Ken Sumrall29d8da82011-05-18 17:20:07 -070057 int updateDeviceInfo(char *new_path, int new_major, int new_minor);
58 int isDecrypted() { return mIsDecrypted; }
59 int getFlags() { return mFlags; }
San Mehatfd7f5872009-10-12 11:32:47 -070060
61private:
62 void handleDiskAdded(const char *devpath, NetlinkEvent *evt);
63 void handleDiskRemoved(const char *devpath, NetlinkEvent *evt);
San Mehata2677e42009-12-13 10:40:18 -080064 void handleDiskChanged(const char *devpath, NetlinkEvent *evt);
San Mehatfd7f5872009-10-12 11:32:47 -070065 void handlePartitionAdded(const char *devpath, NetlinkEvent *evt);
66 void handlePartitionRemoved(const char *devpath, NetlinkEvent *evt);
San Mehata2677e42009-12-13 10:40:18 -080067 void handlePartitionChanged(const char *devpath, NetlinkEvent *evt);
68
69 int doMountVfat(const char *deviceNode, const char *mountPoint);
San Mehat49e2bce2009-10-12 16:29:01 -070070
San Mehatf1b736b2009-10-10 17:22:08 -070071};
72
San Mehatae10b912009-10-12 14:57:05 -070073typedef android::List<DirectVolume *> DirectVolumeCollection;
San Mehatf1b736b2009-10-10 17:22:08 -070074
75#endif