Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
ae827657
S
Startup Init Lite
项目概览
OpenHarmony
/
Startup Init Lite
9 个月 前同步成功
通知
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,体验更适合开发者的 AI 搜索 >>
提交
ae827657
编写于
4月 29, 2021
作者:
L
lanxueyuan
提交者:
Gitee
4月 29, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of gitee.com:openharmony/startup_init_lite into fix-codestyle-check
上级
4e73ac48
f935364b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
31 addition
and
10 deletion
+31
-10
services/src/init_cmds.c
services/src/init_cmds.c
+11
-3
services/src/uevent.c
services/src/uevent.c
+20
-7
未找到文件。
services/src/init_cmds.c
浏览文件 @
ae827657
...
...
@@ -14,6 +14,7 @@
*/
#include "init_cmds.h"
#include <ctype.h>
#include <errno.h>
#include <stdbool.h>
...
...
@@ -28,6 +29,7 @@
#include <linux/module.h>
#include <sys/syscall.h>
#endif
#include "init_service_manager.h"
#include "securec.h"
...
...
@@ -326,7 +328,6 @@ static void DoInsmodInternal(const char *fileName, char *secondPtr, char *restPt
{
int
fd
=
-
1
;
char
options
[
OPTIONS_SIZE
]
=
{
0
};
if
(
flags
==
0
)
{
// '-f' option
if
(
restPtr
!=
NULL
&&
secondPtr
!=
NULL
)
{
// Reset arugments, combine then all.
if
(
snprintf_s
(
options
,
sizeof
(
options
),
OPTIONS_SIZE
-
1
,
"%s %s"
,
secondPtr
,
restPtr
)
==
-
1
)
{
...
...
@@ -339,9 +340,14 @@ static void DoInsmodInternal(const char *fileName, char *secondPtr, char *restPt
}
}
else
{
// Only restPtr is option
if
(
restPtr
!=
NULL
)
{
strncpy_s
(
options
,
OPTIONS_SIZE
-
1
,
restPtr
,
strlen
(
restPtr
));
if
(
strncpy_s
(
options
,
OPTIONS_SIZE
-
1
,
restPtr
,
strlen
(
restPtr
))
!=
0
)
{
goto
out
;
}
}
}
if
(
!
fileName
)
{
goto
out
;
}
fd
=
open
(
fileName
,
O_RDONLY
|
O_NOFOLLOW
|
O_CLOEXEC
);
if
(
fd
<
0
)
{
printf
(
"[Init] failed to open %s: %d
\n
"
,
fileName
,
errno
);
...
...
@@ -352,7 +358,7 @@ static void DoInsmodInternal(const char *fileName, char *secondPtr, char *restPt
printf
(
"[Init] finit_module for %s failed: %d
\n
"
,
fileName
,
errno
);
}
out:
if
(
fd
>
0
)
{
if
(
fd
>
=
0
)
{
close
(
fd
);
}
return
;
...
...
@@ -379,12 +385,14 @@ static void DoInsmod(const char *cmdContent)
if
(
memcpy_s
(
line
,
count
,
cmdContent
,
count
)
!=
EOK
)
{
printf
(
"[Init] memcpy failed
\n
"
);
free
(
line
);
return
;
}
line
[
count
]
=
'\0'
;
do
{
if
((
p
=
strtok_r
(
line
,
" "
,
&
restPtr
))
==
NULL
)
{
printf
(
"[Init] debug, cannot get filename
\n
"
);
free
(
line
);
return
;
}
fileName
=
p
;
...
...
services/src/uevent.c
浏览文件 @
ae827657
...
...
@@ -152,7 +152,7 @@ static void RetriggerUevent()
Trigger
(
"/sys/block"
);
Trigger
(
"/sys/devices"
);
int
fd
=
open
(
g_trigger
,
O_WRONLY
|
O_CREAT
|
O_CLOEXEC
,
DEFAULT_MODE
);
if
(
fd
>
0
)
{
if
(
fd
>
=
0
)
{
close
(
fd
);
}
printf
(
"Re-trigger uevent done
\n
"
);
...
...
@@ -220,7 +220,7 @@ ssize_t ReadUevent(int fd, void *buf, size_t len)
if
(
uid
!=
0
)
{
goto
out
;
}
if
(
addr
.
nl_groups
==
0
||
addr
.
nl_pid
!=
0
)
{
/* ignoring non-kernel or unicast netlink message */
goto
out
;
...
...
@@ -344,7 +344,8 @@ static char **ParsePlatformBlockDevice(const struct Uevent *uevent)
if
(
!
links
)
{
return
NULL
;
}
if
(
snprintf_s
(
linkPath
,
sizeof
(
linkPath
),
sizeof
(
linkPath
),
"/dev/block/%s/%s"
,
type
,
device
)
==
-
1
)
{
if
(
snprintf_s
(
linkPath
,
sizeof
(
linkPath
),
sizeof
(
linkPath
)
-
1
,
"/dev/block/%s/%s"
,
type
,
device
)
==
-
1
)
{
free
(
links
);
return
NULL
;
}
if
(
uevent
->
partitionName
)
{
...
...
@@ -514,7 +515,7 @@ static void HandleBlockDevice(struct Uevent *event)
if
(
strlen
(
name
)
>
MAX_DEVICE_LEN
)
{
// too long
return
;
}
if
(
snprintf_s
(
devpath
,
sizeof
(
devpath
),
sizeof
(
devpath
),
"%s/%s"
,
base
,
name
)
==
-
1
)
{
if
(
snprintf_s
(
devpath
,
sizeof
(
devpath
),
sizeof
(
devpath
)
-
1
,
"%s/%s"
,
base
,
name
)
==
-
1
)
{
return
;
}
MakeDir
(
base
,
DEFAULT_DIR_MODE
);
...
...
@@ -537,10 +538,14 @@ static void AddPlatformDevice(const char *path)
}
printf
(
"adding platform device %s (%s)
\n
"
,
name
,
path
);
struct
PlatformNode
*
bus
=
calloc
(
1
,
sizeof
(
struct
PlatformNode
));
if
(
!
bus
)
{
return
;
}
bus
->
path
=
strdup
(
path
);
bus
->
pathLen
=
pathLen
;
bus
->
name
=
bus
->
path
+
(
name
-
path
);
ListAddTail
(
&
g_platformNames
,
&
bus
->
list
);
return
;
}
static
void
RemovePlatformDevice
(
const
char
*
path
)
...
...
@@ -661,7 +666,7 @@ static int HandleUsbDevice(const struct Uevent *event, char *devpath, int len)
* see drivers/base/core.c
*/
char
*
p
=
devpath
;
if
(
snprintf_s
(
devpath
,
len
,
len
,
"/dev/%s"
,
event
->
deviceName
)
==
-
1
)
{
if
(
snprintf_s
(
devpath
,
len
,
len
-
1
,
"/dev/%s"
,
event
->
deviceName
)
==
-
1
)
{
return
-
1
;
}
/* skip leading /dev/ */
...
...
@@ -702,13 +707,21 @@ static void HandleDeviceEvent(struct Uevent *event, char *devpath, int len, cons
char
**
links
=
NULL
;
links
=
GetCharacterDeviceSymlinks
(
event
);
if
(
!
devpath
[
0
])
{
if
(
snprintf_s
(
devpath
,
len
,
len
,
"%s%s"
,
base
,
name
)
==
-
1
)
{
if
(
snprintf_s
(
devpath
,
len
,
len
-
1
,
"%s%s"
,
base
,
name
)
==
-
1
)
{
printf
(
"[Init] snprintf_s err
\n
"
);
return
;
goto
err
;
}
}
HandleDevice
(
event
,
devpath
,
0
,
links
);
return
;
err:
if
(
links
)
{
for
(
int
i
=
0
;
links
[
i
];
i
++
)
{
free
(
links
[
i
]);
}
free
(
links
);
}
return
;
}
static
void
HandleGenericDevice
(
struct
Uevent
*
event
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录