fs_mgr: clean up dm ioctl flags
DM_READONLY_FLAG should only be used when loading tables, and DM_STATUS_TABLE_FLAG should only be used when querying a table's status. This patch cleans up how we set flags to reflect when the kernel actually cares about them. Bug: 78914864 Test: AVB device still boots Change-Id: I809d8c2ef2105849ebdd095bbe7f08f15ae63465
This commit is contained in:
parent
29954f6062
commit
5a4db628ee
|
@ -1383,7 +1383,7 @@ bool fs_mgr_update_verity_state(fs_mgr_verity_state_callback callback) {
|
|||
mount_point = basename(fstab->recs[i].mount_point);
|
||||
}
|
||||
|
||||
fs_mgr_verity_ioctl_init(io, mount_point, 0);
|
||||
fs_mgr_verity_ioctl_init(io, mount_point);
|
||||
|
||||
const char* status;
|
||||
if (ioctl(fd, DM_TABLE_STATUS, io)) {
|
||||
|
|
|
@ -303,13 +303,14 @@ static std::string construct_verity_table(const AvbHashtreeDescriptor& hashtree_
|
|||
|
||||
static bool load_verity_table(struct dm_ioctl* io, const std::string& dm_device_name, int fd,
|
||||
uint64_t image_size, const std::string& verity_table) {
|
||||
fs_mgr_verity_ioctl_init(io, dm_device_name, DM_STATUS_TABLE_FLAG);
|
||||
fs_mgr_verity_ioctl_init(io, dm_device_name);
|
||||
|
||||
// The buffer consists of [dm_ioctl][dm_target_spec][verity_params].
|
||||
char* buffer = (char*)io;
|
||||
|
||||
// Builds the dm_target_spec arguments.
|
||||
struct dm_target_spec* dm_target = (struct dm_target_spec*)&buffer[sizeof(struct dm_ioctl)];
|
||||
io->flags = DM_READONLY_FLAG;
|
||||
io->target_count = 1;
|
||||
dm_target->status = 0;
|
||||
dm_target->sector_start = 0;
|
||||
|
|
|
@ -23,21 +23,20 @@
|
|||
#include "fs_mgr_priv.h"
|
||||
#include "fs_mgr_priv_dm_ioctl.h"
|
||||
|
||||
void fs_mgr_verity_ioctl_init(struct dm_ioctl* io, const std::string& name, unsigned flags) {
|
||||
void fs_mgr_verity_ioctl_init(struct dm_ioctl* io, const std::string& name) {
|
||||
memset(io, 0, DM_BUF_SIZE);
|
||||
io->data_size = DM_BUF_SIZE;
|
||||
io->data_start = sizeof(struct dm_ioctl);
|
||||
io->version[0] = 4;
|
||||
io->version[1] = 0;
|
||||
io->version[2] = 0;
|
||||
io->flags = flags | DM_READONLY_FLAG;
|
||||
if (!name.empty()) {
|
||||
strlcpy(io->name, name.c_str(), sizeof(io->name));
|
||||
}
|
||||
}
|
||||
|
||||
bool fs_mgr_create_verity_device(struct dm_ioctl* io, const std::string& name, int fd) {
|
||||
fs_mgr_verity_ioctl_init(io, name, 1);
|
||||
fs_mgr_verity_ioctl_init(io, name);
|
||||
if (ioctl(fd, DM_DEV_CREATE, io)) {
|
||||
PERROR << "Error creating device mapping";
|
||||
return false;
|
||||
|
@ -46,7 +45,7 @@ bool fs_mgr_create_verity_device(struct dm_ioctl* io, const std::string& name, i
|
|||
}
|
||||
|
||||
bool fs_mgr_destroy_verity_device(struct dm_ioctl* io, const std::string& name, int fd) {
|
||||
fs_mgr_verity_ioctl_init(io, name, 0);
|
||||
fs_mgr_verity_ioctl_init(io, name);
|
||||
if (ioctl(fd, DM_DEV_REMOVE, io)) {
|
||||
PERROR << "Error removing device mapping";
|
||||
return false;
|
||||
|
@ -58,7 +57,7 @@ bool fs_mgr_get_verity_device_name(struct dm_ioctl* io, const std::string& name,
|
|||
std::string* out_dev_name) {
|
||||
FS_MGR_CHECK(out_dev_name != nullptr);
|
||||
|
||||
fs_mgr_verity_ioctl_init(io, name, 0);
|
||||
fs_mgr_verity_ioctl_init(io, name);
|
||||
if (ioctl(fd, DM_DEV_STATUS, io)) {
|
||||
PERROR << "Error fetching verity device number";
|
||||
return false;
|
||||
|
@ -71,7 +70,7 @@ bool fs_mgr_get_verity_device_name(struct dm_ioctl* io, const std::string& name,
|
|||
}
|
||||
|
||||
bool fs_mgr_resume_verity_table(struct dm_ioctl* io, const std::string& name, int fd) {
|
||||
fs_mgr_verity_ioctl_init(io, name, 0);
|
||||
fs_mgr_verity_ioctl_init(io, name);
|
||||
if (ioctl(fd, DM_DEV_SUSPEND, io)) {
|
||||
PERROR << "Error activating verity device";
|
||||
return false;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include <linux/dm-ioctl.h>
|
||||
#include <string>
|
||||
|
||||
void fs_mgr_verity_ioctl_init(struct dm_ioctl* io, const std::string& name, unsigned flags);
|
||||
void fs_mgr_verity_ioctl_init(struct dm_ioctl* io, const std::string& name);
|
||||
|
||||
bool fs_mgr_create_verity_device(struct dm_ioctl* io, const std::string& name, int fd);
|
||||
|
||||
|
|
|
@ -258,12 +258,13 @@ static int load_verity_table(struct dm_ioctl *io, const std::string &name,
|
|||
char *buffer = (char*) io;
|
||||
size_t bufsize;
|
||||
|
||||
fs_mgr_verity_ioctl_init(io, name, DM_STATUS_TABLE_FLAG);
|
||||
fs_mgr_verity_ioctl_init(io, name);
|
||||
|
||||
struct dm_target_spec *tgt = (struct dm_target_spec *) &buffer[sizeof(struct dm_ioctl)];
|
||||
|
||||
// set tgt arguments
|
||||
io->target_count = 1;
|
||||
io->flags = DM_READONLY_FLAG;
|
||||
tgt->status = 0;
|
||||
tgt->sector_start = 0;
|
||||
tgt->length = device_size / 512;
|
||||
|
|
Loading…
Reference in New Issue