Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
iSulad
提交
a95904f5
I
iSulad
项目概览
openeuler
/
iSulad
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
iSulad
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a95904f5
编写于
5月 12, 2020
作者:
W
wujing
提交者:
lifeng68
7月 25, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
container look interface
Signed-off-by:
N
wujing
<
wujing50@huawei.com
>
上级
fb508141
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
114 addition
and
8 deletion
+114
-8
src/image/oci/storage/container_store/container_store.c
src/image/oci/storage/container_store/container_store.c
+114
-8
未找到文件。
src/image/oci/storage/container_store/container_store.c
浏览文件 @
a95904f5
...
...
@@ -306,7 +306,7 @@ static int save_container(cntr_t *cntr)
}
if
(
util_atomic_write_file
(
container_path
,
json_data
,
strlen
(
json_data
),
SECURE_CONFIG_FILE_MODE
)
!=
0
)
{
ERROR
(
"Failed to save
image
json file"
);
ERROR
(
"Failed to save
container
json file"
);
ret
=
-
1
;
goto
out
;
}
...
...
@@ -372,13 +372,13 @@ static int container_store_load()
}
if
(
get_containers_from_json
()
!=
0
)
{
ERROR
(
"Failed to get
image
s from json"
);
ERROR
(
"Failed to get
container
s from json"
);
return
-
1
;
}
linked_list_for_each_safe
(
item
,
&
(
g_container_store
->
containers_list
),
next
)
{
if
(
load_container_to_store_field
((
cntr_t
*
)
item
->
elem
)
!=
0
)
{
ERROR
(
"Failed to load
image
to container store"
);
ERROR
(
"Failed to load
container
to container store"
);
return
-
1
;
}
}
...
...
@@ -680,20 +680,20 @@ static int container_store_append_container(const char *id, const char *layer, c
g_container_store
->
containers_list_len
++
;
if
(
!
map_insert
(
g_container_store
->
byid
,
(
void
*
)
id
,
(
void
*
)
cntr
))
{
ERROR
(
"Failed to insert
image
to container store"
);
ERROR
(
"Failed to insert
container
to container store"
);
ret
=
-
1
;
goto
out
;
}
if
(
!
map_insert
(
g_container_store
->
by
name
,
(
void
*
)
layer
,
(
void
*
)
cntr
))
{
ERROR
(
"Failed to insert
image
to container store"
);
if
(
!
map_insert
(
g_container_store
->
by
layer
,
(
void
*
)
layer
,
(
void
*
)
cntr
))
{
ERROR
(
"Failed to insert
container
to container store"
);
ret
=
-
1
;
goto
out
;
}
for
(
i
=
0
;
i
<
unique_names_len
;
i
++
)
{
if
(
!
map_insert
(
g_container_store
->
byname
,
(
void
*
)
unique_names
[
i
],
(
void
*
)
cntr
))
{
ERROR
(
"Failed to insert
image to container store's byname
"
);
ERROR
(
"Failed to insert
container to container store's name index
"
);
ret
=
-
1
;
goto
out
;
}
...
...
@@ -785,9 +785,115 @@ out:
return
dst_id
;
}
char
*
container_store_lookup
(
const
char
*
id
)
static
cntr_t
*
get_container_for_store_by_prefix
(
const
char
*
id
)
{
bool
ret
=
true
;
cntr_t
*
value
=
NULL
;
map_itor
*
itor
=
NULL
;
const
char
*
key
=
NULL
;
itor
=
map_itor_new
(
g_container_store
->
byid
);
if
(
itor
==
NULL
)
{
ERROR
(
"Failed to get byid's iterator from container store"
);
return
NULL
;
}
for
(;
map_itor_valid
(
itor
);
map_itor_next
(
itor
))
{
key
=
map_itor_key
(
itor
);
if
(
key
==
NULL
)
{
ERROR
(
"Out of memory"
);
ret
=
false
;
goto
out
;
}
if
(
strncmp
(
key
,
id
,
strlen
(
id
))
==
0
)
{
if
(
value
!=
NULL
)
{
ERROR
(
"Multiple IDs found with provided prefix: %s"
,
id
);
ret
=
false
;
goto
out
;
}
else
{
value
=
map_itor_value
(
itor
);
}
}
}
out:
map_itor_free
(
itor
);
if
(
!
ret
)
{
value
=
NULL
;
}
return
value
;
}
static
cntr_t
*
lookup
(
const
char
*
id
)
{
cntr_t
*
value
=
NULL
;
if
(
id
==
NULL
)
{
ERROR
(
"Invalid input parameter, id is NULL"
);
return
NULL
;
}
value
=
map_search
(
g_container_store
->
byid
,
(
void
*
)
id
);
if
(
value
!=
NULL
)
{
goto
found
;
}
value
=
map_search
(
g_container_store
->
bylayer
,
(
void
*
)
id
);
if
(
value
!=
NULL
)
{
goto
found
;
}
value
=
get_container_for_store_by_prefix
(
id
);
if
(
value
!=
NULL
)
{
goto
found
;
}
return
NULL
;
found:
container_ref_inc
(
value
);
return
value
;
}
static
inline
cntr_t
*
lookup_with_lock
(
const
char
*
id
)
{
cntr_t
*
cntr
=
NULL
;
if
(
!
container_store_lock
(
false
))
{
return
NULL
;
}
cntr
=
lookup
(
id
);
container_store_unlock
();
return
cntr
;
}
char
*
container_store_lookup
(
const
char
*
id
)
{
char
*
container_id
=
NULL
;
cntr_t
*
cntr
=
NULL
;
if
(
id
==
NULL
)
{
ERROR
(
"Invalid input parameter, id is NULL"
);
return
NULL
;
}
if
(
g_container_store
==
NULL
)
{
ERROR
(
"Container store is not ready"
);
return
NULL
;
}
cntr
=
lookup_with_lock
(
id
);
if
(
cntr
==
NULL
)
{
ERROR
(
"Container not known"
);
return
NULL
;
}
container_id
=
util_strdup_s
(
cntr
->
scontainer
->
id
);
container_ref_dec
(
cntr
);
return
container_id
;
}
int
container_store_delete
(
const
char
*
id
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录