Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
b8151479
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看板
提交
b8151479
编写于
10月 28, 2021
作者:
O
openharmony_ci
提交者:
Gitee
10月 28, 2021
浏览文件
操作
浏览文件
下载
差异文件
!151 fix: add service file func
Merge pull request !151 from 熊磊/init1027
上级
00280336
4af662c1
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
404 addition
and
3 deletion
+404
-3
interfaces/innerkits/file/BUILD.gn
interfaces/innerkits/file/BUILD.gn
+30
-0
interfaces/innerkits/file/init_file.c
interfaces/innerkits/file/init_file.c
+61
-0
interfaces/innerkits/include/init_file.h
interfaces/innerkits/include/init_file.h
+23
-0
services/BUILD.gn
services/BUILD.gn
+2
-0
services/include/init_utils.h
services/include/init_utils.h
+2
-0
services/init/include/init_service.h
services/init/include/init_service.h
+2
-0
services/init/include/init_service_file.h
services/init/include/init_service_file.h
+52
-0
services/init/init_common_service.c
services/init/init_common_service.c
+3
-0
services/init/init_service_file.c
services/init/init_service_file.c
+120
-0
services/init/init_service_manager.c
services/init/init_service_manager.c
+92
-3
services/test/unittest/BUILD.gn
services/test/unittest/BUILD.gn
+2
-0
services/test/unittest/common/BUILD.gn
services/test/unittest/common/BUILD.gn
+1
-0
services/utils/init_utils.c
services/utils/init_utils.c
+14
-0
未找到文件。
interfaces/innerkits/file/BUILD.gn
0 → 100755
浏览文件 @
b8151479
# Copyright (c) 2021 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("//build/ohos.gni")
ohos_static_library("libfile") {
sources = [ "//base/startup/init_lite/interfaces/innerkits/file/init_file.c" ]
include_dirs = [
"//base/startup/init_lite/interfaces/innerkits/include",
"//base/startup/init_lite/services/log",
"//base/startup/init_lite/services/include",
"//third_party/bounds_checking_function/include",
]
deps = [
"//base/startup/init_lite/services/log:init_log",
"//base/startup/init_lite/services/utils:libinit_utils",
"//third_party/bounds_checking_function:libsec_static",
]
}
interfaces/innerkits/file/init_file.c
0 → 100755
浏览文件 @
b8151479
/*
* Copyright (c) 2021 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 "init_file.h"
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include "init_log.h"
#include "init_utils.h"
#include "securec.h"
#define N_DEC 10
int
GetControlFile
(
const
char
*
pathName
)
{
if
(
pathName
==
NULL
)
{
return
-
1
;
}
char
path
[
PATH_MAX
]
=
{
0
};
if
(
snprintf_s
(
path
,
sizeof
(
path
),
sizeof
(
path
)
-
1
,
OHOS_FILE_ENV_PREFIX
"%s"
,
pathName
)
==
-
1
)
{
return
-
1
;
}
if
(
StringReplaceChr
(
path
,
'/'
,
'_'
)
<
0
)
{
return
-
1
;
}
INIT_LOGI
(
"Environment path is %s "
,
path
);
const
char
*
val
=
getenv
(
path
);
if
(
val
==
NULL
)
{
INIT_LOGE
(
"Failed getenv err=%d"
,
errno
);
return
-
1
;
}
errno
=
0
;
int
fd
=
strtol
(
val
,
NULL
,
N_DEC
);
if
(
errno
!=
0
)
{
INIT_LOGE
(
"Failed strtol val"
);
return
-
1
;
}
INIT_LOGI
(
"Get environment fd is %d "
,
fd
);
if
(
fcntl
(
fd
,
F_GETFD
)
<
0
)
{
INIT_LOGE
(
"Failed fcntl fd err=%d "
,
errno
);
return
-
1
;
}
return
fd
;
}
interfaces/innerkits/include/init_file.h
0 → 100755
浏览文件 @
b8151479
/*
* Copyright (c) 2021 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.
*/
#ifndef INIT_FILE_API_H
#define INIT_FILE_API_H
#define OHOS_FILE_ENV_PREFIX "OHOS_FILE_"
int
GetControlFile
(
const
char
*
name
);
#endif
services/BUILD.gn
浏览文件 @
b8151479
...
...
@@ -16,6 +16,7 @@ init_common_sources = [
"init/init_common_cmds.c",
"init/init_common_service.c",
"init/init_config.c",
"init/init_service_file.c",
"init/init_service_manager.c",
"init/init_service_socket.c",
"init/main.c",
...
...
@@ -166,6 +167,7 @@ if (defined(ohos_lite)) {
":init",
":init_etc",
"//base/startup/init_lite/interfaces/innerkits/dynamic_service:dynamic_service",
"//base/startup/init_lite/interfaces/innerkits/file:libfile",
"//base/startup/init_lite/interfaces/innerkits/fs_manager:libfsmanager_shared",
"//base/startup/init_lite/interfaces/innerkits/socket:libsocket",
"//base/startup/init_lite/services/cmds/reboot:reboot",
...
...
services/include/init_utils.h
浏览文件 @
b8151479
...
...
@@ -45,6 +45,8 @@ int ReadFileInDir(const char *dirPath, const char *includeExt,
char
**
SplitStringExt
(
char
*
buffer
,
const
char
*
del
,
int
*
returnCount
,
int
maxItemCount
);
void
FreeStringVector
(
char
**
vector
,
int
count
);
int
InUpdaterMode
(
void
);
int
StringReplaceChr
(
char
*
strl
,
char
oldChr
,
char
newChr
);
#ifdef __cplusplus
#if __cplusplus
}
...
...
services/init/include/init_service.h
浏览文件 @
b8151479
...
...
@@ -18,6 +18,7 @@
#include "cJSON.h"
#include "init_cmds.h"
#include "init_service_file.h"
#include "init_service_socket.h"
#ifdef WITH_SELINUX
# include "init_selinux_param.h"
...
...
@@ -84,6 +85,7 @@ typedef struct {
ServiceArgs
writePidArgs
;
CmdLines
*
restartArg
;
ServiceSocket
*
socketCfg
;
ServiceFile
*
fileCfg
;
}
Service
;
int
ServiceStart
(
Service
*
service
);
...
...
services/init/include/init_service_file.h
0 → 100755
浏览文件 @
b8151479
/*
* Copyright (c) 2020-2021 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.
*/
#ifndef INIT_SERVICE_FILE_
#define INIT_SERVICE_FILE_
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#ifdef __cplusplus
#if __cplusplus
extern
"C"
{
#endif
#endif
#define FILE_OPT_NUMS 5
#define SERVICE_FILE_NAME 0
#define SERVICE_FILE_FLAGS 1
#define SERVICE_FILE_PERM 2
#define SERVICE_FILE_UID 3
#define SERVICE_FILE_GID 4
typedef
struct
ServiceFile_
{
struct
ServiceFile_
*
next
;
int
flags
;
uid_t
uid
;
// uid
gid_t
gid
;
// gid
mode_t
perm
;
// Setting permissions
int
fd
;
char
fileName
[
0
];
}
ServiceFile
;
void
CreateServiceFile
(
ServiceFile
*
fileOpt
);
void
CloseServiceFile
(
ServiceFile
*
fileOpt
);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif
#endif
services/init/init_common_service.c
浏览文件 @
b8151479
...
...
@@ -213,6 +213,7 @@ int ServiceStart(Service *service)
INIT_LOGE
(
"service %s exit! create socket failed!"
,
service
->
name
);
_exit
(
PROCESS_EXIT_CODE
);
}
CreateServiceFile
(
service
->
fileCfg
);
if
(
service
->
attribute
&
SERVICE_ATTR_CONSOLE
)
{
OpenConsole
();
}
...
...
@@ -248,6 +249,7 @@ int ServiceStop(Service *service)
return
SERVICE_SUCCESS
;
}
CloseServiceSocket
(
service
->
socketCfg
);
CloseServiceFile
(
service
->
fileCfg
);
if
(
kill
(
service
->
pid
,
SIGKILL
)
!=
0
)
{
INIT_LOGE
(
"stop service %s pid %d failed! err %d."
,
service
->
name
,
service
->
pid
,
errno
);
return
SERVICE_FAILURE
;
...
...
@@ -303,6 +305,7 @@ void ServiceReap(Service *service)
}
CloseServiceSocket
(
service
->
socketCfg
);
CloseServiceFile
(
service
->
fileCfg
);
// stopped by system-init itself, no need to restart even if it is not one-shot service
if
(
service
->
attribute
&
SERVICE_ATTR_NEED_STOP
)
{
service
->
attribute
&=
(
~
SERVICE_ATTR_NEED_STOP
);
...
...
services/init/init_service_file.c
0 → 100755
浏览文件 @
b8151479
/*
* Copyright (c) 2020-2021 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 "init_service_file.h"
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "init_log.h"
#include "init_service.h"
#include "init_utils.h"
#include "securec.h"
#define HOS_FILE_ENV_PREFIX "OHOS_FILE_"
#define MAX_FILE_FD_LEN 16
static
int
CreateFile
(
ServiceFile
*
file
)
{
INIT_CHECK
(
file
!=
NULL
&&
file
->
fileName
!=
NULL
,
return
-
1
);
char
path
[
PATH_MAX
]
=
{
0
};
if
(
realpath
(
file
->
fileName
,
path
)
==
NULL
)
{
INIT_LOGE
(
"Failed realpath err=%d"
,
errno
);
}
INIT_LOGI
(
"File path =%s . file flags =%d, file perm =%u "
,
path
,
file
->
flags
,
file
->
perm
);
if
(
file
->
fd
>=
0
)
{
close
(
file
->
fd
);
file
->
fd
=
-
1
;
}
int
fd
=
open
(
path
,
file
->
flags
|
O_CREAT
,
file
->
perm
);
if
(
fd
<
0
)
{
INIT_LOGE
(
"Failed open %s, err=%d "
,
path
,
errno
);
return
-
1
;
}
close
(
fd
);
fd
=
-
1
;
if
(
chmod
(
path
,
file
->
perm
)
<
0
)
{
INIT_LOGE
(
"Failed chmod err=%d"
,
errno
);
}
if
(
chown
(
path
,
file
->
uid
,
file
->
gid
)
<
0
)
{
INIT_LOGE
(
"Failed chown err=%d"
,
errno
);
}
file
->
fd
=
open
(
path
,
file
->
flags
);
return
file
->
fd
;
}
static
int
SetFileEnv
(
int
fd
,
const
char
*
pathName
)
{
INIT_ERROR_CHECK
(
pathName
!=
NULL
,
return
-
1
,
"Invalid fileName"
);
char
pubName
[
PATH_MAX
]
=
{
0
};
if
(
snprintf_s
(
pubName
,
sizeof
(
pubName
),
sizeof
(
pubName
)
-
1
,
HOS_FILE_ENV_PREFIX
"%s"
,
pathName
)
<
0
)
{
return
-
1
;
}
if
(
StringReplaceChr
(
pubName
,
'/'
,
'_'
)
<
0
)
{
return
-
1
;
}
char
val
[
MAX_FILE_FD_LEN
]
=
{
0
};
if
(
snprintf_s
(
val
,
sizeof
(
val
),
sizeof
(
val
)
-
1
,
"%d"
,
fd
)
<
0
)
{
return
-
1
;
}
INIT_LOGE
(
"Set file env pubName =%s, val =%s."
,
pubName
,
val
);
int
ret
=
setenv
(
pubName
,
val
,
1
);
if
(
ret
<
0
)
{
INIT_LOGE
(
"Failed setenv err=%d "
,
errno
);
return
-
1
;
}
fcntl
(
fd
,
F_SETFD
,
0
);
return
0
;
}
void
CreateServiceFile
(
ServiceFile
*
fileOpt
)
{
INIT_CHECK
(
fileOpt
!=
NULL
,
return
);
ServiceFile
*
tmpFile
=
fileOpt
;
while
(
tmpFile
!=
NULL
)
{
int
fd
=
CreateFile
(
tmpFile
);
if
(
fd
<
0
)
{
INIT_LOGE
(
"Failed Create File err=%d "
,
errno
);
tmpFile
=
tmpFile
->
next
;
continue
;
}
int
ret
=
SetFileEnv
(
fd
,
tmpFile
->
fileName
);
if
(
ret
<
0
)
{
INIT_LOGE
(
"Failed Set File Env"
);
}
tmpFile
=
tmpFile
->
next
;
}
return
;
}
void
CloseServiceFile
(
ServiceFile
*
fileOpt
)
{
INIT_CHECK
(
fileOpt
!=
NULL
,
return
);
ServiceFile
*
tmpFileOpt
=
fileOpt
;
while
(
tmpFileOpt
!=
NULL
)
{
ServiceFile
*
tmp
=
tmpFileOpt
;
if
(
tmp
->
fd
>=
0
)
{
close
(
tmp
->
fd
);
tmp
->
fd
=
-
1
;
}
tmpFileOpt
=
tmpFileOpt
->
next
;
}
return
;
}
services/init/init_service_manager.c
浏览文件 @
b8151479
...
...
@@ -27,6 +27,7 @@
#include "init.h"
#include "init_jobs_internal.h"
#include "init_log.h"
#include "init_service_file.h"
#include "init_service_socket.h"
#include "init_utils.h"
#include "securec.h"
...
...
@@ -131,6 +132,20 @@ static Service *AddService(void)
return
service
;
}
static
void
FreeServiceFile
(
ServiceFile
*
fileOpt
)
{
while
(
fileOpt
!=
NULL
)
{
ServiceFile
*
tmp
=
fileOpt
;
if
(
tmp
->
fd
>=
0
)
{
close
(
tmp
->
fd
);
tmp
->
fd
=
-
1
;
}
fileOpt
=
fileOpt
->
next
;
free
(
tmp
);
}
return
;
}
static
void
ReleaseService
(
Service
*
service
)
{
if
(
service
==
NULL
)
{
...
...
@@ -150,6 +165,7 @@ static void ReleaseService(Service *service)
}
service
->
servPerm
.
gIDCnt
=
0
;
FreeServiceSocket
(
service
->
socketCfg
);
FreeServiceFile
(
service
->
fileCfg
);
if
(
!
ListEmpty
(
service
->
node
))
{
ListRemove
(
&
service
->
node
);
...
...
@@ -331,6 +347,7 @@ static int AddServiceSocket(cJSON *json, Service *service)
if
(
strncmp
(
opt
[
SERVICE_SOCK_SETOPT
],
"passcred"
,
strlen
(
opt
[
SERVICE_SOCK_SETOPT
]))
==
0
)
{
sockopt
->
passcred
=
true
;
}
sockopt
->
sockFd
=
-
1
;
sockopt
->
next
=
NULL
;
if
(
service
->
socketCfg
==
NULL
)
{
service
->
socketCfg
=
sockopt
;
...
...
@@ -358,6 +375,75 @@ static int ParseServiceSocket(const cJSON *curArrItem, Service *curServ)
return
ret
;
}
static
int
AddServiceFile
(
cJSON
*
json
,
Service
*
service
)
{
if
(
!
cJSON_IsString
(
json
)
||
!
cJSON_GetStringValue
(
json
))
{
return
SERVICE_FAILURE
;
}
char
*
fileStr
=
cJSON_GetStringValue
(
json
);
char
*
opt
[
FILE_OPT_NUMS
]
=
{
NULL
,
};
int
num
=
SplitString
(
fileStr
,
" "
,
opt
,
FILE_OPT_NUMS
);
if
(
num
!=
FILE_OPT_NUMS
)
{
return
SERVICE_FAILURE
;
}
if
(
opt
[
SERVICE_FILE_NAME
]
==
NULL
||
opt
[
SERVICE_FILE_FLAGS
]
==
NULL
||
opt
[
SERVICE_FILE_PERM
]
==
NULL
||
opt
[
SERVICE_FILE_UID
]
==
NULL
||
opt
[
SERVICE_FILE_GID
]
==
NULL
)
{
INIT_LOGE
(
"Invalid file opt"
);
return
SERVICE_FAILURE
;
}
ServiceFile
*
fileOpt
=
(
ServiceFile
*
)
calloc
(
1
,
sizeof
(
ServiceFile
)
+
strlen
(
opt
[
SERVICE_FILE_NAME
])
+
1
);
INIT_INFO_CHECK
(
fileOpt
!=
NULL
,
return
SERVICE_FAILURE
,
"Failed to calloc for file %s"
,
opt
[
SERVICE_FILE_NAME
]);
int
ret
=
strcpy_s
(
fileOpt
->
fileName
,
strlen
(
opt
[
SERVICE_FILE_NAME
])
+
1
,
opt
[
SERVICE_FILE_NAME
]);
INIT_INFO_CHECK
(
ret
==
0
,
free
(
fileOpt
);
return
SERVICE_FAILURE
,
"Failed to copy file name %s"
,
opt
[
SERVICE_FILE_NAME
]);
if
(
strcmp
(
opt
[
SERVICE_FILE_FLAGS
],
"rd"
)
==
0
)
{
fileOpt
->
flags
=
O_RDONLY
;
}
else
if
(
strcmp
(
opt
[
SERVICE_FILE_FLAGS
],
"wd"
)
==
0
)
{
fileOpt
->
flags
=
O_WRONLY
;
}
else
if
(
strcmp
(
opt
[
SERVICE_FILE_FLAGS
],
"rw"
)
==
0
)
{
fileOpt
->
flags
=
O_RDWR
;
}
else
{
INIT_LOGE
(
"Failed file flags %s"
,
opt
[
SERVICE_FILE_FLAGS
]);
return
SERVICE_FAILURE
;
}
fileOpt
->
perm
=
strtoul
(
opt
[
SERVICE_FILE_PERM
],
0
,
OCTAL_BASE
);
fileOpt
->
uid
=
DecodeUid
(
opt
[
SERVICE_FILE_UID
]);
fileOpt
->
gid
=
DecodeUid
(
opt
[
SERVICE_FILE_GID
]);
if
(
fileOpt
->
uid
==
(
uid_t
)
-
1
||
fileOpt
->
gid
==
(
gid_t
)
-
1
)
{
free
(
fileOpt
);
INIT_LOGE
(
"Invalid uid %d or gid %d"
,
fileOpt
->
uid
,
fileOpt
->
gid
);
return
SERVICE_FAILURE
;
}
fileOpt
->
fd
=
-
1
;
fileOpt
->
next
=
NULL
;
if
(
service
->
fileCfg
==
NULL
)
{
service
->
fileCfg
=
fileOpt
;
}
else
{
fileOpt
->
next
=
service
->
fileCfg
->
next
;
service
->
fileCfg
->
next
=
fileOpt
;
}
return
SERVICE_SUCCESS
;
}
static
int
ParseServiceFile
(
const
cJSON
*
curArrItem
,
Service
*
curServ
)
{
int
fileCnt
=
0
;
cJSON
*
filedJ
=
GetArrayItem
(
curArrItem
,
&
fileCnt
,
"file"
);
INIT_CHECK
(
filedJ
!=
NULL
&&
fileCnt
>
0
,
return
SERVICE_FAILURE
);
int
ret
=
0
;
curServ
->
fileCfg
=
NULL
;
for
(
int
i
=
0
;
i
<
fileCnt
;
++
i
)
{
cJSON
*
fileJ
=
cJSON_GetArrayItem
(
filedJ
,
i
);
ret
=
AddServiceFile
(
fileJ
,
curServ
);
if
(
ret
!=
0
)
{
break
;
}
}
return
ret
;
}
static
bool
IsServiceInMainStrap
(
Service
*
curServ
)
{
char
*
mainServiceList
[]
=
{
...
...
@@ -402,7 +488,7 @@ static int CheckServiceKeyName(const cJSON *curService)
{
char
*
cfgServiceKeyList
[]
=
{
"name"
,
"path"
,
"uid"
,
"gid"
,
"once"
,
"importance"
,
"caps"
,
"disabled"
,
"writepid"
,
"critical"
,
"socket"
,
"console"
,
"dynamic"
,
"writepid"
,
"critical"
,
"socket"
,
"console"
,
"dynamic"
,
"file"
,
#ifdef WITH_SELINUX
SECON_STR_IN_CFG
,
#endif // WITH_SELINUX
...
...
@@ -512,11 +598,14 @@ void ParseAllServices(const cJSON *fileRoot)
ReleaseService
(
service
);
continue
;
}
ret
=
ParseServiceSocket
(
curItem
,
service
);
if
(
ret
!=
SERVICE_SUCCESS
)
{
if
(
ParseServiceSocket
(
curItem
,
service
)
!=
SERVICE_SUCCESS
)
{
FreeServiceSocket
(
service
->
socketCfg
);
service
->
socketCfg
=
NULL
;
}
if
(
ParseServiceFile
(
curItem
,
service
)
!=
SERVICE_SUCCESS
)
{
FreeServiceFile
(
service
->
fileCfg
);
service
->
fileCfg
=
NULL
;
}
ret
=
GetCmdLinesFromJson
(
cJSON_GetObjectItem
(
curItem
,
"onrestart"
),
&
service
->
restartArg
);
if
(
ret
!=
SERVICE_SUCCESS
)
{
service
->
restartArg
=
NULL
;
...
...
services/test/unittest/BUILD.gn
浏览文件 @
b8151479
...
...
@@ -32,6 +32,7 @@ config("utest_config") {
ohos_unittest("init_ut") {
module_out_path = "startup/init"
sources = [
"//base/startup/init_lite/interfaces/innerkits/file/init_file.c",
"//base/startup/init_lite/interfaces/innerkits/fs_manager/fstab.c",
"//base/startup/init_lite/interfaces/innerkits/fs_manager/fstab_mount.c",
"//base/startup/init_lite/services/init/adapter/init_adapter.c",
...
...
@@ -39,6 +40,7 @@ ohos_unittest("init_ut") {
"//base/startup/init_lite/services/init/init_common_cmds.c",
"//base/startup/init_lite/services/init/init_common_service.c",
"//base/startup/init_lite/services/init/init_config.c",
"//base/startup/init_lite/services/init/init_service_file.c",
"//base/startup/init_lite/services/init/init_service_manager.c",
"//base/startup/init_lite/services/init/init_service_socket.c",
"//base/startup/init_lite/services/init/standard/device.c",
...
...
services/test/unittest/common/BUILD.gn
浏览文件 @
b8151479
...
...
@@ -43,6 +43,7 @@ if (defined(ohos_lite)) {
"//base/startup/init_lite/services/init/init_common_cmds.c",
"//base/startup/init_lite/services/init/init_common_service.c",
"//base/startup/init_lite/services/init/init_config.c",
"//base/startup/init_lite/services/init/init_service_file.c",
"//base/startup/init_lite/services/init/init_service_manager.c",
"//base/startup/init_lite/services/init/init_service_socket.c",
"//base/startup/init_lite/services/init/lite/init.c",
...
...
services/utils/init_utils.c
浏览文件 @
b8151479
...
...
@@ -372,3 +372,17 @@ int InUpdaterMode(void)
return
0
;
}
}
int
StringReplaceChr
(
char
*
strl
,
char
oldChr
,
char
newChr
)
{
INIT_ERROR_CHECK
(
strl
!=
NULL
,
return
-
1
,
"Invalid parament"
);
char
*
p
=
strl
;
while
(
*
p
!=
'\0'
)
{
if
(
*
p
==
oldChr
)
{
*
p
=
newChr
;
}
p
++
;
}
INIT_LOGD
(
"strl is %s"
,
strl
);
return
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录