提交 faf97285 编写于 作者: L ljc

fix switch root bug

Signed-off-by: Nljc <chengjinsong2@huawei.com>
上级 73b064c9
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "init_log.h" #include "init_log.h"
#include "fs_manager/fs_manager.h" #include "fs_manager/fs_manager.h"
#include "securec.h" #include "securec.h"
#include "init_utils.h"
static void FreeOldRoot(DIR *dir, dev_t dev) static void FreeOldRoot(DIR *dir, dev_t dev)
{ {
...@@ -77,20 +78,13 @@ static void FreeOldRoot(DIR *dir, dev_t dev) ...@@ -77,20 +78,13 @@ static void FreeOldRoot(DIR *dir, dev_t dev)
// all sub mount tree in the future. // all sub mount tree in the future.
static bool UnderBasicMountPoint(const char *path) static bool UnderBasicMountPoint(const char *path)
{ {
unsigned int i;
if (path == NULL || *path == '\0') { if (path == NULL || *path == '\0') {
return false; return false;
} }
const char *basicMountPoint[] = {"/dev/", "/sys/", "/proc/"};
size_t pathSize = strlen(path); for (i = 0; i < ARRAY_LENGTH(basicMountPoint); i++) {
if (strncmp(path, "/dev/", strlen("/dev/")) == 0 && pathSize > strlen("/dev/")) { if (strncmp(path, basicMountPoint[i], strlen(basicMountPoint[i])) == 0)
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; return true;
} }
return false; return false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册