Merge "fs_mgr: Better error messages in fs_mgr_update_verity_state."

This commit is contained in:
Treehugger Robot 2018-08-28 18:58:21 +00:00 committed by Gerrit Code Review
commit abf8ff7e81
3 changed files with 18 additions and 6 deletions

View file

@ -79,7 +79,8 @@
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
using DeviceMapper = android::dm::DeviceMapper;
using android::dm::DeviceMapper;
using android::dm::DmDeviceState;
// record fs stat
enum FsStatFlags {
@ -1400,8 +1401,12 @@ bool fs_mgr_update_verity_state(std::function<fs_mgr_verity_state_callback> call
mount_point = basename(fstab->recs[i].mount_point);
}
const char* status = nullptr;
if (dm.GetState(mount_point) == DmDeviceState::INVALID) {
PERROR << "Could not find verity device for mount point: " << mount_point;
continue;
}
const char* status = nullptr;
std::vector<DeviceMapper::TargetInfo> table;
if (!dm.GetTableStatus(mount_point, &table) || table.empty() || table[0].data.empty()) {
if (fstab->recs[i].fs_mgr_flags & MF_VERIFYATBOOT) {

View file

@ -98,9 +98,16 @@ const std::unique_ptr<DmTable> DeviceMapper::table(const std::string& /* name */
return nullptr;
}
DmDeviceState DeviceMapper::state(const std::string& /* name */) const {
// TODO(b/110035986): Return the state, as read from the kernel instead
return DmDeviceState::INVALID;
DmDeviceState DeviceMapper::GetState(const std::string& name) const {
struct dm_ioctl io;
InitIo(&io, name);
if (ioctl(fd_, DM_DEV_STATUS, &io) < 0) {
return DmDeviceState::INVALID;
}
if ((io.flags & DM_ACTIVE_PRESENT_FLAG) && !(io.flags & DM_SUSPEND_FLAG)) {
return DmDeviceState::ACTIVE;
}
return DmDeviceState::SUSPENDED;
}
bool DeviceMapper::CreateDevice(const std::string& name, const DmTable& table) {

View file

@ -79,7 +79,7 @@ class DeviceMapper final {
// Returns the current state of the underlying device mapper device
// with given name.
// One of INVALID, SUSPENDED or ACTIVE.
DmDeviceState state(const std::string& name) const;
DmDeviceState GetState(const std::string& name) const;
// Creates a device, loads the given table, and activates it. If the device
// is not able to be activated, it is destroyed, and false is returned.