Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
iSulad
提交
89a3dcbb
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,发现更多精彩内容 >>
提交
89a3dcbb
编写于
4月 03, 2020
作者:
L
LiFeng
提交者:
lifeng68
7月 25, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
storage: add init storage module
Signed-off-by:
N
LiFeng
<
lifeng68@huawei.com
>
上级
d428449b
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
100 addition
and
41 deletion
+100
-41
src/image/oci/storage/image_store/image_store.c
src/image/oci/storage/image_store/image_store.c
+2
-1
src/image/oci/storage/image_store/image_store.h
src/image/oci/storage/image_store/image_store.h
+2
-2
src/image/oci/storage/layer_store/layer_store.c
src/image/oci/storage/layer_store/layer_store.c
+1
-15
src/image/oci/storage/layer_store/layer_store.h
src/image/oci/storage/layer_store/layer_store.h
+2
-21
src/image/oci/storage/storage.c
src/image/oci/storage/storage.c
+64
-0
src/image/oci/storage/storage.h
src/image/oci/storage/storage.h
+29
-2
未找到文件。
src/image/oci/storage/image_store/image_store.c
浏览文件 @
89a3dcbb
...
...
@@ -601,10 +601,11 @@ static int image_store_load(image_store_t *image_store)
return
load_helper
(
image_store
);
}
int
new_image_store
(
const
char
*
dir
)
int
image_store_init
(
struct
storage_module_init_options
*
opts
)
{
int
ret
=
0
;
image_store_t
*
store
=
NULL
;
char
*
dir
=
NULL
;
// todo gipath := filepath.Join(s.graphRoot, driverPrefix+"images")
ret
=
util_mkdir_p
(
dir
,
IMAGE_STORE_PATH_MODE
);
if
(
ret
<
0
)
{
...
...
src/image/oci/storage/image_store/image_store.h
浏览文件 @
89a3dcbb
...
...
@@ -18,7 +18,7 @@
#include <stdbool.h>
#include <string.h>
#include <pthread.h>
#include "storage
_image
.h"
#include "storage.h"
#include "types_def.h"
#include "map.h"
...
...
@@ -27,7 +27,7 @@ extern "C" {
#endif
// Load the image in the dir folder
int
new_image_store
(
const
char
*
dir
);
int
image_store_init
(
struct
storage_module_init_options
*
opts
);
// Create an image that has a specified ID (or a random one) and optional names, using the specified layer as
// its topmost (hopefully read-only) layer. That layer can be referenced by multiple images.
...
...
src/image/oci/storage/layer_store/layer_store.c
浏览文件 @
89a3dcbb
...
...
@@ -56,7 +56,7 @@ static void layer_map_kvfree(void *key, void *value)
layer_ref_dec
((
layer_t
*
)
value
);
}
int
layer_store_init
(
const
struct
layer_store_config
*
conf
)
int
layer_store_init
(
const
struct
storage_module_init_options
*
conf
)
{
int
nret
;
...
...
@@ -176,20 +176,6 @@ void free_layer(struct layer *ptr)
free
(
ptr
);
}
void
free_layer_store_config
(
struct
layer_store_config
*
ptr
)
{
if
(
ptr
==
NULL
)
{
return
;
}
free
(
ptr
->
driver_name
);
ptr
->
driver_name
=
NULL
;
free
(
ptr
->
driver_root
);
ptr
->
driver_root
=
NULL
;
//TODO: free mount options
free
(
ptr
);
}
void
free_layer_opts
(
struct
layer_opts
*
ptr
)
{
if
(
ptr
==
NULL
)
{
...
...
src/image/oci/storage/layer_store/layer_store.h
浏览文件 @
89a3dcbb
...
...
@@ -17,6 +17,7 @@
#include <stdint.h>
#include "storage.h"
#include "console.h"
#ifdef __cplusplus
...
...
@@ -29,25 +30,6 @@ struct layer_store_mount_opts {
size_t
options_len
;
};
struct
layer_store_config
{
/*configs for graph driver */
char
*
driver_name
;
char
*
driver_root
;
struct
layer_store_mount_opts
*
opts
;
};
struct
layer
{
char
*
id
;
char
*
parent
;
char
*
mount_point
;
int
mount_count
;
char
*
compressed_digest
;
int64_t
compress_size
;
char
*
uncompressed_digest
;
int64_t
uncompress_size
;
};
struct
layer_opts
{
char
*
parent
;
char
**
names
;
...
...
@@ -58,7 +40,7 @@ struct layer_opts {
struct
layer_store_mount_opts
*
opts
;
};
int
layer_store_init
(
const
struct
layer_store_config
*
conf
);
int
layer_store_init
(
const
struct
storage_module_init_options
*
conf
);
bool
layer_store_check
(
const
char
*
id
);
int
layer_store_create
(
const
char
*
id
,
const
struct
layer_opts
*
opts
,
const
struct
io_read_wrapper
*
content
,
...
...
@@ -78,7 +60,6 @@ struct graphdriver_status* layer_store_status();
int
layer_store_try_repair_lowers
(
const
char
*
id
);
void
free_layer
(
struct
layer
*
l
);
void
free_layer_store_config
(
struct
layer_store_config
*
conf
);
void
free_layer_opts
(
struct
layer_opts
*
opts
);
#ifdef __cplusplus
...
...
src/image/oci/storage/storage.c
浏览文件 @
89a3dcbb
...
...
@@ -16,9 +16,13 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "console.h"
#include "utils.h"
#include "log.h"
#include "layer_store.h"
#include "image_store.h"
static
ssize_t
layer_archive_io_read
(
void
*
context
,
void
*
buf
,
size_t
buf_len
)
{
...
...
@@ -268,3 +272,63 @@ out:
return
ret
;
}
static
int
check_module_init_opt
(
struct
storage_module_init_options
*
opts
)
{
if
(
opts
==
NULL
||
opts
->
driver_name
==
NULL
||
opts
->
storage_root
==
NULL
||
opts
->
storage_run_root
==
NULL
)
{
ERROR
(
"Invalid input arguments"
);
return
-
1
;
}
return
0
;
}
static
int
make_storage_directory
(
struct
storage_module_init_options
*
opts
)
{
int
ret
=
0
;
if
(
util_mkdir_p
(
opts
->
storage_root
,
IMAGE_STORE_PATH_MODE
)
!=
0
)
{
SYSERROR
(
"Failed to make %s"
,
opts
->
storage_root
);
ret
=
-
1
;
goto
out
;
}
if
(
util_mkdir_p
(
opts
->
storage_run_root
,
IMAGE_STORE_PATH_MODE
)
!=
0
)
{
SYSERROR
(
"Failed to make %s"
,
opts
->
storage_run_root
);
ret
=
-
1
;
goto
out
;
}
out:
return
ret
;
}
int
storage_module_init
(
struct
storage_module_init_options
*
opts
)
{
int
ret
=
0
;
if
(
check_module_init_opt
(
opts
)
!=
0
)
{
ret
=
-
1
;
goto
out
;
}
if
(
make_storage_directory
(
opts
)
!=
0
)
{
ret
=
-
1
;
goto
out
;
}
if
(
layer_store_init
(
opts
)
!=
0
)
{
ERROR
(
"Failed to init layer store"
);
ret
=
-
1
;
goto
out
;
}
if
(
image_store_init
(
opts
)
!=
0
)
{
ERROR
(
"Failed to init image store"
);
ret
=
-
1
;
goto
out
;
}
out:
return
ret
;
}
src/image/oci/storage/storage.h
浏览文件 @
89a3dcbb
...
...
@@ -19,18 +19,45 @@
#include <stdbool.h>
#include <stddef.h>
#include "types_def.h"
#include "layer_store.h"
#include "image_store.h"
#include "storage_image.h"
#ifdef __cplusplus
extern
"C"
{
#endif
struct
layer
{
char
*
id
;
char
*
parent
;
char
*
mount_point
;
int
mount_count
;
char
*
compressed_digest
;
int64_t
compress_size
;
char
*
uncompressed_digest
;
int64_t
uncompress_size
;
};
struct
storage_module_init_options
{
// storage_run_root is the filesystem path under which we can store run-time info
// e.g. /var/run/isulad/storage
char
*
storage_run_root
;
// storage_root is the filesystem path under which we will store the contents of layers, images, and containers
// e.g. /var/lib/isulad/storage
char
*
storage_root
;
char
*
driver_name
;
// driver_opts are driver-specific options.
char
**
driver_opts
;
size_t
driver_opts_len
;
};
struct
storage_img_create_options
{
types_timestamp_t
*
create_time
;
char
*
digest
;
};
int
storage_module_init
(
struct
storage_module_init_options
*
opts
);
int
storage_layer_create
(
const
char
*
layer_id
,
const
char
*
parent_id
,
bool
writeable
,
const
char
*
layer_data_path
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录