From a4d1867308d284dcbd9f96e8bf54df248568eff8 Mon Sep 17 00:00:00 2001 From: limingkang Date: Fri, 24 Feb 2023 17:59:44 +0800 Subject: [PATCH] update cmdline info for hvb Signed-off-by: limingkang Change-Id: I9710ba13a44ba80b2901fa2c4a75071b46d3f6dd --- .../innerkits/fs_manager/dm_verity/dm_verity.c | 13 +++++++------ interfaces/innerkits/fs_manager/libfs_hvb/fs_hvb.c | 6 ++---- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/interfaces/innerkits/fs_manager/dm_verity/dm_verity.c b/interfaces/innerkits/fs_manager/dm_verity/dm_verity.c index 229ddfee..aa9d6f0a 100755 --- a/interfaces/innerkits/fs_manager/dm_verity/dm_verity.c +++ b/interfaces/innerkits/fs_manager/dm_verity/dm_verity.c @@ -15,6 +15,7 @@ #include "dm_verity.h" #include "fs_hvb.h" +#include "hvb_cmdline.h" #include "securec.h" #include "beget_ext.h" #include @@ -25,10 +26,9 @@ extern "C" { #endif #endif -#define HVB_VERIFIEDBOOT_STATE_STR_MAX_LEN 32 -#define HVB_CMDLINE_VERIFIEDBOOT_STATE "ohos.boot.verifiedbootstate" +#define HVB_VB_STATE_STR_MAX_LEN 32 #define HVB_FORCE_ENABLE_STR_MAX_LEN 16 -#define HVB_CMDLINE_HVB_FORCE_ENABLE "ohos.boot.oem_swtype" +#define HVB_CMDLINE_HVB_FORCE_ENABLE "ohos.boot.hvb.oem_swtype" #define DM_VERITY_RETURN_ERR_IF_NULL(__ptr) \ do { \ @@ -42,20 +42,21 @@ static bool HvbDmVerityIsEnable() { int rc; char forceEnable[HVB_FORCE_ENABLE_STR_MAX_LEN] = {0}; - char verifiedBootState[HVB_VERIFIEDBOOT_STATE_STR_MAX_LEN] = {0}; + char vBState[HVB_VB_STATE_STR_MAX_LEN] = {0}; rc = FsHvbGetValueFromCmdLine(&forceEnable[0], sizeof(forceEnable), HVB_CMDLINE_HVB_FORCE_ENABLE); if (rc == 0 && strcmp(&forceEnable[0], "factory") == 0) { return true; } - rc = FsHvbGetValueFromCmdLine(&verifiedBootState[0], sizeof(verifiedBootState), HVB_CMDLINE_VERIFIEDBOOT_STATE); + rc = FsHvbGetValueFromCmdLine(&vBState[0], sizeof(vBState), HVB_CMDLINE_VB_STATE); + if (rc != 0) { BEGET_LOGE("error 0x%x, get verifed boot state", rc); return false; } - if (strcmp(&verifiedBootState[0], "orange") == 0 || strcmp(&verifiedBootState[0], "ORANGE")) { + if (strcmp(&vBState[0], "false") == 0 || strcmp(&vBState[0], "FALSE") == 0) { return false; } diff --git a/interfaces/innerkits/fs_manager/libfs_hvb/fs_hvb.c b/interfaces/innerkits/fs_manager/libfs_hvb/fs_hvb.c index ab858720..067c5e65 100755 --- a/interfaces/innerkits/fs_manager/libfs_hvb/fs_hvb.c +++ b/interfaces/innerkits/fs_manager/libfs_hvb/fs_hvb.c @@ -41,8 +41,6 @@ extern "C" { #define FS_HVB_DEVPATH_MAX_LEN 128 #define FS_HVB_RVT_PARTITION_NAME "rvt" #define FS_HVB_CMDLINE_PATH "/proc/cmdline" -#define FS_HVB_CMDLINE_HASH_ALG "ohos.boot.hvb.hash_algo" -#define FS_HVB_CMDLINE_CERT_DIGEST "ohos.boot.rvt.digest" #define FS_HVB_PARTITION_PREFIX "/dev/block/by-name/" #define FS_HVB_RETURN_ERR_IF_NULL(__ptr) \ @@ -67,12 +65,12 @@ static char FsHvbHexCharToBin(char hex) static int FsHvbGetHashStr(char *str, size_t size) { - return FsHvbGetValueFromCmdLine(str, size, FS_HVB_CMDLINE_HASH_ALG); + return FsHvbGetValueFromCmdLine(str, size, HVB_CMDLINE_HASH_ALG); } static int FsHvbGetCertDigstStr(char *str, size_t size) { - return FsHvbGetValueFromCmdLine(str, size, FS_HVB_CMDLINE_CERT_DIGEST); + return FsHvbGetValueFromCmdLine(str, size, HVB_CMDLINE_CERT_DIGEST); } static int FsHvbComputeSha256(char *digest, size_t size, struct hvb_cert_data *certs, uint64_t num_certs) -- GitLab