!1306 修复sys_prod挂载unmount丢失

Merge pull request !1306 from cheng_jinsong/fix_under_mount
This commit is contained in:
openharmony_ci 2022-09-27 09:37:50 +00:00 committed by Gitee
commit 69df15ef8e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -25,6 +25,7 @@
#include "init_log.h"
#include "fs_manager/fs_manager.h"
#include "securec.h"
#include "init_utils.h"
static void FreeOldRoot(DIR *dir, dev_t dev)
{
@ -77,21 +78,14 @@ static void FreeOldRoot(DIR *dir, dev_t dev)
// all sub mount tree in the future.
static bool UnderBasicMountPoint(const char *path)
{
unsigned int i;
if (path == NULL || *path == '\0') {
return false;
}
size_t pathSize = strlen(path);
if (strncmp(path, "/dev/", strlen("/dev/")) == 0 && pathSize > strlen("/dev/")) {
return true;
}
if (strncmp(path, "/sys/", strlen("/sys/")) == 0 && pathSize > strlen("/sys/")) {
return true;
}
if (strncmp(path, "/proc/", strlen("/proc/")) == 0 && pathSize > strlen("/proc/")) {
return true;
const char *basicMountPoint[] = {"/dev/", "/sys/", "/proc/"};
for (i = 0; i < ARRAY_LENGTH(basicMountPoint); i++) {
if (strncmp(path, basicMountPoint[i], strlen(basicMountPoint[i])) == 0)
return true;
}
return false;
}