Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
a496c0ea
S
Startup Init Lite
项目概览
OpenHarmony
/
Startup Init Lite
大约 1 年 前同步成功
通知
3
Star
37
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Startup Init Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
a496c0ea
编写于
10月 09, 2022
作者:
O
openharmony_ci
提交者:
Gitee
10月 09, 2022
浏览文件
操作
浏览文件
下载
差异文件
!1348 optimize mount code
Merge pull request !1348 from cheng_jinsong/optimize
上级
35c8fb3f
a9fc666f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
8 addition
and
17 deletion
+8
-17
interfaces/innerkits/fs_manager/fstab_mount.c
interfaces/innerkits/fs_manager/fstab_mount.c
+4
-13
test/unittest/init/mount_unittest.cpp
test/unittest/init/mount_unittest.cpp
+1
-1
test/unittest/innerkits/innerkits_unittest.cpp
test/unittest/innerkits/innerkits_unittest.cpp
+1
-1
test/unittest/param/param_stub.cpp
test/unittest/param/param_stub.cpp
+2
-2
未找到文件。
interfaces/innerkits/fs_manager/fstab_mount.c
浏览文件 @
a496c0ea
...
@@ -61,6 +61,7 @@ static int ExecCommand(int argc, char **argv)
...
@@ -61,6 +61,7 @@ static int ExecCommand(int argc, char **argv)
if
(
argc
==
0
||
argv
==
NULL
||
argv
[
0
]
==
NULL
)
{
if
(
argc
==
0
||
argv
==
NULL
||
argv
[
0
]
==
NULL
)
{
return
-
1
;
return
-
1
;
}
}
BEGET_LOGI
(
"Execute %s begin"
,
argv
[
0
]);
pid_t
pid
=
fork
();
pid_t
pid
=
fork
();
if
(
pid
<
0
)
{
if
(
pid
<
0
)
{
BEGET_LOGE
(
"Fork new process to format failed: %d"
,
errno
);
BEGET_LOGE
(
"Fork new process to format failed: %d"
,
errno
);
...
@@ -75,6 +76,7 @@ static int ExecCommand(int argc, char **argv)
...
@@ -75,6 +76,7 @@ static int ExecCommand(int argc, char **argv)
if
(
!
WIFEXITED
(
status
)
||
WEXITSTATUS
(
status
)
!=
0
)
{
if
(
!
WIFEXITED
(
status
)
||
WEXITSTATUS
(
status
)
!=
0
)
{
BEGET_LOGE
(
"Command %s failed with status %d"
,
argv
[
0
],
WEXITSTATUS
(
status
));
BEGET_LOGE
(
"Command %s failed with status %d"
,
argv
[
0
],
WEXITSTATUS
(
status
));
}
}
BEGET_LOGI
(
"Execute %s end"
,
argv
[
0
]);
return
WEXITSTATUS
(
status
);
return
WEXITSTATUS
(
status
);
}
}
...
@@ -192,7 +194,6 @@ static int DoResizeF2fs(const char* device, const unsigned long long size)
...
@@ -192,7 +194,6 @@ static int DoResizeF2fs(const char* device, const unsigned long long size)
char
**
argv
=
(
char
**
)
cmd
;
char
**
argv
=
(
char
**
)
cmd
;
ret
=
ExecCommand
(
argc
,
argv
);
ret
=
ExecCommand
(
argc
,
argv
);
}
}
BEGET_LOGI
(
"resize.f2fs is ending."
);
return
ret
;
return
ret
;
}
}
...
@@ -209,7 +210,6 @@ static int DoFsckF2fs(const char* device)
...
@@ -209,7 +210,6 @@ static int DoFsckF2fs(const char* device)
};
};
int
argc
=
ARRAY_LENGTH
(
cmd
);
int
argc
=
ARRAY_LENGTH
(
cmd
);
char
**
argv
=
(
char
**
)
cmd
;
char
**
argv
=
(
char
**
)
cmd
;
BEGET_LOGI
(
"fsck.f2fs is ending."
);
return
ExecCommand
(
argc
,
argv
);
return
ExecCommand
(
argc
,
argv
);
}
}
...
@@ -242,7 +242,6 @@ static int DoResizeExt(const char* device, const unsigned long long size)
...
@@ -242,7 +242,6 @@ static int DoResizeExt(const char* device, const unsigned long long size)
char
**
argv
=
(
char
**
)
cmd
;
char
**
argv
=
(
char
**
)
cmd
;
ret
=
ExecCommand
(
argc
,
argv
);
ret
=
ExecCommand
(
argc
,
argv
);
}
}
BEGET_LOGI
(
"resize2fs is ending."
);
return
ret
;
return
ret
;
}
}
...
@@ -259,7 +258,6 @@ static int DoFsckExt(const char* device)
...
@@ -259,7 +258,6 @@ static int DoFsckExt(const char* device)
};
};
int
argc
=
ARRAY_LENGTH
(
cmd
);
int
argc
=
ARRAY_LENGTH
(
cmd
);
char
**
argv
=
(
char
**
)
cmd
;
char
**
argv
=
(
char
**
)
cmd
;
BEGET_LOGI
(
"e2fsck is ending."
);
return
ExecCommand
(
argc
,
argv
);
return
ExecCommand
(
argc
,
argv
);
}
}
...
@@ -287,15 +285,8 @@ static int Mount(const char *source, const char *target, const char *fsType,
...
@@ -287,15 +285,8 @@ static int Mount(const char *source, const char *target, const char *fsType,
}
}
}
}
errno
=
0
;
errno
=
0
;
while
((
rc
=
mount
(
source
,
target
,
fsType
,
flags
,
data
))
!=
0
)
{
if
((
rc
=
mount
(
source
,
target
,
fsType
,
flags
,
data
))
!=
0
)
{
if
(
errno
==
EAGAIN
)
{
BEGET_WARNING_CHECK
(
errno
!=
EBUSY
,
rc
=
0
,
"Mount %s to %s busy, ignore"
,
source
,
target
);
BEGET_LOGE
(
"Mount %s to %s failed. try again"
,
source
,
target
);
continue
;
}
if
(
errno
==
EBUSY
)
{
rc
=
0
;
}
break
;
}
}
return
rc
;
return
rc
;
}
}
...
...
test/unittest/init/mount_unittest.cpp
浏览文件 @
a496c0ea
...
@@ -34,7 +34,7 @@ public:
...
@@ -34,7 +34,7 @@ public:
HWTEST_F
(
MountUnitTest
,
TestMountRequriedPartitions
,
TestSize
.
Level0
)
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
*
fstab
=
NULL
;
fstab
=
ReadFstabFromFile
(
fstabFiles
,
false
);
fstab
=
ReadFstabFromFile
(
fstabFiles
,
false
);
if
(
fstab
!=
NULL
)
{
if
(
fstab
!=
NULL
)
{
...
...
test/unittest/innerkits/innerkits_unittest.cpp
浏览文件 @
a496c0ea
...
@@ -218,7 +218,7 @@ HWTEST_F(InnerkitsUnitTest, DoFormat_unittest, TestSize.Level1)
...
@@ -218,7 +218,7 @@ HWTEST_F(InnerkitsUnitTest, DoFormat_unittest, TestSize.Level1)
*/
*/
HWTEST_F
(
InnerkitsUnitTest
,
MountAllWithFstabFile_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
)
HWTEST_F
(
InnerkitsUnitTest
,
others_unittest
,
TestSize
.
Level1
)
...
...
test/unittest/param/param_stub.cpp
浏览文件 @
a496c0ea
...
@@ -207,14 +207,14 @@ static void PrepareInnerKitsCfg()
...
@@ -207,14 +207,14 @@ static void PrepareInnerKitsCfg()
"aa aa aa aa
\n
"
;
"aa aa aa aa
\n
"
;
const
char
*
fstabRequired
=
"# fstab file.
\n
"
const
char
*
fstabRequired
=
"# fstab file.
\n
"
"#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
\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/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/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/testuserdata2 /data ext4 noatime,fscrypt=xxx wait,check,quota
\n
"
"/dev/block/platform/fe310000.sdhci/by-name/testmisc /misc none none wait,required"
;
"/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
);
mkdir
(
"/data/init_ut/mount_unitest/"
,
S_IRWXU
|
S_IRWXG
|
S_IRWXO
);
CreateTestFile
(
"/data/init_ut/mount_unitest/ReadFstabFromFile1.fstable"
,
innerKitsCfg
);
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
()
static
void
PrepareGroupTestCfg
()
{
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录