Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
iSulad
提交
cd503ba4
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,发现更多精彩内容 >>
提交
cd503ba4
编写于
5月 16, 2020
作者:
W
wujing
提交者:
lifeng68
7月 25, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rootfs store interface implement
Signed-off-by:
N
wujing
<
wujing50@huawei.com
>
上级
4537c008
变更
8
展开全部
显示空白变更内容
内联
并排
Showing
8 changed file
with
854 addition
and
171 deletion
+854
-171
src/cutils/utils_images.c
src/cutils/utils_images.c
+69
-0
src/cutils/utils_images.h
src/cutils/utils_images.h
+1
-0
src/image/oci/registry/registry.h
src/image/oci/registry/registry.h
+2
-0
src/image/oci/storage/image_store/image_store.c
src/image/oci/storage/image_store/image_store.c
+11
-73
src/image/oci/storage/rootfs_store/rootfs.c
src/image/oci/storage/rootfs_store/rootfs.c
+3
-3
src/image/oci/storage/rootfs_store/rootfs.h
src/image/oci/storage/rootfs_store/rootfs.h
+1
-1
src/image/oci/storage/rootfs_store/rootfs_store.c
src/image/oci/storage/rootfs_store/rootfs_store.c
+765
-93
src/image/oci/storage/storage.h
src/image/oci/storage/storage.h
+2
-1
未找到文件。
src/cutils/utils_images.c
浏览文件 @
cd503ba4
...
...
@@ -290,3 +290,72 @@ char *oci_strip_dockerio_prefix(const char *name)
return
util_strdup_s
(
name
);
}
static
bool
should_use_origin_name
(
const
char
*
name
)
{
size_t
i
;
for
(
i
=
0
;
i
<
strlen
(
name
);
i
++
)
{
char
ch
=
name
[
i
];
if
(
ch
!=
'.'
&&
!
(
ch
>=
'0'
&&
ch
<=
'9'
)
&&
!
(
ch
>=
'a'
&&
ch
<=
'z'
))
{
return
false
;
}
}
return
true
;
}
// Convert a BigData key name into an acceptable file name.
char
*
make_big_data_base_name
(
const
char
*
key
)
{
int
ret
=
0
;
int
nret
=
0
;
char
*
b64_encode_name
=
NULL
;
size_t
b64_encode_name_len
=
0
;
char
*
base_name
=
NULL
;
size_t
name_size
;
if
(
should_use_origin_name
(
key
))
{
return
util_strdup_s
(
key
);
}
b64_encode_name_len
=
util_base64_encode_len
(
strlen
(
key
));
b64_encode_name
=
util_common_calloc_s
(
b64_encode_name_len
+
1
);
if
(
b64_encode_name
==
NULL
)
{
ERROR
(
"Out of memory"
);
ret
=
-
1
;
goto
out
;
}
nret
=
util_base64_encode
((
unsigned
char
*
)
key
,
strlen
(
key
),
b64_encode_name
,
b64_encode_name_len
);
if
(
nret
<
0
)
{
ret
=
-
1
;
ERROR
(
"Encode auth to base64 failed"
);
goto
out
;
}
name_size
=
1
+
strlen
(
b64_encode_name
)
+
1
;
// '=' + encode string + '\0'
base_name
=
(
char
*
)
util_common_calloc_s
(
name_size
*
sizeof
(
char
));
if
(
base_name
==
NULL
)
{
ERROR
(
"Out of memory"
);
ret
=
-
1
;
goto
out
;
}
nret
=
snprintf
(
base_name
,
name_size
,
"=%s"
,
b64_encode_name
);
if
(
nret
<
0
||
(
size_t
)
nret
>=
name_size
)
{
ERROR
(
"Out of memory"
);
ret
=
-
1
;
goto
out
;
}
DEBUG
(
"big data file name : %s"
,
base_name
);
out:
if
(
ret
!=
0
)
{
free
(
base_name
);
base_name
=
NULL
;
}
free
(
b64_encode_name
);
return
base_name
;
}
src/cutils/utils_images.h
浏览文件 @
cd503ba4
...
...
@@ -39,6 +39,7 @@ char *oci_normalize_image_name(const char *name);
int
oci_split_image_name
(
const
char
*
image_name
,
char
**
host
,
char
**
name
,
char
**
tag
);
char
*
oci_full_image_name
(
const
char
*
host
,
const
char
*
name
,
const
char
*
tag
);
char
*
oci_strip_dockerio_prefix
(
const
char
*
name
);
char
*
make_big_data_base_name
(
const
char
*
key
);
#ifdef __cplusplus
}
...
...
src/image/oci/registry/registry.h
浏览文件 @
cd503ba4
...
...
@@ -15,6 +15,8 @@
#ifndef __IMAGE_REGISTRY_H
#define __IMAGE_REGISTRY_H
#include <stdbool.h>
#ifdef __cplusplus
extern
"C"
{
#endif
...
...
src/image/oci/storage/image_store/image_store.c
浏览文件 @
cd503ba4
...
...
@@ -23,7 +23,6 @@
#include <unistd.h>
#include <string.h>
#include <stddef.h>
#include <libwebsockets.h>
#include <sha256.h>
#include "utils.h"
#include "log.h"
...
...
@@ -1296,75 +1295,6 @@ out:
return
ret
;
}
static
bool
should_use_origin_name
(
const
char
*
name
)
{
size_t
i
;
for
(
i
=
0
;
i
<
strlen
(
name
);
i
++
)
{
char
ch
=
name
[
i
];
if
(
ch
!=
'.'
&&
!
(
ch
>=
'0'
&&
ch
<=
'9'
)
&&
!
(
ch
>=
'a'
&&
ch
<=
'z'
))
{
return
false
;
}
}
return
true
;
}
// Convert a BigData key name into an acceptable file name.
static
char
*
make_big_data_base_name
(
const
char
*
key
)
{
int
ret
=
0
;
int
nret
=
0
;
char
*
b64_encode_name
=
NULL
;
size_t
b64_encode_name_len
=
0
;
char
*
base_name
=
NULL
;
size_t
name_size
;
if
(
should_use_origin_name
(
key
))
{
return
util_strdup_s
(
key
);
}
b64_encode_name_len
=
util_base64_encode_len
(
strlen
(
key
));
b64_encode_name
=
util_common_calloc_s
(
b64_encode_name_len
+
1
);
if
(
b64_encode_name
==
NULL
)
{
ERROR
(
"Out of memory"
);
ret
=
-
1
;
goto
out
;
}
nret
=
util_base64_encode
((
unsigned
char
*
)
key
,
strlen
(
key
),
b64_encode_name
,
b64_encode_name_len
);
if
(
nret
<
0
)
{
ret
=
-
1
;
ERROR
(
"Encode auth to base64 failed"
);
goto
out
;
}
name_size
=
1
+
strlen
(
b64_encode_name
)
+
1
;
// '=' + encode string + '\0'
base_name
=
(
char
*
)
util_common_calloc_s
(
name_size
*
sizeof
(
char
));
if
(
base_name
==
NULL
)
{
ERROR
(
"Out of memory"
);
ret
=
-
1
;
goto
out
;
}
nret
=
snprintf
(
base_name
,
name_size
,
"=%s"
,
b64_encode_name
);
if
(
nret
<
0
||
(
size_t
)
nret
>=
name_size
)
{
ERROR
(
"Out of memory"
);
ret
=
-
1
;
goto
out
;
}
DEBUG
(
"big data file name : %s"
,
base_name
);
out:
if
(
ret
!=
0
)
{
free
(
base_name
);
base_name
=
NULL
;
}
free
(
b64_encode_name
);
return
base_name
;
}
static
int
get_data_path
(
const
char
*
id
,
const
char
*
key
,
char
*
path
,
size_t
len
)
{
int
ret
=
0
;
...
...
@@ -1779,7 +1709,7 @@ int image_store_set_names(const char *id, const char **names, size_t names_len)
}
if
(
!
image_store_lock
(
EXCLUSIVE
))
{
ERROR
(
"Failed to lock image store with exclusive lock, not allowed to change image name assignments"
);
ERROR
(
"Failed to lock image store with exclusive lock, not allowed to change image name
s
assignments"
);
return
-
1
;
}
...
...
@@ -1914,7 +1844,11 @@ int image_store_set_metadata(const char *id, const char *metadata)
free
(
img
->
simage
->
metadata
);
img
->
simage
->
metadata
=
util_strdup_s
(
metadata
);
save_image
(
img
);
if
(
save_image
(
img
)
!=
0
)
{
ERROR
(
"Failed to save image"
);
ret
=
-
1
;
goto
out
;
}
out:
image_ref_dec
(
img
);
...
...
@@ -2357,7 +2291,11 @@ int image_store_set_image_size(const char *id, uint64_t size)
}
img
->
simage
->
size
=
size
;
save_image
(
img
);
if
(
save_image
(
img
)
!=
0
)
{
ERROR
(
"Failed to save image"
);
ret
=
-
1
;
goto
out
;
}
out:
image_ref_dec
(
img
);
...
...
src/image/oci/storage/rootfs_store/rootfs.c
浏览文件 @
cd503ba4
...
...
@@ -51,7 +51,7 @@ cntrootfs_t *new_rootfs(storage_rootfs *scntr)
return
NULL
;
}
c
->
s
container
=
scntr
;
c
->
s
rootfs
=
scntr
;
return
c
;
...
...
@@ -86,8 +86,8 @@ void free_rootfs_t(cntrootfs_t *ptr)
if
(
ptr
==
NULL
)
{
return
;
}
free_storage_rootfs
(
ptr
->
s
container
);
ptr
->
s
container
=
NULL
;
free_storage_rootfs
(
ptr
->
s
rootfs
);
ptr
->
s
rootfs
=
NULL
;
free
(
ptr
);
}
...
...
src/image/oci/storage/rootfs_store/rootfs.h
浏览文件 @
cd503ba4
...
...
@@ -26,7 +26,7 @@ extern "C" {
#endif
typedef
struct
_cntrootfs_t
{
storage_rootfs
*
s
container
;
storage_rootfs
*
s
rootfs
;
uint64_t
refcnt
;
}
cntrootfs_t
;
...
...
src/image/oci/storage/rootfs_store/rootfs_store.c
浏览文件 @
cd503ba4
此差异已折叠。
点击以展开。
src/image/oci/storage/storage.h
浏览文件 @
cd503ba4
...
...
@@ -20,6 +20,7 @@
#include <stddef.h>
#include "types_def.h"
#include "storage_image.h"
#include "storage_rootfs.h"
#include "imagetool_images_list.h"
#include "imagetool_fs_info.h"
...
...
@@ -46,7 +47,7 @@ struct layer_list {
};
struct
rootfs_list
{
st
ruct
st
orage_rootfs
**
rootfs
;
storage_rootfs
**
rootfs
;
size_t
rootfs_len
;
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录