Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
iSulad
提交
cfa05ed2
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,发现更多精彩内容 >>
提交
cfa05ed2
编写于
4月 21, 2020
作者:
H
haozi007
提交者:
lifeng68
7月 25, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
finish mount and umount
Signed-off-by:
N
haozi007
<
liuhao27@huawei.com
>
上级
c3906dc2
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
140 addition
and
4 deletion
+140
-4
src/image/oci/storage/layer_store/graphdriver/driver.c
src/image/oci/storage/layer_store/graphdriver/driver.c
+13
-0
src/image/oci/storage/layer_store/graphdriver/driver.h
src/image/oci/storage/layer_store/graphdriver/driver.h
+2
-0
src/image/oci/storage/layer_store/layer_store.c
src/image/oci/storage/layer_store/layer_store.c
+124
-3
src/image/oci/storage/layer_store/layer_store.h
src/image/oci/storage/layer_store/layer_store.h
+1
-1
未找到文件。
src/image/oci/storage/layer_store/graphdriver/driver.c
浏览文件 @
cfa05ed2
...
...
@@ -21,6 +21,7 @@
#include "driver_overlay2.h"
#include "driver_devmapper.h"
#include "utils_array.h"
#include "utils.h"
#include "libisulad.h"
#include "isula_libutils/log.h"
...
...
@@ -274,6 +275,18 @@ void free_graphdriver_status(struct graphdriver_status *status)
free
(
status
);
}
void
free_graphdriver_mount_opts
(
struct
driver_mount_opts
*
opts
)
{
if
(
opts
==
NULL
)
{
return
;
}
free
(
opts
->
mount_label
);
opts
->
mount_label
=
NULL
;
util_free_array_by_len
(
opts
->
options
,
opts
->
options_len
);
free
(
opts
);
}
int
graphdriver_cleanup
(
void
)
{
if
(
g_graphdriver
==
NULL
)
{
...
...
src/image/oci/storage/layer_store/graphdriver/driver.h
浏览文件 @
cfa05ed2
...
...
@@ -112,6 +112,8 @@ struct graphdriver_status *graphdriver_get_status(void);
void
free_graphdriver_status
(
struct
graphdriver_status
*
status
);
void
free_graphdriver_mount_opts
(
struct
driver_mount_opts
*
opts
);
int
graphdriver_cleanup
(
void
);
#ifdef __cplusplus
...
...
src/image/oci/storage/layer_store/layer_store.c
浏览文件 @
cfa05ed2
...
...
@@ -627,6 +627,14 @@ free_out:
static
int
umount_helper
(
layer_t
*
l
,
bool
force
)
{
int
ret
=
0
;
int32_t
save_cnt
=
0
;
char
*
save_path
=
NULL
;
if
(
l
->
smount_point
==
NULL
)
{
return
0
;
}
save_cnt
=
l
->
smount_point
->
count
;
save_path
=
l
->
smount_point
->
path
;
if
(
!
force
&&
l
->
smount_point
->
count
>
1
)
{
l
->
smount_point
->
count
-=
1
;
...
...
@@ -644,6 +652,12 @@ static int umount_helper(layer_t *l, bool force)
save_json:
ret
=
save_mount_point
(
l
);
if
(
ret
!=
0
)
{
l
->
smount_point
->
count
=
save_cnt
;
l
->
smount_point
->
path
=
save_path
;
save_path
=
NULL
;
}
free
(
save_path
);
err_out:
return
ret
;
}
...
...
@@ -851,17 +865,120 @@ struct layer** layer_store_by_uncompress_digest(const char *digest)
char
*
layer_store_lookup
(
const
char
*
name
)
{
char
*
result
=
NULL
;
layer_t
*
l
=
NULL
;
if
(
name
==
NULL
)
{
return
result
;
}
l
=
lookup
(
name
);
if
(
l
==
NULL
)
{
return
result
;
}
result
=
util_strdup_s
(
l
->
slayer
->
id
);
layer_ref_dec
(
l
);
return
result
;
}
static
char
*
mount_helper
(
layer_t
*
l
,
const
struct
layer_store_mount_opts
*
opts
)
{
char
*
mount_point
=
NULL
;
int
nret
=
0
;
int32_t
save_cnt
=
0
;
char
*
save_path
=
NULL
;
struct
driver_mount_opts
*
d_opts
=
NULL
;
size_t
i
=
0
;
if
(
l
->
smount_point
==
NULL
)
{
l
->
smount_point
=
util_common_calloc_s
(
sizeof
(
storage_mount_point
));
if
(
l
->
smount_point
==
NULL
)
{
ERROR
(
"Out of memory"
);
return
NULL
;
}
}
save_cnt
=
l
->
smount_point
->
count
;
save_path
=
l
->
smount_point
->
path
;
if
(
l
->
smount_point
->
count
>
0
)
{
l
->
smount_point
->
count
+=
1
;
mount_point
=
util_strdup_s
(
save_path
);
goto
save_json
;
}
d_opts
=
util_common_calloc_s
(
sizeof
(
struct
driver_mount_opts
));
if
(
d_opts
==
NULL
)
{
ERROR
(
"Out of meoroy"
);
goto
err_out
;
}
if
(
opts
->
mount_label
==
NULL
)
{
d_opts
->
mount_label
=
util_strdup_s
(
l
->
slayer
->
mountlabel
);
}
else
{
d_opts
->
mount_label
=
util_strdup_s
(
opts
->
mount_label
);
}
if
(
opts
->
mount_opts
->
len
>
0
)
{
d_opts
->
options
=
util_smart_calloc_s
(
sizeof
(
char
*
),
opts
->
mount_opts
->
len
);
for
(;
i
<
opts
->
mount_opts
->
len
;
i
++
)
{
char
*
tmp_opt
=
NULL
;
if
(
asprintf
(
&
tmp_opt
,
"%s=%s"
,
opts
->
mount_opts
->
keys
[
i
],
opts
->
mount_opts
->
values
[
i
])
!=
0
)
{
ERROR
(
"Out of memory"
);
goto
err_out
;
}
d_opts
->
options_len
+=
1
;
}
}
mount_point
=
graphdriver_mount_layer
(
l
->
slayer
->
id
,
d_opts
);
if
(
mount_point
==
NULL
)
{
ERROR
(
"Call driver mount: %s failed"
,
l
->
slayer
->
id
);
goto
err_out
;
}
l
->
smount_point
->
count
+=
1
;
l
->
smount_point
->
path
=
util_strdup_s
(
mount_point
);
save_json:
nret
=
save_mount_point
(
l
);
if
(
nret
!=
0
)
{
l
->
smount_point
->
count
=
save_cnt
;
free
(
l
->
smount_point
->
path
);
l
->
smount_point
->
path
=
save_path
;
save_path
=
NULL
;
goto
err_out
;
}
free_graphdriver_mount_opts
(
d_opts
);
free
(
save_path
);
return
mount_point
;
err_out:
free_graphdriver_mount_opts
(
d_opts
);
free
(
mount_point
);
free
(
save_path
);
return
NULL
;
}
int
layer_store_mount
(
const
char
*
id
,
const
struct
layer_store_mount_opts
*
opts
)
char
*
layer_store_mount
(
const
char
*
id
,
const
struct
layer_store_mount_opts
*
opts
)
{
return
0
;
layer_t
*
l
=
NULL
;
char
*
result
=
NULL
;
if
(
id
==
NULL
)
{
ERROR
(
"Invalid arguments"
);
return
NULL
;
}
l
=
lookup
(
id
);
if
(
l
==
NULL
)
{
ERROR
(
"layer not known"
);
return
NULL
;
}
result
=
mount_helper
(
l
,
opts
);
layer_ref_dec
(
l
);
return
result
;
}
int
layer_store_umount
(
const
char
*
id
,
bool
force
)
{
layer_t
*
l
=
NULL
;
int
ret
=
0
;
if
(
id
==
NULL
)
{
// ignore null id
...
...
@@ -869,9 +986,13 @@ int layer_store_umount(const char *id, bool force)
}
l
=
lookup
(
id
);
if
(
l
==
NULL
)
{
ERROR
(
"layer not known"
);
return
-
1
;
}
ret
=
umount_helper
(
l
,
force
);
return
0
;
layer_ref_dec
(
l
);
return
ret
;
}
int
layer_store_mounted
(
const
char
*
id
)
...
...
src/image/oci/storage/layer_store/layer_store.h
浏览文件 @
cfa05ed2
...
...
@@ -52,7 +52,7 @@ bool layer_store_is_used(const char *id);
struct
layer
**
layer_store_by_compress_digest
(
const
char
*
digest
);
struct
layer
**
layer_store_by_uncompress_digest
(
const
char
*
digest
);
char
*
layer_store_lookup
(
const
char
*
name
);
int
layer_store_mount
(
const
char
*
id
,
const
struct
layer_store_mount_opts
*
opts
);
char
*
layer_store_mount
(
const
char
*
id
,
const
struct
layer_store_mount_opts
*
opts
);
int
layer_store_umount
(
const
char
*
id
,
bool
force
);
int
layer_store_mounted
(
const
char
*
id
);
int
layer_store_set_names
(
const
char
*
id
,
const
char
*
const
*
names
,
size_t
names_len
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录