update services/init/standard/device.c.

先判断dev是否已挂载文件系统,没有挂载则挂载tmpfs,已经挂载则不再重复挂载。

Signed-off-by: liangshenglin1 <liangshenglin1@huawei.com>
This commit is contained in:
liangshenglin1 2023-12-30 12:08:06 +00:00 committed by Gitee
parent c246fbeb58
commit 7c9faf6f1c
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -14,6 +14,7 @@
*/
#include "device.h"
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/mount.h>
@ -28,8 +29,13 @@
static void MountBasicFs(void)
{
if (mount("tmpfs", "/dev", "tmpfs", MS_NOSUID, "mode=0755") != 0) {
INIT_LOGE("Mount tmpfs failed. %s", strerror(errno));
if (access("dev/null", F_OK) != 0) {
INIT_LOGI("mount dev tmpfs");
if (mount("tmpfs", "/dev", "tmpfs", MS_NOSUID, "mode=0755") != 0) {
INIT_LOGE("Mount tmpfs failed. %s", strerror(errno));
}
} else {
INIT_LOGI("dev already mounted");
}
if (mount("tmpfs", "/mnt", "tmpfs", MS_NOSUID, "mode=0755") != 0) {
INIT_LOGE("Mount tmpfs failed. %s", strerror(errno));