Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
cfa0307a
S
Startup Init Lite
项目概览
OpenHarmony
/
Startup Init Lite
11 个月 前同步成功
通知
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
cfa0307a
编写于
12月 07, 2022
作者:
O
openharmony_ci
提交者:
Gitee
12月 07, 2022
浏览文件
操作
浏览文件
下载
差异文件
!1593 do not stop if required fstab file not exists
Merge pull request !1593 from 许云通/excludecfg
上级
a1b388d9
d2275ee8
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
9 addition
and
12 deletion
+9
-12
services/init/standard/init.c
services/init/standard/init.c
+6
-3
services/init/standard/init_mount.c
services/init/standard/init_mount.c
+2
-2
services/init/standard/init_mount.h
services/init/standard/init_mount.h
+1
-1
services/init/standard/switch_root.c
services/init/standard/switch_root.c
+0
-6
未找到文件。
services/init/standard/init.c
浏览文件 @
cfa0307a
...
@@ -175,9 +175,8 @@ static int StartUeventd(char **requiredDevices, int num)
...
@@ -175,9 +175,8 @@ static int StartUeventd(char **requiredDevices, int num)
static
void
StartInitSecondStage
(
void
)
static
void
StartInitSecondStage
(
void
)
{
{
int
requiredNum
=
0
;
int
requiredNum
=
0
;
Fstab
*
fstab
=
LoadRequiredFstab
();
Fstab
*
fstab
=
LoadRequiredFstab
();
INIT_ERROR_CHECK
(
fstab
!=
NULL
,
abort
(),
"Failed to load required fstab"
);
char
**
devices
=
(
fstab
!=
NULL
)
?
GetRequiredDevices
(
*
fstab
,
&
requiredNum
)
:
NULL
;
char
**
devices
=
GetRequiredDevices
(
*
fstab
,
&
requiredNum
);
if
(
devices
!=
NULL
&&
requiredNum
>
0
)
{
if
(
devices
!=
NULL
&&
requiredNum
>
0
)
{
int
ret
=
StartUeventd
(
devices
,
requiredNum
);
int
ret
=
StartUeventd
(
devices
,
requiredNum
);
if
(
ret
==
0
)
{
if
(
ret
==
0
)
{
...
@@ -200,6 +199,10 @@ static void StartInitSecondStage(void)
...
@@ -200,6 +199,10 @@ static void StartInitSecondStage(void)
}
}
}
}
if
(
fstab
!=
NULL
)
{
ReleaseFstab
(
fstab
);
fstab
=
NULL
;
}
// It will panic if close stdio before execv("/bin/sh", NULL)
// It will panic if close stdio before execv("/bin/sh", NULL)
CloseStdio
();
CloseStdio
();
...
...
services/init/standard/init_mount.c
浏览文件 @
cfa0307a
...
@@ -32,7 +32,7 @@ int MountRequriedPartitions(const Fstab *fstab)
...
@@ -32,7 +32,7 @@ int MountRequriedPartitions(const Fstab *fstab)
return
rc
;
return
rc
;
}
}
Fstab
*
LoadRequiredFstab
(
void
)
Fstab
*
LoadRequiredFstab
(
void
)
{
{
Fstab
*
fstab
=
NULL
;
Fstab
*
fstab
=
NULL
;
fstab
=
LoadFstabFromCommandLine
();
fstab
=
LoadFstabFromCommandLine
();
...
@@ -40,7 +40,7 @@ Fstab* LoadRequiredFstab(void)
...
@@ -40,7 +40,7 @@ Fstab* LoadRequiredFstab(void)
INIT_LOGI
(
"Cannot load fstab from command line, try read from fstab.required"
);
INIT_LOGI
(
"Cannot load fstab from command line, try read from fstab.required"
);
const
char
*
fstabFile
=
STARTUP_INIT_UT_PATH
"/etc/fstab.required"
;
const
char
*
fstabFile
=
STARTUP_INIT_UT_PATH
"/etc/fstab.required"
;
INIT_CHECK
(
access
(
fstabFile
,
F_OK
)
==
0
,
fstabFile
=
"/system/etc/fstab.required"
);
INIT_CHECK
(
access
(
fstabFile
,
F_OK
)
==
0
,
fstabFile
=
"/system/etc/fstab.required"
);
INIT_ERROR_CHECK
(
access
(
fstabFile
,
F_OK
)
==
0
,
abort
()
,
"Failed get fstab.required"
);
INIT_ERROR_CHECK
(
access
(
fstabFile
,
F_OK
)
==
0
,
return
NULL
,
"Failed get fstab.required"
);
fstab
=
ReadFstabFromFile
(
fstabFile
,
false
);
fstab
=
ReadFstabFromFile
(
fstabFile
,
false
);
}
}
return
fstab
;
return
fstab
;
...
...
services/init/standard/init_mount.h
浏览文件 @
cfa0307a
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
#endif
#endif
Fstab
*
LoadRequiredFstab
(
void
);
Fstab
*
LoadRequiredFstab
(
void
);
int
MountRequriedPartitions
(
const
Fstab
*
fstab
);
int
MountRequriedPartitions
(
const
Fstab
*
fstab
);
#ifdef __cplusplus
#ifdef __cplusplus
#if __cplusplus
#if __cplusplus
...
...
services/init/standard/switch_root.c
浏览文件 @
cfa0307a
...
@@ -154,37 +154,31 @@ int SwitchRoot(const char *newRoot)
...
@@ -154,37 +154,31 @@ int SwitchRoot(const char *newRoot)
struct
stat
newRootStat
=
{};
struct
stat
newRootStat
=
{};
if
(
stat
(
newRoot
,
&
newRootStat
)
!=
0
)
{
if
(
stat
(
newRoot
,
&
newRootStat
)
!=
0
)
{
INIT_LOGE
(
"Failed to get new root
\"
%s
\"
stat"
,
newRoot
);
INIT_LOGE
(
"Failed to get new root
\"
%s
\"
stat"
,
newRoot
);
FreeRootDir
(
oldRoot
,
oldRootStat
.
st_dev
);
return
-
1
;
return
-
1
;
}
}
if
(
oldRootStat
.
st_dev
==
newRootStat
.
st_dev
)
{
if
(
oldRootStat
.
st_dev
==
newRootStat
.
st_dev
)
{
INIT_LOGW
(
"Try to switch root in same device, skip switching root"
);
INIT_LOGW
(
"Try to switch root in same device, skip switching root"
);
FreeRootDir
(
oldRoot
,
oldRootStat
.
st_dev
);
return
0
;
return
0
;
}
}
if
(
MountToNewTarget
(
newRoot
)
<
0
)
{
if
(
MountToNewTarget
(
newRoot
)
<
0
)
{
INIT_LOGE
(
"Failed to move mount to new root
\"
%s
\"
stat"
,
newRoot
);
INIT_LOGE
(
"Failed to move mount to new root
\"
%s
\"
stat"
,
newRoot
);
FreeRootDir
(
oldRoot
,
oldRootStat
.
st_dev
);
return
-
1
;
return
-
1
;
}
}
// OK, we've done move mount.
// OK, we've done move mount.
// Now mount new root.
// Now mount new root.
if
(
chdir
(
newRoot
)
<
0
)
{
if
(
chdir
(
newRoot
)
<
0
)
{
INIT_LOGE
(
"Failed to change directory to %s, err = %d"
,
newRoot
,
errno
);
INIT_LOGE
(
"Failed to change directory to %s, err = %d"
,
newRoot
,
errno
);
FreeRootDir
(
oldRoot
,
oldRootStat
.
st_dev
);
return
-
1
;
return
-
1
;
}
}
if
(
mount
(
newRoot
,
"/"
,
NULL
,
MS_MOVE
,
NULL
)
<
0
)
{
if
(
mount
(
newRoot
,
"/"
,
NULL
,
MS_MOVE
,
NULL
)
<
0
)
{
INIT_LOGE
(
"Failed to mount moving %s to %s, err = %d"
,
newRoot
,
"/"
,
errno
);
INIT_LOGE
(
"Failed to mount moving %s to %s, err = %d"
,
newRoot
,
"/"
,
errno
);
FreeRootDir
(
oldRoot
,
oldRootStat
.
st_dev
);
return
-
1
;
return
-
1
;
}
}
if
(
chroot
(
"."
)
<
0
)
{
if
(
chroot
(
"."
)
<
0
)
{
INIT_LOGE
(
"Failed to change root directory"
);
INIT_LOGE
(
"Failed to change root directory"
);
FreeRootDir
(
oldRoot
,
oldRootStat
.
st_dev
);
return
-
1
;
return
-
1
;
}
}
FreeRootDir
(
oldRoot
,
oldRootStat
.
st_dev
);
FreeRootDir
(
oldRoot
,
oldRootStat
.
st_dev
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录