From 9d68335556ae786525458249a893e64b06cf5a57 Mon Sep 17 00:00:00 2001 From: chengjinsong Date: Fri, 30 Sep 2022 10:02:09 +0800 Subject: [PATCH] fixed e64623a from https://gitee.com/chneg-jinsong/startup_init_lite/pulls/1339 nofail Signed-off-by: chengjinsong Change-Id: I59f131d939c780c4208b8a49690ba3d562c3a3f3 --- interfaces/innerkits/fs_manager/fstab.c | 1 + interfaces/innerkits/fs_manager/fstab_mount.c | 7 ++++++- interfaces/innerkits/include/fs_manager/fs_manager.h | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/interfaces/innerkits/fs_manager/fstab.c b/interfaces/innerkits/fs_manager/fstab.c index 00f492d3..6645d5a1 100644 --- a/interfaces/innerkits/fs_manager/fstab.c +++ b/interfaces/innerkits/fs_manager/fstab.c @@ -50,6 +50,7 @@ static unsigned int ConvertFlags(char *flagBuffer) {"check", FS_MANAGER_CHECK}, {"wait", FS_MANAGER_WAIT}, {"required", FS_MANAGER_REQUIRED}, + {"nofail", FS_MANAGER_NOFAIL}, }; BEGET_CHECK_RETURN_VALUE(flagBuffer != NULL && *flagBuffer != '\0', 0); // No valid flags. diff --git a/interfaces/innerkits/fs_manager/fstab_mount.c b/interfaces/innerkits/fs_manager/fstab_mount.c index 80995bf7..154e7121 100644 --- a/interfaces/innerkits/fs_manager/fstab_mount.c +++ b/interfaces/innerkits/fs_manager/fstab_mount.c @@ -406,7 +406,12 @@ int MountOneItem(FstabItem *item) int rc = Mount(item->deviceName, item->mountPoint, item->fsType, mountFlags, fsSpecificData); if (rc != 0) { - BEGET_LOGE("Mount %s to %s failed %d", item->deviceName, item->mountPoint, errno); + if (FM_MANAGER_NOFAIL_ENABLED(item->fsManagerFlags)) { + BEGET_LOGE("Mount no fail device %s to %s failed, err = %d", item->deviceName, item->mountPoint, errno); + } else { + BEGET_LOGW("Mount %s to %s failed, err = %d. Ignore failure", item->deviceName, item->mountPoint, errno); + rc = 0; + } } else { BEGET_LOGI("Mount %s to %s successful", item->deviceName, item->mountPoint); } diff --git a/interfaces/innerkits/include/fs_manager/fs_manager.h b/interfaces/innerkits/include/fs_manager/fs_manager.h index 0446e774..5c59fb02 100644 --- a/interfaces/innerkits/include/fs_manager/fs_manager.h +++ b/interfaces/innerkits/include/fs_manager/fs_manager.h @@ -29,6 +29,7 @@ extern "C" { #define FS_MANAGER_CHECK 0x00000001 #define FS_MANAGER_WAIT 0x00000002 #define FS_MANAGER_REQUIRED 0x00000004 +#define FS_MANAGER_NOFAIL 0x00000008 #define NAME_SIZE 32 #define MAX_SLOT 2 @@ -38,6 +39,7 @@ extern "C" { #define FM_MANAGER_CHECK_ENABLED(fsMgrFlags) FS_MANAGER_FLAGS_ENABLED((fsMgrFlags), CHECK) #define FM_MANAGER_WAIT_ENABLED(fsMgrFlags) FS_MANAGER_FLAGS_ENABLED((fsMgrFlags), WAIT) #define FM_MANAGER_REQUIRED_ENABLED(fsMgrFlags) FS_MANAGER_FLAGS_ENABLED((fsMgrFlags), REQUIRED) +#define FM_MANAGER_NOFAIL_ENABLED(fsMgrFlags) FS_MANAGER_FLAGS_ENABLED((fsMgrFlags), NOFAIL) typedef enum MountStatus { MOUNT_ERROR = -1, -- GitLab