Merge changes I1c50546e,I8254cb6b,Ib179299a,Iec1c2801
* changes: EncryptInplace: Rename variable Checkpoint: Assure proper buffer alignment vold: Pass std::string by const reference vold: const-ify some of the API
This commit is contained in:
commit
2374693556
12 changed files with 42 additions and 42 deletions
|
@ -296,9 +296,9 @@ Status cp_restoreCheckpoint(const std::string& blockDevice) {
|
||||||
PLOG(ERROR) << "Cannot open " << blockDevice;
|
PLOG(ERROR) << "Cannot open " << blockDevice;
|
||||||
return Status::fromExceptionCode(errno, ("Cannot open " + blockDevice).c_str());
|
return Status::fromExceptionCode(errno, ("Cannot open " + blockDevice).c_str());
|
||||||
}
|
}
|
||||||
char buffer[kBlockSize];
|
alignas(alignof(log_sector)) char ls_buffer[kBlockSize];
|
||||||
device.read(buffer, kBlockSize);
|
device.read(ls_buffer, kBlockSize);
|
||||||
log_sector& ls = *(log_sector*)buffer;
|
log_sector& ls = *reinterpret_cast<log_sector*>(ls_buffer);
|
||||||
if (ls.magic != kMagic) {
|
if (ls.magic != kMagic) {
|
||||||
LOG(ERROR) << "No magic";
|
LOG(ERROR) << "No magic";
|
||||||
return Status::fromExceptionCode(EINVAL, "No magic");
|
return Status::fromExceptionCode(EINVAL, "No magic");
|
||||||
|
@ -307,10 +307,9 @@ Status cp_restoreCheckpoint(const std::string& blockDevice) {
|
||||||
LOG(INFO) << "Restoring " << ls.sequence << " log sectors";
|
LOG(INFO) << "Restoring " << ls.sequence << " log sectors";
|
||||||
|
|
||||||
for (int sequence = ls.sequence; sequence >= 0; sequence--) {
|
for (int sequence = ls.sequence; sequence >= 0; sequence--) {
|
||||||
char buffer[kBlockSize];
|
|
||||||
device.seekg(0);
|
device.seekg(0);
|
||||||
device.read(buffer, kBlockSize);
|
device.read(ls_buffer, kBlockSize);
|
||||||
log_sector& ls = *(log_sector*)buffer;
|
ls = *reinterpret_cast<log_sector*>(ls_buffer);
|
||||||
if (ls.magic != kMagic) {
|
if (ls.magic != kMagic) {
|
||||||
LOG(ERROR) << "No magic!";
|
LOG(ERROR) << "No magic!";
|
||||||
return Status::fromExceptionCode(EINVAL, "No magic");
|
return Status::fromExceptionCode(EINVAL, "No magic");
|
||||||
|
|
|
@ -524,11 +524,11 @@ static int cryptfs_enable_inplace_full(char* crypto_blkdev, char* real_blkdev, o
|
||||||
for (i /= CRYPT_SECTORS_PER_BUFSIZE; i < numblocks; i++) {
|
for (i /= CRYPT_SECTORS_PER_BUFSIZE; i < numblocks; i++) {
|
||||||
new_pct = (i + blocks_already_done) / one_pct;
|
new_pct = (i + blocks_already_done) / one_pct;
|
||||||
if (set_progress_properties && new_pct > cur_pct) {
|
if (set_progress_properties && new_pct > cur_pct) {
|
||||||
char buf[8];
|
char property_buf[8];
|
||||||
|
|
||||||
cur_pct = new_pct;
|
cur_pct = new_pct;
|
||||||
snprintf(buf, sizeof(buf), "%" PRId64, cur_pct);
|
snprintf(property_buf, sizeof(property_buf), "%" PRId64, cur_pct);
|
||||||
android::base::SetProperty("vold.encrypt_progress", buf);
|
android::base::SetProperty("vold.encrypt_progress", property_buf);
|
||||||
}
|
}
|
||||||
if (unix_read(realfd, buf, CRYPT_INPLACE_BUFSIZE) <= 0) {
|
if (unix_read(realfd, buf, CRYPT_INPLACE_BUFSIZE) <= 0) {
|
||||||
PLOG(ERROR) << "Error reading real_blkdev " << real_blkdev << " for inplace encrypt";
|
PLOG(ERROR) << "Error reading real_blkdev " << real_blkdev << " for inplace encrypt";
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace vold {
|
||||||
// If only "secret" is nonempty, it is used to decrypt in a non-Keymaster process.
|
// If only "secret" is nonempty, it is used to decrypt in a non-Keymaster process.
|
||||||
class KeyAuthentication {
|
class KeyAuthentication {
|
||||||
public:
|
public:
|
||||||
KeyAuthentication(std::string t, std::string s) : token{t}, secret{s} {};
|
KeyAuthentication(const std::string& t, const std::string& s) : token{t}, secret{s} {};
|
||||||
|
|
||||||
bool usesKeymaster() const { return !token.empty() || secret.empty(); };
|
bool usesKeymaster() const { return !token.empty() || secret.empty(); };
|
||||||
|
|
||||||
|
|
|
@ -46,8 +46,8 @@ class KeymasterOperation {
|
||||||
~KeymasterOperation();
|
~KeymasterOperation();
|
||||||
// Is this instance valid? This is false if creation fails, and becomes
|
// Is this instance valid? This is false if creation fails, and becomes
|
||||||
// false on finish or if an update fails.
|
// false on finish or if an update fails.
|
||||||
explicit operator bool() { return mError == km::ErrorCode::OK; }
|
explicit operator bool() const { return mError == km::ErrorCode::OK; }
|
||||||
km::ErrorCode errorCode() { return mError; }
|
km::ErrorCode errorCode() const { return mError; }
|
||||||
// Call "update" repeatedly until all of the input is consumed, and
|
// Call "update" repeatedly until all of the input is consumed, and
|
||||||
// concatenate the output. Return true on success.
|
// concatenate the output. Return true on success.
|
||||||
template <class TI, class TO>
|
template <class TI, class TO>
|
||||||
|
|
|
@ -84,7 +84,7 @@ namespace vold {
|
||||||
|
|
||||||
// Note: It is possible to orphan a key if it is removed before deleting
|
// Note: It is possible to orphan a key if it is removed before deleting
|
||||||
// Update this once keymaster APIs change, and we have a proper commit.
|
// Update this once keymaster APIs change, and we have a proper commit.
|
||||||
static void commit_key(std::string dir) {
|
static void commit_key(const std::string& dir) {
|
||||||
while (!android::base::WaitForProperty("vold.checkpoint_committed", "1")) {
|
while (!android::base::WaitForProperty("vold.checkpoint_committed", "1")) {
|
||||||
LOG(ERROR) << "Wait for boot timed out";
|
LOG(ERROR) << "Wait for boot timed out";
|
||||||
}
|
}
|
||||||
|
|
|
@ -319,7 +319,8 @@ std::shared_ptr<android::vold::VolumeBase> VolumeManager::findVolume(const std::
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VolumeManager::listVolumes(android::vold::VolumeBase::Type type, std::list<std::string>& list) {
|
void VolumeManager::listVolumes(android::vold::VolumeBase::Type type,
|
||||||
|
std::list<std::string>& list) const {
|
||||||
list.clear();
|
list.clear();
|
||||||
for (const auto& disk : mDisks) {
|
for (const auto& disk : mDisks) {
|
||||||
disk->listVolumes(type, list);
|
disk->listVolumes(type, list);
|
||||||
|
|
|
@ -52,7 +52,7 @@ class VolumeManager {
|
||||||
std::mutex& getCryptLock() { return mCryptLock; }
|
std::mutex& getCryptLock() { return mCryptLock; }
|
||||||
|
|
||||||
void setListener(android::sp<android::os::IVoldListener> listener) { mListener = listener; }
|
void setListener(android::sp<android::os::IVoldListener> listener) { mListener = listener; }
|
||||||
android::sp<android::os::IVoldListener> getListener() { return mListener; }
|
android::sp<android::os::IVoldListener> getListener() const { return mListener; }
|
||||||
|
|
||||||
int start();
|
int start();
|
||||||
int stop();
|
int stop();
|
||||||
|
@ -68,8 +68,8 @@ class VolumeManager {
|
||||||
return !fnmatch(mSysPattern.c_str(), sysPath.c_str(), 0);
|
return !fnmatch(mSysPattern.c_str(), sysPath.c_str(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& getNickname() { return mNickname; }
|
const std::string& getNickname() const { return mNickname; }
|
||||||
int getFlags() { return mFlags; }
|
int getFlags() const { return mFlags; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string mSysPattern;
|
std::string mSysPattern;
|
||||||
|
@ -82,7 +82,7 @@ class VolumeManager {
|
||||||
std::shared_ptr<android::vold::Disk> findDisk(const std::string& id);
|
std::shared_ptr<android::vold::Disk> findDisk(const std::string& id);
|
||||||
std::shared_ptr<android::vold::VolumeBase> findVolume(const std::string& id);
|
std::shared_ptr<android::vold::VolumeBase> findVolume(const std::string& id);
|
||||||
|
|
||||||
void listVolumes(android::vold::VolumeBase::Type type, std::list<std::string>& list);
|
void listVolumes(android::vold::VolumeBase::Type type, std::list<std::string>& list) const;
|
||||||
|
|
||||||
int forgetPartition(const std::string& partGuid, const std::string& fsUuid);
|
int forgetPartition(const std::string& partGuid, const std::string& fsUuid);
|
||||||
|
|
||||||
|
|
|
@ -153,7 +153,7 @@ std::shared_ptr<VolumeBase> Disk::findVolume(const std::string& id) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Disk::listVolumes(VolumeBase::Type type, std::list<std::string>& list) {
|
void Disk::listVolumes(VolumeBase::Type type, std::list<std::string>& list) const {
|
||||||
for (const auto& vol : mVolumes) {
|
for (const auto& vol : mVolumes) {
|
||||||
if (vol->getType() == type) {
|
if (vol->getType() == type) {
|
||||||
list.push_back(vol->getId());
|
list.push_back(vol->getId());
|
||||||
|
|
18
model/Disk.h
18
model/Disk.h
|
@ -54,18 +54,18 @@ class Disk {
|
||||||
kEmmc = 1 << 4,
|
kEmmc = 1 << 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
const std::string& getId() { return mId; }
|
const std::string& getId() const { return mId; }
|
||||||
const std::string& getEventPath() { return mEventPath; }
|
const std::string& getEventPath() const { return mEventPath; }
|
||||||
const std::string& getSysPath() { return mSysPath; }
|
const std::string& getSysPath() const { return mSysPath; }
|
||||||
const std::string& getDevPath() { return mDevPath; }
|
const std::string& getDevPath() const { return mDevPath; }
|
||||||
dev_t getDevice() { return mDevice; }
|
dev_t getDevice() const { return mDevice; }
|
||||||
uint64_t getSize() { return mSize; }
|
uint64_t getSize() const { return mSize; }
|
||||||
const std::string& getLabel() { return mLabel; }
|
const std::string& getLabel() const { return mLabel; }
|
||||||
int getFlags() { return mFlags; }
|
int getFlags() const { return mFlags; }
|
||||||
|
|
||||||
std::shared_ptr<VolumeBase> findVolume(const std::string& id);
|
std::shared_ptr<VolumeBase> findVolume(const std::string& id);
|
||||||
|
|
||||||
void listVolumes(VolumeBase::Type type, std::list<std::string>& list);
|
void listVolumes(VolumeBase::Type type, std::list<std::string>& list) const;
|
||||||
|
|
||||||
status_t create();
|
status_t create();
|
||||||
status_t destroy();
|
status_t destroy();
|
||||||
|
|
|
@ -39,9 +39,9 @@ class PrivateVolume : public VolumeBase {
|
||||||
public:
|
public:
|
||||||
PrivateVolume(dev_t device, const std::string& keyRaw);
|
PrivateVolume(dev_t device, const std::string& keyRaw);
|
||||||
virtual ~PrivateVolume();
|
virtual ~PrivateVolume();
|
||||||
const std::string& getFsType() { return mFsType; };
|
const std::string& getFsType() const { return mFsType; };
|
||||||
const std::string& getRawDevPath() { return mRawDevPath; };
|
const std::string& getRawDevPath() const { return mRawDevPath; };
|
||||||
const std::string& getRawDmDevPath() { return mDmDevPath; };
|
const std::string& getRawDmDevPath() const { return mDmDevPath; };
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
status_t doCreate() override;
|
status_t doCreate() override;
|
||||||
|
|
|
@ -143,7 +143,7 @@ status_t VolumeBase::setInternalPath(const std::string& internalPath) {
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
android::sp<android::os::IVoldListener> VolumeBase::getListener() {
|
android::sp<android::os::IVoldListener> VolumeBase::getListener() const {
|
||||||
if (mSilent) {
|
if (mSilent) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -76,15 +76,15 @@ class VolumeBase {
|
||||||
kBadRemoval,
|
kBadRemoval,
|
||||||
};
|
};
|
||||||
|
|
||||||
const std::string& getId() { return mId; }
|
const std::string& getId() const { return mId; }
|
||||||
const std::string& getDiskId() { return mDiskId; }
|
const std::string& getDiskId() const { return mDiskId; }
|
||||||
const std::string& getPartGuid() { return mPartGuid; }
|
const std::string& getPartGuid() const { return mPartGuid; }
|
||||||
Type getType() { return mType; }
|
Type getType() const { return mType; }
|
||||||
int getMountFlags() { return mMountFlags; }
|
int getMountFlags() const { return mMountFlags; }
|
||||||
userid_t getMountUserId() { return mMountUserId; }
|
userid_t getMountUserId() const { return mMountUserId; }
|
||||||
State getState() { return mState; }
|
State getState() const { return mState; }
|
||||||
const std::string& getPath() { return mPath; }
|
const std::string& getPath() const { return mPath; }
|
||||||
const std::string& getInternalPath() { return mInternalPath; }
|
const std::string& getInternalPath() const { return mInternalPath; }
|
||||||
|
|
||||||
status_t setDiskId(const std::string& diskId);
|
status_t setDiskId(const std::string& diskId);
|
||||||
status_t setPartGuid(const std::string& partGuid);
|
status_t setPartGuid(const std::string& partGuid);
|
||||||
|
@ -116,7 +116,7 @@ class VolumeBase {
|
||||||
status_t setPath(const std::string& path);
|
status_t setPath(const std::string& path);
|
||||||
status_t setInternalPath(const std::string& internalPath);
|
status_t setInternalPath(const std::string& internalPath);
|
||||||
|
|
||||||
android::sp<android::os::IVoldListener> getListener();
|
android::sp<android::os::IVoldListener> getListener() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* ID that uniquely references volume while alive */
|
/* ID that uniquely references volume while alive */
|
||||||
|
|
Loading…
Reference in a new issue