Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Musl
提交
ce642737
T
Third Party Musl
项目概览
OpenHarmony
/
Third Party Musl
1 年多 前同步成功
通知
37
Star
125
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Musl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
ce642737
编写于
4月 20, 2023
作者:
O
openharmony_ci
提交者:
Gitee
4月 20, 2023
浏览文件
操作
浏览文件
下载
差异文件
!874 Support check duplicate so name for system app
Merge pull request !874 from yinchuang/support_same_so
上级
fad47f04
282968bf
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
31 addition
and
1 deletion
+31
-1
porting/linux/user/include/dlfcn.h
porting/linux/user/include/dlfcn.h
+1
-0
porting/linux/user/ldso/dynlink.c
porting/linux/user/ldso/dynlink.c
+19
-1
porting/linux/user/ldso/namespace.c
porting/linux/user/ldso/namespace.c
+9
-0
porting/linux/user/ldso/namespace.h
porting/linux/user/ldso/namespace.h
+2
-0
未找到文件。
porting/linux/user/include/dlfcn.h
浏览文件 @
ce642737
...
...
@@ -24,6 +24,7 @@ extern "C" {
/* create flags for dlns_create */
#define CREATE_INHERIT_DEFAULT 0x1
#define CREATE_INHERIT_CURRENT 0x2
#define LOCAL_NS_PREFERED 0x4
/* Use app's library when app's library has same name as system library. */
int
dlclose
(
void
*
);
char
*
dlerror
(
void
);
...
...
porting/linux/user/ldso/dynlink.c
浏览文件 @
ce642737
...
...
@@ -1714,6 +1714,18 @@ static struct dso *search_dso_by_fstat(const struct stat *st, const ns_t *ns, ui
}
return
NULL
;
}
static
inline
int
app_has_same_name_so
(
const
char
*
so_name
,
const
ns_t
*
ns
)
{
int
fd
=
-
1
;
/* Only check system app. */
if
(((
ns
->
flag
&
LOCAL_NS_PREFERED
)
!=
0
)
&&
ns
->
lib_paths
)
{
char
tmp_buf
[
PATH_MAX
+
1
];
fd
=
path_open
(
so_name
,
ns
->
lib_paths
,
tmp_buf
,
sizeof
tmp_buf
);
}
return
fd
;
}
/* Find loaded so by name */
static
struct
dso
*
find_library_by_name
(
const
char
*
name
,
const
ns_t
*
ns
,
bool
check_inherited
)
{
...
...
@@ -1727,7 +1739,12 @@ static struct dso *find_library_by_name(const char *name, const ns_t *ns, bool c
for
(
size_t
i
=
0
;
i
<
ns
->
ns_inherits
->
num
;
i
++
){
ns_inherit
*
inherit
=
ns
->
ns_inherits
->
inherits
[
i
];
p
=
search_dso_by_name
(
name
,
inherit
->
inherited_ns
);
if
(
p
&&
is_sharable
(
inherit
,
name
))
return
p
;
if
(
p
&&
is_sharable
(
inherit
,
name
))
{
if
(
app_has_same_name_so
(
name
,
ns
)
!=
-
1
)
{
return
NULL
;
}
return
p
;
}
}
}
return
NULL
;
...
...
@@ -3387,6 +3404,7 @@ int dlns_create2(Dl_namespace *dlns, const char *lib_path, int flags)
return
ENOMEM
;
}
ns_set_name
(
ns
,
dlns
->
name
);
ns_set_flag
(
ns
,
flags
);
ns_add_dso
(
ns
,
get_default_ns
()
->
ns_dsos
->
dsos
[
0
]);
/* add main app to this namespace*/
nslist_add_ns
(
ns
);
/* add ns to list*/
ns_set_lib_paths
(
ns
,
lib_path
);
...
...
porting/linux/user/ldso/namespace.c
浏览文件 @
ce642737
...
...
@@ -602,3 +602,12 @@ bool is_sharable(ns_inherit *inherit, const char *lib_name)
LD_LOGD
(
"is_sharable shared_libs not config, return true."
);
return
true
;
}
void
ns_set_flag
(
ns_t
*
ns
,
int
flag
)
{
if
(
!
ns
)
{
return
;
}
ns
->
flag
=
flag
;
LD_LOGD
(
"ns_set_flag ns[%{public}s] flag:%{public}d."
,
ns
->
ns_name
,
ns
->
flag
);
}
\ No newline at end of file
porting/linux/user/ldso/namespace.h
浏览文件 @
ce642737
...
...
@@ -47,6 +47,7 @@ typedef struct _namespace_t_ {
strlist
*
allowed_libs
;
/* when separated, allowed library names splited by ':'. */
dsolist
*
ns_dsos
;
/* dso list in this namespace */
struct
_ns_inherit_list_
*
ns_inherits
;
/* inherit list in this namespace */
int
flag
;
}
ns_t
;
/* define namespace list */
typedef
struct
_namespaces_list_
{
...
...
@@ -83,6 +84,7 @@ void ns_set_allowed_libs(ns_t *ns, const char *allowed_libs);
void
ns_add_dso
(
ns_t
*
ns
,
struct
dso
*
dso
);
void
nslist_add_ns
(
ns_t
*
ns
);
void
ns_add_inherit
(
ns_t
*
ns
,
ns_t
*
inherited
,
const
char
*
shared_libs
);
void
ns_set_flag
(
ns_t
*
ns
,
int
flag
);
/* get default namespace */
ns_t
*
get_default_ns
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录