Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
e18e0d7f
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看板
提交
e18e0d7f
编写于
5月 08, 2023
作者:
C
cheng_jinsong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
系统优化
Signed-off-by:
N
cheng_jinsong
<
chengjinsong2@huawei.com
>
上级
1a391451
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
40 addition
and
53 deletion
+40
-53
interfaces/innerkits/fs_manager/fstab.c
interfaces/innerkits/fs_manager/fstab.c
+1
-7
interfaces/innerkits/fs_manager/fstab_mount.c
interfaces/innerkits/fs_manager/fstab_mount.c
+2
-6
interfaces/innerkits/fs_manager/libfs_hvb/fs_hvb.c
interfaces/innerkits/fs_manager/libfs_hvb/fs_hvb.c
+1
-11
services/include/init_utils.h
services/include/init_utils.h
+1
-0
services/init/init_group_manager.c
services/init/init_group_manager.c
+6
-10
services/log/init_log.c
services/log/init_log.c
+1
-7
services/modules/seccomp/seccomp_policy_static.c
services/modules/seccomp/seccomp_policy_static.c
+0
-2
services/param/linux/param_request.c
services/param/linux/param_request.c
+12
-0
services/utils/init_utils.c
services/utils/init_utils.c
+10
-0
ueventd/ueventd.c
ueventd/ueventd.c
+2
-8
ueventd/ueventd_device_handler.c
ueventd/ueventd_device_handler.c
+4
-2
未找到文件。
interfaces/innerkits/fs_manager/fstab.c
浏览文件 @
e18e0d7f
...
...
@@ -306,13 +306,7 @@ static char *GetFstabFile(char *fileName, size_t size)
}
}
else
{
char
hardware
[
MAX_BUFFER_LEN
]
=
{
0
};
char
*
buffer
=
ReadFileData
(
"/proc/cmdline"
);
if
(
buffer
==
NULL
)
{
BEGET_LOGE
(
"Failed to read
\"
/proc/cmdline
\"
"
);
return
NULL
;
}
int
ret
=
GetProcCmdlineValue
(
"hardware"
,
buffer
,
hardware
,
MAX_BUFFER_LEN
);
free
(
buffer
);
int
ret
=
GetParameterFromCmdLine
(
"hardware"
,
hardware
,
MAX_BUFFER_LEN
);
if
(
ret
!=
0
)
{
BEGET_LOGE
(
"Failed get hardware from cmdline"
);
return
NULL
;
...
...
interfaces/innerkits/fs_manager/fstab_mount.c
浏览文件 @
e18e0d7f
...
...
@@ -318,12 +318,8 @@ static int GetSlotInfoFromParameter(const char *slotInfoName)
static
int
GetSlotInfoFromCmdLine
(
const
char
*
slotInfoName
)
{
char
value
[
MAX_BUFFER_LEN
]
=
{
0
};
char
*
buffer
=
ReadFileData
(
BOOT_CMD_LINE
);
BEGET_ERROR_CHECK
(
buffer
!=
NULL
,
return
-
1
,
"Failed to read cmdline"
);
BEGET_INFO_CHECK
(
GetProcCmdlineValue
(
slotInfoName
,
buffer
,
value
,
MAX_BUFFER_LEN
)
==
0
,
free
(
buffer
);
buffer
=
NULL
;
return
-
1
,
"Failed to get %s value from cmdline"
,
slotInfoName
);
free
(
buffer
);
buffer
=
NULL
;
BEGET_INFO_CHECK
(
GetParameterFromCmdLine
(
slotInfoName
,
value
,
MAX_BUFFER_LEN
)
==
0
,
return
-
1
,
"Failed to get %s value from cmdline"
,
slotInfoName
);
return
atoi
(
value
);
}
...
...
interfaces/innerkits/fs_manager/libfs_hvb/fs_hvb.c
浏览文件 @
e18e0d7f
...
...
@@ -512,20 +512,10 @@ int FsHvbGetValueFromCmdLine(char *val, size_t size, const char *key)
FS_HVB_RETURN_ERR_IF_NULL
(
val
);
FS_HVB_RETURN_ERR_IF_NULL
(
key
);
char
*
buffer
=
ReadFileData
(
FS_HVB_CMDLINE_PATH
);
if
(
buffer
==
NULL
)
{
BEGET_LOGE
(
"error, read %s fail"
,
FS_HVB_CMDLINE_PATH
);
return
-
1
;
}
ret
=
GetProcCmdlineValue
(
key
,
buffer
,
val
,
size
);
ret
=
GetParameterFromCmdLine
(
key
,
val
,
size
);
if
(
ret
!=
0
)
{
BEGET_LOGE
(
"error 0x%x, get %s val from cmdline"
,
ret
,
key
);
}
free
(
buffer
);
return
ret
;
}
...
...
services/include/init_utils.h
浏览文件 @
e18e0d7f
...
...
@@ -95,6 +95,7 @@ void CloseStdio(void);
void
RedirectStdio
(
int
fd
);
int
GetServiceGroupIdByPid
(
pid_t
pid
,
gid_t
*
gids
,
uint32_t
gidSize
);
int
GetParameterFromCmdLine
(
const
char
*
paramName
,
char
*
value
,
size_t
valueLen
);
#ifdef __cplusplus
#if __cplusplus
}
...
...
services/init/init_group_manager.c
浏览文件 @
e18e0d7f
...
...
@@ -190,17 +190,13 @@ void InitServiceSpace(void)
}
// get boot mode, set default mode
strcpy_s
(
g_initWorkspace
.
groupModeStr
,
sizeof
(
g_initWorkspace
.
groupModeStr
),
BOOT_GROUP_DEFAULT
);
char
*
data
=
ReadFileData
(
BOOT_CMD_LINE
);
if
(
data
!=
NULL
)
{
int
ret
=
GetProcCmdlineValue
(
BOOT_GROUP_NAME
,
data
,
g_initWorkspace
.
groupModeStr
,
sizeof
(
g_initWorkspace
.
groupModeStr
));
if
(
ret
!=
0
)
{
INIT_LOGV
(
"Failed to get boot group"
);
if
(
GetBootModeFromMisc
()
==
GROUP_CHARGE
)
{
strcpy_s
(
g_initWorkspace
.
groupModeStr
,
sizeof
(
g_initWorkspace
.
groupModeStr
),
"device.charge.group"
);
}
int
ret
=
GetParameterFromCmdLine
(
BOOT_GROUP_NAME
,
g_initWorkspace
.
groupModeStr
,
sizeof
(
g_initWorkspace
.
groupModeStr
));
if
(
ret
!=
0
)
{
INIT_LOGV
(
"Failed to get boot group"
);
if
(
GetBootModeFromMisc
()
==
GROUP_CHARGE
)
{
strcpy_s
(
g_initWorkspace
.
groupModeStr
,
sizeof
(
g_initWorkspace
.
groupModeStr
),
"device.charge.group"
);
}
free
(
data
);
}
INIT_LOGI
(
"boot start %s"
,
g_initWorkspace
.
groupModeStr
);
g_initWorkspace
.
groupMode
=
GetBootGroupMode
();
...
...
services/log/init_log.c
浏览文件 @
e18e0d7f
...
...
@@ -149,13 +149,7 @@ INIT_LOCAL_API void EnableInitLogFromCmdline(void)
{
SetInitCommLog
(
InitLog
);
char
level
[
MAX_BUFFER_LEN
]
=
{
0
};
char
*
buffer
=
ReadFileData
(
BOOT_CMD_LINE
);
if
(
buffer
==
NULL
)
{
INIT_LOGE
(
"Failed to read
\"
/proc/cmdline
\"
"
);
return
;
}
int
ret
=
GetProcCmdlineValue
(
"initloglevel"
,
buffer
,
level
,
MAX_BUFFER_LEN
);
free
(
buffer
);
int
ret
=
GetParameterFromCmdLine
(
"initloglevel"
,
level
,
MAX_BUFFER_LEN
);
if
(
ret
==
0
)
{
errno
=
0
;
unsigned
int
logLevel
=
(
unsigned
int
)
strtoul
(
level
,
0
,
10
);
// 10 is decimal
...
...
services/modules/seccomp/seccomp_policy_static.c
浏览文件 @
e18e0d7f
...
...
@@ -21,7 +21,6 @@
static
int
SetSystemSeccompPolicy
(
int
id
,
const
char
*
name
,
int
argc
,
const
char
**
argv
)
{
PLUGIN_LOGI
(
"SetSystemSeccompPolicy argc %d %s"
,
argc
,
name
);
PLUGIN_CHECK
(
argc
==
2
,
return
-
1
,
"Invalid parameter"
);
SeccompFilterType
type
=
SYSTEM_SA
;
if
(
strncmp
(
SA_MAIN_PATH
,
argv
[
1
],
strlen
(
SA_MAIN_PATH
))
!=
0
)
{
...
...
@@ -39,7 +38,6 @@ static int SetSeccompPolicyInit(void)
{
if
(
g_executorId
==
-
1
)
{
g_executorId
=
AddCmdExecutor
(
"SetSeccompPolicy"
,
SetSystemSeccompPolicy
);
PLUGIN_LOGI
(
"SetSeccompPolicy executorId %d"
,
g_executorId
);
}
return
0
;
}
...
...
services/param/linux/param_request.c
浏览文件 @
e18e0d7f
...
...
@@ -45,6 +45,18 @@ __attribute__((constructor)) static void ParameterInit(void)
ops
.
setfilecon
=
NULL
;
#endif
InitParamWorkSpace
(
1
,
&
ops
);
// modify log level
char
logLevel
[
2
]
=
{
0
};
// 2 is set param "persist.init.debug.loglevel" value length.
uint32_t
len
=
sizeof
(
logLevel
);
int
ret
=
SystemReadParam
(
INIT_DEBUG_LEVEL
,
logLevel
,
&
len
);
INIT_INFO_CHECK
(
ret
==
0
,
return
,
"Can not get log level from param, keep the original loglevel."
);
errno
=
0
;
int
level
=
atoi
(
logLevel
);
if
(
errno
!=
0
)
{
return
;
}
SetInitLogLevel
((
InitLogLevel
)
level
);
}
__attribute__
((
destructor
))
static
void
ParameterDeinit
(
void
)
...
...
services/utils/init_utils.c
浏览文件 @
e18e0d7f
...
...
@@ -674,3 +674,13 @@ char *TrimHead(char *str, char c)
}
return
head
;
}
int
GetParameterFromCmdLine
(
const
char
*
paramName
,
char
*
value
,
size_t
valueLen
)
{
char
*
buffer
=
ReadFileData
(
BOOT_CMD_LINE
);
BEGET_ERROR_CHECK
(
buffer
!=
NULL
,
return
-
1
,
"Failed to read /proc/cmdline"
);
int
ret
=
GetProcCmdlineValue
(
paramName
,
buffer
,
value
,
valueLen
);
free
(
buffer
);
return
ret
;
}
ueventd/ueventd.c
浏览文件 @
e18e0d7f
...
...
@@ -190,11 +190,9 @@ static void HandleRequiredBlockDeviceNodes(const struct Uevent *uevent, char **d
INIT_LOGI
(
"Handle required partitionName %s"
,
uevent
->
partitionName
);
HandleBlockDeviceEvent
(
uevent
);
return
;
}
else
{
INIT_LOGI
(
"Handle required partitionName %s"
,
uevent
->
partitionName
);
INIT_LOGE
(
"Handle required device %s"
,
devices
[
i
]);
}
}
INIT_LOGW
(
"Not found device for partitionName %s "
,
uevent
->
partitionName
);
}
static
void
HandleUeventRequired
(
const
struct
Uevent
*
uevent
,
char
**
devices
,
int
num
)
...
...
@@ -360,13 +358,9 @@ void RetriggerUeventByPath(int sockFd, char *path)
void
RetriggerUevent
(
int
sockFd
,
char
**
devices
,
int
num
)
{
char
*
buffer
=
ReadFileData
(
"/proc/cmdline"
);
int
ret
=
GetProcCmdlineValue
(
"default_boot_device"
,
buffer
,
bootDevice
,
CMDLINE_VALUE_LEN_MAX
);
int
ret
=
GetParameterFromCmdLine
(
"default_boot_device"
,
bootDevice
,
CMDLINE_VALUE_LEN_MAX
);
INIT_CHECK_ONLY_ELOG
(
ret
==
0
,
"Failed get default_boot_device value from cmdline"
);
Trigger
(
"/sys/block"
,
sockFd
,
devices
,
num
);
Trigger
(
"/sys/class"
,
sockFd
,
devices
,
num
);
Trigger
(
"/sys/devices"
,
sockFd
,
devices
,
num
);
if
(
buffer
!=
NULL
)
{
free
(
buffer
);
}
}
ueventd/ueventd_device_handler.c
浏览文件 @
e18e0d7f
...
...
@@ -95,9 +95,9 @@ static inline void AdjustDeviceNodePermissions(const char *deviceNode, uid_t uid
}
}
#if defined(WITH_SELINUX) && !defined(__RAMDISK__)
static
void
SetDeviceLable
(
const
char
*
path
)
{
#ifdef WITH_SELINUX
int
rc
=
0
;
char
buffer
[
PATH_MAX
]
=
{};
const
char
*
p
=
NULL
;
...
...
@@ -130,8 +130,8 @@ static void SetDeviceLable(const char *path)
}
return
;
#endif
}
#endif
static
int
CreateDeviceNode
(
const
struct
Uevent
*
uevent
,
const
char
*
deviceNode
,
char
**
symLinks
,
bool
isBlock
)
{
...
...
@@ -180,7 +180,9 @@ static int CreateDeviceNode(const struct Uevent *uevent, const char *deviceNode,
if
(
symLinks
!=
NULL
)
{
CreateSymbolLinks
(
deviceNode
,
symLinks
);
}
#if defined(WITH_SELINUX) && !defined(__RAMDISK__)
SetDeviceLable
(
deviceNode
);
#endif
// No matter what result the symbol links returns,
// as long as create device node done, just returns success.
rc
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录