fs_mgr: target-agnostic device-mapper helpers
Remove "verity" from device-mapper helper functions so it's clear they can be re-used for non-verity targets. Bug: 78914864 Test: AVB device still boots Change-Id: Id8474b2c6e23e828eff563263ebb409031cde17e
This commit is contained in:
parent
5a4db628ee
commit
0b8e22eb5f
5 changed files with 30 additions and 30 deletions
|
@ -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);
|
||||
fs_mgr_dm_ioctl_init(io, DM_BUF_SIZE, mount_point);
|
||||
|
||||
const char* status;
|
||||
if (ioctl(fd, DM_TABLE_STATUS, io)) {
|
||||
|
|
|
@ -303,7 +303,7 @@ 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);
|
||||
fs_mgr_dm_ioctl_init(io, DM_BUF_SIZE, dm_device_name);
|
||||
|
||||
// The buffer consists of [dm_ioctl][dm_target_spec][verity_params].
|
||||
char* buffer = (char*)io;
|
||||
|
@ -360,14 +360,14 @@ static bool hashtree_dm_verity_setup(struct fstab_rec* fstab_entry,
|
|||
alignas(dm_ioctl) char buffer[DM_BUF_SIZE];
|
||||
struct dm_ioctl* io = (struct dm_ioctl*)buffer;
|
||||
const std::string mount_point(basename(fstab_entry->mount_point));
|
||||
if (!fs_mgr_create_verity_device(io, mount_point, fd)) {
|
||||
if (!fs_mgr_dm_create_device(io, mount_point, fd)) {
|
||||
LERROR << "Couldn't create verity device!";
|
||||
return false;
|
||||
}
|
||||
|
||||
// Gets the name of the device file.
|
||||
std::string verity_blk_name;
|
||||
if (!fs_mgr_get_verity_device_name(io, mount_point, fd, &verity_blk_name)) {
|
||||
if (!fs_mgr_dm_get_device_name(io, mount_point, fd, &verity_blk_name)) {
|
||||
LERROR << "Couldn't get verity device number!";
|
||||
return false;
|
||||
}
|
||||
|
@ -386,7 +386,7 @@ static bool hashtree_dm_verity_setup(struct fstab_rec* fstab_entry,
|
|||
}
|
||||
|
||||
// Activates the device.
|
||||
if (!fs_mgr_resume_verity_table(io, mount_point, fd)) {
|
||||
if (!fs_mgr_dm_resume_table(io, mount_point, fd)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,9 +23,9 @@
|
|||
#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) {
|
||||
memset(io, 0, DM_BUF_SIZE);
|
||||
io->data_size = DM_BUF_SIZE;
|
||||
void fs_mgr_dm_ioctl_init(struct dm_ioctl* io, size_t size, const std::string& name) {
|
||||
memset(io, 0, size);
|
||||
io->data_size = size;
|
||||
io->data_start = sizeof(struct dm_ioctl);
|
||||
io->version[0] = 4;
|
||||
io->version[1] = 0;
|
||||
|
@ -35,8 +35,8 @@ 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) {
|
||||
fs_mgr_verity_ioctl_init(io, name);
|
||||
bool fs_mgr_dm_create_device(struct dm_ioctl* io, const std::string& name, int fd) {
|
||||
fs_mgr_dm_ioctl_init(io, sizeof(*io), name);
|
||||
if (ioctl(fd, DM_DEV_CREATE, io)) {
|
||||
PERROR << "Error creating device mapping";
|
||||
return false;
|
||||
|
@ -44,8 +44,8 @@ bool fs_mgr_create_verity_device(struct dm_ioctl* io, const std::string& name, i
|
|||
return true;
|
||||
}
|
||||
|
||||
bool fs_mgr_destroy_verity_device(struct dm_ioctl* io, const std::string& name, int fd) {
|
||||
fs_mgr_verity_ioctl_init(io, name);
|
||||
bool fs_mgr_dm_destroy_device(struct dm_ioctl* io, const std::string& name, int fd) {
|
||||
fs_mgr_dm_ioctl_init(io, sizeof(*io), name);
|
||||
if (ioctl(fd, DM_DEV_REMOVE, io)) {
|
||||
PERROR << "Error removing device mapping";
|
||||
return false;
|
||||
|
@ -53,13 +53,13 @@ bool fs_mgr_destroy_verity_device(struct dm_ioctl* io, const std::string& name,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool fs_mgr_get_verity_device_name(struct dm_ioctl* io, const std::string& name, int fd,
|
||||
std::string* out_dev_name) {
|
||||
bool fs_mgr_dm_get_device_name(struct dm_ioctl* io, const std::string& name, int fd,
|
||||
std::string* out_dev_name) {
|
||||
FS_MGR_CHECK(out_dev_name != nullptr);
|
||||
|
||||
fs_mgr_verity_ioctl_init(io, name);
|
||||
fs_mgr_dm_ioctl_init(io, sizeof(*io), name);
|
||||
if (ioctl(fd, DM_DEV_STATUS, io)) {
|
||||
PERROR << "Error fetching verity device number";
|
||||
PERROR << "Error fetching device-mapper device number";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -69,10 +69,10 @@ bool fs_mgr_get_verity_device_name(struct dm_ioctl* io, const std::string& name,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool fs_mgr_resume_verity_table(struct dm_ioctl* io, const std::string& name, int fd) {
|
||||
fs_mgr_verity_ioctl_init(io, name);
|
||||
bool fs_mgr_dm_resume_table(struct dm_ioctl* io, const std::string& name, int fd) {
|
||||
fs_mgr_dm_ioctl_init(io, sizeof(*io), name);
|
||||
if (ioctl(fd, DM_DEV_SUSPEND, io)) {
|
||||
PERROR << "Error activating verity device";
|
||||
PERROR << "Error activating device table";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -20,15 +20,15 @@
|
|||
#include <linux/dm-ioctl.h>
|
||||
#include <string>
|
||||
|
||||
void fs_mgr_verity_ioctl_init(struct dm_ioctl* io, const std::string& name);
|
||||
void fs_mgr_dm_ioctl_init(struct dm_ioctl* io, size_t size, const std::string& name);
|
||||
|
||||
bool fs_mgr_create_verity_device(struct dm_ioctl* io, const std::string& name, int fd);
|
||||
bool fs_mgr_dm_create_device(struct dm_ioctl* io, const std::string& name, int fd);
|
||||
|
||||
bool fs_mgr_destroy_verity_device(struct dm_ioctl* io, const std::string& name, int fd);
|
||||
bool fs_mgr_dm_destroy_device(struct dm_ioctl* io, const std::string& name, int fd);
|
||||
|
||||
bool fs_mgr_get_verity_device_name(struct dm_ioctl* io, const std::string& name, int fd,
|
||||
std::string* out_dev_name);
|
||||
bool fs_mgr_dm_get_device_name(struct dm_ioctl* io, const std::string& name, int fd,
|
||||
std::string* out_dev_name);
|
||||
|
||||
bool fs_mgr_resume_verity_table(struct dm_ioctl* io, const std::string& name, int fd);
|
||||
bool fs_mgr_dm_resume_table(struct dm_ioctl* io, const std::string& name, int fd);
|
||||
|
||||
#endif /* __CORE_FS_MGR_PRIV_DM_IOCTL_H */
|
||||
|
|
|
@ -258,7 +258,7 @@ 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);
|
||||
fs_mgr_dm_ioctl_init(io, DM_BUF_SIZE, name);
|
||||
|
||||
struct dm_target_spec *tgt = (struct dm_target_spec *) &buffer[sizeof(struct dm_ioctl)];
|
||||
|
||||
|
@ -805,13 +805,13 @@ int fs_mgr_setup_verity(struct fstab_rec *fstab, bool wait_for_verity_dev)
|
|||
}
|
||||
|
||||
// create the device
|
||||
if (!fs_mgr_create_verity_device(io, mount_point, fd)) {
|
||||
if (!fs_mgr_dm_create_device(io, mount_point, fd)) {
|
||||
LERROR << "Couldn't create verity device!";
|
||||
goto out;
|
||||
}
|
||||
|
||||
// get the name of the device file
|
||||
if (!fs_mgr_get_verity_device_name(io, mount_point, fd, &verity_blk_name)) {
|
||||
if (!fs_mgr_dm_get_device_name(io, mount_point, fd, &verity_blk_name)) {
|
||||
LERROR << "Couldn't get verity device number!";
|
||||
goto out;
|
||||
}
|
||||
|
@ -900,7 +900,7 @@ int fs_mgr_setup_verity(struct fstab_rec *fstab, bool wait_for_verity_dev)
|
|||
loaded:
|
||||
|
||||
// activate the device
|
||||
if (!fs_mgr_resume_verity_table(io, mount_point, fd)) {
|
||||
if (!fs_mgr_dm_resume_table(io, mount_point, fd)) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -923,7 +923,7 @@ loaded:
|
|||
if (!verified_at_boot) {
|
||||
free(fstab->blk_device);
|
||||
fstab->blk_device = strdup(verity_blk_name.c_str());
|
||||
} else if (!fs_mgr_destroy_verity_device(io, mount_point, fd)) {
|
||||
} else if (!fs_mgr_dm_destroy_device(io, mount_point, fd)) {
|
||||
LERROR << "Failed to remove verity device " << mount_point.c_str();
|
||||
goto out;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue