Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
iSulad
提交
2ce23cbd
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,发现更多精彩内容 >>
提交
2ce23cbd
编写于
4月 09, 2020
作者:
W
WangFengTu
提交者:
lifeng68
7月 25, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
register image to store
Signed-off-by:
N
WangFengTu
<
wangfengtu@huawei.com
>
上级
65d17387
变更
9
展开全部
隐藏空白更改
内联
并排
Showing
9 changed file
with
680 addition
and
25 deletion
+680
-25
src/cutils/utils_file.c
src/cutils/utils_file.c
+1
-0
src/cutils/utils_file.h
src/cutils/utils_file.h
+4
-0
src/http/mediatype.h
src/http/mediatype.h
+2
-0
src/image/oci/isula_image_pull.c
src/image/oci/isula_image_pull.c
+1
-0
src/image/oci/registry/registry.c
src/image/oci/registry/registry.c
+580
-22
src/image/oci/registry/registry.h
src/image/oci/registry/registry.h
+1
-0
src/image/oci/registry/registry_type.h
src/image/oci/registry/registry_type.h
+6
-2
src/sha256/sha256.c
src/sha256/sha256.c
+83
-1
src/sha256/sha256.h
src/sha256/sha256.h
+2
-0
未找到文件。
src/cutils/utils_file.c
浏览文件 @
2ce23cbd
...
...
@@ -31,6 +31,7 @@
#include "utils.h"
#include "sha256.h"
#include "path.h"
#include "libtar.h"
bool
util_dir_exists
(
const
char
*
path
)
{
...
...
src/cutils/utils_file.h
浏览文件 @
2ce23cbd
...
...
@@ -59,6 +59,10 @@ char *util_file_digest(const char *filename);
char
*
util_full_file_digest
(
const
char
*
filename
);
int
util_gzip_compressed
(
const
char
*
filename
,
bool
*
gzip
);
char
*
util_full_gzip_digest
(
const
char
*
filename
);
char
*
util_path_dir
(
const
char
*
path
);
char
*
util_add_path
(
const
char
*
path
,
const
char
*
name
);
...
...
src/http/mediatype.h
浏览文件 @
2ce23cbd
...
...
@@ -78,8 +78,10 @@
#define OCI_MANIFEST_V1_JSON "application/vnd.oci.image.manifest.v1+json"
#define OCI_INDEX_V1_JSON "application/vnd.oci.image.index.v1+json"
#define DOCKER_IMAGE_LAYER_TAR_GZIP "application/vnd.docker.image.rootfs.diff.tar.gzip"
#define DOCKER_IMAGE_LAYER_FOREIGN_TAR_GZIP "application/vnd.docker.image.rootfs.foreign.diff.tar.gzip"
#define DOCKER_IMAGE_V1 "application/vnd.docker.container.image.v1+json"
#define OCI_IMAGE_V1 "application/vnd.oci.image.config.v1+json"
#define OCI_IMAGE_LAYER_TAR_GZIP "application/vnd.oci.image.layer.v1.tar+gzip"
#endif
src/image/oci/isula_image_pull.c
浏览文件 @
2ce23cbd
...
...
@@ -39,6 +39,7 @@ int isula_pull_image(const im_pull_request *request, im_pull_response **response
}
options
->
image_name
=
util_strdup_s
(
request
->
image
);
options
->
dest_image_name
=
util_strdup_s
(
request
->
image
);
ret
=
registry_pull
(
options
);
if
(
ret
!=
0
)
{
...
...
src/image/oci/registry/registry.c
浏览文件 @
2ce23cbd
此差异已折叠。
点击以展开。
src/image/oci/registry/registry.h
浏览文件 @
2ce23cbd
...
...
@@ -35,6 +35,7 @@ typedef struct {
registry_options
comm_opt
;
registry_auth
auth
;
char
*
image_name
;
char
*
dest_image_name
;
}
registry_pull_options
;
typedef
struct
{
...
...
src/image/oci/registry/registry_type.h
浏览文件 @
2ce23cbd
...
...
@@ -4,6 +4,8 @@
#include <stdint.h>
#include <time.h>
#include "types_def.h"
// 8 is enough for challenge, usually only one challenge is provided.
#define CHALLENGE_MAX 8
...
...
@@ -29,9 +31,11 @@ typedef struct {
char
*
digest
;
// Downloaded file path
char
*
file
;
types_timestamp_t
create_time
;
}
config_blob
;
typedef
struct
{
bool
empty_layer
;
char
*
media_type
;
// blob size
size_t
size
;
...
...
@@ -44,11 +48,11 @@ typedef struct {
// Downloaded file path
char
*
file
;
// already exist on local store
char
*
already_exist
;
bool
already_exist
;
}
layer_blob
;
typedef
struct
{
char
*
full
_name
;
char
*
dest_image
_name
;
char
*
host
;
char
*
name
;
char
*
tag
;
...
...
src/sha256/sha256.c
浏览文件 @
2ce23cbd
...
...
@@ -55,6 +55,7 @@ static bool stream_check_error(void *stream, bool isgzip)
return
true
;
}
if
(
gzerr
!=
NULL
&&
strcmp
(
gzerr
,
""
)
!=
0
)
{
ERROR
(
"gzread error: %s"
,
gzerr
);
return
true
;
}
return
false
;
...
...
@@ -283,7 +284,7 @@ char *sha256_digest_str(const char *val)
for
(
i
=
0
;
i
<
SHA256_DIGEST_LENGTH
;
i
++
)
{
int
ret
=
snprintf
(
output_buffer
+
(
i
*
2
),
3
,
"%02x"
,
(
unsigned
int
)
hash
[
i
]);
if
(
ret
>=
3
||
ret
<
0
)
{
return
""
;
return
NULL
;
}
}
output_buffer
[
SHA256_DIGEST_LENGTH
*
2
]
=
'\0'
;
...
...
@@ -291,3 +292,84 @@ char *sha256_digest_str(const char *val)
return
util_strdup_s
(
output_buffer
);
}
char
*
sha256_digest_file
(
const
char
*
filename
,
bool
isgzip
)
{
SHA256_CTX
ctx
;
unsigned
char
hash
[
SHA256_DIGEST_LENGTH
]
=
{
0x00
};
char
output_buffer
[(
SHA256_DIGEST_LENGTH
*
2
)
+
1
]
=
{
0x00
};
int
i
=
0
;
char
*
buffer
=
NULL
;
int
n
=
0
;
int
ret
=
0
;
void
*
stream
=
NULL
;
if
(
filename
==
NULL
)
{
ERROR
(
"Invalid NULL pointer"
);
return
NULL
;
}
if
(
isgzip
)
{
stream
=
(
void
*
)
gzopen
(
filename
,
"r"
);
}
else
{
stream
=
(
void
*
)
fopen
(
filename
,
"r"
);
}
if
(
stream
==
NULL
)
{
ERROR
(
"open file %s failed: %s"
,
filename
,
strerror
(
errno
));
return
NULL
;
}
buffer
=
util_common_calloc_s
(
BLKSIZE
);
if
(
buffer
==
NULL
)
{
ERROR
(
"out of memory"
);
return
NULL
;
}
SHA256_Init
(
&
ctx
);
while
(
true
)
{
if
(
isgzip
)
{
n
=
gzread
((
gzFile
)
stream
,
buffer
,
BLKSIZE
);
}
else
{
n
=
fread
(
buffer
,
1
,
BLKSIZE
,
(
FILE
*
)
stream
);
}
if
(
n
<=
0
)
{
if
(
stream_check_error
(
stream
,
isgzip
))
{
ret
=
-
1
;
goto
out
;
}
break
;
}
if
(
n
>
0
)
{
SHA256_Update
(
&
ctx
,
buffer
,
n
);
}
if
(
stream_check_eof
(
stream
,
isgzip
))
{
break
;
}
}
SHA256_Final
(
hash
,
&
ctx
);
for
(
i
=
0
;
i
<
SHA256_DIGEST_LENGTH
;
i
++
)
{
int
sret
=
snprintf
(
output_buffer
+
(
i
*
2
),
3
,
"%02x"
,
(
unsigned
int
)
hash
[
i
]);
if
(
sret
>=
3
||
sret
<
0
)
{
ERROR
(
"snprintf failed when calc sha256 from file %s, result is %s"
,
filename
,
sret
);
return
NULL
;
}
}
output_buffer
[
SHA256_DIGEST_LENGTH
*
2
]
=
'\0'
;
out:
if
(
isgzip
)
{
gzclose
((
gzFile
)
stream
);
}
else
{
fclose
((
FILE
*
)
stream
);
}
if
(
ret
==
0
)
{
return
util_strdup_s
(
output_buffer
);
}
else
{
return
NULL
;
}
}
src/sha256/sha256.h
浏览文件 @
2ce23cbd
...
...
@@ -42,6 +42,8 @@ extern int sha256sum_calculate(void *stream, char *buffer_out, size_t len,
The result is a 64 characters string without prefix "sha256:" */
char
*
sha256_digest
(
void
*
stream
,
bool
isgzip
);
char
*
sha256_digest_file
(
const
char
*
filename
,
bool
isgzip
);
char
*
sha256_digest_str
(
const
char
*
val
);
# ifdef __cplusplus
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录