From b5065fcb284a20e8f9f72d896ddba0a2c91f995a Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Wed, 27 Jun 2018 14:57:10 -0700 Subject: [PATCH] fs_mgr: fs_mgr_update_verity_state take std::function By changing to a std:function from a plain function pointer as an argument to fs_mgr_update_verity_state(), a lambda with captured objects can be executed providing thread safety. Test: compile and boot Bug: 109821005 Change-Id: I2699a08cc2c5216625dcbf84eeac0c460f4ae36a --- fs_mgr/fs_mgr.cpp | 3 ++- fs_mgr/include/fs_mgr.h | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/fs_mgr/fs_mgr.cpp b/fs_mgr/fs_mgr.cpp index 6417a5c04..b3df811e4 100644 --- a/fs_mgr/fs_mgr.cpp +++ b/fs_mgr/fs_mgr.cpp @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -1356,7 +1357,7 @@ bool fs_mgr_load_verity_state(int* mode) { return true; } -bool fs_mgr_update_verity_state(fs_mgr_verity_state_callback callback) { +bool fs_mgr_update_verity_state(std::function callback) { if (!callback) { return false; } diff --git a/fs_mgr/include/fs_mgr.h b/fs_mgr/include/fs_mgr.h index c1b2ed97a..1049fb6cc 100644 --- a/fs_mgr/include/fs_mgr.h +++ b/fs_mgr/include/fs_mgr.h @@ -22,6 +22,8 @@ #include #include +#include + #include // Magic number at start of verity metadata @@ -48,8 +50,8 @@ enum mount_mode { }; // Callback function for verity status -typedef void (*fs_mgr_verity_state_callback)(struct fstab_rec *fstab, - const char *mount_point, int mode, int status); +typedef void fs_mgr_verity_state_callback(struct fstab_rec* fstab, const char* mount_point, + int mode, int status); #define FS_MGR_MNTALL_DEV_IS_METADATA_ENCRYPTED 7 #define FS_MGR_MNTALL_DEV_NEEDS_METADATA_ENCRYPTION 6 @@ -73,7 +75,7 @@ int fs_mgr_do_tmpfs_mount(const char *n_name); struct fstab_rec const* fs_mgr_get_crypt_entry(struct fstab const* fstab); void fs_mgr_get_crypt_info(struct fstab* fstab, char* key_loc, char* real_blk_device, size_t size); bool fs_mgr_load_verity_state(int* mode); -bool fs_mgr_update_verity_state(fs_mgr_verity_state_callback callback); +bool fs_mgr_update_verity_state(std::function callback); int fs_mgr_swapon_all(struct fstab *fstab); bool fs_mgr_update_logical_partition(struct fstab_rec* rec);