Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
3d333c7b
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看板
提交
3d333c7b
编写于
7月 24, 2021
作者:
Z
zhong_ning
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
init : fix code style
Signed-off-by:
N
zhong_ning
<
zhong_ning@hoperun.com
>
上级
ef7909f9
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
79 addition
and
101 deletion
+79
-101
services/include/device.h
services/include/device.h
+5
-0
services/src/device.c
services/src/device.c
+6
-8
services/src/init_cmds.c
services/src/init_cmds.c
+27
-31
services/src/uevent.c
services/src/uevent.c
+39
-60
services/test/unittest/common/cmd_func_test.cpp
services/test/unittest/common/cmd_func_test.cpp
+2
-2
未找到文件。
services/include/device.h
浏览文件 @
3d333c7b
...
...
@@ -23,6 +23,11 @@ extern "C" {
#endif
#include <sys/types.h>
#define DEV_KMSG_MINOR 11
#define DEV_NULL_MINOR 3
#define DEV_RANDOM_MINOR 8
#define DEV_URANDOM_MINOR 9
void
MountBasicFs
();
void
CreateDeviceNode
();
int
MakeSocketDir
(
const
char
*
path
,
mode_t
mode
);
...
...
services/src/device.c
浏览文件 @
3d333c7b
...
...
@@ -13,7 +13,9 @@
* limitations under the License.
*/
#include "device.h"
#include <errno.h>
#include <linux/major.h>
#include <stdio.h>
#include <string.h>
#include <sys/mount.h>
...
...
@@ -24,10 +26,6 @@
#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 DEVICE_ID_THIRD 3
#define DEVICE_ID_EIGHTH 8
#define DEVICE_ID_NINTH 9
#define DEVICE_ID_ELEVNTH 11
void
MountBasicFs
()
{
...
...
@@ -57,17 +55,17 @@ void MountBasicFs()
void
CreateDeviceNode
()
{
if
(
mknod
(
"/dev/kmsg"
,
S_IFCHR
|
DEFAULT_NO_AUTHORITY_MODE
,
makedev
(
1
,
DEVICE_ID_ELEVNTH
))
!=
0
)
{
if
(
mknod
(
"/dev/kmsg"
,
S_IFCHR
|
DEFAULT_NO_AUTHORITY_MODE
,
makedev
(
MEM_MAJOR
,
DEV_KMSG_MINOR
))
!=
0
)
{
INIT_LOGE
(
"Create /dev/kmsg device node failed. %s"
,
strerror
(
errno
));
}
if
(
mknod
(
"/dev/null"
,
S_IFCHR
|
DEFAULT_RW_MODE
,
makedev
(
1
,
DEVICE_ID_THIRD
))
!=
0
)
{
if
(
mknod
(
"/dev/null"
,
S_IFCHR
|
DEFAULT_RW_MODE
,
makedev
(
MEM_MAJOR
,
DEV_NULL_MINOR
))
!=
0
)
{
INIT_LOGE
(
"Create /dev/null device node failed. %s"
,
strerror
(
errno
));
}
if
(
mknod
(
"/dev/random"
,
S_IFCHR
|
DEFAULT_RW_MODE
,
makedev
(
1
,
DEVICE_ID_EIGHTH
))
!=
0
)
{
if
(
mknod
(
"/dev/random"
,
S_IFCHR
|
DEFAULT_RW_MODE
,
makedev
(
MEM_MAJOR
,
DEV_RANDOM_MINOR
))
!=
0
)
{
INIT_LOGE
(
"Create /dev/random device node failed. %s"
,
strerror
(
errno
));
}
if
(
mknod
(
"/dev/urandom"
,
S_IFCHR
|
DEFAULT_RW_MODE
,
makedev
(
1
,
DEVICE_ID_NINTH
))
!=
0
)
{
if
(
mknod
(
"/dev/urandom"
,
S_IFCHR
|
DEFAULT_RW_MODE
,
makedev
(
MEM_MAJOR
,
DEV_URANDOM_MINOR
))
!=
0
)
{
INIT_LOGE
(
"Create /dev/urandom device node failed. %s"
,
strerror
(
errno
));
}
}
...
...
services/src/init_cmds.c
浏览文件 @
3d333c7b
...
...
@@ -287,20 +287,21 @@ static void DoSleep(const char *cmdContent)
const
int
argsCount
=
1
;
struct
CmdArgs
*
ctx
=
GetCmd
(
cmdContent
,
" "
,
argsCount
);
if
(
ctx
==
NULL
||
ctx
->
argv
==
NULL
||
ctx
->
argc
!=
argsCount
)
{
INIT_LOGE
(
"Command
\"
sleep
\"
with invalid arguments
"
);
INIT_LOGE
(
"Command
\"
sleep
\"
with invalid arguments
:%s"
,
cmdContent
);
goto
out
;
}
errno
=
0
;
unsigned
long
sleepTime
=
strtoul
(
ctx
->
argv
[
0
],
NULL
,
10
);
unsigned
long
sleepTime
=
strtoul
(
ctx
->
argv
[
0
],
NULL
,
DECIMAL_BASE
);
if
(
errno
!=
0
)
{
INIT_LOGE
(
"cannot covert sleep time in command
\"
sleep
\"
"
);
goto
out
;
}
// Limit sleep time in 5 seconds
if
(
sleepTime
>
5
)
{
sleepTime
=
5
;
const
unsigned
long
sleepTimeLimit
=
5
;
if
(
sleepTime
>
sleepTimeLimit
)
{
sleepTime
=
sleepTimeLimit
;
}
INIT_LOGI
(
"Sleeping %d second(s)"
,
sleepTime
);
sleep
((
unsigned
int
)
sleepTime
);
...
...
@@ -343,7 +344,7 @@ static void DoCopy(const char* cmdContent)
struct
CmdArgs
*
ctx
=
GetCmd
(
cmdContent
,
" "
,
argsCount
);
if
(
ctx
==
NULL
||
ctx
->
argv
==
NULL
||
ctx
->
argv
[
0
]
==
NULL
||
ctx
->
argv
[
1
]
==
NULL
||
ctx
->
argc
!=
DEFAULT_COPY_ARGS_CNT
)
{
INIT_LOGE
(
"DoCopy
failed."
);
INIT_LOGE
(
"DoCopy
invalid arguments :%s"
,
cmdContent
);
goto
out
;
}
realPath1
=
realpath
(
ctx
->
argv
[
0
],
NULL
);
...
...
@@ -393,25 +394,15 @@ static void DoChown(const char* cmdContent)
const
int
argsCount
=
3
;
struct
CmdArgs
*
ctx
=
GetCmd
(
cmdContent
,
" "
,
argsCount
);
if
(
ctx
==
NULL
||
ctx
->
argv
==
NULL
||
ctx
->
argc
!=
argsCount
)
{
INIT_LOGE
(
"DoChown
failed."
);
INIT_LOGE
(
"DoChown
invalid arguments :%s"
,
cmdContent
);
goto
out
;
}
uid_t
owner
=
(
uid_t
)
-
1
;
gid_t
group
=
(
gid_t
)
-
1
;
if
(
isalpha
(
ctx
->
argv
[
0
][
0
]))
{
owner
=
DecodeUid
(
ctx
->
argv
[
0
]);
INIT_ERROR_CHECK
(
owner
!=
(
uid_t
)
-
1
,
goto
out
,
"DoChown decode owner failed."
);
}
else
{
owner
=
strtoul
(
ctx
->
argv
[
0
],
NULL
,
0
);
}
uid_t
owner
=
DecodeUid
(
ctx
->
argv
[
0
]);
INIT_ERROR_CHECK
(
owner
!=
(
uid_t
)
-
1
,
goto
out
,
"DoChown invalid uid :%s."
,
ctx
->
argv
[
0
]);
if
(
isalpha
(
ctx
->
argv
[
1
][
0
]))
{
group
=
DecodeUid
(
ctx
->
argv
[
1
]);
INIT_ERROR_CHECK
(
group
!=
(
gid_t
)
-
1
,
goto
out
,
"DoChown decode group failed."
);
}
else
{
group
=
strtoul
(
ctx
->
argv
[
1
],
NULL
,
0
);
}
gid_t
group
=
DecodeUid
(
ctx
->
argv
[
1
]);
INIT_ERROR_CHECK
(
group
!=
(
gid_t
)
-
1
,
goto
out
,
"DoChown invalid gid :%s."
,
ctx
->
argv
[
1
]);
int
pathPos
=
2
;
if
(
chown
(
ctx
->
argv
[
pathPos
],
owner
,
group
)
!=
0
)
{
...
...
@@ -428,7 +419,7 @@ static void DoMkDir(const char* cmdContent)
const
int
argsCount
=
4
;
struct
CmdArgs
*
ctx
=
GetCmd
(
cmdContent
,
" "
,
argsCount
);
if
(
ctx
==
NULL
||
ctx
->
argv
==
NULL
||
ctx
->
argc
<
1
)
{
INIT_LOGE
(
"DoMkDir
failed."
);
INIT_LOGE
(
"DoMkDir
invalid arguments :%s"
,
cmdContent
);
goto
out
;
}
...
...
@@ -438,6 +429,11 @@ static void DoMkDir(const char* cmdContent)
goto
out
;
}
if
(
ctx
->
argc
!=
1
&&
ctx
->
argc
!=
argsCount
)
{
INIT_LOGE
(
"DoMkDir invalid arguments: %s"
,
cmdContent
);
goto
out
;
}
if
(
ctx
->
argc
>
1
)
{
mode
=
strtoul
(
ctx
->
argv
[
1
],
NULL
,
OCTAL_TYPE
);
if
(
chmod
(
ctx
->
argv
[
0
],
mode
)
!=
0
)
{
...
...
@@ -464,7 +460,7 @@ static void DoChmod(const char* cmdContent)
int
argsCount
=
2
;
struct
CmdArgs
*
ctx
=
GetCmd
(
cmdContent
,
" "
,
argsCount
);
if
(
ctx
==
NULL
||
ctx
->
argv
==
NULL
||
ctx
->
argc
!=
argsCount
)
{
INIT_LOGE
(
"DoChmod
failed."
);
INIT_LOGE
(
"DoChmod
invalid arguments :%s"
,
cmdContent
);
goto
out
;
}
...
...
@@ -831,7 +827,7 @@ static void DoWrite(const char *cmdContent)
const
int
argsCount
=
2
;
struct
CmdArgs
*
ctx
=
GetCmd
(
cmdContent
,
" "
,
argsCount
);
if
(
ctx
==
NULL
||
ctx
->
argv
==
NULL
||
ctx
->
argv
[
0
]
==
NULL
||
ctx
->
argc
!=
argsCount
)
{
INIT_LOGE
(
"DoWrite: invalid arguments
"
);
INIT_LOGE
(
"DoWrite: invalid arguments
:%s"
,
cmdContent
);
goto
out
;
}
char
*
realPath
=
realpath
(
ctx
->
argv
[
0
],
NULL
);
...
...
@@ -867,7 +863,7 @@ static void DoRmdir(const char *cmdContent)
// format: rmdir path
struct
CmdArgs
*
ctx
=
GetCmd
(
cmdContent
,
" "
,
1
);
if
(
ctx
==
NULL
||
ctx
->
argv
==
NULL
||
ctx
->
argc
!=
1
)
{
INIT_LOGE
(
"DoRmdir: invalid arguments
"
);
INIT_LOGE
(
"DoRmdir: invalid arguments
:%s"
,
cmdContent
);
goto
out
;
}
...
...
@@ -893,7 +889,7 @@ static void DoSetrlimit(const char *cmdContent)
struct
CmdArgs
*
ctx
=
GetCmd
(
cmdContent
,
" "
,
argsCount
);
const
int
rlimMaxPos
=
2
;
if
(
ctx
==
NULL
||
ctx
->
argv
==
NULL
||
ctx
->
argc
!=
argsCount
)
{
INIT_LOGE
(
"DoSetrlimit: invalid arguments
"
);
INIT_LOGE
(
"DoSetrlimit: invalid arguments
:%s"
,
cmdContent
);
goto
out
;
}
...
...
@@ -925,7 +921,7 @@ static void DoRm(const char *cmdContent)
// format: rm /xxx/xxx/xxx
struct
CmdArgs
*
ctx
=
GetCmd
(
cmdContent
,
" "
,
1
);
if
(
ctx
==
NULL
||
ctx
->
argv
==
NULL
||
ctx
->
argc
!=
1
)
{
INIT_LOGE
(
"DoRm: invalid arguments
"
);
INIT_LOGE
(
"DoRm: invalid arguments
:%s"
,
cmdContent
);
goto
out
;
}
int
ret
=
unlink
(
ctx
->
argv
[
0
]);
...
...
@@ -944,7 +940,7 @@ static void DoExport(const char *cmdContent)
const
int
argsCount
=
2
;
struct
CmdArgs
*
ctx
=
GetCmd
(
cmdContent
,
" "
,
argsCount
);
if
(
ctx
==
NULL
||
ctx
->
argv
==
NULL
||
ctx
->
argc
!=
argsCount
)
{
INIT_LOGE
(
"DoExport: invalid arguments
"
);
INIT_LOGE
(
"DoExport: invalid arguments
:%s"
,
cmdContent
);
goto
out
;
}
int
ret
=
setenv
(
ctx
->
argv
[
0
],
ctx
->
argv
[
1
],
1
);
...
...
@@ -969,7 +965,7 @@ static void DoExec(const char *cmdContent)
int
argsCount
=
10
;
struct
CmdArgs
*
ctx
=
GetCmd
(
cmdContent
,
" "
,
argsCount
);
if
(
ctx
==
NULL
||
ctx
->
argv
==
NULL
||
ctx
->
argv
[
0
]
==
NULL
)
{
INIT_LOGE
(
"DoExec: invalid arguments
"
);
INIT_LOGE
(
"DoExec: invalid arguments
:%s"
,
cmdContent
);
_exit
(
0x7f
);
}
#ifdef OHOS_LITE
...
...
@@ -993,7 +989,7 @@ static void DoSymlink(const char *cmdContent)
const
int
argsCount
=
2
;
struct
CmdArgs
*
ctx
=
GetCmd
(
cmdContent
,
" "
,
argsCount
);
if
(
ctx
==
NULL
||
ctx
->
argv
==
NULL
||
ctx
->
argc
!=
argsCount
)
{
INIT_LOGE
(
"DoSymlink: invalid arguments
."
);
INIT_LOGE
(
"DoSymlink: invalid arguments
:%s"
,
cmdContent
);
goto
out
;
}
...
...
@@ -1036,7 +1032,7 @@ static void DoMakeNode(const char *cmdContent)
const
int
decimal
=
10
;
const
int
octal
=
8
;
if
(
ctx
==
NULL
||
ctx
->
argv
==
NULL
||
ctx
->
argc
!=
argsCount
)
{
INIT_LOGE
(
"DoMakeNode: invalid arguments
"
);
INIT_LOGE
(
"DoMakeNode: invalid arguments
:%s"
,
cmdContent
);
goto
out
;
}
...
...
@@ -1066,7 +1062,7 @@ static void DoMakeDevice(const char *cmdContent)
struct
CmdArgs
*
ctx
=
GetCmd
(
cmdContent
,
" "
,
argsCount
);
const
int
decimal
=
10
;
if
(
ctx
==
NULL
||
ctx
->
argv
==
NULL
||
ctx
->
argc
!=
argsCount
)
{
INIT_LOGE
(
"DoMakedevice: invalid ar
ugments"
);
INIT_LOGE
(
"DoMakedevice: invalid ar
guments :%s"
,
cmdContent
);
goto
out
;
}
unsigned
int
major
=
strtoul
(
ctx
->
argv
[
0
],
NULL
,
decimal
);
...
...
services/src/uevent.c
浏览文件 @
3d333c7b
...
...
@@ -34,28 +34,6 @@
#define LINK_NUMBER 4
#define DEFAULT_DIR_MODE (S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
#define DEV_DRM 3
#define DEV_ONCRPC 6
#define DEV_ADSP 4
#define DEV_INPUT 5
#define DEV_MTD 3
#define DEV_SOUND 5
#define DEV_MISC 4
#define DEV_DEFAULT 4
#define DEV_PLAT_FORM 9
#define DEV_USB 4
#define DEV_GRAPHICS 8
#define EVENT_ACTION 7
#define EVENT_DEVPATH 8
#define EVENT_SYSTEM 10
#define EVENT_FIRMWARE 9
#define EVENT_MAJOR 6
#define EVENT_MINOR 6
#define EVENT_PARTN 6
#define EVENT_PART_NAME 9
#define EVENT_DEV_NAME 8
#define EVENT_BLOCK 5
#define EVENT_PLAT_FORM 8
#define TRIGGER_ADDR_SIZE 4
#define BASE_BUFFER_SIZE 1024
#define MAX_BUFFER 256
...
...
@@ -65,8 +43,6 @@
#define SYS_LINK_NUMBER 2
#define MAX_DEVICE_LEN 64
#define DEFAULT_MODE 0000
#define DEVICE_SKIP 5
#define HANDLE_DEVICE_USB 3
#define DEVICE_DEFAULT_MODE (S_IRUSR | S_IWUSR | S_IRGRP)
int
g_ueventFD
=
-
1
;
...
...
@@ -252,32 +228,32 @@ static void ParseUevent(const char *buf, struct Uevent *event)
{
InitUevent
(
event
);
while
(
*
buf
)
{
if
(
strncmp
(
buf
,
"ACTION="
,
EVENT_ACTION
)
==
0
)
{
buf
+=
EVENT_ACTION
;
if
(
strncmp
(
buf
,
"ACTION="
,
strlen
(
"ACTION="
)
)
==
0
)
{
buf
+=
strlen
(
"ACTION="
)
;
event
->
action
=
buf
;
}
else
if
(
strncmp
(
buf
,
"DEVPATH="
,
EVENT_DEVPATH
)
==
0
)
{
buf
+=
EVENT_DEVPATH
;
}
else
if
(
strncmp
(
buf
,
"DEVPATH="
,
strlen
(
"DEVPATH="
)
)
==
0
)
{
buf
+=
strlen
(
"DEVPATH="
)
;
event
->
path
=
buf
;
}
else
if
(
strncmp
(
buf
,
"SUBSYSTEM="
,
EVENT_SYSTEM
)
==
0
)
{
buf
+=
EVENT_SYSTEM
;
}
else
if
(
strncmp
(
buf
,
"SUBSYSTEM="
,
strlen
(
"SUBSYSTEM="
)
)
==
0
)
{
buf
+=
strlen
(
"SUBSYSTEM="
)
;
event
->
subsystem
=
buf
;
}
else
if
(
strncmp
(
buf
,
"FIRMWARE="
,
EVENT_FIRMWARE
)
==
0
)
{
buf
+=
EVENT_FIRMWARE
;
}
else
if
(
strncmp
(
buf
,
"FIRMWARE="
,
strlen
(
"FIRMWARE="
)
)
==
0
)
{
buf
+=
strlen
(
"FIRMWARE="
)
;
event
->
firmware
=
buf
;
}
else
if
(
strncmp
(
buf
,
"MAJOR="
,
EVENT_MAJOR
)
==
0
)
{
buf
+=
EVENT_MAJOR
;
}
else
if
(
strncmp
(
buf
,
"MAJOR="
,
strlen
(
"MAJOR="
)
)
==
0
)
{
buf
+=
strlen
(
"MAJOR="
)
;
event
->
major
=
atoi
(
buf
);
}
else
if
(
strncmp
(
buf
,
"MINOR="
,
EVENT_MINOR
)
==
0
)
{
buf
+=
EVENT_MINOR
;
}
else
if
(
strncmp
(
buf
,
"MINOR="
,
strlen
(
"MINOR="
)
)
==
0
)
{
buf
+=
strlen
(
"MINOR="
)
;
event
->
minor
=
atoi
(
buf
);
}
else
if
(
strncmp
(
buf
,
"PARTN="
,
EVENT_PARTN
)
==
0
)
{
buf
+=
EVENT_PARTN
;
}
else
if
(
strncmp
(
buf
,
"PARTN="
,
strlen
(
"PARTN="
)
)
==
0
)
{
buf
+=
strlen
(
"PARTN="
)
;
event
->
partitionNum
=
atoi
(
buf
);
}
else
if
(
strncmp
(
buf
,
"PARTNAME="
,
EVENT_PART_NAME
)
==
0
)
{
buf
+=
EVENT_PART_NAME
;
}
else
if
(
strncmp
(
buf
,
"PARTNAME="
,
strlen
(
"PARTNAME="
)
)
==
0
)
{
buf
+=
strlen
(
"PARTNAME="
)
;
event
->
partitionName
=
buf
;
}
else
if
(
strncmp
(
buf
,
"DEVNAME="
,
EVENT_DEV_NAME
)
==
0
)
{
buf
+=
EVENT_DEV_NAME
;
}
else
if
(
strncmp
(
buf
,
"DEVNAME="
,
strlen
(
"DEVNAME="
)
)
==
0
)
{
buf
+=
strlen
(
"DEVNAME="
)
;
event
->
deviceName
=
buf
;
}
// Drop reset.
...
...
@@ -605,7 +581,7 @@ static void HandleBlockDevice(struct Uevent *event)
return
;
}
MakeDir
(
base
,
DEFAULT_DIR_MODE
);
if
(
!
strncmp
(
event
->
path
,
"/devices/"
,
DEV_PLAT_FORM
))
{
if
(
!
strncmp
(
event
->
path
,
"/devices/"
,
strlen
(
"/devices/"
)
))
{
links
=
ParsePlatformBlockDevice
(
event
);
}
HandleDevice
(
event
,
devpath
,
1
,
links
);
...
...
@@ -615,11 +591,12 @@ static void AddPlatformDevice(const char *path)
{
size_t
pathLen
=
strlen
(
path
);
const
char
*
name
=
path
;
if
(
!
strncmp
(
path
,
"/devices/"
,
DEV_PLAT_FORM
))
{
name
+=
DEV_PLAT_FORM
;
if
(
!
strncmp
(
name
,
"platform/"
,
DEV_PLAT_FORM
))
{
name
+=
DEV_PLAT_FORM
;
size_t
deviceLength
=
strlen
(
"/devices/"
);
size_t
platformLength
=
strlen
(
"platform/"
);
if
(
!
strncmp
(
path
,
"/devices/"
,
deviceLength
))
{
name
+=
deviceLength
;
if
(
!
strncmp
(
name
,
"platform/"
,
platformLength
))
{
name
+=
platformLength
;
}
}
INIT_LOGI
(
"adding platform device %s (%s)"
,
name
,
path
);
...
...
@@ -701,7 +678,7 @@ static char **GetCharacterDeviceSymlinks(const struct Uevent *uevent)
goto
err
;
}
if
(
strncmp
(
parent
,
"/usb"
,
DEV_USB
))
{
if
(
strncmp
(
parent
,
"/usb"
,
strlen
(
"/usb"
)
))
{
goto
err
;
}
/* skip root hub name and device. use device interface */
...
...
@@ -741,7 +718,9 @@ static int HandleUsbDevice(const struct Uevent *event, char *devpath, int len)
return
-
1
;
}
/* skip leading /dev/ */
p
+=
DEVICE_SKIP
;
p
+=
strlen
(
"/dev/"
);
/* build directories */
while
(
*
p
)
{
if
(
*
p
==
'/'
)
{
...
...
@@ -802,7 +781,7 @@ static void HandleGenericDevice(struct Uevent *event)
if
(
!
name
)
{
return
;
}
if
(
!
strncmp
(
event
->
subsystem
,
"usb"
,
HANDLE_DEVICE_USB
))
{
if
(
!
strncmp
(
event
->
subsystem
,
"usb"
,
strlen
(
"usb"
)
))
{
if
(
!
strcmp
(
event
->
subsystem
,
"usb"
))
{
if
(
HandleUsbDevice
(
event
,
devpath
,
MAX_DEV_PATH
)
==
-
1
)
{
return
;
...
...
@@ -811,25 +790,25 @@ static void HandleGenericDevice(struct Uevent *event)
/* ignore other USB events */
return
;
}
}
else
if
(
!
strncmp
(
event
->
subsystem
,
"graphics"
,
DEV_GRAPHICS
))
{
}
else
if
(
!
strncmp
(
event
->
subsystem
,
"graphics"
,
strlen
(
"graphics"
)
))
{
base
=
"/dev/graphics/"
;
MakeDir
(
base
,
DEFAULT_DIR_MODE
);
}
else
if
(
!
strncmp
(
event
->
subsystem
,
"drm"
,
DEV_DRM
))
{
}
else
if
(
!
strncmp
(
event
->
subsystem
,
"drm"
,
strlen
(
"drm"
)
))
{
base
=
"/dev/dri/"
;
MakeDir
(
base
,
DEFAULT_DIR_MODE
);
}
else
if
(
!
strncmp
(
event
->
subsystem
,
"oncrpc"
,
DEV_ONCRPC
))
{
}
else
if
(
!
strncmp
(
event
->
subsystem
,
"oncrpc"
,
strlen
(
"oncrpc"
)
))
{
base
=
"/dev/oncrpc/"
;
MakeDir
(
base
,
DEFAULT_DIR_MODE
);
}
else
if
(
!
strncmp
(
event
->
subsystem
,
"adsp"
,
DEV_ADSP
))
{
}
else
if
(
!
strncmp
(
event
->
subsystem
,
"adsp"
,
strlen
(
"adsp"
)
))
{
base
=
"/dev/adsp/"
;
MakeDir
(
base
,
DEFAULT_DIR_MODE
);
}
else
if
(
!
strncmp
(
event
->
subsystem
,
"input"
,
DEV_INPUT
))
{
}
else
if
(
!
strncmp
(
event
->
subsystem
,
"input"
,
strlen
(
"input"
)
))
{
base
=
"/dev/input/"
;
MakeDir
(
base
,
DEFAULT_DIR_MODE
);
}
else
if
(
!
strncmp
(
event
->
subsystem
,
"mtd"
,
DEV_MTD
))
{
}
else
if
(
!
strncmp
(
event
->
subsystem
,
"mtd"
,
strlen
(
"mtd"
)
))
{
base
=
"/dev/mtd/"
;
MakeDir
(
base
,
DEFAULT_DIR_MODE
);
}
else
if
(
!
strncmp
(
event
->
subsystem
,
"sound"
,
DEV_SOUND
))
{
}
else
if
(
!
strncmp
(
event
->
subsystem
,
"sound"
,
strlen
(
"sound"
)
))
{
base
=
"/dev/snd/"
;
MakeDir
(
base
,
DEFAULT_DIR_MODE
);
}
else
{
...
...
@@ -844,9 +823,9 @@ static void HandleDeviceUevent(struct Uevent *event)
if
(
strcmp
(
event
->
action
,
"add"
)
==
0
||
strcmp
(
event
->
action
,
"change"
)
==
0
)
{
/* Do nothing for now */
}
if
(
strncmp
(
event
->
subsystem
,
"block"
,
EVENT_BLOCK
)
==
0
)
{
if
(
strncmp
(
event
->
subsystem
,
"block"
,
strlen
(
"block"
)
)
==
0
)
{
HandleBlockDevice
(
event
);
}
else
if
(
strncmp
(
event
->
subsystem
,
"platform"
,
EVENT_PLAT_FORM
)
==
0
)
{
}
else
if
(
strncmp
(
event
->
subsystem
,
"platform"
,
strlen
(
"platform"
)
)
==
0
)
{
HandlePlatformDevice
(
event
);
}
else
{
HandleGenericDevice
(
event
);
...
...
services/test/unittest/common/cmd_func_test.cpp
浏览文件 @
3d333c7b
...
...
@@ -318,8 +318,8 @@ HWTEST_F(StartupInitUTest, cmdFuncDoCmdTest_003, TestSize.Level1)
dirTmp
=
nullptr
;
}
//
too many spaces
, bad format
cmdContentStr
=
"
/storage/data/cmdFuncDoCmdTest003
"
;
//
error argument count
, bad format
cmdContentStr
=
"
/storage/data/cmdFuncDoCmdTest003 0755 system
"
;
ParseCmdLine
((
cmdStr
+
cmdContentStr
).
c_str
(),
&
curCmdLine
);
EXPECT_EQ
(
0
,
strcmp
(
cmdStr
.
c_str
(),
curCmdLine
.
name
));
EXPECT_EQ
(
0
,
strcmp
(
cmdContentStr
.
c_str
(),
curCmdLine
.
cmdContent
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录