Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
0051965d
S
Startup Init Lite
项目概览
OpenHarmony
/
Startup Init Lite
接近 2 年 前同步成功
通知
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看板
未验证
提交
0051965d
编写于
5月 11, 2023
作者:
O
openharmony_ci
提交者:
Gitee
5月 11, 2023
浏览文件
操作
浏览文件
下载
差异文件
!1933 Add: 挂载新增eng_system, eng_chipset分区
Merge pull request !1933 from cheng_jinsong/init_eng_mode
上级
025dd7a4
0c22659e
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
302 addition
and
2 deletion
+302
-2
interfaces/innerkits/init_module_engine/stub/libinit.stub.json
...faces/innerkits/init_module_engine/stub/libinit.stub.json
+3
-1
services/modules/BUILD.gn
services/modules/BUILD.gn
+2
-0
services/modules/init_eng/BUILD.gn
services/modules/init_eng/BUILD.gn
+55
-0
services/modules/init_eng/init_eng.c
services/modules/init_eng/init_eng.c
+201
-0
services/modules/init_eng/init_eng_static.c
services/modules/init_eng/init_eng_static.c
+37
-0
services/param/manager/param_server.c
services/param/manager/param_server.c
+1
-0
services/utils/init_utils.c
services/utils/init_utils.c
+2
-1
ueventd/ueventd.c
ueventd/ueventd.c
+1
-0
未找到文件。
interfaces/innerkits/init_module_engine/stub/libinit.stub.json
浏览文件 @
0051965d
...
...
@@ -19,5 +19,7 @@
{
"name"
:
"GetServiceExtData"
},
{
"name"
:
"UpdateMiscMessage"
},
{
"name"
:
"AddRebootCmdExecutor"
},
{
"name"
:
"GetBootEventList"
}
{
"name"
:
"GetBootEventList"
},
{
"name"
:
"WaitForFile"
},
{
"name"
:
"DoCmdByName"
}
]
services/modules/BUILD.gn
浏览文件 @
0051965d
...
...
@@ -17,6 +17,7 @@ group("static_modules") {
deps = [
"bootchart:libbootchart_static",
"bootevent:libbootevent_static",
"init_eng:libiniteng_static",
"init_hook:inithook",
"reboot:libreboot_static",
"udid:libudid_static",
...
...
@@ -38,6 +39,7 @@ group("modulesgroup") {
if (!defined(ohos_lite)) {
deps = [
"bootchart:bootchart",
"init_eng:init_eng",
"reboot:rebootmodule",
"sysevent:eventmodule",
"trace:inittrace",
...
...
services/modules/init_eng/BUILD.gn
0 → 100644
浏览文件 @
0051965d
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//base/startup/init/begetd.gni")
import("//build/ohos.gni")
comm_include = [
".",
"..",
"../../include",
"../../include/param",
]
ohos_shared_library("init_eng") {
sources = [ "init_eng.c" ]
include_dirs = comm_include
include_dirs += [ "../../init/include" ]
deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
external_deps = [ "init:libinit_module_engine" ]
part_name = "init"
subsystem_name = "startup"
if (target_cpu == "arm64") {
module_install_dir = "lib64/init"
} else {
module_install_dir = "lib/init"
}
}
config("initeng_static_config") {
include_dirs = comm_include
}
ohos_source_set("libiniteng_static") {
sources = [ "init_eng_static.c" ]
include_dirs = comm_include
public_configs = [ ":initeng_static_config" ]
public_configs += [ "../../../interfaces/innerkits/init_module_engine:init_module_engine_exported_config" ]
part_name = "init"
subsystem_name = "startup"
}
services/modules/init_eng/init_eng.c
0 → 100644
浏览文件 @
0051965d
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <dirent.h>
#include <limits.h>
#include <sys/mount.h>
#include "plugin_adapter.h"
#include "init_cmds.h"
#include "init_utils.h"
#include "init_module_engine.h"
#include "securec.h"
#define MOUNT_CMD_MAX_LEN 128U
#define ENG_SYSTEM_DEVICE_PATH "/dev/block/by-name/eng_system"
#define ENG_CHIPSET_DEVICE_PATH "/dev/block/by-name/eng_chipset"
typedef
enum
{
TYPE_DIR
=
0
,
TYPE_REG
,
TYPE_LINK
,
TYPE_ANY
}
FileType
;
static
bool
IsFileExistWithType
(
const
char
*
file
,
FileType
type
)
{
bool
isExist
=
false
;
struct
stat
st
=
{};
if
(
lstat
(
file
,
&
st
)
==
0
)
{
switch
(
type
)
{
case
TYPE_DIR
:
if
(
S_ISDIR
(
st
.
st_mode
))
{
isExist
=
true
;
}
break
;
case
TYPE_REG
:
if
(
S_ISREG
(
st
.
st_mode
))
{
isExist
=
true
;
}
break
;
case
TYPE_LINK
:
if
(
S_ISLNK
(
st
.
st_mode
))
{
isExist
=
true
;
}
break
;
case
TYPE_ANY
:
// fallthrough
default:
isExist
=
true
;
break
;
}
}
return
isExist
;
}
static
bool
IsRegularFile
(
const
char
*
file
)
{
return
file
==
NULL
?
false
:
IsFileExistWithType
(
file
,
TYPE_REG
);
}
static
bool
IsExistFile
(
const
char
*
file
)
{
return
file
==
NULL
?
false
:
IsFileExistWithType
(
file
,
TYPE_ANY
);
}
static
void
BuildMountCmd
(
char
*
buffer
,
size_t
len
,
const
char
*
mp
,
const
char
*
dev
,
const
char
*
fstype
)
{
int
ret
=
snprintf_s
(
buffer
,
len
,
len
-
1
,
"%s %s %s ro barrier=1"
,
fstype
,
dev
,
mp
);
if
(
ret
==
-
1
)
{
*
buffer
=
'\0'
;
}
}
static
void
MountEngPartitions
(
void
)
{
char
mountCmd
[
MOUNT_CMD_MAX_LEN
]
=
{};
// Mount eng_system
BuildMountCmd
(
mountCmd
,
MOUNT_CMD_MAX_LEN
,
"/eng_system"
,
"/dev/block/by-name/eng_system"
,
"ext4"
);
WaitForFile
(
ENG_SYSTEM_DEVICE_PATH
,
WAIT_MAX_SECOND
);
DoCmdByName
(
"mount "
,
mountCmd
);
// Mount eng_chipset
BuildMountCmd
(
mountCmd
,
MOUNT_CMD_MAX_LEN
,
"/eng_chipset"
,
"/dev/block/by-name/eng_chipset"
,
"ext4"
);
WaitForFile
(
ENG_CHIPSET_DEVICE_PATH
,
WAIT_MAX_SECOND
);
DoCmdByName
(
"mount "
,
mountCmd
);
}
static
void
BindMountFile
(
const
char
*
source
,
const
char
*
target
)
{
char
targetFullPath
[
PATH_MAX
]
=
{};
const
char
*
p
=
source
;
char
*
q
=
NULL
;
const
char
*
end
=
source
+
strlen
(
source
);
if
(
*
p
!=
'/'
)
{
// source must start with '/'
return
;
}
// Get next '/'
q
=
strchr
(
p
+
1
,
'/'
);
if
(
q
==
NULL
)
{
PLUGIN_LOGI
(
"path
\'
%s
\'
without extra slash, ignore it"
,
source
);
return
;
}
if
(
q
==
end
-
1
)
{
PLUGIN_LOGI
(
"path
\'
%s
\'
ends with slash, ignore it"
,
source
);
return
;
}
// OK, now get sub dir and combine it with target
int
ret
=
snprintf_s
(
targetFullPath
,
PATH_MAX
,
PATH_MAX
-
1
,
"%s%s"
,
strcmp
(
target
,
"/"
)
==
0
?
""
:
target
,
q
);
if
(
ret
==
-
1
)
{
PLUGIN_LOGE
(
"Failed to build target path"
);
return
;
}
PLUGIN_LOGI
(
"target full path is %s"
,
targetFullPath
);
if
(
IsRegularFile
(
targetFullPath
))
{
if
(
mount
(
source
,
targetFullPath
,
NULL
,
MS_BIND
,
NULL
)
!=
0
)
{
PLUGIN_LOGE
(
"Failed to bind mount %s to %s, err = %d"
,
source
,
targetFullPath
,
errno
);
}
else
{
PLUGIN_LOGI
(
"Bind mount %s to %s done"
,
source
,
targetFullPath
);
}
}
else
{
if
(
!
IsExistFile
(
targetFullPath
))
{
if
(
symlink
(
source
,
targetFullPath
)
<
0
)
{
PLUGIN_LOGE
(
"Failed to link %s to %s, err = %d"
,
source
,
targetFullPath
,
errno
);
}
}
else
{
PLUGIN_LOGW
(
"%s without expected type, skip overlay"
,
targetFullPath
);
}
}
}
static
void
DebugFilesOverlay
(
const
char
*
source
,
const
char
*
target
)
{
DIR
*
dir
=
NULL
;
struct
dirent
*
de
=
NULL
;
if
((
dir
=
opendir
(
source
))
==
NULL
)
{
PLUGIN_LOGE
(
"Open path
\'
%s
\'
failed. err = %d"
,
source
,
errno
);
return
;
}
int
dfd
=
dirfd
(
dir
);
char
srcPath
[
PATH_MAX
]
=
{};
while
((
de
=
readdir
(
dir
))
!=
NULL
)
{
if
(
de
->
d_name
[
0
]
==
'.'
)
{
continue
;
}
if
(
snprintf_s
(
srcPath
,
PATH_MAX
,
PATH_MAX
-
1
,
"%s/%s"
,
source
,
de
->
d_name
)
==
-
1
)
{
PLUGIN_LOGE
(
"Failed to build path for overlaying"
);
break
;
}
// Determine file type
struct
stat
st
=
{};
if
(
fstatat
(
dfd
,
de
->
d_name
,
&
st
,
AT_SYMLINK_NOFOLLOW
)
<
0
)
{
continue
;
}
if
(
S_ISDIR
(
st
.
st_mode
))
{
DebugFilesOverlay
(
srcPath
,
target
);
}
else
if
(
S_ISREG
(
st
.
st_mode
))
{
BindMountFile
(
srcPath
,
target
);
}
else
{
// Ignore any other file types
PLUGIN_LOGI
(
"Ignore %s while overlaying"
,
srcPath
);
}
}
closedir
(
dir
);
dir
=
NULL
;
}
static
void
EngineerOverlay
(
void
)
{
PLUGIN_LOGI
(
"system overlay..."
);
DebugFilesOverlay
(
"/eng_system"
,
"/"
);
PLUGIN_LOGI
(
"vendor overlay..."
);
DebugFilesOverlay
(
"/eng_chipset"
,
"/chipset"
);
}
MODULE_CONSTRUCTOR
(
void
)
{
PLUGIN_LOGI
(
"Start eng mode now ..."
);
MountEngPartitions
();
EngineerOverlay
();
}
services/modules/init_eng/init_eng_static.c
0 → 100644
浏览文件 @
0051965d
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <string.h>
#include "init_module_engine.h"
#include "plugin_adapter.h"
#include "init_utils.h"
static
int
InitEngEarlyHook
(
const
HOOK_INFO
*
info
,
void
*
cookie
)
{
char
value
[
MAX_BUFFER_LEN
]
=
{
0
};
int
ret
=
GetParameterFromCmdLine
(
"eng_mode"
,
value
,
MAX_BUFFER_LEN
);
if
(
ret
==
0
&&
strcmp
(
value
,
"on"
)
==
0
)
{
InitModuleMgrInstall
(
"init_eng"
);
InitModuleMgrUnInstall
(
"init_eng"
);
PLUGIN_LOGI
(
"eng_mode enable."
);
}
return
0
;
}
MODULE_CONSTRUCTOR
(
void
)
{
InitAddGlobalInitHook
(
0
,
InitEngEarlyHook
);
}
services/param/manager/param_server.c
浏览文件 @
0051965d
...
...
@@ -115,6 +115,7 @@ static void CmdlineIterator(const NAME_VALUE_PAIR *nv, void *context)
{
"reboot_reason"
,
CommonDealFun
},
{
"bootslots"
,
CommonDealFun
},
{
"sn"
,
SnDealFun
},
{
"eng_mode"
,
CommonDealFun
},
{
"serialno"
,
SnDealFun
}
};
...
...
services/utils/init_utils.c
浏览文件 @
0051965d
...
...
@@ -368,7 +368,8 @@ char **SplitStringExt(char *buffer, const char *del, int *returnCount, int maxIt
void
WaitForFile
(
const
char
*
source
,
unsigned
int
maxSecond
)
{
INIT_ERROR_CHECK
(
maxSecond
<=
WAIT_MAX_SECOND
,
maxSecond
=
WAIT_MAX_SECOND
,
"WaitForFile max time is 5s"
);
INIT_ERROR_CHECK
(
maxSecond
<=
WAIT_MAX_SECOND
,
maxSecond
=
WAIT_MAX_SECOND
,
"WaitForFile max time is %us"
,
WAIT_MAX_SECOND
);
struct
stat
sourceInfo
=
{
0
};
unsigned
int
waitTime
=
500000
;
/* 500ms interval, check maxSecond*2 times total */
...
...
ueventd/ueventd.c
浏览文件 @
0051965d
...
...
@@ -184,6 +184,7 @@ static void HandleRequiredBlockDeviceNodes(const struct Uevent *uevent, char **d
}
else
if
(
strstr
(
devices
[
i
],
uevent
->
partitionName
)
!=
NULL
||
strstr
(
uevent
->
partitionName
,
"vendor"
)
!=
NULL
||
strstr
(
uevent
->
partitionName
,
"system"
)
!=
NULL
||
strstr
(
uevent
->
partitionName
,
"chipset"
)
!=
NULL
||
strstr
(
uevent
->
partitionName
,
"boot"
)
!=
NULL
||
strstr
(
uevent
->
partitionName
,
"ramdisk"
)
!=
NULL
||
strstr
(
uevent
->
partitionName
,
"rvt"
)
!=
NULL
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录