Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
be20fbfa
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
be20fbfa
编写于
9月 09, 2022
作者:
C
chengjinsong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
codex
Signed-off-by:
N
chengjinsong
<
chengjinsong2@huawei.com
>
上级
c96253d2
变更
22
隐藏空白更改
内联
并排
Showing
22 changed file
with
105 addition
and
100 deletion
+105
-100
device_info/device_info_proxy.h
device_info/device_info_proxy.h
+2
-2
device_info/device_info_stub.h
device_info/device_info_stub.h
+2
-2
interfaces/innerkits/fs_manager/fstab.c
interfaces/innerkits/fs_manager/fstab.c
+6
-6
interfaces/innerkits/sandbox/sandbox.c
interfaces/innerkits/sandbox/sandbox.c
+8
-8
interfaces/kits/jskits/src/native_parameters_js.cpp
interfaces/kits/jskits/src/native_parameters_js.cpp
+1
-2
scripts/param_cfg_to_code.py
scripts/param_cfg_to_code.py
+26
-26
services/begetctl/misc_daemon.cpp
services/begetctl/misc_daemon.cpp
+1
-1
services/begetctl/sandbox.cpp
services/begetctl/sandbox.cpp
+1
-1
services/etc/param/param_fixer.py
services/etc/param/param_fixer.py
+3
-2
services/init/init_common_service.c
services/init/init_common_service.c
+12
-7
services/init/init_service_manager.c
services/init/init_service_manager.c
+1
-2
services/modules/reboot/reboot_adp.h
services/modules/reboot/reboot_adp.h
+3
-3
services/modules/seccomp/scripts/generate_code_from_policy.py
...ices/modules/seccomp/scripts/generate_code_from_policy.py
+6
-6
services/modules/selinux/selinux_adp.h
services/modules/selinux/selinux_adp.h
+3
-3
services/param/watcher/agent/watcher_manager_kits.cpp
services/param/watcher/agent/watcher_manager_kits.cpp
+2
-2
services/param/watcher/agent/watcher_manager_kits.h
services/param/watcher/agent/watcher_manager_kits.h
+1
-1
services/param/watcher/proxy/watcher_manager.cpp
services/param/watcher/proxy/watcher_manager.cpp
+1
-1
test/unittest/begetctl/begetctl_unittest.cpp
test/unittest/begetctl/begetctl_unittest.cpp
+12
-12
test/unittest/init/group_unittest.cpp
test/unittest/init/group_unittest.cpp
+3
-3
test/unittest/param/client_unittest.cpp
test/unittest/param/client_unittest.cpp
+4
-2
test/unittest/param/trigger_unittest.cpp
test/unittest/param/trigger_unittest.cpp
+1
-1
ueventd/ueventd.c
ueventd/ueventd.c
+6
-7
未找到文件。
device_info/device_info_proxy.h
浏览文件 @
be20fbfa
...
...
@@ -26,8 +26,8 @@ public:
explicit
DeviceInfoProxy
(
const
sptr
<
IRemoteObject
>
&
impl
)
:
IRemoteProxy
<
IDeviceInfo
>
(
impl
)
{}
virtual
~
DeviceInfoProxy
()
{}
virtual
int32_t
GetUdid
(
std
::
string
&
result
)
override
;
virtual
int32_t
GetSerialID
(
std
::
string
&
result
)
override
;
int32_t
GetUdid
(
std
::
string
&
result
)
override
;
int32_t
GetSerialID
(
std
::
string
&
result
)
override
;
private:
static
inline
BrokerDelegator
<
DeviceInfoProxy
>
delegator_
;
};
...
...
device_info/device_info_stub.h
浏览文件 @
be20fbfa
...
...
@@ -39,8 +39,8 @@ public:
{
}
~
DeviceInfoService
()
override
{}
virtual
int32_t
GetUdid
(
std
::
string
&
result
)
override
;
virtual
int32_t
GetSerialID
(
std
::
string
&
result
)
override
;
int32_t
GetUdid
(
std
::
string
&
result
)
override
;
int32_t
GetSerialID
(
std
::
string
&
result
)
override
;
#ifndef STARTUP_INIT_TEST
protected:
#endif
...
...
interfaces/innerkits/fs_manager/fstab.c
浏览文件 @
be20fbfa
...
...
@@ -348,7 +348,7 @@ int GetBlockDeviceByName(const char *deviceName, const Fstab *fstab, char* miscD
return
-
1
;
}
static
const
struct
MountFlags
mountFlags
[]
=
{
static
const
struct
MountFlags
MOUNT_FLAGS
[]
=
{
{
"noatime"
,
MS_NOATIME
},
{
"noexec"
,
MS_NOEXEC
},
{
"nosuid"
,
MS_NOSUID
},
...
...
@@ -372,8 +372,8 @@ static bool IsDefaultMountFlags(const char *str)
bool
isDefault
=
false
;
if
(
str
!=
NULL
)
{
for
(
size_t
i
=
0
;
i
<
ARRAY_LENGTH
(
mountFlags
);
i
++
)
{
if
(
strcmp
(
str
,
mountFlags
[
i
].
name
)
==
0
)
{
for
(
size_t
i
=
0
;
i
<
ARRAY_LENGTH
(
MOUNT_FLAGS
);
i
++
)
{
if
(
strcmp
(
str
,
MOUNT_FLAGS
[
i
].
name
)
==
0
)
{
isDefault
=
true
;
}
}
...
...
@@ -386,9 +386,9 @@ static unsigned long ParseDefaultMountFlag(const char *str)
unsigned
long
flags
=
0
;
if
(
str
!=
NULL
)
{
for
(
size_t
i
=
0
;
i
<
ARRAY_LENGTH
(
mountFlags
);
i
++
)
{
if
(
strcmp
(
str
,
mountFlags
[
i
].
name
)
==
0
)
{
flags
=
mountFlags
[
i
].
flags
;
for
(
size_t
i
=
0
;
i
<
ARRAY_LENGTH
(
MOUNT_FLAGS
);
i
++
)
{
if
(
strcmp
(
str
,
MOUNT_FLAGS
[
i
].
name
)
==
0
)
{
flags
=
MOUNT_FLAGS
[
i
].
flags
;
break
;
}
}
...
...
interfaces/innerkits/sandbox/sandbox.c
浏览文件 @
be20fbfa
...
...
@@ -68,7 +68,7 @@ struct SandboxMountFlags {
unsigned
long
value
;
};
static
const
struct
SandboxMountFlags
g_flags
[]
=
{
static
const
struct
SandboxMountFlags
FLAGS
[]
=
{
{
.
flag
=
"bind"
,
.
value
=
MS_BIND
,
...
...
@@ -99,7 +99,7 @@ struct SandboxMap {
const
char
*
configfile
;
};
static
const
struct
SandboxMap
g_map
[]
=
{
static
const
struct
SandboxMap
MAP
[]
=
{
{
.
name
=
"system"
,
.
sandbox
=
&
g_systemSandbox
,
...
...
@@ -124,9 +124,9 @@ static unsigned long GetSandboxMountFlags(cJSON *item)
BEGET_ERROR_CHECK
(
item
!=
NULL
,
return
0
,
"Invalid parameter."
);
char
*
str
=
cJSON_GetStringValue
(
item
);
BEGET_CHECK
(
str
!=
NULL
,
return
0
);
for
(
size_t
i
=
0
;
i
<
ARRAY_LENGTH
(
g_flags
);
i
++
)
{
if
(
strcmp
(
str
,
g_flags
[
i
].
flag
)
==
0
)
{
return
g_flags
[
i
].
value
;
for
(
size_t
i
=
0
;
i
<
ARRAY_LENGTH
(
FLAGS
);
i
++
)
{
if
(
strcmp
(
str
,
FLAGS
[
i
].
flag
)
==
0
)
{
return
FLAGS
[
i
].
value
;
}
}
return
0
;
...
...
@@ -260,10 +260,10 @@ static int ParseSandboxConfig(cJSON *root, sandbox_t *sandbox)
static
const
struct
SandboxMap
*
GetSandboxMapByName
(
const
char
*
name
)
{
BEGET_ERROR_CHECK
(
name
!=
NULL
,
return
NULL
,
"Sandbox map name is NULL."
);
int
len
=
ARRAY_LENGTH
(
g_map
);
int
len
=
ARRAY_LENGTH
(
MAP
);
for
(
int
i
=
0
;
i
<
len
;
i
++
)
{
if
(
strcmp
(
g_map
[
i
].
name
,
name
)
==
0
)
{
return
&
g_map
[
i
];
if
(
strcmp
(
MAP
[
i
].
name
,
name
)
==
0
)
{
return
&
MAP
[
i
];
}
}
return
NULL
;
...
...
interfaces/kits/jskits/src/native_parameters_js.cpp
浏览文件 @
be20fbfa
...
...
@@ -202,8 +202,7 @@ static napi_value GetSync(napi_env env, napi_callback_info info)
napi_value
napiValue
=
nullptr
;
if
(
ret
==
0
)
{
const
char
*
value
=
getValue
.
c_str
();
NAPI_CALL
(
env
,
napi_create_string_utf8
(
env
,
value
,
strlen
(
value
),
&
napiValue
));
NAPI_CALL
(
env
,
napi_create_string_utf8
(
env
,
getValue
.
c_str
(),
strlen
(
getValue
.
c_str
()),
&
napiValue
));
}
return
napiValue
;
}
...
...
scripts/param_cfg_to_code.py
浏览文件 @
be20fbfa
...
...
@@ -20,7 +20,7 @@ import argparse
import
os
import
sys
def
DecodeCfgL
ine
(
data
):
def
decode_cfg_l
ine
(
data
):
data
.
replace
(
'
\n
'
,
''
).
replace
(
'
\r
'
,
''
)
data
=
data
.
strip
()
if
(
len
(
data
)
==
0
or
data
[
0
]
==
'#'
):
...
...
@@ -30,46 +30,46 @@ def DecodeCfgLine(data):
return
""
,
""
return
strs
[
0
].
strip
(),
strs
[
1
].
strip
()
def
GetParamFromCfg
(
cfgN
ame
):
def
get_param_from_cfg
(
cfg_n
ame
):
dict
=
{}
with
open
(
cfg
N
ame
)
as
afile
:
with
open
(
cfg
_n
ame
)
as
afile
:
data
=
afile
.
readline
()
while
data
:
name
,
value
=
DecodeCfgL
ine
(
data
)
name
,
value
=
decode_cfg_l
ine
(
data
)
if
len
(
name
)
!=
0
and
len
(
value
)
!=
0
:
dict
[
name
]
=
value
print
(
"sample file name={%s %s}"
%
(
name
,
value
))
data
=
afile
.
readline
()
return
dict
def
DecodeCodeL
ine
(
data
):
def
decode_code_l
ine
(
data
):
data
.
replace
(
'
\n
'
,
''
).
replace
(
'
\r
'
,
''
)
data
=
data
.
strip
()
if
(
not
data
.
startswith
(
"PARAM_MAP"
)):
return
""
,
""
data
L
en
=
len
(
data
)
data
=
data
[
len
(
"PARAM_MAP"
)
+
1
:
data
L
en
-
1
]
data
_l
en
=
len
(
data
)
data
=
data
[
len
(
"PARAM_MAP"
)
+
1
:
data
_l
en
-
1
]
data
=
data
.
strip
()
strs
=
data
.
split
(
','
)
if
len
(
strs
)
<=
1
:
return
""
,
""
return
strs
[
0
].
strip
(),
data
[
len
(
strs
[
0
])
+
1
:
].
strip
()
def
GetParamFromCCode
(
codeN
ame
):
def
get_param_from_c_code
(
code_n
ame
):
dict
=
{}
with
open
(
code
N
ame
,
"r+"
)
as
afile
:
with
open
(
code
_n
ame
,
"r+"
)
as
afile
:
data
=
afile
.
readline
()
while
data
:
name
,
value
=
DecodeCodeL
ine
(
data
)
name
,
value
=
decode_code_l
ine
(
data
)
if
len
(
name
)
!=
0
and
len
(
value
)
!=
0
:
dict
[
name
]
=
value
data
=
afile
.
readline
()
afile
.
truncate
(
0
)
return
dict
def
WriteMapToCode
(
codeN
ame
,
dict
):
def
write_map_to_code
(
code_n
ame
,
dict
):
try
:
with
open
(
code
N
ame
,
"w"
)
as
f
:
with
open
(
code
_n
ame
,
"w"
)
as
f
:
# start with 0
f
.
seek
(
0
)
# write file header
...
...
@@ -110,18 +110,18 @@ def WriteMapToCode(codeName, dict):
f
.
write
(
os
.
linesep
)
f
.
truncate
()
except
IOError
:
print
(
"Error: open or write file %s fail"
%
{
code
N
ame
})
print
(
"Error: open or write file %s fail"
%
{
code
_n
ame
})
return
0
def
AddToCodeDict
(
codeDict
,
cfgD
ict
,
high
=
True
):
for
name
,
value
in
cfg
D
ict
.
items
():
def
add_to_code_dict
(
code_dict
,
cfg_d
ict
,
high
=
True
):
for
name
,
value
in
cfg
_d
ict
.
items
():
# check if name exit
has
Key
=
name
in
codeDict
#codeD
ict.has_key(name)
if
has
K
ey
and
high
:
code
D
ict
[
name
]
=
value
elif
not
has
K
ey
:
code
D
ict
[
name
]
=
value
return
code
D
ict
has
_key
=
name
in
code_dict
#code_d
ict.has_key(name)
if
has
_k
ey
and
high
:
code
_d
ict
[
name
]
=
value
elif
not
has
_k
ey
:
code
_d
ict
[
name
]
=
value
return
code
_d
ict
def
main
():
parser
=
argparse
.
ArgumentParser
(
...
...
@@ -146,16 +146,16 @@ def main():
print
(
"source {}"
.
format
(
out_dir
))
assert
os
.
path
.
exists
(
source
)
src
Dict
=
GetParamFromC
fg
(
source
)
src
_dict
=
get_param_from_c
fg
(
source
)
dst
=
""
.
join
([
out_dir
,
"param_cfg.h"
])
if
os
.
path
.
exists
(
dst
):
dst
Dict
=
GetParamFromCC
ode
(
dst
)
dst
_dict
=
get_param_from_c_c
ode
(
dst
)
else
:
dst
D
ict
=
{}
dst
_d
ict
=
{}
dst
Dict
=
AddToCodeDict
(
dstDict
,
srcD
ict
,
False
)
WriteMapToCode
(
dst
,
dstD
ict
)
dst
_dict
=
add_to_code_dict
(
dst_dict
,
src_d
ict
,
False
)
write_map_to_code
(
dst
,
dst_d
ict
)
return
0
...
...
services/begetctl/misc_daemon.cpp
浏览文件 @
be20fbfa
...
...
@@ -206,7 +206,7 @@ static void WriteLogoToMisc(const std::string &logoPath)
static
int
main_cmd
(
BShellHandle
shell
,
int
argc
,
char
**
argv
)
{
if
(
argc
>=
2
&&
strcmp
(
(
char
*
)
"--write_logo"
,
argv
[
0
])
==
0
)
{
// 2 min arg
if
(
argc
>=
2
&&
strcmp
(
const_cast
<
char
*>
(
"--write_logo"
)
,
argv
[
0
])
==
0
)
{
// 2 min arg
WriteLogoToMisc
(
argv
[
1
]);
}
else
{
char
*
helpArgs
[]
=
{
const_cast
<
char
*>
(
"misc_daemon"
),
nullptr
};
...
...
services/begetctl/sandbox.cpp
浏览文件 @
be20fbfa
...
...
@@ -74,7 +74,7 @@ static void RunSandbox(const std::string &sandboxName)
static
void
EnterShell
()
{
char
*
argv
[]
=
{
(
char
*
)
"sh"
,
NULL
};
char
*
argv
[]
=
{
const_cast
<
char
*>
(
"sh"
)
,
NULL
};
char
*
envp
[]
=
{
nullptr
};
if
(
execve
(
"/system/bin/sh"
,
argv
,
envp
)
!=
0
)
{
std
::
cout
<<
"execve sh failed! err = "
<<
errno
<<
std
::
endl
;
...
...
services/etc/param/param_fixer.py
浏览文件 @
be20fbfa
...
...
@@ -18,7 +18,8 @@ import os
import
sys
import
json
sys
.
path
.
append
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
os
.
pardir
,
os
.
pardir
,
os
.
pardir
,
os
.
pardir
,
os
.
pardir
,
os
.
pardir
,
"build"
))
sys
.
path
.
append
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
os
.
pardir
,
os
.
pardir
,
os
.
pardir
,
os
.
pardir
,
os
.
pardir
,
os
.
pardir
,
"build"
))
from
scripts.util
import
build_utils
# noqa: E402
def
parse_args
(
args
):
...
...
@@ -39,7 +40,7 @@ def parse_params(line, contents):
if
pos
<=
0
:
return
name
=
line
[:
pos
]
value
=
line
[
pos
+
1
:]
value
=
line
[
pos
+
1
:]
name
=
name
.
strip
()
value
=
value
.
strip
()
contents
[
name
]
=
value
...
...
services/init/init_common_service.c
浏览文件 @
be20fbfa
...
...
@@ -478,6 +478,17 @@ static void CheckServiceSocket(Service *service)
return
;
}
static
void
CheckOndemandService
(
service
)
{
CheckServiceSocket
(
service
);
if
(
strcmp
(
service
->
name
,
"console"
)
==
0
)
{
if
(
WatchConsoleDevice
(
service
)
<
0
)
{
INIT_LOGE
(
"Failed to watch console service after it exit, mark console service invalid"
);
service
->
attribute
|=
SERVICE_ATTR_INVALID
;
}
}
}
void
ServiceReap
(
Service
*
service
)
{
INIT_CHECK
(
service
!=
NULL
,
return
);
...
...
@@ -530,13 +541,7 @@ void ServiceReap(Service *service)
}
// service no need to restart if it is an ondemand service.
if
(
IsOnDemandService
(
service
))
{
CheckServiceSocket
(
service
);
if
(
strcmp
(
service
->
name
,
"console"
)
==
0
)
{
if
(
WatchConsoleDevice
(
service
)
<
0
)
{
INIT_LOGE
(
"Failed to watch console service after it exit, mark console service invalid"
);
service
->
attribute
|=
SERVICE_ATTR_INVALID
;
}
}
CheckOndemandService
(
service
);
return
;
}
...
...
services/init/init_service_manager.c
浏览文件 @
be20fbfa
...
...
@@ -1018,8 +1018,7 @@ void ParseAllServices(const cJSON *fileRoot)
// Watch "/dev/console" node for starting console service ondemand.
if
((
strcmp
(
service
->
name
,
"console"
)
==
0
)
&&
IsOnDemandService
(
service
))
{
if
(
WatchConsoleDevice
(
service
)
<
0
)
{
INIT_LOGW
(
"Failed to watch
\'
/dev/console
\'
device"
);
INIT_LOGW
(
"Remove service
\'
%s
\'
ondemand attribute"
,
service
->
name
);
INIT_LOGW
(
"Failed to watch console device, unset
\'
%s
\'
ondemand attribute"
,
service
->
name
);
UnMarkServiceAsOndemand
(
service
);
}
}
...
...
services/modules/reboot/reboot_adp.h
浏览文件 @
be20fbfa
...
...
@@ -13,11 +13,11 @@
* limitations under the License.
*/
#ifndef
_
MODULE_REBOOT_ADP_H
#define
_
MODULE_REBOOT_ADP_H
#ifndef MODULE_REBOOT_ADP_H
#define MODULE_REBOOT_ADP_H
#include <stdio.h>
int
GetRebootReasonFromMisc
(
char
*
reason
,
size_t
size
);
int
UpdateMiscMessage
(
const
char
*
valueData
,
const
char
*
cmd
,
const
char
*
cmdExt
,
const
char
*
boot
);
#endif
/*
_
MODULE_REBOOT_ADP_H */
#endif
/* MODULE_REBOOT_ADP_H */
services/modules/seccomp/scripts/generate_code_from_policy.py
浏览文件 @
be20fbfa
...
...
@@ -303,7 +303,7 @@ class GenBpfPolicy:
@
staticmethod
def
gen_bpf_ge32
(
const_str
,
jt
,
jf
):
bpf_policy
=
[]
bpf_policy
.
append
(
BPF_JGE
.
format
(
const_str
+
' & 0xffffffff'
,
jt
,
jf
))
bpf_policy
.
append
(
BPF_JGE
.
format
(
const_str
+
' & 0xffffffff'
,
jt
,
jf
))
return
bpf_policy
@
staticmethod
...
...
@@ -315,12 +315,12 @@ class GenBpfPolicy:
low
=
number
&
0xffffffff
if
digit_flag
and
hight
==
0
:
bpf_policy
.
append
(
BPF_JGT
.
format
(
'((unsigned long)'
+
const_str
+
') >> 32'
,
jt
+
2
,
0
))
bpf_policy
.
append
(
BPF_JGT
.
format
(
'((unsigned long)'
+
const_str
+
') >> 32'
,
jt
+
2
,
0
))
else
:
bpf_policy
.
append
(
BPF_JGT
.
format
(
'((unsigned long)'
+
const_str
+
') >> 32'
,
jt
+
3
,
0
))
bpf_policy
.
append
(
BPF_JEQ
.
format
(
'((unsigned long)'
+
const_str
+
') >> 32'
,
0
,
jf
+
2
))
bpf_policy
.
append
(
BPF_JGT
.
format
(
'((unsigned long)'
+
const_str
+
') >> 32'
,
jt
+
3
,
0
))
bpf_policy
.
append
(
BPF_JEQ
.
format
(
'((unsigned long)'
+
const_str
+
') >> 32'
,
0
,
jf
+
2
))
bpf_policy
.
append
(
BPF_LOAD_MEM
.
format
(
0
))
bpf_policy
.
append
(
BPF_JGE
.
format
(
const_str
+
' & 0xffffffff'
,
jt
,
jf
))
bpf_policy
.
append
(
BPF_JGE
.
format
(
const_str
+
' & 0xffffffff'
,
jt
,
jf
))
return
bpf_policy
def
gen_bpf_ge
(
self
,
const_str
,
jt
,
jf
):
...
...
@@ -342,7 +342,7 @@ class GenBpfPolicy:
@
staticmethod
def
gen_bpf_set64
(
const_str
,
jt
,
jf
):
bpf_policy
=
[]
bpf_policy
.
append
(
BPF_JSET
.
format
(
'((unsigned long)'
+
const_str
+
') >> 32'
,
jt
+
2
,
0
))
bpf_policy
.
append
(
BPF_JSET
.
format
(
'((unsigned long)'
+
const_str
+
') >> 32'
,
jt
+
2
,
0
))
bpf_policy
.
append
(
BPF_LOAD_MEM
.
format
(
0
))
bpf_policy
.
append
(
BPF_JSET
.
format
(
const_str
+
' & 0xffffffff'
,
jt
,
jf
))
return
bpf_policy
...
...
services/modules/selinux/selinux_adp.h
浏览文件 @
be20fbfa
...
...
@@ -13,11 +13,11 @@
* limitations under the License.
*/
#ifndef
_
PLUGIN_SELINUX_ADP_H
#define
_
PLUGIN_SELINUX_ADP_H
#ifndef PLUGIN_SELINUX_ADP_H
#define PLUGIN_SELINUX_ADP_H
# define SECON_STR_IN_CFG ("secon")
// https://github.com/xelerance/Openswan/blob/86dff2b/include/pluto/state.h#L222
# define MAX_SECON_LEN (257)
#endif
/*
_
PLUGIN_SELINUX_ADP_H */
#endif
/* PLUGIN_SELINUX_ADP_H */
services/param/watcher/agent/watcher_manager_kits.cpp
浏览文件 @
be20fbfa
...
...
@@ -205,7 +205,7 @@ void WatcherManagerKits::ParamWatcher::OnParameterChange(const std::string &name
WATCHER_LOGI
(
"OnParameterChange name %s value %s"
,
name
.
c_str
(),
value
.
c_str
());
uint32_t
index
=
0
;
ParameterChangeListener
*
listener
=
GetParameterListener
(
&
index
);
while
(
listener
!=
NULL
)
{
while
(
listener
!=
nullptr
)
{
if
(
!
listener
->
CheckValueChange
(
value
))
{
listener
->
OnParameterChange
(
name
,
value
);
}
...
...
@@ -240,7 +240,7 @@ int WatcherManagerKits::ParamWatcher::DelParameterListener(ParameterChangePtr ca
{
uint32_t
index
=
0
;
ParameterChangeListener
*
listener
=
GetParameterListener
(
&
index
);
while
(
listener
!=
NULL
)
{
while
(
listener
!=
nullptr
)
{
if
((
callback
==
nullptr
&&
context
==
nullptr
))
{
RemoveParameterListener
(
index
);
}
else
if
(
listener
->
IsEqual
(
callback
,
context
))
{
...
...
services/param/watcher/agent/watcher_manager_kits.h
浏览文件 @
be20fbfa
...
...
@@ -66,7 +66,7 @@ private:
class
ParamWatcher
final
:
public
Watcher
{
public:
explicit
ParamWatcher
(
const
std
::
string
&
key
)
:
keyPrefix_
(
key
)
{}
virtual
~
ParamWatcher
()
~
ParamWatcher
()
override
{
parameterChangeListeners
.
clear
();
};
...
...
services/param/watcher/proxy/watcher_manager.cpp
浏览文件 @
be20fbfa
...
...
@@ -236,7 +236,7 @@ void WatcherManager::SendLocalChange(const std::string &keyPrefix, ParamWatcherP
SystemGetParameterValue
(
handle
,
context
->
buffer
+
PARAM_NAME_LEN_MAX
,
&
size
);
WATCHER_LOGV
(
"SendLocalChange key %s value: %s "
,
context
->
buffer
,
context
->
buffer
+
PARAM_NAME_LEN_MAX
);
context
->
watcher
->
ProcessParameterChange
(
context
->
buffer
,
context
->
buffer
+
PARAM_NAME_LEN_MAX
);
},
(
void
*
)
&
context
);
},
reinterpret_cast
<
void
*>
(
&
context
)
);
}
void
WatcherManager
::
RunLoop
()
...
...
test/unittest/begetctl/begetctl_unittest.cpp
浏览文件 @
be20fbfa
...
...
@@ -38,7 +38,7 @@ HWTEST_F(BegetctlUnitTest, TestShellInit, TestSize.Level0)
const
char
*
args
[]
=
{
"param"
};
BShellEnvDirectExecute
(
GetShellHandle
(),
1
,
(
char
**
)
args
);
BShellEnvDirectExecute
(
GetShellHandle
(),
1
,
const_cast
<
char
**>
(
args
)
);
}
HWTEST_F
(
BegetctlUnitTest
,
TestShellLs
,
TestSize
.
Level1
)
...
...
@@ -47,7 +47,7 @@ HWTEST_F(BegetctlUnitTest, TestShellLs, TestSize.Level1)
const
char
*
args
[]
=
{
"param"
,
"ls"
};
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
(
char
**
)
args
);
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
const_cast
<
char
**>
(
args
)
);
}
HWTEST_F
(
BegetctlUnitTest
,
TestShellLsWithR
,
TestSize
.
Level1
)
...
...
@@ -56,7 +56,7 @@ HWTEST_F(BegetctlUnitTest, TestShellLsWithR, TestSize.Level1)
const
char
*
args
[]
=
{
"param"
,
"ls"
,
"-r"
};
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
(
char
**
)
args
);
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
const_cast
<
char
**>
(
args
)
);
}
HWTEST_F
(
BegetctlUnitTest
,
TestShellLsGet
,
TestSize
.
Level1
)
...
...
@@ -65,7 +65,7 @@ HWTEST_F(BegetctlUnitTest, TestShellLsGet, TestSize.Level1)
const
char
*
args
[]
=
{
"param"
,
"get"
};
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
(
char
**
)
args
);
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
const_cast
<
char
**>
(
args
)
);
}
HWTEST_F
(
BegetctlUnitTest
,
TestShellSet
,
TestSize
.
Level1
)
...
...
@@ -74,7 +74,7 @@ HWTEST_F(BegetctlUnitTest, TestShellSet, TestSize.Level1)
const
char
*
args
[]
=
{
"param"
,
"set"
,
"aaaaa"
,
"1234567"
};
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
(
char
**
)
args
);
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
const_cast
<
char
**>
(
args
)
);
}
HWTEST_F
(
BegetctlUnitTest
,
TestShellGetWithKey
,
TestSize
.
Level1
)
...
...
@@ -83,7 +83,7 @@ HWTEST_F(BegetctlUnitTest, TestShellGetWithKey, TestSize.Level1)
const
char
*
args
[]
=
{
"param"
,
"get"
,
"aaaaa"
};
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
(
char
**
)
args
);
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
const_cast
<
char
**>
(
args
)
);
}
HWTEST_F
(
BegetctlUnitTest
,
TestShellWait
,
TestSize
.
Level1
)
...
...
@@ -92,7 +92,7 @@ HWTEST_F(BegetctlUnitTest, TestShellWait, TestSize.Level1)
const
char
*
args
[]
=
{
"param"
,
"wait"
,
"aaaaa"
};
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
(
char
**
)
args
);
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
const_cast
<
char
**>
(
args
)
);
}
HWTEST_F
(
BegetctlUnitTest
,
TestShellWaitFalse
,
TestSize
.
Level1
)
{
...
...
@@ -100,7 +100,7 @@ HWTEST_F(BegetctlUnitTest, TestShellWaitFalse, TestSize.Level1)
const
char
*
args
[]
=
{
"param"
,
"wait"
};
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
(
char
**
)
args
);
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
const_cast
<
char
**>
(
args
)
);
}
HWTEST_F
(
BegetctlUnitTest
,
TestShellWaitWithKey
,
TestSize
.
Level1
)
...
...
@@ -109,7 +109,7 @@ HWTEST_F(BegetctlUnitTest, TestShellWaitWithKey, TestSize.Level1)
const
char
*
args
[]
=
{
"param"
,
"wait"
,
"aaaaa"
,
"12*"
,
"30"
};
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
(
char
**
)
args
);
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
const_cast
<
char
**>
(
args
)
);
}
HWTEST_F
(
BegetctlUnitTest
,
TestShellParamShell
,
TestSize
.
Level1
)
{
...
...
@@ -117,7 +117,7 @@ HWTEST_F(BegetctlUnitTest, TestShellParamShell, TestSize.Level1)
const
char
*
args
[]
=
{
"param"
,
"shell"
};
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
(
char
**
)
args
);
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
const_cast
<
char
**>
(
args
)
);
}
HWTEST_F
(
BegetctlUnitTest
,
TestShellLsWithvalue
,
TestSize
.
Level1
)
{
...
...
@@ -126,7 +126,7 @@ HWTEST_F(BegetctlUnitTest, TestShellLsWithvalue, TestSize.Level1)
const
char
*
args
[]
=
{
"param"
,
"ls"
,
PARAM_REVERESD_NAME_CURR_PARAMETER
};
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
(
char
**
)
args
);
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
const_cast
<
char
**>
(
args
)
);
}
HWTEST_F
(
BegetctlUnitTest
,
TestShellLsWithvalueExist
,
TestSize
.
Level1
)
{
...
...
@@ -135,6 +135,6 @@ HWTEST_F(BegetctlUnitTest, TestShellLsWithvalueExist, TestSize.Level1)
const
char
*
args
[]
=
{
"param"
,
"ls"
,
"-r"
,
PARAM_REVERESD_NAME_CURR_PARAMETER
};
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
(
char
**
)
args
);
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
const_cast
<
char
**>
(
args
)
);
}
}
// namespace init_ut
test/unittest/init/group_unittest.cpp
浏览文件 @
be20fbfa
...
...
@@ -43,14 +43,14 @@ static int TestHashNodeCompare(const HashNode *node1, const HashNode *node2)
static
int
TestHashKeyCompare
(
const
HashNode
*
node1
,
const
void
*
key
)
{
TestHashNode
*
testNode1
=
HASHMAP_ENTRY
(
node1
,
TestHashNode
,
node
);
return
strcmp
(
testNode1
->
name
,
(
char
*
)
key
);
return
strcmp
(
testNode1
->
name
,
reinterpret_cast
<
char
*>
(
const_cast
<
void
*>
(
key
))
);
}
static
int
TestHashNodeFunction
(
const
HashNode
*
node
)
{
TestHashNode
*
testNode
=
HASHMAP_ENTRY
(
node
,
TestHashNode
,
node
);
int
code
=
0
;
for
(
int
i
=
0
;
i
<
(
int
)
strlen
(
testNode
->
name
);
i
++
)
{
for
(
size_t
i
=
0
;
i
<
strlen
(
testNode
->
name
);
i
++
)
{
code
+=
testNode
->
name
[
i
]
-
'A'
;
}
return
code
;
...
...
@@ -60,7 +60,7 @@ static int TestHashKeyFunction(const void *key)
{
int
code
=
0
;
char
*
buff
=
const_cast
<
char
*>
(
static_cast
<
const
char
*>
(
key
));
for
(
int
i
=
0
;
i
<
(
int
)
strlen
(
buff
);
i
++
)
{
for
(
size_t
i
=
0
;
i
<
strlen
(
buff
);
i
++
)
{
code
+=
buff
[
i
]
-
'A'
;
}
return
code
;
...
...
test/unittest/param/client_unittest.cpp
浏览文件 @
be20fbfa
...
...
@@ -74,10 +74,12 @@ static void TestForMultiThread()
"thread.5555.1111.2222.3333.4444"
};
for
(
size_t
i
=
0
;
i
<
threadMaxNumer
;
i
++
)
{
pthread_create
(
&
tids
[
i
],
nullptr
,
TestSendParamSetMsg
,
(
void
*
)
names
[
i
%
ARRAY_LENGTH
(
names
)]);
pthread_create
(
&
tids
[
i
],
nullptr
,
TestSendParamSetMsg
,
reinterpret_cast
<
void
*>
(
const_cast
<
char
*>
(
names
[
i
%
ARRAY_LENGTH
(
names
)])));
}
for
(
size_t
i
=
threadMaxNumer
;
i
<
threadMaxNumer
+
threadMaxNumer
;
i
++
)
{
pthread_create
(
&
tids
[
i
],
nullptr
,
TestSendParamWaitMsg
,
(
void
*
)
names
[
i
%
ARRAY_LENGTH
(
names
)]);
pthread_create
(
&
tids
[
i
],
nullptr
,
TestSendParamWaitMsg
,
reinterpret_cast
<
void
*>
(
const_cast
<
char
*>
(
names
[
i
%
ARRAY_LENGTH
(
names
)])));
}
for
(
size_t
i
=
0
;
i
<
threadMaxNumer
+
threadMaxNumer
;
i
++
)
{
pthread_join
(
tids
[
i
],
nullptr
);
...
...
test/unittest/param/trigger_unittest.cpp
浏览文件 @
be20fbfa
...
...
@@ -90,7 +90,7 @@ public:
int
cmdKeyIndex
=
0
;
const
char
*
matchCmd
=
GetMatchCmd
(
"setparam aaaa aaaa"
,
&
cmdKeyIndex
);
printf
(
"cmd %d
\n
"
,
matchCmd
!=
nullptr
);
EXPECT_
EQ
(
matchCmd
!=
0
,
1
);
EXPECT_
NE
(
matchCmd
,
nullptr
);
ReadConfig
();
ParseInitCfg
(
STARTUP_INIT_UT_PATH
"/trigger_test.cfg"
);
...
...
ueventd/ueventd.c
浏览文件 @
be20fbfa
...
...
@@ -133,11 +133,10 @@ typedef struct {
#define DEV_NODE_PATH_PREFIX "/dev/"
#define DEV_NODE_PATH_PREFIX_LEN 5
static
const
DYNAMIC_DEVICE_NODE
dynamicDevices
[]
=
{
static
const
DYNAMIC_DEVICE_NODE
DYNAMIC_DEVICES
[]
=
{
{
DEV_NODE_PATH_PREFIX
"tty"
,
S_IFCHR
|
DEFAULT_RW_MODE
},
{
DEV_NODE_PATH_PREFIX
"binder"
,
S_IFCHR
|
DEFAULT_RW_MODE
},
{
DEV_NODE_PATH_PREFIX
"console"
,
S_IFCHR
|
DEFAULT_RW_MODE
},
{
DEV_NODE_PATH_PREFIX
"tty"
,
S_IFCHR
|
DEFAULT_RW_MODE
}
{
DEV_NODE_PATH_PREFIX
"console"
,
S_IFCHR
|
S_IRUSR
|
S_IWUSR
|
S_IRGRP
|
S_IWGRP
}
};
static
void
HandleRequiredDynamicDeviceNodes
(
const
struct
Uevent
*
uevent
)
...
...
@@ -149,17 +148,17 @@ static void HandleRequiredDynamicDeviceNodes(const struct Uevent *uevent)
return
;
}
while
(
idx
<
sizeof
(
dynamicDevices
)
/
sizeof
(
dynamicDevices
[
0
]))
{
if
(
strcmp
(
uevent
->
deviceName
,
dynamicDevices
[
idx
].
dev
+
DEV_NODE_PATH_PREFIX_LEN
)
!=
0
)
{
while
(
idx
<
sizeof
(
DYNAMIC_DEVICES
)
/
sizeof
(
DYNAMIC_DEVICES
[
0
]))
{
if
(
strcmp
(
uevent
->
deviceName
,
DYNAMIC_DEVICES
[
idx
].
dev
+
DEV_NODE_PATH_PREFIX_LEN
)
!=
0
)
{
idx
++
;
continue
;
}
// Matched
mask
=
umask
(
0
);
if
(
mknod
(
dynamicDevices
[
idx
].
dev
,
dynamicDevices
[
idx
].
mode
,
if
(
mknod
(
DYNAMIC_DEVICES
[
idx
].
dev
,
DYNAMIC_DEVICES
[
idx
].
mode
,
makedev
(
uevent
->
major
,
uevent
->
minor
))
!=
0
)
{
INIT_LOGE
(
"Create device node %s failed. %s"
,
dynamicDevices
[
idx
].
dev
,
strerror
(
errno
));
INIT_LOGE
(
"Create device node %s failed. %s"
,
DYNAMIC_DEVICES
[
idx
].
dev
,
strerror
(
errno
));
}
// Restore umask
umask
(
mask
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录