Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
0cbac6f4
S
Startup Init Lite
项目概览
OpenHarmony
/
Startup Init Lite
11 个月 前同步成功
通知
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0cbac6f4
编写于
12月 13, 2021
作者:
O
openharmony_ci
提交者:
Gitee
12月 13, 2021
浏览文件
操作
浏览文件
下载
差异文件
!187 代码整改
Merge pull request !187 from 熊磊/startup_init_lite1213
上级
df51f3bd
d7f420d8
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
45 addition
and
31 deletion
+45
-31
interfaces/innerkits/fs_manager/fs_manager_log.c
interfaces/innerkits/fs_manager/fs_manager_log.c
+1
-1
interfaces/innerkits/fs_manager/fstab.c
interfaces/innerkits/fs_manager/fstab.c
+2
-2
services/begetctl/init_cmd_reboot.c
services/begetctl/init_cmd_reboot.c
+1
-1
services/begetctl/misc_daemon.cpp
services/begetctl/misc_daemon.cpp
+5
-0
services/init/init_common_service.c
services/init/init_common_service.c
+2
-2
services/init/init_service_manager.c
services/init/init_service_manager.c
+3
-3
services/init/lite/init_cmds.c
services/init/lite/init_cmds.c
+1
-1
services/init/standard/init_cmds.c
services/init/standard/init_cmds.c
+1
-1
services/init/standard/init_mount.c
services/init/standard/init_mount.c
+2
-2
services/init/standard/init_reboot.c
services/init/standard/init_reboot.c
+3
-3
services/log/init_log.c
services/log/init_log.c
+2
-1
services/param/adapter/param_libuvadp.c
services/param/adapter/param_libuvadp.c
+1
-1
services/param/watcher/proxy/watcher_manager.cpp
services/param/watcher/proxy/watcher_manager.cpp
+5
-2
test/unittest/init/cmds_unittest.cpp
test/unittest/init/cmds_unittest.cpp
+2
-2
test/unittest/init/service_file_unittest.cpp
test/unittest/init/service_file_unittest.cpp
+1
-1
test/unittest/init/service_unittest.cpp
test/unittest/init/service_unittest.cpp
+2
-0
test/unittest/param/client_unittest.cpp
test/unittest/param/client_unittest.cpp
+9
-6
ueventd/ueventd_device_handler.c
ueventd/ueventd_device_handler.c
+1
-1
watchdog/init_watchdog.c
watchdog/init_watchdog.c
+1
-1
未找到文件。
interfaces/innerkits/fs_manager/fs_manager_log.c
浏览文件 @
0cbac6f4
...
...
@@ -92,7 +92,7 @@ static void WriteLogToFile(FILE *fp, const char *fileName, int line, const char
char
fullLogMsg
[
LOG_BUFFER_MAX
];
if
(
snprintf_s
(
fullLogMsg
,
LOG_BUFFER_MAX
,
LOG_BUFFER_MAX
-
1
,
"[%s:%d][%s] %s"
,
fileName
==
NULL
?
""
:
fileName
,
line
,
"fs_manager"
,
fmt
)
==
-
1
)
{
(
fileName
==
NULL
)
?
""
:
fileName
,
line
,
"fs_manager"
,
fmt
)
==
-
1
)
{
return
;
}
(
void
)
fprintf
(
fp
,
"%s"
,
fullLogMsg
);
...
...
interfaces/innerkits/fs_manager/fstab.c
浏览文件 @
0cbac6f4
...
...
@@ -106,8 +106,8 @@ void ReleaseFstabItem(FstabItem *item)
free
(
item
->
mountOptions
);
item
->
mountOptions
=
NULL
;
}
free
(
item
);
item
=
NULL
;
}
}
...
...
@@ -179,7 +179,7 @@ static int ParseFstabPerLine(char *str, Fstab *fstab, bool procMounts)
return
0
;
}
while
(
0
);
free
(
item
);
ReleaseFstabItem
(
item
);
item
=
NULL
;
return
-
1
;
}
...
...
services/begetctl/init_cmd_reboot.c
浏览文件 @
0cbac6f4
...
...
@@ -44,7 +44,7 @@ static int main_cmd(int argc, char* argv[])
printf
(
"%s"
,
USAGE_INFO
);
return
0
;
}
int
ret
=
0
;
int
ret
;
if
(
argc
==
REBOOT_CMD_NUMBER
)
{
ret
=
DoReboot
(
argv
[
1
]);
}
else
{
...
...
services/begetctl/misc_daemon.cpp
浏览文件 @
0cbac6f4
...
...
@@ -199,6 +199,9 @@ static void WriteLogoToMisc(const std::string &logoPath)
close
(
fd
);
int
addrOffset
=
(
PARTITION_INFO_POS
+
PARTITION_INFO_MAX_LENGTH
+
BLOCK_SZIE_1
-
1
)
/
BLOCK_SZIE_1
;
int
fd1
=
open
(
miscDev
.
c_str
(),
O_RDWR
|
O_CLOEXEC
,
S_IRUSR
|
S_IWUSR
|
S_IRGRP
|
S_IROTH
);
if
(
fd1
<
0
)
{
return
;
}
if
(
lseek
(
fd1
,
addrOffset
*
BLOCK_SZIE_1
,
SEEK_SET
)
<
0
)
{
std
::
cout
<<
"Failed to seek file
\n
"
;
close
(
fd1
);
...
...
@@ -209,10 +212,12 @@ static void WriteLogoToMisc(const std::string &logoPath)
uint32_t
size
=
0
;
if
(
read
(
fd1
,
&
magic
,
sizeof
(
uint32_t
))
!=
sizeof
(
uint32_t
))
{
std
::
cout
<<
"Failed to read magic number
\n
"
;
close
(
fd1
);
return
;
}
if
(
read
(
fd1
,
&
size
,
sizeof
(
uint32_t
))
!=
sizeof
(
uint32_t
))
{
std
::
cout
<<
"Failed to read magic number
\n
"
;
close
(
fd1
);
return
;
}
...
...
services/init/init_common_service.c
浏览文件 @
0cbac6f4
...
...
@@ -12,7 +12,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "init_service.h"
#include <errno.h>
#include <fcntl.h>
...
...
@@ -32,6 +31,7 @@
#include "init_adapter.h"
#include "init_cmds.h"
#include "init_log.h"
#include "init_service.h"
#include "init_service_socket.h"
#include "init_utils.h"
#include "securec.h"
...
...
@@ -322,7 +322,7 @@ void ServiceReap(Service *service)
}
}
int
ret
=
0
;
int
ret
;
if
(
service
->
restartArg
!=
NULL
)
{
ret
=
ExecRestartCmd
(
service
);
INIT_CHECK_ONLY_ELOG
(
ret
==
SERVICE_SUCCESS
,
"Failed to exec restartArg for %s"
,
service
->
name
);
...
...
services/init/init_service_manager.c
浏览文件 @
0cbac6f4
...
...
@@ -238,7 +238,7 @@ static int GetUid(cJSON *json, uid_t *uid)
static
int
GetServiceGids
(
const
cJSON
*
curArrItem
,
Service
*
curServ
)
{
int
gidCount
=
0
;
int
gidCount
;
cJSON
*
arrItem
=
cJSON_GetObjectItemCaseSensitive
(
curArrItem
,
GID_STR_IN_CFG
);
if
(
!
cJSON_IsArray
(
arrItem
))
{
gidCount
=
1
;
...
...
@@ -327,7 +327,7 @@ static int AddServiceSocket(cJSON *json, Service *service)
if
(
sockopt
->
uid
==
(
uid_t
)
-
1
||
sockopt
->
gid
==
(
uid_t
)
-
1
)
{
free
(
sockopt
);
sockopt
=
NULL
;
INIT_LOGE
(
"Invalid uid
%d or gid %d"
,
sockopt
->
uid
,
sockopt
->
gid
);
INIT_LOGE
(
"Invalid uid
or gid"
);
return
SERVICE_FAILURE
;
}
sockopt
->
passcred
=
false
;
...
...
@@ -401,7 +401,7 @@ static int AddServiceFile(cJSON *json, Service *service)
if
(
fileOpt
->
uid
==
(
uid_t
)
-
1
||
fileOpt
->
gid
==
(
gid_t
)
-
1
)
{
free
(
fileOpt
);
fileOpt
=
NULL
;
INIT_LOGE
(
"Invalid uid
%d or gid %d"
,
fileOpt
->
uid
,
fileOpt
->
gid
);
INIT_LOGE
(
"Invalid uid
or gid"
);
return
SERVICE_FAILURE
;
}
fileOpt
->
fd
=
-
1
;
...
...
services/init/lite/init_cmds.c
浏览文件 @
0cbac6f4
...
...
@@ -38,7 +38,7 @@ static void DoExec(const struct CmdArgs *ctx)
}
if
(
pid
==
0
)
{
if
(
ctx
==
NULL
||
ctx
->
argv
[
0
]
==
NULL
)
{
INIT_LOGE
(
"DoExec: invalid arguments
for :%s"
,
ctx
->
argv
[
0
]
);
INIT_LOGE
(
"DoExec: invalid arguments
"
);
_exit
(
0x7f
);
}
int
ret
=
execve
(
ctx
->
argv
[
0
],
ctx
->
argv
,
NULL
);
...
...
services/init/standard/init_cmds.c
浏览文件 @
0cbac6f4
...
...
@@ -43,7 +43,7 @@ int GetParamValue(const char *symValue, unsigned int symLen, char *paramValue, u
{
INIT_CHECK_RETURN_VALUE
((
symValue
!=
NULL
)
&&
(
paramValue
!=
NULL
)
&&
(
paramLen
!=
0
),
-
1
);
char
tmpName
[
PARAM_NAME_LEN_MAX
]
=
{
0
};
int
ret
=
0
;
int
ret
;
uint32_t
curr
=
0
;
char
*
start
=
(
char
*
)
symValue
;
char
*
end
=
(
char
*
)
symValue
+
symLen
;
...
...
services/init/standard/init_mount.c
浏览文件 @
0cbac6f4
...
...
@@ -21,8 +21,8 @@
int
MountRequriedPartitions
(
const
Fstab
*
fstab
)
{
INIT_ERROR_CHECK
(
fstab
!=
NULL
,
return
-
1
,
"Failed fstab is NULL"
);
int
rc
=
-
1
;
int
rc
;
INIT_LOGI
(
"Mount required partitions"
);
rc
=
MountAllWithFstab
(
fstab
,
1
);
return
rc
;
}
\ No newline at end of file
}
services/init/standard/init_reboot.c
浏览文件 @
0cbac6f4
...
...
@@ -59,17 +59,17 @@ static int RBMiscReadUpdaterMessage(const char *path, struct RBMiscUpdateMessage
INIT_CHECK_RETURN_VALUE
(
realPath
!=
NULL
,
-
1
);
int
ret
=
0
;
FILE
*
fp
=
fopen
(
realPath
,
"rb"
);
free
(
realPath
);
realPath
=
NULL
;
if
(
fp
!=
NULL
)
{
size_t
readLen
=
fread
(
boot
,
1
,
sizeof
(
struct
RBMiscUpdateMessage
),
fp
);
(
void
)
fclose
(
fp
);
INIT_ERROR_CHECK
(
readLen
>
0
,
ret
=
-
1
,
"Failed to read misc for reboot"
);
}
else
{
ret
=
-
1
;
INIT_LOGE
(
"Failed to open %s"
,
path
);
}
free
(
realPath
);
realPath
=
NULL
;
(
void
)
fclose
(
fp
);
return
ret
;
}
...
...
services/log/init_log.c
浏览文件 @
0cbac6f4
...
...
@@ -14,6 +14,7 @@
*/
#include "init_log.h"
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
...
...
@@ -162,4 +163,4 @@ void InitLog(const char *outFileName, InitLogLevel logLevel, const char *kLevel,
fclose
(
outfile
);
return
;
}
#endif
\ No newline at end of file
#endif
services/param/adapter/param_libuvadp.c
浏览文件 @
0cbac6f4
...
...
@@ -241,7 +241,7 @@ int ParamTaskSendMsg(const ParamTaskPtr stream, const ParamMessage *msg)
LibuvStreamTask
*
worker
=
(
LibuvStreamTask
*
)
stream
;
req
->
buf
=
uv_buf_init
((
char
*
)
msg
,
msg
->
msgSize
);
int
ret
=
uv_write
(
&
req
->
writer
,
(
uv_stream_t
*
)
&
worker
->
stream
.
pipe
,
&
req
->
buf
,
1
,
OnWriteResponse
);
PARAM_CHECK
(
ret
>=
0
,
LibuvFreeMsg
(
stream
,
msg
);
PARAM_CHECK
(
ret
>=
0
,
LibuvFreeMsg
(
stream
,
msg
);
free
(
req
);
return
-
1
,
"Failed to uv_write2 ret %s"
,
uv_strerror
(
ret
));
#endif
return
0
;
...
...
services/param/watcher/proxy/watcher_manager.cpp
浏览文件 @
0cbac6f4
...
...
@@ -243,9 +243,12 @@ void WatcherManager::RunLoop()
const
int32_t
RECV_BUFFER_MAX
=
5
*
1024
;
std
::
vector
<
char
>
buffer
(
RECV_BUFFER_MAX
,
0
);
bool
retry
=
false
;
ssize_t
recvLen
=
0
;
while
(
!
stop_
)
{
int
fd
=
GetServerFd
(
retry
);
ssize_t
recvLen
=
recv
(
fd
,
buffer
.
data
(),
RECV_BUFFER_MAX
,
0
);
if
(
fd
>=
0
)
{
recvLen
=
recv
(
fd
,
buffer
.
data
(),
RECV_BUFFER_MAX
,
0
);
}
if
(
stop_
)
{
break
;
}
...
...
@@ -291,7 +294,7 @@ int WatcherManager::GetServerFd(bool retry)
do
{
serverFd_
=
socket
(
PF_UNIX
,
SOCK_STREAM
,
0
);
int
flags
=
fcntl
(
serverFd_
,
F_GETFL
,
0
);
(
void
)
fcntl
(
serverFd_
,
F_SETFL
,
flags
&
~
O_NONBLOCK
);
(
void
)
fcntl
(
serverFd_
,
F_SETFL
,
flags
&
~
O_NONBLOCK
);
ret
=
ConntectServer
(
serverFd_
,
CLIENT_PIPE_NAME
);
if
(
ret
==
0
)
{
break
;
...
...
test/unittest/init/cmds_unittest.cpp
浏览文件 @
0cbac6f4
...
...
@@ -143,7 +143,7 @@ HWTEST_F(CmdsUnitTest, TestCommonCopy, TestSize.Level1)
HWTEST_F
(
CmdsUnitTest
,
TestCommonWrite
,
TestSize
.
Level1
)
{
const
char
*
testFile1
=
"/data/init_ut/test_dir0/test_file_write1"
;
int
fd
=
open
(
testFile1
,
O_RDWR
|
O_CREAT
);
int
fd
=
open
(
testFile1
,
O_RDWR
|
O_CREAT
,
S_IRUSR
|
S_IWUSR
|
S_IRGRP
|
S_IWGRP
|
S_IROTH
|
S_IWOTH
);
ASSERT_GE
(
fd
,
0
);
DoCmdByName
(
"write "
,
"/data/init_ut/test_dir0/test_file_write1 aaa"
);
...
...
@@ -221,7 +221,7 @@ HWTEST_F(CmdsUnitTest, TestGetCmdLinesFromJson, TestSize.Level1)
cJSON
*
cmdsItem1
=
cJSON_GetArrayItem
(
cmdsItem
,
0
);
ASSERT_NE
(
nullptr
,
cmdsItem1
);
CmdLines
**
cmdLines
=
(
CmdLines
**
)
calloc
(
1
,
1
);
CmdLines
**
cmdLines
=
(
CmdLines
**
)
calloc
(
1
,
sizeof
(
CmdLines
*
)
);
ASSERT_NE
(
nullptr
,
cmdLines
);
int
ret
=
GetCmdLinesFromJson
(
cmdsItem1
,
cmdLines
);
EXPECT_EQ
(
ret
,
-
1
);
...
...
test/unittest/init/service_file_unittest.cpp
浏览文件 @
0cbac6f4
...
...
@@ -49,7 +49,7 @@ HWTEST_F(ServiceFileUnitTest, TestServiceFile, TestSize.Level1)
if
(
strncpy_s
(
fileOpt
->
fileName
,
strlen
(
fileName
)
+
1
,
fileName
,
strlen
(
fileName
))
!=
0
)
{
free
(
fileOpt
);
fileOpt
=
nullptr
;
ASSERT_TRUE
(
1
);
FAIL
(
);
}
CreateServiceFile
(
fileOpt
);
int
ret
=
GetControlFile
(
"/data/filetest"
);
...
...
test/unittest/init/service_unittest.cpp
浏览文件 @
0cbac6f4
...
...
@@ -21,6 +21,7 @@
#include "init_service_manager.h"
#include "init_service_socket.h"
#include "init_unittest.h"
#include "init_utils.h"
#include "securec.h"
using
namespace
testing
::
ext
;
...
...
@@ -226,6 +227,7 @@ HWTEST_F(ServiceUnitTest, TestServiceExec, TestSize.Level1)
ret
=
SetImportantValue
(
service
,
""
,
invalidImportantValue
,
1
);
EXPECT_EQ
(
ret
,
-
1
);
if
(
service
!=
nullptr
)
{
FreeStringVector
(
service
->
pathArgs
.
argv
,
service
->
pathArgs
.
count
);
free
(
service
);
service
=
nullptr
;
}
...
...
test/unittest/param/client_unittest.cpp
浏览文件 @
0cbac6f4
...
...
@@ -97,7 +97,8 @@ static void TestParamTraversal()
u_int32_t
len
=
PARAM_BUFFER_SIZE
;
SystemGetParameterValue
(
handle
,
((
char
*
)
value
)
+
PARAM_BUFFER_SIZE
,
&
len
);
printf
(
"$$$$$$$$Param %s=%s
\n
"
,
(
char
*
)
value
,
((
char
*
)
value
)
+
PARAM_BUFFER_SIZE
);
},
nullptr
);
},
nullptr
);
}
static
void
TestPersistParam
()
...
...
@@ -117,14 +118,16 @@ static void TestPermission()
{
const
char
*
testName
=
"persist.111.ffff.bbbb.cccc.dddd.eeee.55555"
;
char
tmp
[
PARAM_BUFFER_SIZE
]
=
{
0
};
int
ret
;
// 允许本地校验
ParamSecurityOps
*
paramSecurityOps
=
&
GetClientParamWorkSpace
()
->
paramSecurityOps
;
paramSecurityOps
->
securityCheckParamPermission
=
TestCheckParamPermission
;
g_testPermissionResult
=
DAC_RESULT_FORBIDED
;
GetClientParamWorkSpace
()
->
securityLabel
->
flags
=
LABEL_CHECK_FOR_ALL_PROCESS
;
int
ret
=
SystemSetParameter
(
testName
,
"22202"
);
EXPECT_EQ
(
ret
,
DAC_RESULT_FORBIDED
);
if
((
GetClientParamWorkSpace
()
!=
nullptr
)
&&
(
GetClientParamWorkSpace
()
->
securityLabel
!=
nullptr
))
{
GetClientParamWorkSpace
()
->
securityLabel
->
flags
=
LABEL_CHECK_FOR_ALL_PROCESS
;
ret
=
SystemSetParameter
(
testName
,
"22202"
);
EXPECT_EQ
(
ret
,
DAC_RESULT_FORBIDED
);
}
paramSecurityOps
->
securityEncodeLabel
=
TestEncodeSecurityLabel
;
paramSecurityOps
->
securityDecodeLabel
=
TestDecodeSecurityLabel
;
paramSecurityOps
->
securityFreeLabel
=
TestFreeLocalSecurityLabel
;
...
...
@@ -291,4 +294,4 @@ int TestCheckParamPermission(const ParamSecurityLabel *srcLabel, const ParamAudi
int
TestFreeLocalSecurityLabel
(
ParamSecurityLabel
*
srcLabel
)
{
return
0
;
}
\ No newline at end of file
}
ueventd/ueventd_device_handler.c
浏览文件 @
0cbac6f4
...
...
@@ -262,7 +262,7 @@ static char **GetBlockDeviceSymbolLinks(const struct Uevent *uevent)
BuildDeviceSymbolLinks
(
links
,
linkNum
,
parent
,
uevent
->
partitionName
,
uevent
->
deviceName
);
}
linkNum
++
;
if
(
STRINGEQUAL
(
parent
,
bootDevice
))
{
if
(
(
parent
!=
NULL
)
&&
STRINGEQUAL
(
parent
,
bootDevice
))
{
BuildBootDeviceSymbolLink
(
links
,
linkNum
,
uevent
->
partitionName
);
linkNum
++
;
}
...
...
watchdog/init_watchdog.c
浏览文件 @
0cbac6f4
...
...
@@ -85,7 +85,7 @@ int main(int argc, const char *argv[])
if
(
ret
)
{
INIT_LOGE
(
"Failed to get timeout
\n
"
);
}
else
{
interval
=
(
timeoutGet
>
gap
)
?
timeoutGet
-
gap
:
1
;
interval
=
(
timeoutGet
>
gap
)
?
(
timeoutGet
-
gap
)
:
1
;
}
while
(
1
)
{
ioctl
(
fd
,
WDIOC_KEEPALIVE
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录