提交 91f6a548 编写于 作者: L LiFeng 提交者: lifeng68

storage: API add implement add names

Signed-off-by: NLiFeng <lifeng68@huawei.com>
上级 201a7576
...@@ -130,7 +130,7 @@ out: ...@@ -130,7 +130,7 @@ out:
return ret; return ret;
} }
struct layer *storage_layer_get(const char *id) struct layer *storage_layer_get(const char *layer_id)
{ {
// TODO call layer_store functions to get layer info // TODO call layer_store functions to get layer info
return NULL; return NULL;
...@@ -154,7 +154,7 @@ void free_layer(struct layer *ptr) ...@@ -154,7 +154,7 @@ void free_layer(struct layer *ptr)
free(ptr); free(ptr);
} }
int storage_layer_try_repair_lowers(const char *id, const char *last_layer_id) int storage_layer_try_repair_lowers(const char *layer_id, const char *last_layer_id)
{ {
// TODO layer_store_try_repair_lowers // TODO layer_store_try_repair_lowers
int ret = 0; int ret = 0;
...@@ -162,6 +162,35 @@ int storage_layer_try_repair_lowers(const char *id, const char *last_layer_id) ...@@ -162,6 +162,35 @@ int storage_layer_try_repair_lowers(const char *id, const char *last_layer_id)
return ret; return ret;
} }
int storage_layer_set_names(const char *layer_id, const char **names, size_t names_len)
{
int ret = 0;
char **unique_names = NULL;
size_t unique_names_len = 0;
if (layer_id == NULL || names == NULL || names_len == 0) {
ERROR("Invalid arguments");
ret = -1;
goto out;
}
if (util_string_array_unique(names, names_len, &unique_names, &unique_names_len) != 0) {
ERROR("Failed to unique names");
ret = -1;
goto out;
}
if (layer_store_set_names(layer_id, (const char **)unique_names, unique_names_len) != 0) {
ERROR("Failed to set layer %s names", layer_id);
ret = -1;
goto out;
}
out:
return ret;
}
int storage_img_create(const char *id, const char *parent_id, const char *metadata, int storage_img_create(const char *id, const char *parent_id, const char *metadata,
struct storage_img_create_options *opts) struct storage_img_create_options *opts)
{ {
......
...@@ -85,9 +85,11 @@ int storage_img_set_names(const char *img_id, const char **names, size_t names_l ...@@ -85,9 +85,11 @@ int storage_img_set_names(const char *img_id, const char **names, size_t names_l
/* layer operations */ /* layer operations */
int storage_layer_create(const char *layer_id, const char *parent_id, bool writeable, const char *layer_data_path); int storage_layer_create(const char *layer_id, const char *parent_id, bool writeable, const char *layer_data_path);
struct layer *storage_layer_get(const char *id); struct layer *storage_layer_get(const char *layer_id);
int storage_layer_try_repair_lowers(const char *id, const char *last_layer_id); int storage_layer_try_repair_lowers(const char *layer_id, const char *last_layer_id);
int storage_layer_set_names(const char *layer_id, const char **names, size_t names_len);
void free_layer(struct layer *l); void free_layer(struct layer *l);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册