Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
d3b233a6
S
Startup Init Lite
项目概览
OpenHarmony
/
Startup Init Lite
接近 2 年 前同步成功
通知
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看板
未验证
提交
d3b233a6
编写于
7月 22, 2022
作者:
O
openharmony_ci
提交者:
Gitee
7月 22, 2022
浏览文件
操作
浏览文件
下载
差异文件
!931 optimize ueventd by-name symlink
Merge pull request !931 from Mupceet/ueventd
上级
be1d8e12
68f3e0b1
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
16 addition
and
30 deletion
+16
-30
ueventd/ueventd_device_handler.c
ueventd/ueventd_device_handler.c
+16
-30
未找到文件。
ueventd/ueventd_device_handler.c
浏览文件 @
d3b233a6
...
@@ -37,6 +37,17 @@
...
@@ -37,6 +37,17 @@
#include <policycoreutils.h>
#include <policycoreutils.h>
#endif
#endif
static
bool
IsBootDeviceLinkDir
(
const
char
*
linkDir
,
const
char
*
bootDevice
)
{
size_t
pathLen
=
strlen
(
"/dev/block/platform/"
);
INIT_CHECK_RETURN_VALUE
(
strncmp
(
linkDir
,
"/dev/block/platform/"
,
pathLen
)
==
0
,
false
);
const
char
*
vernier
=
linkDir
+
pathLen
;
INIT_CHECK_RETURN_VALUE
(
strncmp
(
vernier
,
bootDevice
,
strlen
(
bootDevice
))
==
0
,
false
);
vernier
+=
strlen
(
bootDevice
);
INIT_CHECK_RETURN_VALUE
(
strncmp
(
vernier
,
"/by-name"
,
strlen
(
"/by-name"
))
==
0
,
false
);
return
true
;
}
static
void
CreateSymbolLinks
(
const
char
*
deviceNode
,
char
**
symLinks
)
static
void
CreateSymbolLinks
(
const
char
*
deviceNode
,
char
**
symLinks
)
{
{
if
(
INVALIDSTRING
(
deviceNode
)
||
symLinks
==
NULL
)
{
if
(
INVALIDSTRING
(
deviceNode
)
||
symLinks
==
NULL
)
{
...
@@ -54,6 +65,11 @@ static void CreateSymbolLinks(const char *deviceNode, char **symLinks)
...
@@ -54,6 +65,11 @@ static void CreateSymbolLinks(const char *deviceNode, char **symLinks)
const
char
*
linkDir
=
dirname
(
linkBuf
);
const
char
*
linkDir
=
dirname
(
linkBuf
);
if
(
MakeDirRecursive
(
linkDir
,
DIRMODE
)
<
0
)
{
if
(
MakeDirRecursive
(
linkDir
,
DIRMODE
)
<
0
)
{
INIT_LOGE
(
"[uevent] Failed to create dir
\"
%s
\"
, err = %d"
,
linkDir
,
errno
);
INIT_LOGE
(
"[uevent] Failed to create dir
\"
%s
\"
, err = %d"
,
linkDir
,
errno
);
return
;
}
if
(
IsBootDeviceLinkDir
(
linkDir
,
bootDevice
)
&&
access
(
"/dev/block/by-name"
,
F_OK
)
!=
0
)
{
INIT_CHECK_ONLY_ELOG
(
symlink
(
linkDir
,
"/dev/block/by-name"
)
==
0
,
"Failed to create by-name symlink, err %d"
,
errno
);
}
}
errno
=
0
;
errno
=
0
;
int
rc
=
symlink
(
deviceNode
,
linkName
);
int
rc
=
symlink
(
deviceNode
,
linkName
);
...
@@ -214,32 +230,6 @@ static char *FindPlatformDeviceName(char *path)
...
@@ -214,32 +230,6 @@ static char *FindPlatformDeviceName(char *path)
return
NULL
;
return
NULL
;
}
}
static
void
BuildBootDeviceSymbolLink
(
char
**
links
,
int
linkNum
,
const
char
*
partitionName
)
{
if
(
links
==
NULL
)
{
INIT_LOGE
(
"Function parameter error."
);
return
;
}
if
(
linkNum
>
BLOCKDEVICE_LINKS
-
1
)
{
INIT_LOGW
(
"Too many links, ignore."
);
return
;
}
if
(
partitionName
==
NULL
)
{
INIT_LOGW
(
"Partition name is null, skip creating links"
);
return
;
}
links
[
linkNum
]
=
calloc
(
sizeof
(
char
),
DEVICE_FILE_SIZE
);
if
(
links
[
linkNum
]
==
NULL
)
{
INIT_LOGE
(
"Failed to allocate memory for link, err = %d"
,
errno
);
return
;
}
if
(
snprintf_s
(
links
[
linkNum
],
DEVICE_FILE_SIZE
,
DEVICE_FILE_SIZE
-
1
,
"/dev/block/by-name/%s"
,
partitionName
)
==
-
1
)
{
INIT_LOGE
(
"Failed to build link"
);
}
}
static
void
BuildDeviceSymbolLinks
(
char
**
links
,
int
linkNum
,
const
char
*
parent
,
static
void
BuildDeviceSymbolLinks
(
char
**
links
,
int
linkNum
,
const
char
*
parent
,
const
char
*
partitionName
,
const
char
*
deviceName
)
const
char
*
partitionName
,
const
char
*
deviceName
)
{
{
...
@@ -325,10 +315,6 @@ static char **GetBlockDeviceSymbolLinks(const struct Uevent *uevent)
...
@@ -325,10 +315,6 @@ static char **GetBlockDeviceSymbolLinks(const struct Uevent *uevent)
parent
=
FindPlatformDeviceName
(
parent
);
parent
=
FindPlatformDeviceName
(
parent
);
if
(
parent
!=
NULL
)
{
if
(
parent
!=
NULL
)
{
BuildDeviceSymbolLinks
(
links
,
linkNum
,
parent
,
uevent
->
partitionName
,
uevent
->
deviceName
);
BuildDeviceSymbolLinks
(
links
,
linkNum
,
parent
,
uevent
->
partitionName
,
uevent
->
deviceName
);
}
linkNum
++
;
if
((
parent
!=
NULL
)
&&
STRINGEQUAL
(
parent
,
bootDevice
))
{
BuildBootDeviceSymbolLink
(
links
,
linkNum
,
uevent
->
partitionName
);
linkNum
++
;
linkNum
++
;
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录