提交 a9fc666f 编写于 作者: C chengjinsong

optimize

Signed-off-by: Nchengjinsong <chengjinsong2@huawei.com>
上级 e827e20b
......@@ -61,6 +61,7 @@ static int ExecCommand(int argc, char **argv)
if (argc == 0 || argv == NULL || argv[0] == NULL) {
return -1;
}
BEGET_LOGI("Execute %s begin", argv[0]);
pid_t pid = fork();
if (pid < 0) {
BEGET_LOGE("Fork new process to format failed: %d", errno);
......@@ -75,6 +76,7 @@ static int ExecCommand(int argc, char **argv)
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
BEGET_LOGE("Command %s failed with status %d", argv[0], WEXITSTATUS(status));
}
BEGET_LOGI("Execute %s end", argv[0]);
return WEXITSTATUS(status);
}
......@@ -192,7 +194,6 @@ static int DoResizeF2fs(const char* device, const unsigned long long size)
char **argv = (char **)cmd;
ret = ExecCommand(argc, argv);
}
BEGET_LOGI("resize.f2fs is ending.");
return ret;
}
......@@ -209,7 +210,6 @@ static int DoFsckF2fs(const char* device)
};
int argc = ARRAY_LENGTH(cmd);
char **argv = (char **)cmd;
BEGET_LOGI("fsck.f2fs is ending.");
return ExecCommand(argc, argv);
}
......@@ -242,7 +242,6 @@ static int DoResizeExt(const char* device, const unsigned long long size)
char **argv = (char **)cmd;
ret = ExecCommand(argc, argv);
}
BEGET_LOGI("resize2fs is ending.");
return ret;
}
......@@ -259,7 +258,6 @@ static int DoFsckExt(const char* device)
};
int argc = ARRAY_LENGTH(cmd);
char **argv = (char **)cmd;
BEGET_LOGI("e2fsck is ending.");
return ExecCommand(argc, argv);
}
......@@ -287,15 +285,8 @@ static int Mount(const char *source, const char *target, const char *fsType,
}
}
errno = 0;
while ((rc = mount(source, target, fsType, flags, data)) != 0) {
if (errno == EAGAIN) {
BEGET_LOGE("Mount %s to %s failed. try again", source, target);
continue;
}
if (errno == EBUSY) {
rc = 0;
}
break;
if ((rc = mount(source, target, fsType, flags, data)) != 0) {
BEGET_WARNING_CHECK(errno != EBUSY, rc = 0, "Mount %s to %s busy, ignore", source, target);
}
return rc;
}
......
......@@ -34,7 +34,7 @@ public:
HWTEST_F(MountUnitTest, TestMountRequriedPartitions, TestSize.Level0)
{
const char *fstabFiles = "/etc/fstab.required";
const char *fstabFiles = "/data/init_ut/etc/fstab.required";
Fstab *fstab = NULL;
fstab = ReadFstabFromFile(fstabFiles, false);
if (fstab != NULL) {
......
......@@ -218,7 +218,7 @@ HWTEST_F(InnerkitsUnitTest, DoFormat_unittest, TestSize.Level1)
*/
HWTEST_F(InnerkitsUnitTest, MountAllWithFstabFile_unittest, TestSize.Level1)
{
EXPECT_NE(MountAllWithFstabFile("/etc/fstab.required", 0), 1);
EXPECT_NE(MountAllWithFstabFile("/data/init_ut/etc/fstab.required", 0), 1);
}
HWTEST_F(InnerkitsUnitTest, others_unittest, TestSize.Level1)
......
......@@ -207,14 +207,14 @@ static void PrepareInnerKitsCfg()
"aa aa aa aa\n";
const char *fstabRequired = "# fstab file.\n"
"#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>\n"
"/dev/block/platform/fe310000.sdhci/by-name/testsystem /usr ext4 ro,barrier=1 wait,required\n"
"/dev/block/platform/fe310000.sdhci/by-name/testsystem /usr ext4 ro,barrier=1 wait,required,nofail\n"
"/dev/block/platform/fe310000.sdhci/by-name/testvendor /vendor ext4 ro,barrier=1 wait,required\n"
"/dev/block/platform/fe310000.sdhci/by-name/testuserdata1 /data f2fs noatime,nosuid,nodev wait,check,quota\n"
"/dev/block/platform/fe310000.sdhci/by-name/testuserdata2 /data ext4 noatime,fscrypt=xxx wait,check,quota\n"
"/dev/block/platform/fe310000.sdhci/by-name/testmisc /misc none none wait,required";
mkdir("/data/init_ut/mount_unitest/", S_IRWXU | S_IRWXG | S_IRWXO);
CreateTestFile("/data/init_ut/mount_unitest/ReadFstabFromFile1.fstable", innerKitsCfg);
CreateTestFile("/etc/fstab.required", fstabRequired);
CreateTestFile("/data/init_ut/etc/fstab.required", fstabRequired);
}
static void PrepareGroupTestCfg()
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册