Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
993580a8
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看板
提交
993580a8
编写于
7月 28, 2021
作者:
O
openharmony_ci
提交者:
Gitee
7月 28, 2021
浏览文件
操作
浏览文件
下载
差异文件
!69 修改l2init
Merge pull request !69 from 熊磊/init0727
上级
93c056ea
22ee1b14
变更
7
展开全部
隐藏空白更改
内联
并排
Showing
7 changed file
with
316 addition
and
268 deletion
+316
-268
services/include/init_service.h
services/include/init_service.h
+1
-0
services/log/init_log.h
services/log/init_log.h
+11
-1
services/src/device.c
services/src/device.c
+2
-2
services/src/init_cmds.c
services/src/init_cmds.c
+257
-249
services/src/init_service.c
services/src/init_service.c
+12
-3
services/src/init_service_manager.c
services/src/init_service_manager.c
+25
-8
services/src/uevent.c
services/src/uevent.c
+8
-5
未找到文件。
services/include/init_service.h
浏览文件 @
993580a8
...
...
@@ -71,6 +71,7 @@ typedef struct {
time_t
firstCriticalCrashTime
;
// record for critical
char
*
writepidFiles
[
MAX_WRITEPID_FILES
];
unsigned
int
attribute
;
int
importance
;
Perms
servPerm
;
struct
OnRestartCmd
*
onRestart
;
struct
ServiceSocket
*
socketCfg
;
...
...
services/log/init_log.h
浏览文件 @
993580a8
...
...
@@ -80,11 +80,21 @@ void SetLogLevel(InitLogLevel logLevel);
statement
;
\
}
#define INIT_CHECK
_ONLY_RETURN
(ret, statement) \
#define INIT_CHECK(ret, statement) \
if
(
!
(
ret
))
{
\
statement
;
\
}
#define INIT_CHECK_RETURN_VALUE(ret, result) \
if
(
!
(
ret
))
{
\
return
result
;
\
}
#define INIT_CHECK_ONLY_RETURN(ret) \
if
(
!
(
ret
))
{
\
return
;
\
}
#ifdef __cplusplus
#if __cplusplus
}
...
...
services/src/device.c
浏览文件 @
993580a8
...
...
@@ -24,8 +24,8 @@
#include <unistd.h>
#include "init_log.h"
#define DEFAULT_RW_MODE
S_IRUSR | S_IWUSR | S_IRGRP | S_IRGRP | S_IROTH | S_IWOTH
#define DEFAULT_NO_AUTHORITY_MODE
S_IWUSR | S_IRUSR
#define DEFAULT_RW_MODE
(S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
#define DEFAULT_NO_AUTHORITY_MODE
(S_IWUSR | S_IRUSR)
void
MountBasicFs
()
{
...
...
services/src/init_cmds.c
浏览文件 @
993580a8
此差异已折叠。
点击以展开。
services/src/init_service.c
浏览文件 @
993580a8
...
...
@@ -26,6 +26,9 @@
#include <stropts.h>
#endif
#include <sys/param.h>
#ifndef OHOS_LITE
#include <sys/resource.h>
#endif
#include <sys/stat.h>
#include <time.h>
#include <unistd.h>
...
...
@@ -223,10 +226,16 @@ int ServiceStart(Service *service)
INIT_LOGI
(
"service->name is %s "
,
service
->
name
);
#ifndef OHOS_LITE
// L2 Can not be reset env
if
(
execv
(
service
->
pathArgs
[
0
],
service
->
pathArgs
)
!=
0
)
{
if
(
service
->
importance
!=
0
)
{
if
(
setpriority
(
PRIO_PROCESS
,
0
,
service
->
importance
)
!=
0
)
{
INIT_LOGE
(
"setpriority failed for %s, importance = %d"
,
service
->
name
,
service
->
importance
);
_exit
(
0x7f
);
// 0x7f: user specified
}
}
// L2 Can not be reset env
if
(
execv
(
service
->
pathArgs
[
0
],
service
->
pathArgs
)
!=
0
)
{
INIT_LOGE
(
"service %s execve failed! err %d."
,
service
->
name
,
errno
);
}
}
#else
char
*
env
[]
=
{
"LD_LIBRARY_PATH=/storage/app/libs"
,
NULL
};
if
(
execve
(
service
->
pathArgs
[
0
],
service
->
pathArgs
,
env
)
!=
0
)
{
...
...
services/src/init_service_manager.c
浏览文件 @
993580a8
...
...
@@ -34,6 +34,9 @@
#include "init_utils.h"
#include "securec.h"
#define MIN_IMPORTANT_LEVEL (-20)
#define MAX_IMPORTANT_LEVEL 19
// All serivce processes that init will fork+exec.
static
Service
*
g_services
=
NULL
;
static
int
g_servicesCnt
=
0
;
...
...
@@ -362,6 +365,23 @@ static int GetServicePathAndArgs(const cJSON* curArrItem, Service* curServ)
return
SERVICE_SUCCESS
;
}
static
int
GetImportantValue
(
int
value
,
Service
*
curServ
)
{
#ifdef OHOS_LITE
if
(
value
!=
0
)
{
curServ
->
attribute
|=
SERVICE_ATTR_IMPORTANT
;
}
#else
if
(
value
>=
MIN_IMPORTANT_LEVEL
&&
value
<=
MAX_IMPORTANT_LEVEL
)
{
// -20~19
curServ
->
importance
=
value
;
}
else
{
INIT_LOGE
(
"importance level = %d, is not between -20 and 19, error"
,
value
);
return
SERVICE_FAILURE
;
}
#endif
return
SERVICE_SUCCESS
;
}
static
int
GetServiceNumber
(
const
cJSON
*
curArrItem
,
Service
*
curServ
,
const
char
*
targetField
)
{
cJSON
*
filedJ
=
cJSON_GetObjectItem
(
curArrItem
,
targetField
);
...
...
@@ -374,15 +394,15 @@ static int GetServiceNumber(const cJSON* curArrItem, Service* curServ, const cha
}
if
(
!
cJSON_IsNumber
(
filedJ
))
{
INIT_LOGE
(
"
GetServiceNumber, %s is null or is not a number, error."
,
targetField
);
INIT_LOGE
(
"
%s is null or is not a number, error.service name is %s"
,
targetField
,
curServ
->
name
);
return
SERVICE_FAILURE
;
}
int
value
=
(
int
)
cJSON_GetNumberValue
(
filedJ
);
// importan
t
value allow < 0
// importan
ce
value allow < 0
if
(
strncmp
(
targetField
,
IMPORTANT_STR_IN_CFG
,
strlen
(
IMPORTANT_STR_IN_CFG
))
!=
0
)
{
if
(
value
<
0
)
{
INIT_LOGE
(
"
GetServiceNumber, value = %d, error."
,
valu
e
);
INIT_LOGE
(
"
value = %d, error.service name is %s"
,
value
,
curServ
->
nam
e
);
return
SERVICE_FAILURE
;
}
}
...
...
@@ -392,9 +412,7 @@ static int GetServiceNumber(const cJSON* curArrItem, Service* curServ, const cha
curServ
->
attribute
|=
SERVICE_ATTR_ONCE
;
}
}
else
if
(
strncmp
(
targetField
,
IMPORTANT_STR_IN_CFG
,
strlen
(
IMPORTANT_STR_IN_CFG
))
==
0
)
{
if
(
value
!=
0
)
{
curServ
->
attribute
|=
SERVICE_ATTR_IMPORTANT
;
}
INIT_CHECK_RETURN_VALUE
(
GetImportantValue
(
value
,
curServ
)
==
SERVICE_SUCCESS
,
SERVICE_FAILURE
);
}
else
if
(
strncmp
(
targetField
,
CRITICAL_STR_IN_CFG
,
strlen
(
CRITICAL_STR_IN_CFG
))
==
0
)
{
// set critical
curServ
->
attribute
&=
~
SERVICE_ATTR_CRITICAL
;
if
(
value
==
1
)
{
...
...
@@ -411,7 +429,7 @@ static int GetServiceNumber(const cJSON* curArrItem, Service* curServ, const cha
curServ
->
attribute
|=
SERVICE_ATTR_CONSOLE
;
}
}
else
{
INIT_LOGE
(
"
GetServiceNumber, item = %s, not expected, error."
,
targetField
);
INIT_LOGE
(
"
item = %s, not expected, error.service name is %s"
,
targetField
,
curServ
->
name
);
return
SERVICE_FAILURE
;
}
return
SERVICE_SUCCESS
;
...
...
@@ -644,7 +662,6 @@ void ParseAllServices(const cJSON* fileRoot)
return
;
}
INIT_LOGI
(
"servArrSize is %d "
,
servArrSize
);
if
(
servArrSize
>
MAX_SERVICES_CNT_IN_FILE
)
{
INIT_LOGE
(
"ParseAllServices, too many services[cnt %d] detected, should not exceed %d."
,
servArrSize
,
MAX_SERVICES_CNT_IN_FILE
);
...
...
services/src/uevent.c
浏览文件 @
993580a8
...
...
@@ -363,10 +363,10 @@ struct DevPermissionMapper {
struct
DevPermissionMapper
DEV_MAPPER
[]
=
{
{
"/dev/binder"
,
0666
,
0
,
0
},
{
"/dev/input/event0"
,
0660
,
0
,
1004
},
{
"/dev/input/event0"
,
0660
,
0
,
0
},
{
"/dev/input/event1"
,
0660
,
0
,
1004
},
{
"/dev/input/mice"
,
0660
,
0
,
1004
},
{
"/dev/input/mouse0"
,
0660
,
0
,
1004
},
{
"/dev/input/mouse0"
,
0660
,
0
,
0
},
{
"/dev/snd/timer"
,
0660
,
1000
,
1005
},
{
"/dev/zero"
,
0666
,
0
,
0
},
{
"/dev/full"
,
0666
,
0
,
0
},
...
...
@@ -375,7 +375,7 @@ struct DevPermissionMapper DEV_MAPPER[] = {
{
"/dev/random"
,
0666
,
0
,
0
},
{
"/dev/urandom"
,
0666
,
0
,
0
},
{
"/dev/ashmem"
,
0666
,
0
,
0
},
{
"/dev/pmsg0"
,
0222
,
0
,
0
},
{
"/dev/pmsg0"
,
0222
,
0
,
1007
},
{
"/dev/jpeg"
,
0666
,
1000
,
1003
},
{
"/dev/vinput"
,
0660
,
1000
,
1004
},
{
"/dev/mmz_userdev"
,
0644
,
1000
,
1005
},
...
...
@@ -383,7 +383,7 @@ struct DevPermissionMapper DEV_MAPPER[] = {
{
"/dev/mem"
,
0660
,
1000
,
1005
},
{
"/dev/ion"
,
0666
,
1000
,
1000
},
{
"/dev/btusb0"
,
0660
,
1002
,
1002
},
{
"/dev/uhid"
,
0660
,
1002
,
1002
},
{
"/dev/uhid"
,
0660
,
3011
,
3011
},
{
"/dev/tc_ns_client"
,
0660
,
1000
,
1005
},
{
"/dev/rtk_btusb"
,
0660
,
1002
,
0
},
{
"/dev/sil9293"
,
0660
,
1000
,
1005
},
...
...
@@ -418,7 +418,10 @@ struct DevPermissionMapper DEV_MAPPER[] = {
{
"/dev/dri/card0"
,
0666
,
0
,
1003
},
{
"/dev/dri/card0-DSI-1"
,
0666
,
0
,
1003
},
{
"/dev/dri/card0-HDMI-A-1"
,
0666
,
0
,
1003
},
{
"/dev/dri/renderD128"
,
0666
,
0
,
1003
}
{
"/dev/dri/renderD128"
,
0666
,
0
,
1003
},
{
"/dev/rtc0"
,
0640
,
1000
,
1000
},
{
"/dev/tty0"
,
0660
,
0
,
1000
},
{
"/dev/uinput"
,
0660
,
3011
,
3011
}
};
static
void
AdjustDevicePermission
(
const
char
*
devPath
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录