未验证 提交 898339c0 编写于 作者: O openharmony_ci 提交者: Gitee

!1824 告警清理

Merge pull request !1824 from 李明康/0313告警处理
...@@ -38,7 +38,7 @@ extern "C" { ...@@ -38,7 +38,7 @@ extern "C" {
} \ } \
} while (0) } while (0)
static bool HvbDmVerityIsEnable() static bool HvbDmVerityIsEnable(void)
{ {
int rc; int rc;
char forceEnable[HVB_FORCE_ENABLE_STR_MAX_LEN] = {0}; char forceEnable[HVB_FORCE_ENABLE_STR_MAX_LEN] = {0};
...@@ -80,7 +80,7 @@ int HvbDmVerityinit(const Fstab *fstab) ...@@ -80,7 +80,7 @@ int HvbDmVerityinit(const Fstab *fstab)
if (p == NULL) { if (p == NULL) {
BEGET_LOGI("no need init fs hvb"); BEGET_LOGI("no need init fs hvb");
// return 0; return 0;
} }
rc = FsHvbInit(); rc = FsHvbInit();
......
...@@ -452,7 +452,7 @@ static int CheckRequiredAndMount(FstabItem *item, bool required) ...@@ -452,7 +452,7 @@ static int CheckRequiredAndMount(FstabItem *item, bool required)
rc = HvbDmVeritySetUp(item); rc = HvbDmVeritySetUp(item);
if (rc != 0) { if (rc != 0) {
BEGET_LOGE("set dm_verity err, ret = 0x%x", rc); BEGET_LOGE("set dm_verity err, ret = 0x%x", rc);
// return rc; return rc;
} }
#endif #endif
rc = MountOneItem(item); rc = MountOneItem(item);
...@@ -479,7 +479,7 @@ int MountAllWithFstab(const Fstab *fstab, bool required) ...@@ -479,7 +479,7 @@ int MountAllWithFstab(const Fstab *fstab, bool required)
rc = HvbDmVerityinit(fstab); rc = HvbDmVerityinit(fstab);
if (rc != 0) { if (rc != 0) {
BEGET_LOGE("set dm_verity init, ret = 0x%x", rc); BEGET_LOGE("set dm_verity init, ret = 0x%x", rc);
// return rc; return rc;
} }
} }
#endif #endif
......
...@@ -97,7 +97,8 @@ static int CreateDmDevice(int fd, const char *devName) ...@@ -97,7 +97,8 @@ static int CreateDmDevice(int fd, const char *devName)
return 0; return 0;
} }
static int LoadDmDeviceTable(int fd, const char *devName, DmVerityTarget *target) static int LoadDmDeviceTable(int fd, const char *devName,
DmVerityTarget *target)
{ {
int rc; int rc;
errno_t err; errno_t err;
......
...@@ -284,9 +284,9 @@ static int FsHvbVerityTargetAppendOctets(char **p, char *end, char *octs, size_t ...@@ -284,9 +284,9 @@ static int FsHvbVerityTargetAppendOctets(char **p, char *end, char *octs, size_t
} }
rc = FsHvbVerityTargetAppendString(p, end, str, str_len); rc = FsHvbVerityTargetAppendString(p, end, str, str_len);
if (rc != 0) if (rc != 0) {
BEGET_LOGE("error 0x%x, append str fail", rc); BEGET_LOGE("error 0x%x, append str fail", rc);
}
free(str); free(str);
return rc; return rc;
...@@ -380,7 +380,7 @@ static int FsHvbConstructVerityTarget(DmVerityTarget *target, char *devName, str ...@@ -380,7 +380,7 @@ static int FsHvbConstructVerityTarget(DmVerityTarget *target, char *devName, str
if (snprintf_s(&devPath[0], sizeof(devPath), sizeof(devPath) - 1, "%s%s", FS_HVB_PARTITION_PREFIX, devName) == -1) { if (snprintf_s(&devPath[0], sizeof(devPath), sizeof(devPath) - 1, "%s%s", FS_HVB_PARTITION_PREFIX, devName) == -1) {
BEGET_LOGE("error, snprintf_s devPath"); BEGET_LOGE("error, snprintf_s devPath");
return -1; return -1;
} }
BEGET_LOGE("puck devPath=%s", &devPath[0]); BEGET_LOGE("puck devPath=%s", &devPath[0]);
......
...@@ -13,14 +13,15 @@ ...@@ -13,14 +13,15 @@
* limitations under the License. * limitations under the License.
*/ */
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include "beget_ext.h" #include "beget_ext.h"
#include "fs_dm.h" #include "fs_dm.h"
#include "fs_hvb.h" #include "fs_hvb.h"
#include "securec.h" #include "securec.h"
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
...@@ -28,9 +29,9 @@ extern "C" { ...@@ -28,9 +29,9 @@ extern "C" {
#endif #endif
#endif #endif
#define PARTITION_PATH_PREFIX "/dev/block/by-name/" #define PARTITION_PATH_PREFIX "/dev/block/by-name/"
static int64_t GetImageSizeForHVB(const int fd, const char *image) static int64_t GetImageSizeForHVB(const int fd, const char* image)
{ {
if (fd < 0) { if (fd < 0) {
BEGET_LOGE("param is error"); BEGET_LOGE("param is error");
...@@ -40,12 +41,14 @@ static int64_t GetImageSizeForHVB(const int fd, const char *image) ...@@ -40,12 +41,14 @@ static int64_t GetImageSizeForHVB(const int fd, const char *image)
return lseek64(fd, 0, SEEK_END); return lseek64(fd, 0, SEEK_END);
} }
static enum hvb_io_errno HvbReadFromPartition( static enum hvb_io_errno HvbReadFromPartition(struct hvb_ops* ops,
struct hvb_ops *ops, const char *partition, int64_t offset, uint64_t numBytes, void *buf, uint64_t *outNumRead) const char* partition,
int64_t offset, uint64_t numBytes,
void* buf, uint64_t* outNumRead)
{ {
int rc; int rc;
int fd = -1; int fd = -1;
char *path = NULL; char* path = NULL;
size_t pathLen = 0; size_t pathLen = 0;
enum hvb_io_errno ret = HVB_IO_ERROR_IO; enum hvb_io_errno ret = HVB_IO_ERROR_IO;
...@@ -66,20 +69,23 @@ static enum hvb_io_errno HvbReadFromPartition( ...@@ -66,20 +69,23 @@ static enum hvb_io_errno HvbReadFromPartition(
return HVB_IO_ERROR_OOM; return HVB_IO_ERROR_OOM;
} }
rc = snprintf_s(path, pathLen + 1, pathLen, "%s%s", PARTITION_PATH_PREFIX, partition); rc = snprintf_s(path, pathLen + 1, pathLen, "%s%s", PARTITION_PATH_PREFIX,
partition);
if (rc < 0) { if (rc < 0) {
BEGET_LOGE("error, snprintf_s fail, ret = %d", rc); BEGET_LOGE("error, snprintf_s fail, ret = %d", rc);
ret = HVB_IO_ERROR_IO; ret = HVB_IO_ERROR_IO;
goto exit; goto exit;
} }
fd = open(path , O_RDONLY | O_CLOEXEC); fd = open(path, O_RDONLY | O_CLOEXEC);
if (fd < 0) { if (fd < 0) {
BEGET_LOGE("error, Failed to open %s, errno = %d", path, errno); BEGET_LOGE("error, Failed to open %s, errno = %d", path, errno);
fd = open("/dev/block/by-name/rvt_system", O_RDONLY | O_CLOEXEC); fd = open("/dev/block/by-name/rvt_system", O_RDONLY | O_CLOEXEC);
BEGET_LOGE("open %s, fd=%d errno = %d", "/dev/block/by-name/rvt_system", fd, errno); BEGET_LOGE("open %s, fd=%d errno = %d", "/dev/block/by-name/rvt_system",
if (fd >= 0) fd, errno);
if (fd >= 0) {
close(fd); close(fd);
}
ret = HVB_IO_ERROR_IO; ret = HVB_IO_ERROR_IO;
goto exit; goto exit;
} }
...@@ -91,14 +97,15 @@ static enum hvb_io_errno HvbReadFromPartition( ...@@ -91,14 +97,15 @@ static enum hvb_io_errno HvbReadFromPartition(
ret = HVB_IO_ERROR_IO; ret = HVB_IO_ERROR_IO;
goto exit; goto exit;
} }
offset = total_size + offset; offset = total_size + offset;
} }
lseek64(fd, offset, SEEK_SET); lseek64(fd, offset, SEEK_SET);
ssize_t numRead = read(fd, buf, numBytes); ssize_t numRead = read(fd, buf, numBytes);
if (numRead < 0 || (size_t)numRead != numBytes) { if (numRead < 0 || (size_t)numRead != numBytes) {
BEGET_LOGE("Failed to read %lld bytes from %s offset %lld", numBytes, path, offset); BEGET_LOGE("Failed to read %lld bytes from %s offset %lld", numBytes,
path, offset);
ret = HVB_IO_ERROR_IO; ret = HVB_IO_ERROR_IO;
goto exit; goto exit;
} }
...@@ -111,23 +118,30 @@ static enum hvb_io_errno HvbReadFromPartition( ...@@ -111,23 +118,30 @@ static enum hvb_io_errno HvbReadFromPartition(
exit: exit:
if (path != NULL) if (path != NULL) {
free(path); free(path);
}
if (fd >= 0) if (fd >= 0) {
close(fd); close(fd);
}
return ret; return ret;
} }
static enum hvb_io_errno HvbWriteToPartition( static enum hvb_io_errno HvbWriteToPartition(struct hvb_ops* ops,
struct hvb_ops *ops, const char *partition, int64_t offset, uint64_t numBytes, const void *buf) const char* partition,
int64_t offset, uint64_t numBytes,
const void* buf)
{ {
return HVB_IO_OK; return HVB_IO_OK;
} }
static enum hvb_io_errno HvbInvaldateKey(struct hvb_ops *ops, const uint8_t *publicKeyData, uint64_t publicKeyLength, static enum hvb_io_errno HvbInvaldateKey(struct hvb_ops* ops,
const uint8_t *publicKeyMetadata, uint64_t publicKeyMetadataLength, bool *outIsTrusted) const uint8_t* publicKeyData,
uint64_t publicKeyLength,
const uint8_t* publicKeyMetadata,
uint64_t publicKeyMetadataLength,
bool* outIsTrusted)
{ {
if (outIsTrusted == NULL) { if (outIsTrusted == NULL) {
return HVB_IO_ERROR_IO; return HVB_IO_ERROR_IO;
...@@ -138,8 +152,9 @@ static enum hvb_io_errno HvbInvaldateKey(struct hvb_ops *ops, const uint8_t *pub ...@@ -138,8 +152,9 @@ static enum hvb_io_errno HvbInvaldateKey(struct hvb_ops *ops, const uint8_t *pub
return HVB_IO_OK; return HVB_IO_OK;
} }
static enum hvb_io_errno HvbReadRollbackIdx( static enum hvb_io_errno HvbReadRollbackIdx(struct hvb_ops* ops,
struct hvb_ops *ops, uint64_t rollBackIndexLocation, uint64_t *outRollbackIndex) uint64_t rollBackIndexLocation,
uint64_t* outRollbackIndex)
{ {
if (outRollbackIndex == NULL) { if (outRollbackIndex == NULL) {
return HVB_IO_ERROR_IO; return HVB_IO_ERROR_IO;
...@@ -151,18 +166,22 @@ static enum hvb_io_errno HvbReadRollbackIdx( ...@@ -151,18 +166,22 @@ static enum hvb_io_errno HvbReadRollbackIdx(
return HVB_IO_OK; return HVB_IO_OK;
} }
static enum hvb_io_errno HvbWriteRollbackIdx( static enum hvb_io_errno HvbWriteRollbackIdx(struct hvb_ops* ops,
struct hvb_ops *ops, uint64_t rollBackIndexLocation, uint64_t rollbackIndex) uint64_t rollBackIndexLocation,
uint64_t rollbackIndex)
{ {
return HVB_IO_OK; return HVB_IO_OK;
} }
static enum hvb_io_errno HvbReadLockState(struct hvb_ops *ops, bool *lock_state) static enum hvb_io_errno HvbReadLockState(struct hvb_ops* ops,
bool* lock_state)
{ {
return HVB_IO_OK; return HVB_IO_OK;
} }
static enum hvb_io_errno HvbGetSizeOfPartition(struct hvb_ops *ops, const char *partition, uint64_t *size) static enum hvb_io_errno HvbGetSizeOfPartition(struct hvb_ops* ops,
const char* partition,
uint64_t* size)
{ {
if (size == NULL) { if (size == NULL) {
return HVB_IO_ERROR_IO; return HVB_IO_ERROR_IO;
...@@ -186,7 +205,7 @@ static struct hvb_ops g_hvb_ops = { ...@@ -186,7 +205,7 @@ static struct hvb_ops g_hvb_ops = {
.get_partiton_size = HvbGetSizeOfPartition, .get_partiton_size = HvbGetSizeOfPartition,
}; };
struct hvb_ops *FsHvbGetOps(void) struct hvb_ops* FsHvbGetOps(void)
{ {
return &g_hvb_ops; return &g_hvb_ops;
} }
......
...@@ -38,7 +38,7 @@ WatcherManager::~WatcherManager() ...@@ -38,7 +38,7 @@ WatcherManager::~WatcherManager()
uint32_t WatcherManager::AddRemoteWatcher(uint32_t id, const sptr<IWatcher> &watcher) uint32_t WatcherManager::AddRemoteWatcher(uint32_t id, const sptr<IWatcher> &watcher)
{ {
if (id == (uint32_t)getpid()) { if (id == static_cast<uint32_t>(getpid())) {
WATCHER_LOGE("Failed to add remote watcher %u", id); WATCHER_LOGE("Failed to add remote watcher %u", id);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册