Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
f935364b
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看板
提交
f935364b
编写于
4月 29, 2021
作者:
O
openharmony_ci
提交者:
Gitee
4月 29, 2021
浏览文件
操作
浏览文件
下载
差异文件
!25 updater init
Merge pull request !25 from chengjinsong/updater_0429
上级
44e40185
14856393
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
41 addition
and
19 deletion
+41
-19
services/src/device.c
services/src/device.c
+1
-1
services/src/init_cmds.c
services/src/init_cmds.c
+12
-4
services/src/uevent.c
services/src/uevent.c
+28
-14
未找到文件。
services/src/device.c
浏览文件 @
f935364b
...
...
@@ -13,12 +13,12 @@
* limitations under the License.
*/
#include <errno.h>
#include <sys/sysmacros.h>
#include <sys/stat.h>
#include <sys/mount.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#define DEFAULT_RW_MODE 0666
#define DEFAULT_NO_AUTHORITY_MODE 0600
...
...
services/src/init_cmds.c
浏览文件 @
f935364b
...
...
@@ -14,6 +14,7 @@
*/
#include "init_cmds.h"
#include <ctype.h>
#include <errno.h>
#include <stdbool.h>
...
...
@@ -24,10 +25,11 @@
#include <sys/stat.h>
#include <unistd.h>
#ifndef OHOS_LITE
#include <sys/syscall.h>
#include <fcntl.h>
#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
浏览文件 @
f935364b
...
...
@@ -13,21 +13,22 @@
* limitations under the License.
*/
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <linux/netlink.h>
#include <poll.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <poll.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <ctype.h>
#include <signal.h>
#include <
dirent
.h>
#include <linux/netlink.h>
#include <
unistd
.h>
#include "list.h"
#include "securec.h"
...
...
@@ -152,7 +153,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 +221,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 +345,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 +516,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 +539,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 +667,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 +708,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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录