You need to sign in or sign up before continuing.
提交 a6a19a0d 编写于 作者: H handyohos

bugfix: remove fsmanager_static from libbegetutil.

1) remove fsmanager_static from libbegetutil
2) declare fsmanager_static as inner api for updater only
3) remove begetctl and partitionslot dependency for fsmanager by accessing /dev/block/by-name/misc directly
Signed-off-by: Nhandyohos <zhangxiaotian@huawei.com>
Change-Id: I5288d77b07e5e993cbe68eff8803a130a11b009a

#I5YBEN
上级 894d2c5e
...@@ -73,7 +73,6 @@ ...@@ -73,7 +73,6 @@
"header_files": [ "header_files": [
"init_socket.h", "init_socket.h",
"init_file.h", "init_file.h",
"fs_manager/fs_manager.h",
"init_reboot.h", "init_reboot.h",
"service_control.h", "service_control.h",
"beget_ext.h", "beget_ext.h",
...@@ -87,6 +86,15 @@ ...@@ -87,6 +86,15 @@
}, },
"name": "//base/startup/init/interfaces/innerkits:libbegetutil" "name": "//base/startup/init/interfaces/innerkits:libbegetutil"
}, },
{
"header": {
"header_base": "//base/startup/init/interfaces/innerkits/include/fs_manager/",
"header_files": [
"fs_manager.h"
]
},
"name": "//base/startup/init/interfaces/innerkits/fs_manager:libfsmanager_static"
},
{ {
"header": { "header": {
"header_base": "//base/startup/init/interfaces/innerkits/include/", "header_base": "//base/startup/init/interfaces/innerkits/include/",
......
...@@ -25,7 +25,6 @@ config("exported_header_files") { ...@@ -25,7 +25,6 @@ config("exported_header_files") {
include_dirs = [ include_dirs = [
"//base/startup/init/interfaces/innerkits/include", "//base/startup/init/interfaces/innerkits/include",
"//base/startup/init/interfaces/innerkits/include/syspara", "//base/startup/init/interfaces/innerkits/include/syspara",
"//base/startup/init/interfaces/innerkits/include/fs_manager",
"//base/startup/init/interfaces/innerkits/include/token", "//base/startup/init/interfaces/innerkits/include/token",
"//base/startup/init/services/include", "//base/startup/init/services/include",
] ]
...@@ -177,7 +176,6 @@ if (defined(ohos_lite)) { ...@@ -177,7 +176,6 @@ if (defined(ohos_lite)) {
"//base/startup/init/interfaces/innerkits/control_fd:libcontrolfd", "//base/startup/init/interfaces/innerkits/control_fd:libcontrolfd",
"//base/startup/init/interfaces/innerkits/fd_holder:fdholder", "//base/startup/init/interfaces/innerkits/fd_holder:fdholder",
"//base/startup/init/interfaces/innerkits/file:libfile", "//base/startup/init/interfaces/innerkits/file:libfile",
"//base/startup/init/interfaces/innerkits/fs_manager:libfsmanager_static",
"//base/startup/init/interfaces/innerkits/socket:libsocket", "//base/startup/init/interfaces/innerkits/socket:libsocket",
"//base/startup/init/services/log:agent_log", "//base/startup/init/services/log:agent_log",
"//base/startup/init/services/loopevent:loopevent", "//base/startup/init/services/loopevent:loopevent",
......
...@@ -35,15 +35,7 @@ constexpr int PARTITION_INFO_MAX_LENGTH = 256; ...@@ -35,15 +35,7 @@ constexpr int PARTITION_INFO_MAX_LENGTH = 256;
constexpr int BLOCK_SZIE_1 = 512; constexpr int BLOCK_SZIE_1 = 512;
constexpr uint64_t LOGO_MAGIC = 0XABCABCAB; constexpr uint64_t LOGO_MAGIC = 0XABCABCAB;
static std::string GetMiscDevicePath() #define MISC_DEVICE_NODE "/dev/block/by-name/misc"
{
char miscDevice[PATH_MAX] = {0};
int ret = GetBlockDevicePath("/misc", miscDevice, PATH_MAX);
if (ret != 0) {
return std::string("");
}
return std::string(miscDevice);
}
static void ClearLogo(int fd) static void ClearLogo(int fd)
{ {
...@@ -162,28 +154,23 @@ static void WriteLogoToMisc(const std::string &logoPath) ...@@ -162,28 +154,23 @@ static void WriteLogoToMisc(const std::string &logoPath)
std::cout << "logo path is empty\n"; std::cout << "logo path is empty\n";
return; return;
} }
std::string miscDev = GetMiscDevicePath(); int fd = open(MISC_DEVICE_NODE, O_RDWR | O_CLOEXEC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (miscDev.empty()) {
return;
}
BSH_LOGI("WriteLogoToMisc miscDev %s ", miscDev.c_str());
int fd = open(miscDev.c_str(), O_RDWR | O_CLOEXEC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (fd < 0) { if (fd < 0) {
BSH_LOGI("Failed to writeLogoToMisc miscDev %s errno %d ", miscDev.c_str(), errno); BSH_LOGI("Failed to writeLogoToMisc errno %d ", errno);
return; return;
} }
if (WriteLogo(fd, logoPath) < 0) { if (WriteLogo(fd, logoPath) < 0) {
BSH_LOGI("Failed WriteLogo miscDev %s errno %d ", miscDev.c_str(), errno); BSH_LOGI("Failed WriteLogo errno %d ", errno);
} }
close(fd); close(fd);
int addrOffset = (PARTITION_INFO_POS + PARTITION_INFO_MAX_LENGTH + BLOCK_SZIE_1 - 1) / BLOCK_SZIE_1; int addrOffset = (PARTITION_INFO_POS + PARTITION_INFO_MAX_LENGTH + BLOCK_SZIE_1 - 1) / BLOCK_SZIE_1;
int fd1 = open(miscDev.c_str(), O_RDWR | O_CLOEXEC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); int fd1 = open(MISC_DEVICE_NODE, O_RDWR | O_CLOEXEC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (fd1 < 0) { if (fd1 < 0) {
return; return;
} }
if (lseek(fd1, addrOffset * BLOCK_SZIE_1, SEEK_SET) < 0) { if (lseek(fd1, addrOffset * BLOCK_SZIE_1, SEEK_SET) < 0) {
BSH_LOGI("Failed lseek miscDev %s errno %d ", miscDev.c_str(), errno); BSH_LOGI("Failed lseek errno %d ", errno);
close(fd1); close(fd1);
return; return;
} }
...@@ -191,12 +178,12 @@ static void WriteLogoToMisc(const std::string &logoPath) ...@@ -191,12 +178,12 @@ static void WriteLogoToMisc(const std::string &logoPath)
uint32_t magic = 0; uint32_t magic = 0;
uint32_t size = 0; uint32_t size = 0;
if (read(fd1, &magic, sizeof(uint32_t)) != sizeof(uint32_t)) { if (read(fd1, &magic, sizeof(uint32_t)) != sizeof(uint32_t)) {
BSH_LOGI("Failed read miscDev %s errno %d ", miscDev.c_str(), errno); BSH_LOGI("Failed read errno %d ", errno);
close(fd1); close(fd1);
return; return;
} }
if (read(fd1, &size, sizeof(uint32_t)) != sizeof(uint32_t)) { if (read(fd1, &size, sizeof(uint32_t)) != sizeof(uint32_t)) {
BSH_LOGI("Failed read migic miscDev %s errno %d ", miscDev.c_str(), errno); BSH_LOGI("Failed read migic errno %d ", errno);
close(fd1); close(fd1);
return; return;
} }
......
...@@ -115,6 +115,7 @@ ohos_fuzztest("MountAllFstabFuzzTest") { ...@@ -115,6 +115,7 @@ ohos_fuzztest("MountAllFstabFuzzTest") {
deps = [ deps = [
"//base/startup/init/interfaces/innerkits:libbegetutil", "//base/startup/init/interfaces/innerkits:libbegetutil",
"//base/startup/init/interfaces/innerkits/fs_manager:libfsmanager_static",
"//base/startup/init/test/fuzztest:libfuzz_utils", "//base/startup/init/test/fuzztest:libfuzz_utils",
"//third_party/bounds_checking_function:libsec_static", "//third_party/bounds_checking_function:libsec_static",
] ]
...@@ -501,6 +502,7 @@ ohos_fuzztest("UmountAllFstabFuzzTest") { ...@@ -501,6 +502,7 @@ ohos_fuzztest("UmountAllFstabFuzzTest") {
deps = [ deps = [
"//base/startup/init/interfaces/innerkits:libbegetutil", "//base/startup/init/interfaces/innerkits:libbegetutil",
"//base/startup/init/interfaces/innerkits/fs_manager:libfsmanager_static",
"//base/startup/init/test/fuzztest:libfuzz_utils", "//base/startup/init/test/fuzztest:libfuzz_utils",
"//third_party/bounds_checking_function:libsec_static", "//third_party/bounds_checking_function:libsec_static",
] ]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册