Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
b5bb48df
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看板
未验证
提交
b5bb48df
编写于
4月 27, 2022
作者:
O
openharmony_ci
提交者:
Gitee
4月 27, 2022
浏览文件
操作
浏览文件
下载
差异文件
!506 Fix: appspawn归一化
Merge pull request !506 from 熊磊/init_0411
上级
b6ef7fa2
83b89775
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
93 addition
and
16 deletion
+93
-16
interfaces/innerkits/reboot/init_reboot_innerkits.c
interfaces/innerkits/reboot/init_reboot_innerkits.c
+23
-1
interfaces/innerkits/sandbox/app-sandbox.json
interfaces/innerkits/sandbox/app-sandbox.json
+16
-0
interfaces/innerkits/sandbox/privapp-sandbox.json
interfaces/innerkits/sandbox/privapp-sandbox.json
+16
-0
services/include/init_hashmap.h
services/include/init_hashmap.h
+2
-0
services/init/init_common_service.c
services/init/init_common_service.c
+9
-7
services/init/init_service_manager.c
services/init/init_service_manager.c
+4
-3
services/loopevent/include/loop_event.h
services/loopevent/include/loop_event.h
+1
-0
services/loopevent/signal/le_signal.c
services/loopevent/signal/le_signal.c
+1
-1
services/loopevent/task/le_streamtask.c
services/loopevent/task/le_streamtask.c
+5
-2
services/utils/init_hashmap.c
services/utils/init_hashmap.c
+16
-2
未找到文件。
interfaces/innerkits/reboot/init_reboot_innerkits.c
浏览文件 @
b5bb48df
...
...
@@ -32,7 +32,7 @@
#define DOREBOOT_PARAM "reboot.ut"
#endif
int
DoReboot
(
const
char
*
option
)
int
DoReboot
_
(
const
char
*
option
)
{
char
value
[
MAX_REBOOT_OPTION_SIZE
];
int
ret
=
0
;
...
...
@@ -63,3 +63,25 @@ int DoReboot(const char *option)
BEGET_ERROR_CHECK
(
ret
==
0
,
return
-
1
,
"Set parameter to trigger reboot command
\"
%s
\"
failed"
,
value
);
return
0
;
}
int
DoReboot
(
const
char
*
option
)
{
// check if param set ok
const
int
maxCount
=
10
;
int
count
=
0
;
DoReboot_
(
option
);
while
(
count
<
maxCount
)
{
usleep
(
100
*
1000
);
// 100 * 1000 wait 100ms
char
result
[
10
]
=
{
0
};
// 10 stop len
uint32_t
len
=
sizeof
(
result
);
int
ret
=
SystemGetParameter
(
STARTUP_DEVICE_CTL
,
result
,
&
len
);
if
(
ret
==
0
&&
strcmp
(
result
,
DEVICE_CMD_STOP
)
==
0
)
{
BEGET_LOGE
(
"Success to reboot system"
);
return
0
;
}
count
++
;
DoReboot_
(
option
);
}
BEGET_LOGE
(
"Failed to reboot system"
);
return
0
;
}
interfaces/innerkits/sandbox/app-sandbox.json
浏览文件 @
b5bb48df
...
...
@@ -44,6 +44,22 @@
"src-path"
:
"/data"
,
"sandbox-path"
:
"/data"
,
"sandbox-flags"
:
[
"bind"
,
"rec"
,
"private"
]
},
{
"src-path"
:
"/system/fonts"
,
"sandbox-path"
:
"/system/fonts"
,
"sandbox-flags"
:
[
"bind"
,
"rec"
,
"private"
]
},
{
"src-path"
:
"/config"
,
"sandbox-path"
:
"/config"
,
"sandbox-flags"
:
[
"bind"
,
"rec"
]
},
{
"src-path"
:
"/sys_prod"
,
"sandbox-path"
:
"/sys_prod"
,
"sandbox-flags"
:
[
"bind"
,
"rec"
]
},
{
"src-path"
:
"/storage"
,
"sandbox-path"
:
"/storage"
,
"sandbox-flags"
:
[
"bind"
,
"rec"
,
"private"
]
}
],
"mount-bind-files"
:
[{
...
...
interfaces/innerkits/sandbox/privapp-sandbox.json
浏览文件 @
b5bb48df
...
...
@@ -48,6 +48,22 @@
"src-path"
:
"/data"
,
"sandbox-path"
:
"/data"
,
"sandbox-flags"
:
[
"bind"
,
"rec"
]
},
{
"src-path"
:
"/system/fonts"
,
"sandbox-path"
:
"/system/fonts"
,
"sandbox-flags"
:
[
"bind"
,
"rec"
,
"private"
]
},
{
"src-path"
:
"/config"
,
"sandbox-path"
:
"/config"
,
"sandbox-flags"
:
[
"bind"
,
"rec"
]
},
{
"src-path"
:
"/sys_prod"
,
"sandbox-path"
:
"/sys_prod"
,
"sandbox-flags"
:
[
"bind"
,
"rec"
]
},
{
"src-path"
:
"/storage"
,
"sandbox-path"
:
"/storage"
,
"sandbox-flags"
:
[
"bind"
,
"rec"
,
"private"
]
}
],
"mount-bind-files"
:
[{
...
...
services/include/init_hashmap.h
浏览文件 @
b5bb48df
...
...
@@ -59,6 +59,8 @@ void HashMapRemove(HashMapHandle handle, const void *key);
HashNode
*
HashMapGet
(
HashMapHandle
handle
,
const
void
*
key
);
HashNode
*
HashMapFind
(
HashMapHandle
handle
,
int
hashCode
,
const
void
*
key
,
HashKeyCompare
keyCompare
);
void
HashMapTraverse
(
HashMapHandle
handle
,
void
(
*
hashNodeTraverse
)(
const
HashNode
*
node
,
const
void
*
context
),
const
void
*
context
);
#ifdef __cplusplus
#if __cplusplus
}
...
...
services/init/init_common_service.c
浏览文件 @
b5bb48df
...
...
@@ -259,13 +259,15 @@ static int BindCpuCore(Service *service)
return
SERVICE_SUCCESS
;
}
static
void
ClearEnvironment
(
void
)
static
void
ClearEnvironment
(
Service
*
service
)
{
sigset_t
mask
;
sigemptyset
(
&
mask
);
sigaddset
(
&
mask
,
SIGCHLD
);
sigaddset
(
&
mask
,
SIGTERM
);
sigprocmask
(
SIG_UNBLOCK
,
&
mask
,
NULL
);
if
(
strcmp
(
service
->
name
,
"appspawn"
)
!=
0
)
{
sigset_t
mask
;
sigemptyset
(
&
mask
);
sigaddset
(
&
mask
,
SIGCHLD
);
sigaddset
(
&
mask
,
SIGTERM
);
sigprocmask
(
SIG_UNBLOCK
,
&
mask
,
NULL
);
}
return
;
}
...
...
@@ -297,7 +299,7 @@ int ServiceStart(Service *service)
DoJobNow
(
service
->
serviceJobs
.
jobsName
[
JOB_ON_START
]);
}
ClearEnvironment
();
ClearEnvironment
(
service
);
if
(
!
IsOnDemandService
(
service
))
{
INIT_ERROR_CHECK
(
CreateServiceSocket
(
service
)
>=
0
,
return
SERVICE_FAILURE
,
...
...
services/init/init_service_manager.c
浏览文件 @
b5bb48df
...
...
@@ -781,8 +781,7 @@ int ParseOneService(const cJSON *curItem, Service *service)
INIT_CHECK_RETURN_VALUE
(
curItem
!=
NULL
&&
service
!=
NULL
,
SERVICE_FAILURE
);
int
ret
=
0
;
#ifdef WITH_SELINUX
ret
=
GetStringItem
(
curItem
,
SECON_STR_IN_CFG
,
service
->
secon
,
MAX_SECON_LEN
);
INIT_CHECK_ONLY_ELOG
(
ret
==
0
,
"GetServiceSecon %s section not found, skip"
,
SECON_STR_IN_CFG
);
(
void
)
GetStringItem
(
curItem
,
SECON_STR_IN_CFG
,
service
->
secon
,
MAX_SECON_LEN
);
#endif // WITH_SELINUX
ret
=
GetServiceArgs
(
curItem
,
"path"
,
MAX_PATH_ARGS_CNT
,
&
service
->
pathArgs
);
INIT_ERROR_CHECK
(
ret
==
0
,
return
SERVICE_FAILURE
,
"Failed to get path for service %s"
,
service
->
name
);
...
...
@@ -944,8 +943,10 @@ void StopAllServices(int flags, const char **exclude, int size,
int
(
*
filter
)(
const
Service
*
service
,
const
char
**
exclude
,
int
size
))
{
Service
*
service
=
GetServiceByName
(
"appspawn"
);
if
(((
SERVICE_ATTR_NEEDWAIT
&
flags
)
==
SERVICE_ATTR_NEEDWAIT
)
&&
service
!=
NULL
&&
service
->
pid
!=
0
)
{
if
(
service
!=
NULL
&&
service
->
pid
!=
-
1
)
{
// notify appspawn stop
kill
(
service
->
pid
,
SIGTERM
);
waitpid
(
service
->
pid
,
0
,
0
);
service
->
pid
=
-
1
;
}
InitGroupNode
*
node
=
GetNextGroupNode
(
NODE_TYPE_SERVICES
,
NULL
);
...
...
services/loopevent/include/loop_event.h
浏览文件 @
b5bb48df
...
...
@@ -100,6 +100,7 @@ typedef int (*LE_IncommingConntect)(const LoopHandle loopHandle, const TaskHandl
typedef
struct
{
LE_BaseInfo
baseInfo
;
char
*
server
;
int
socketId
;
LE_DisConntectComplete
disConntectComplete
;
LE_IncommingConntect
incommingConntect
;
LE_SendMessageComplete
sendMessageComplete
;
...
...
services/loopevent/signal/le_signal.c
浏览文件 @
b5bb48df
...
...
@@ -33,7 +33,7 @@ static LE_STATUS HandleSignalEvent_(const LoopHandle loop, const TaskHandle task
}
struct
signalfd_siginfo
fdsi
;
ssize_t
s
=
read
(
GetSocketFd
(
task
),
&
fdsi
,
sizeof
(
fdsi
));
LE_CHECK
(
s
==
sizeof
(
fdsi
),
return
LE_FAILURE
,
"Failed to read sign
"
);
LE_CHECK
(
s
==
sizeof
(
fdsi
),
return
LE_FAILURE
,
"Failed to read sign
%d %d"
,
s
,
errno
);
SignalTask
*
sigTask
=
(
SignalTask
*
)
task
;
if
(
sigTask
->
processSignal
)
{
sigTask
->
processSignal
(
&
fdsi
);
...
...
services/loopevent/task/le_streamtask.c
浏览文件 @
b5bb48df
...
...
@@ -164,8 +164,11 @@ LE_STATUS LE_CreateStreamServer(const LoopHandle loopHandle,
LE_CHECK
(
info
->
incommingConntect
!=
NULL
,
return
LE_INVALID_PARAM
,
"Invalid parameters incommingConntect %s"
,
info
->
server
);
int
fd
=
CreateSocket
(
info
->
baseInfo
.
flags
,
info
->
server
);
LE_CHECK
(
fd
>
0
,
return
LE_FAILURE
,
"Failed to create socket %s"
,
info
->
server
);
int
fd
=
info
->
socketId
;
if
(
info
->
socketId
<=
0
)
{
fd
=
CreateSocket
(
info
->
baseInfo
.
flags
,
info
->
server
);
LE_CHECK
(
fd
>
0
,
return
LE_FAILURE
,
"Failed to create socket %s"
,
info
->
server
);
}
EventLoop
*
loop
=
(
EventLoop
*
)
loopHandle
;
StreamServerTask
*
task
=
(
StreamServerTask
*
)
CreateTask
(
loopHandle
,
fd
,
&
info
->
baseInfo
,
...
...
services/utils/init_hashmap.c
浏览文件 @
b5bb48df
...
...
@@ -113,7 +113,6 @@ void HashMapRemove(HashMapHandle handle, const void *key)
while
(
node
!=
NULL
)
{
int
ret
=
tab
->
keyCompare
(
node
,
key
);
if
(
ret
==
0
)
{
INIT_LOGV
(
"HashMapRemove tableId %d hashCode %d node %p"
,
tab
->
tableId
,
hashCode
,
node
);
if
(
node
==
tab
->
buckets
[
hashCode
])
{
tab
->
buckets
[
hashCode
]
=
node
->
next
;
}
else
{
...
...
@@ -173,4 +172,19 @@ HashNode *HashMapFind(HashMapHandle handle,
"Invalid hashcode %d %d"
,
tab
->
maxBucket
,
hashCode
);
INIT_LOGV
(
"HashMapGet tableId %d hashCode %d"
,
tab
->
tableId
,
hashCode
);
return
GetHashNodeByKey
(
tab
,
tab
->
buckets
[
hashCode
],
key
,
keyCompare
);
}
\ No newline at end of file
}
void
HashMapTraverse
(
HashMapHandle
handle
,
void
(
*
hashNodeTraverse
)(
const
HashNode
*
node
,
const
void
*
context
),
const
void
*
context
)
{
INIT_ERROR_CHECK
(
handle
!=
NULL
&&
hashNodeTraverse
!=
NULL
,
return
,
"Invalid param"
);
HashTab
*
tab
=
(
HashTab
*
)
handle
;
for
(
int
i
=
0
;
i
<
tab
->
maxBucket
;
i
++
)
{
HashNode
*
node
=
tab
->
buckets
[
i
];
while
(
node
!=
NULL
)
{
HashNode
*
next
=
node
->
next
;
hashNodeTraverse
(
node
,
context
);
node
=
next
;
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录