Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 73bf853e authored by Elliott Hughes's avatar Elliott Hughes Committed by Gerrit Code Review
Browse files

Merge "Switch fs_mgr_verity.c to C++."

parents f8376607 246c18ca
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_SRC_FILES:= fs_mgr.c fs_mgr_verity.c fs_mgr_fstab.c
LOCAL_SRC_FILES:= fs_mgr.c fs_mgr_verity.cpp fs_mgr_fstab.c
LOCAL_SRC_FILES += fs_mgr_format.c fs_mgr_slotselect.c

LOCAL_C_INCLUDES := $(LOCAL_PATH)/include \
+4 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@
#include <cutils/klog.h>
#include <fs_mgr.h>

__BEGIN_DECLS

#define INFO(x...)    KLOG_INFO("fs_mgr", x)
#define WARNING(x...) KLOG_WARNING("fs_mgr", x)
#define ERROR(x...)   KLOG_ERROR("fs_mgr", x)
@@ -86,4 +88,6 @@
int fs_mgr_set_blk_ro(const char *blockdev);
int fs_mgr_update_for_slotselect(struct fstab *fstab);

__END_DECLS

#endif /* __CORE_FS_MGR_PRIV_H */
+7 −0
Original line number Diff line number Diff line
@@ -14,7 +14,14 @@
 * limitations under the License.
 */

#include <sys/cdefs.h>

#define FS_MGR_SETUP_VERITY_DISABLED -2
#define FS_MGR_SETUP_VERITY_FAIL -1
#define FS_MGR_SETUP_VERITY_SUCCESS 0

__BEGIN_DECLS

int fs_mgr_setup_verity(struct fstab_rec *fstab);

__END_DECLS
+8 −10
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@
#include "ext4_sb.h"
#include "squashfs_utils.h"

#include "fs_mgr.h"
#include "fs_mgr_priv.h"
#include "fs_mgr_priv_verity.h"

@@ -74,18 +75,15 @@ struct verity_state {

extern struct fs_info info;

static RSAPublicKey *load_key(char *path)
static RSAPublicKey *load_key(const char *path)
{
    FILE *f;
    RSAPublicKey *key;

    key = malloc(sizeof(RSAPublicKey));
    RSAPublicKey* key = static_cast<RSAPublicKey*>(malloc(sizeof(RSAPublicKey)));
    if (!key) {
        ERROR("Can't malloc key\n");
        return NULL;
    }

    f = fopen(path, "r");
    FILE* f = fopen(path, "r");
    if (!f) {
        ERROR("Can't open '%s'\n", path);
        free(key);
@@ -314,7 +312,7 @@ static int read_verity_metadata(uint64_t device_size, char *block_device, char *
    }

    // get the table + null terminator
    *table = malloc(table_length + 1);
    *table = static_cast<char*>(malloc(table_length + 1));
    if (!*table) {
        ERROR("Couldn't allocate memory for verity table!\n");
        goto out;
@@ -887,7 +885,7 @@ out:

int fs_mgr_update_verity_state(fs_mgr_verity_state_callback callback)
{
    _Alignas(struct dm_ioctl) char buffer[DM_BUF_SIZE];
    alignas(dm_ioctl) char buffer[DM_BUF_SIZE];
    bool use_state = true;
    char fstab_filename[PROPERTY_VALUE_MAX + sizeof(FSTAB_PREFIX)];
    char *mount_point;
@@ -989,7 +987,7 @@ int fs_mgr_setup_verity(struct fstab_rec *fstab) {
    int verity_table_length = 0;
    uint64_t device_size = 0;

    _Alignas(struct dm_ioctl) char buffer[DM_BUF_SIZE];
    alignas(dm_ioctl) char buffer[DM_BUF_SIZE];
    struct dm_ioctl *io = (struct dm_ioctl *) buffer;
    char *mount_point = basename(fstab->mount_point);