Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
67c1e114
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看板
提交
67c1e114
编写于
4月 23, 2021
作者:
L
leon
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix coding style
上级
3494a968
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
28 addition
and
38 deletion
+28
-38
services/src/init_cmds.c
services/src/init_cmds.c
+3
-3
services/src/uevent.c
services/src/uevent.c
+25
-35
未找到文件。
services/src/init_cmds.c
浏览文件 @
67c1e114
...
...
@@ -39,7 +39,7 @@
#define LOADCFG_BUF_SIZE 128 // loadcfg, max buffer for one cmdline
#define LOADCFG_MAX_FILE_LEN 51200 // loadcfg, max file size is 50K
#define LOADCFG_MAX_LOOP 20 // loadcfg, to prevent to be trapped in infite loop
#define OCTAL_TYPE 8 //8 means octal to decimal
#define OCTAL_TYPE 8 //
8 means octal to decimal
static
const
char
*
g_supportCfg
[]
=
{
"/patch/fstab.cfg"
,
};
...
...
@@ -321,7 +321,7 @@ static void DoMount(const char* cmdContent)
}
#ifndef OHOS_LITE
#define OPTIONS_SIZE
(128u)
#define OPTIONS_SIZE
128u
static
void
DoInsmodInternal
(
const
char
*
fileName
,
char
*
secondPtr
,
char
*
restPtr
,
int
flags
)
{
int
fd
=
-
1
;
...
...
@@ -332,7 +332,7 @@ static void DoInsmodInternal(const char *fileName, char *secondPtr, char *restPt
if
(
snprintf_s
(
options
,
sizeof
(
options
),
OPTIONS_SIZE
-
1
,
"%s %s"
,
secondPtr
,
restPtr
)
==
-
1
)
{
goto
out
;
}
}
else
{
}
else
if
(
secondPtr
!=
NULL
)
{
if
(
strncpy_s
(
options
,
OPTIONS_SIZE
-
1
,
secondPtr
,
strlen
(
secondPtr
))
!=
0
)
{
goto
out
;
}
...
...
services/src/uevent.c
浏览文件 @
67c1e114
...
...
@@ -70,18 +70,6 @@
int
g_ueventFD
=
-
1
;
#define CHECK_RESULT_DONE(ret, do, another) \
if (ret) { \
do; \
} else { \
another; \
}
#define CHECK_RETURN(ret, statement) \
if (!(ret)) { \
statement; \
}
struct
Uevent
{
const
char
*
action
;
const
char
*
path
;
...
...
@@ -106,7 +94,7 @@ static struct ListNode g_platformNames = {
.
prev
=
&
g_platformNames
,
};
const
char
*
TRIGGER
=
"/dev/.trigger_uevent"
;
const
char
*
g_trigger
=
"/dev/.trigger_uevent"
;
static
void
HandleUevent
();
static
int
UeventFD
()
...
...
@@ -156,14 +144,14 @@ void Trigger(const char *sysPath)
static
void
RetriggerUevent
()
{
if
(
access
(
TRIGGER
,
F_OK
)
==
0
)
{
if
(
access
(
g_trigger
,
F_OK
)
==
0
)
{
printf
(
"Skip trigger uevent, alread done
\n
"
);
return
;
}
Trigger
(
"/sys/class"
);
Trigger
(
"/sys/block"
);
Trigger
(
"/sys/devices"
);
int
fd
=
open
(
TRIGGER
,
O_WRONLY
|
O_CREAT
|
O_CLOEXEC
,
DEFAULT_MODE
);
int
fd
=
open
(
g_trigger
,
O_WRONLY
|
O_CREAT
|
O_CLOEXEC
,
DEFAULT_MODE
);
if
(
fd
>
0
)
{
close
(
fd
);
}
...
...
@@ -347,15 +335,15 @@ static char **ParsePlatformBlockDevice(const struct Uevent *uevent)
char
*
p
=
NULL
;
struct
PlatformNode
*
pDev
=
FindPlatformDevice
(
uevent
->
path
);
CHECK_RESULT_DONE
(
pDev
,
device
=
pDev
->
name
;
type
=
"platform"
,
printf
(
"Non platform device.
\n
"
);
return
NULL
);
char
**
links
=
malloc
(
sizeof
(
char
*
)
*
LINK_NUMBER
);
if
(
!
links
)
{
if
(
!
pDev
)
{
return
NULL
;
}
if
(
memset_s
(
links
,
sizeof
(
char
*
)
*
LINK_NUMBER
,
0
,
sizeof
(
char
*
)
*
LINK_NUMBER
)
!=
0
)
{
device
=
pDev
->
name
;
type
=
"platform"
;
char
**
links
=
calloc
(
sizeof
(
char
*
),
LINK_NUMBER
);
if
(
!
links
)
{
return
NULL
;
}
printf
(
"found %s device %s
\n
"
,
type
,
device
);
if
(
snprintf_s
(
linkPath
,
sizeof
(
linkPath
),
sizeof
(
linkPath
),
"/dev/block/%s/%s"
,
type
,
device
)
==
-
1
)
{
return
NULL
;
}
...
...
@@ -601,6 +589,16 @@ static const char *ParseDeviceName(const struct Uevent *uevent, unsigned int len
return
name
;
}
static
void
FindCharEnd
(
const
char
*
parent
)
{
while
(
*++
parent
)
{
if
(
*
parent
==
'/'
)
{
return
;
}
}
return
;
}
static
char
**
GetCharacterDeviceSymlinks
(
const
struct
Uevent
*
uevent
)
{
char
*
slash
=
NULL
;
...
...
@@ -608,11 +606,11 @@ static char **GetCharacterDeviceSymlinks(const struct Uevent *uevent)
int
width
;
struct
PlatformNode
*
pDev
=
FindPlatformDevice
(
uevent
->
path
);
CHECK_RETURN
(
pDev
,
return
NULL
);
char
**
links
=
malloc
(
sizeof
(
char
*
)
*
SYS_LINK_NUMBER
);
CHECK_RETURN
(
links
,
return
NULL
);
if
(
memset_s
(
links
,
sizeof
(
char
*
)
*
SYS_LINK_NUMBER
,
0
,
sizeof
(
char
*
)
*
SYS_LINK_NUMBER
)
!=
0
)
{
if
(
!
pDev
)
{
return
NULL
;
}
char
**
links
=
calloc
(
sizeof
(
char
*
),
SYS_LINK_NUMBER
);
if
(
!
links
)
{
return
NULL
;
}
...
...
@@ -624,17 +622,9 @@ static char **GetCharacterDeviceSymlinks(const struct Uevent *uevent)
if
(
!
strncmp
(
parent
,
"/usb"
,
DEV_USB
))
{
/* skip root hub name and device. use device interface */
while
(
*++
parent
)
{
if
(
*
parent
==
'/'
)
{
break
;
}
}
FindCharEnd
(
parent
);
if
(
*
parent
)
{
while
(
*++
parent
)
{
if
(
*
parent
==
'/'
)
{
break
;
}
}
FindCharEnd
(
parent
);
}
if
(
!*
parent
)
{
goto
err
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录