2009-10-11 02:22:08 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2008 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _DEVICEVOLUME_H
|
|
|
|
#define _DEVICEVOLUME_H
|
|
|
|
|
|
|
|
#include <utils/List.h>
|
|
|
|
|
|
|
|
#include "Volume.h"
|
|
|
|
|
|
|
|
typedef android::List<char *> PathCollection;
|
|
|
|
|
2009-10-12 23:57:05 +02:00
|
|
|
class DirectVolume : public Volume {
|
2009-10-21 20:06:52 +02:00
|
|
|
public:
|
2011-03-08 05:51:22 +01:00
|
|
|
static const int MAX_PARTITIONS = 32;
|
2009-10-11 02:22:08 +02:00
|
|
|
protected:
|
2013-07-16 03:14:25 +02:00
|
|
|
const char* mMountpoint;
|
|
|
|
const char* mFuseMountpoint;
|
|
|
|
|
2009-10-11 02:22:08 +02:00
|
|
|
PathCollection *mPaths;
|
2009-10-21 20:06:52 +02:00
|
|
|
int mDiskMajor;
|
|
|
|
int mDiskMinor;
|
|
|
|
int mPartMinors[MAX_PARTITIONS];
|
2011-09-01 01:14:23 +02:00
|
|
|
int mOrigDiskMajor;
|
|
|
|
int mOrigDiskMinor;
|
|
|
|
int mOrigPartMinors[MAX_PARTITIONS];
|
2009-10-11 02:22:08 +02:00
|
|
|
int mDiskNumParts;
|
2011-03-08 05:51:22 +01:00
|
|
|
unsigned int mPendingPartMap;
|
2011-05-19 02:20:07 +02:00
|
|
|
int mIsDecrypted;
|
2009-10-11 02:22:08 +02:00
|
|
|
|
|
|
|
public:
|
2013-07-16 03:14:25 +02:00
|
|
|
DirectVolume(VolumeManager *vm, const fstab_rec* rec, int flags);
|
2009-10-12 23:57:05 +02:00
|
|
|
virtual ~DirectVolume();
|
2009-10-11 02:22:08 +02:00
|
|
|
|
|
|
|
int addPath(const char *path);
|
|
|
|
|
2013-07-16 03:14:25 +02:00
|
|
|
const char *getMountpoint() { return mMountpoint; }
|
|
|
|
const char *getFuseMountpoint() { return mFuseMountpoint; }
|
|
|
|
|
2009-10-12 20:32:47 +02:00
|
|
|
int handleBlockEvent(NetlinkEvent *evt);
|
2009-12-13 19:40:18 +01:00
|
|
|
dev_t getDiskDevice();
|
2010-09-18 00:50:51 +02:00
|
|
|
dev_t getShareDevice();
|
2009-12-13 19:40:18 +01:00
|
|
|
void handleVolumeShared();
|
|
|
|
void handleVolumeUnshared();
|
2011-05-19 02:20:07 +02:00
|
|
|
int getVolInfo(struct volume_info *v);
|
2009-12-13 19:40:18 +01:00
|
|
|
|
2009-10-13 01:29:01 +02:00
|
|
|
protected:
|
2009-12-13 19:40:18 +01:00
|
|
|
int getDeviceNodes(dev_t *devs, int max);
|
2011-05-19 02:20:07 +02:00
|
|
|
int updateDeviceInfo(char *new_path, int new_major, int new_minor);
|
2011-09-01 01:14:23 +02:00
|
|
|
virtual void revertDeviceInfo(void);
|
2011-05-19 02:20:07 +02:00
|
|
|
int isDecrypted() { return mIsDecrypted; }
|
2009-10-12 20:32:47 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
void handleDiskAdded(const char *devpath, NetlinkEvent *evt);
|
|
|
|
void handleDiskRemoved(const char *devpath, NetlinkEvent *evt);
|
2009-12-13 19:40:18 +01:00
|
|
|
void handleDiskChanged(const char *devpath, NetlinkEvent *evt);
|
2009-10-12 20:32:47 +02:00
|
|
|
void handlePartitionAdded(const char *devpath, NetlinkEvent *evt);
|
|
|
|
void handlePartitionRemoved(const char *devpath, NetlinkEvent *evt);
|
2009-12-13 19:40:18 +01:00
|
|
|
void handlePartitionChanged(const char *devpath, NetlinkEvent *evt);
|
|
|
|
|
|
|
|
int doMountVfat(const char *deviceNode, const char *mountPoint);
|
2009-10-13 01:29:01 +02:00
|
|
|
|
2009-10-11 02:22:08 +02:00
|
|
|
};
|
|
|
|
|
2009-10-12 23:57:05 +02:00
|
|
|
typedef android::List<DirectVolume *> DirectVolumeCollection;
|
2009-10-11 02:22:08 +02:00
|
|
|
|
|
|
|
#endif
|