* Support nonremovable disks and expose a nonremovable flag in the DiskCreated message. * New DiskPartition class to hold single partitions. DiskPartition is used when the fs_mgr entry has a partnum (eg. when fs_mgr_flags contains voldmanaged=label:#). Override disk partitioning methods to prevent destroying the emmc. Change-Id: Id7ec3ea409b5c96e691730604e4b1e9cc3aa9d33 vold: Correct base header paths These headers were moved to android-base Change-Id: I3eaa8316006b9017c5f5e31cd1e91efc2862106d DiskPartition.cpp: Add sysmacros.h dependency for major/minor Change-Id: I22c267c8f12b40fb3e2295becd88f12b75907b69 Signed-off-by: Adrian DC <radian.dc@gmail.com> [mikeioannina] Adapt for Pie and Q Change-Id: Id7ec3ea409b5c96e691730604e4b1e9cc3aa9d33gugelfrei
parent
c803d524ea
commit
af516f8875
@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2015 Cyanogen, Inc.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "DiskPartition.h"
|
||||||
|
#include "PublicVolume.h"
|
||||||
|
#include "PrivateVolume.h"
|
||||||
|
#include "Utils.h"
|
||||||
|
#include "VolumeBase.h"
|
||||||
|
#include "VolumeManager.h"
|
||||||
|
|
||||||
|
#include <android-base/file.h>
|
||||||
|
#include <android-base/stringprintf.h>
|
||||||
|
#include <android-base/logging.h>
|
||||||
|
#include <diskconfig/diskconfig.h>
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/sysmacros.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
|
|
||||||
|
using android::base::ReadFileToString;
|
||||||
|
using android::base::WriteStringToFile;
|
||||||
|
using android::base::StringPrintf;
|
||||||
|
|
||||||
|
namespace android {
|
||||||
|
namespace vold {
|
||||||
|
|
||||||
|
DiskPartition::DiskPartition(const std::string& eventPath, dev_t device,
|
||||||
|
const std::string& nickname, int flags, int partnum) :
|
||||||
|
Disk(eventPath, device, nickname, flags),
|
||||||
|
mPartNum(partnum) {
|
||||||
|
// Empty
|
||||||
|
}
|
||||||
|
|
||||||
|
DiskPartition::~DiskPartition() {
|
||||||
|
// Empty
|
||||||
|
}
|
||||||
|
|
||||||
|
status_t DiskPartition::create() {
|
||||||
|
CHECK(!mCreated);
|
||||||
|
mCreated = true;
|
||||||
|
auto listener = VolumeManager::Instance()->getListener();
|
||||||
|
if (listener) listener->onDiskCreated(getId(), mFlags);
|
||||||
|
dev_t partDevice = makedev(major(mDevice), minor(mDevice) + mPartNum);
|
||||||
|
createPublicVolume(partDevice);
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
status_t DiskPartition::destroy() {
|
||||||
|
CHECK(mCreated);
|
||||||
|
destroyAllVolumes();
|
||||||
|
mCreated = false;
|
||||||
|
auto listener = VolumeManager::Instance()->getListener();
|
||||||
|
if (listener) listener->onDiskDestroyed(getId());
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
status_t DiskPartition::partitionPublic() {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
status_t DiskPartition::partitionPrivate() {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
status_t DiskPartition::partitionMixed(int8_t ratio) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace vold
|
||||||
|
} // namespace android
|
||||||
|
|
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2015 Cyanogen, Inc.
|
||||||
|
*
|
||||||
|
* 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 ANDROID_VOLD_DISKPARTITION_H
|
||||||
|
#define ANDROID_VOLD_DISKPARTITION_H
|
||||||
|
|
||||||
|
#include "Disk.h"
|
||||||
|
|
||||||
|
namespace android {
|
||||||
|
namespace vold {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Representation of a single partition on physical media. Useful for
|
||||||
|
* single media partitions such as "internal" sdcard partitions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class DiskPartition : public Disk {
|
||||||
|
public:
|
||||||
|
DiskPartition(const std::string& eventPath, dev_t device,
|
||||||
|
const std::string& nickname,
|
||||||
|
int flags, int partnum);
|
||||||
|
virtual ~DiskPartition();
|
||||||
|
|
||||||
|
virtual status_t create();
|
||||||
|
virtual status_t destroy();
|
||||||
|
|
||||||
|
virtual status_t partitionPublic();
|
||||||
|
virtual status_t partitionPrivate();
|
||||||
|
virtual status_t partitionMixed(int8_t ratio);
|
||||||
|
|
||||||
|
private:
|
||||||
|
/* Partition number */
|
||||||
|
int mPartNum;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace vold
|
||||||
|
} // namespace android
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in new issue