1576 lines
58 KiB
Diff
1576 lines
58 KiB
Diff
From c6442b5805d39d8749a1016e2932543a130f16dc Mon Sep 17 00:00:00 2001
|
|
From: zhongtao <zhongtao17@huawei.com>
|
|
Date: Fri, 25 Aug 2023 17:34:12 +0800
|
|
Subject: [PATCH 18/33] make sure the input parameter is not empty and optimize
|
|
the code
|
|
|
|
Signed-off-by: zhongtao <zhongtao17@huawei.com>
|
|
---
|
|
src/daemon/modules/api/image_api.h | 2 +-
|
|
src/daemon/modules/image/external/ext_image.c | 8 ++-
|
|
src/daemon/modules/image/image.c | 47 +++++++++++-----
|
|
src/daemon/modules/image/image_spec_merge.c | 2 +-
|
|
.../modules/image/oci/oci_common_operators.c | 9 ++-
|
|
src/daemon/modules/image/oci/oci_image.c | 8 +--
|
|
src/daemon/modules/image/oci/oci_image.h | 2 +-
|
|
src/daemon/modules/image/oci/oci_image_type.h | 42 --------------
|
|
src/daemon/modules/image/oci/oci_import.c | 1 +
|
|
src/daemon/modules/image/oci/oci_load.c | 10 +---
|
|
src/daemon/modules/image/oci/oci_load.h | 2 +-
|
|
src/daemon/modules/image/oci/oci_login.c | 2 +-
|
|
src/daemon/modules/image/oci/oci_logout.c | 2 +-
|
|
src/daemon/modules/image/oci/oci_pull.c | 4 +-
|
|
.../image/oci/registry/registry_apiv2.c | 2 +-
|
|
.../oci/storage/image_store/image_store.c | 45 ++++++++++++---
|
|
.../oci/storage/image_store/image_store.h | 4 +-
|
|
.../graphdriver/devmapper/deviceset.c | 10 ++--
|
|
.../graphdriver/devmapper/driver_devmapper.c | 4 +-
|
|
.../graphdriver/devmapper/wrapper_devmapper.c | 14 +++--
|
|
.../graphdriver/devmapper/wrapper_devmapper.h | 8 +--
|
|
.../graphdriver/overlay2/driver_overlay2.c | 17 +++---
|
|
.../graphdriver/overlay2/driver_overlay2.h | 2 -
|
|
.../image/oci/storage/layer_store/layer.c | 2 +-
|
|
.../image/oci/storage/layer_store/layer.h | 2 +-
|
|
.../oci/storage/layer_store/layer_store.c | 55 ++++++++-----------
|
|
.../oci/storage/layer_store/layer_store.h | 8 +--
|
|
.../remote_layer_support/image_remote_impl.c | 12 +++-
|
|
.../remote_layer_support/layer_remote_impl.c | 10 ++++
|
|
.../overlay_remote_impl.c | 10 ++++
|
|
.../remote_layer_support/remote_support.c | 5 ++
|
|
.../ro_symlink_maintain.c | 11 +++-
|
|
.../oci/storage/rootfs_store/rootfs_store.c | 8 +--
|
|
.../oci/storage/rootfs_store/rootfs_store.h | 6 +-
|
|
.../modules/image/oci/storage/storage.c | 35 ++++++++++--
|
|
.../modules/image/oci/storage/storage.h | 6 +-
|
|
src/daemon/modules/image/oci/utils_images.c | 7 ++-
|
|
src/daemon/modules/image/oci/utils_images.h | 2 +-
|
|
src/utils/http/http.h | 2 +
|
|
.../oci/storage/layers/storage_driver_ut.cc | 10 +---
|
|
.../oci/storage/layers/storage_layers_ut.cc | 34 ------------
|
|
test/mocks/driver_overlay2_mock.cc | 8 ---
|
|
test/mocks/driver_overlay2_mock.h | 1 -
|
|
43 files changed, 251 insertions(+), 230 deletions(-)
|
|
delete mode 100644 src/daemon/modules/image/oci/oci_image_type.h
|
|
|
|
diff --git a/src/daemon/modules/api/image_api.h b/src/daemon/modules/api/image_api.h
|
|
index 4bb8d1a9..2f2c00a2 100644
|
|
--- a/src/daemon/modules/api/image_api.h
|
|
+++ b/src/daemon/modules/api/image_api.h
|
|
@@ -239,7 +239,7 @@ typedef struct {
|
|
|
|
int image_module_init(const isulad_daemon_configs *args);
|
|
|
|
-void image_module_exit();
|
|
+void image_module_exit(void);
|
|
|
|
int im_get_container_filesystem_usage(const char *image_type, const char *id, imagetool_fs_info **fs_usage);
|
|
|
|
diff --git a/src/daemon/modules/image/external/ext_image.c b/src/daemon/modules/image/external/ext_image.c
|
|
index e1706469..5b6b7298 100644
|
|
--- a/src/daemon/modules/image/external/ext_image.c
|
|
+++ b/src/daemon/modules/image/external/ext_image.c
|
|
@@ -138,13 +138,17 @@ int ext_list_images(const im_list_request *request, imagetool_images_list **list
|
|
{
|
|
int ret = 0;
|
|
|
|
+ if (request == NULL || list == NULL) {
|
|
+ ERROR("Empty request or list");
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
*list = util_common_calloc_s(sizeof(imagetool_images_list));
|
|
if (*list == NULL) {
|
|
ERROR("Memory out");
|
|
ret = -1;
|
|
- goto out;
|
|
}
|
|
-out:
|
|
+
|
|
return ret;
|
|
}
|
|
|
|
diff --git a/src/daemon/modules/image/image.c b/src/daemon/modules/image/image.c
|
|
index 322ab67c..408ceea2 100644
|
|
--- a/src/daemon/modules/image/image.c
|
|
+++ b/src/daemon/modules/image/image.c
|
|
@@ -374,8 +374,8 @@ int im_resolv_image_name(const char *image_type, const char *image_name, char **
|
|
int ret = -1;
|
|
const struct bim_type *q = NULL;
|
|
|
|
- if (image_type == NULL) {
|
|
- ERROR("Image type is required");
|
|
+ if (image_type == NULL || image_name == NULL || resolved_name == NULL) {
|
|
+ ERROR("Image type image_name and resolved_name is required");
|
|
goto out;
|
|
}
|
|
q = get_bim_by_type(image_type);
|
|
@@ -402,8 +402,8 @@ int im_get_filesystem_info(const char *image_type, im_fs_info_response **respons
|
|
int ret = -1;
|
|
const struct bim_type *q = NULL;
|
|
|
|
- if (image_type == NULL) {
|
|
- ERROR("Image type is required");
|
|
+ if (image_type == NULL || response == NULL) {
|
|
+ ERROR("Image type and response is required");
|
|
goto out;
|
|
}
|
|
|
|
@@ -419,7 +419,7 @@ int im_get_filesystem_info(const char *image_type, im_fs_info_response **respons
|
|
INFO("Event: {Object: get image filesystem info, Type: inspecting}");
|
|
ret = q->ops->get_filesystem_info(response);
|
|
if (ret != 0) {
|
|
- if (response != NULL && *response != NULL) {
|
|
+ if (*response != NULL && (*response)->errmsg != NULL) {
|
|
ERROR("Get filesystem info failed: %s", (*response)->errmsg);
|
|
} else {
|
|
ERROR("Get filesystem info failed");
|
|
@@ -439,7 +439,7 @@ int im_get_container_filesystem_usage(const char *image_type, const char *id, im
|
|
const struct bim_type *q = NULL;
|
|
im_container_fs_usage_request *request = NULL;
|
|
|
|
- if (image_type == NULL || id == NULL) {
|
|
+ if (image_type == NULL || id == NULL || fs_usage == NULL) {
|
|
ERROR("Invalid input arguments");
|
|
ret = -1;
|
|
goto out;
|
|
@@ -763,6 +763,12 @@ bool im_config_image_exist(const char *image_name)
|
|
{
|
|
const struct bim_type *bim_type = NULL;
|
|
|
|
+ if (image_name == NULL) {
|
|
+ ERROR("Invalid input arguments");
|
|
+ isulad_set_error_message("Invalid input arguments");
|
|
+ return false;
|
|
+ }
|
|
+
|
|
bim_type = bim_query(image_name);
|
|
if (bim_type == NULL) {
|
|
ERROR("Config image %s not exist", image_name);
|
|
@@ -778,7 +784,7 @@ int im_merge_image_config(const char *image_type, const char *image_name, contai
|
|
int ret = 0;
|
|
struct bim *bim = NULL;
|
|
|
|
- if (container_spec == NULL || image_type == NULL) {
|
|
+ if (container_spec == NULL || image_name == NULL || image_type == NULL) {
|
|
ERROR("Invalid input arguments");
|
|
ret = -1;
|
|
goto out;
|
|
@@ -905,7 +911,7 @@ int im_list_images(const im_list_request *ctx, im_list_response **response)
|
|
size_t i;
|
|
imagetool_images_list *images_tmp = NULL;
|
|
|
|
- if (response == NULL) {
|
|
+ if (ctx == NULL || response == NULL) {
|
|
ERROR("Empty arguments");
|
|
return -1;
|
|
}
|
|
@@ -982,6 +988,12 @@ static bool check_im_pull_args(const im_pull_request *req, im_pull_response * co
|
|
isulad_set_error_message("Empty image required");
|
|
return false;
|
|
}
|
|
+
|
|
+ if (req->type == NULL) {
|
|
+ ERROR("Empty type required");
|
|
+ isulad_set_error_message("Empty type required");
|
|
+ return false;
|
|
+ }
|
|
return true;
|
|
}
|
|
|
|
@@ -1079,7 +1091,7 @@ int im_import_image(const im_import_request *request, char **id)
|
|
return -1;
|
|
}
|
|
|
|
- if (request->file == NULL) {
|
|
+ if (request->file == NULL || request->tag == NULL) {
|
|
ERROR("Import image requires image tarball file path");
|
|
isulad_set_error_message("Import image requires image tarball file path");
|
|
goto pack_response;
|
|
@@ -1185,7 +1197,8 @@ int im_load_image(const im_load_request *request, im_load_response **response)
|
|
|
|
ret = bim->ops->load_image(request);
|
|
if (ret != 0) {
|
|
- ERROR("Failed to load image from %s with tag %s and type %s", request->file, request->tag, request->type);
|
|
+ // request->tag may be empty
|
|
+ ERROR("Failed to load image from %s with type %s", request->file, request->type);
|
|
ret = -1;
|
|
goto pack_response;
|
|
}
|
|
@@ -1368,11 +1381,16 @@ int im_logout(const im_logout_request *request, im_logout_response **response)
|
|
int ret = -1;
|
|
struct bim *bim = NULL;
|
|
|
|
- if (response == NULL) {
|
|
+ if (request == NULL || response == NULL) {
|
|
ERROR("Empty response");
|
|
return -1;
|
|
}
|
|
|
|
+ if (request->type == NULL || request->server == NULL) {
|
|
+ ERROR("Empty type or server");
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
*response = util_common_calloc_s(sizeof(im_logout_response));
|
|
if (*response == NULL) {
|
|
ERROR("Out of memory");
|
|
@@ -1842,13 +1860,12 @@ char *im_get_rootfs_dir(const im_get_rf_dir_request *request)
|
|
char *dir = NULL;
|
|
struct bim *bim = NULL;
|
|
|
|
- if (request->type == NULL) {
|
|
+ if (request == NULL || request->type == NULL) {
|
|
ERROR("Missing image type");
|
|
return NULL;
|
|
}
|
|
|
|
bim = bim_get(request->type, NULL, NULL, NULL);
|
|
-
|
|
if (bim == NULL) {
|
|
ERROR("Failed to init bim, image type:%s", request->type);
|
|
return NULL;
|
|
@@ -1916,7 +1933,7 @@ int image_module_init(const isulad_daemon_configs *args)
|
|
return bims_init(args);
|
|
}
|
|
|
|
-void image_module_exit()
|
|
+void image_module_exit(void)
|
|
{
|
|
size_t i;
|
|
|
|
@@ -2085,7 +2102,7 @@ int im_prepare_container_rootfs(const im_prepare_request *request, char **real_r
|
|
int nret = 0;
|
|
struct bim *bim = NULL;
|
|
|
|
- if (request == NULL) {
|
|
+ if (request == NULL || real_rootfs == NULL) {
|
|
ERROR("Invalid input arguments");
|
|
return -1;
|
|
}
|
|
diff --git a/src/daemon/modules/image/image_spec_merge.c b/src/daemon/modules/image/image_spec_merge.c
|
|
index e8cdae28..1e857bb7 100644
|
|
--- a/src/daemon/modules/image/image_spec_merge.c
|
|
+++ b/src/daemon/modules/image/image_spec_merge.c
|
|
@@ -29,7 +29,7 @@ int image_spec_merge_env(const char **env, size_t env_len, container_config *con
|
|
char **im_kv = NULL;
|
|
char **custom_kv = NULL;
|
|
|
|
- if (env == NULL || env_len == 0) {
|
|
+ if (env == NULL || env_len == 0 || container_spec == NULL) {
|
|
return 0;
|
|
}
|
|
|
|
diff --git a/src/daemon/modules/image/oci/oci_common_operators.c b/src/daemon/modules/image/oci/oci_common_operators.c
|
|
index 83cccbe6..e15423e6 100644
|
|
--- a/src/daemon/modules/image/oci/oci_common_operators.c
|
|
+++ b/src/daemon/modules/image/oci/oci_common_operators.c
|
|
@@ -57,7 +57,7 @@ char *oci_resolve_image_name(const char *name)
|
|
|
|
int oci_get_user_conf(const char *basefs, host_config *hc, const char *userstr, defs_process_user *puser)
|
|
{
|
|
- if (basefs == NULL || puser == NULL) {
|
|
+ if (basefs == NULL || puser == NULL || hc == NULL) {
|
|
ERROR("Empty basefs or puser");
|
|
return -1;
|
|
}
|
|
@@ -371,6 +371,11 @@ int oci_list_images(const im_list_request *request, imagetool_images_list **imag
|
|
int ret = 0;
|
|
struct filters_args *image_filters = NULL;
|
|
|
|
+ if (request == NULL || images == NULL) {
|
|
+ ERROR("Empty request or images");
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
if (request != NULL && request->image_filters != NULL) {
|
|
image_filters = request->image_filters;
|
|
}
|
|
@@ -408,7 +413,7 @@ int oci_summary_image(im_summary_request *request, im_summary_response *response
|
|
char *image_ref = NULL;
|
|
char *resolved_name = NULL;
|
|
|
|
- if (response == NULL) {
|
|
+ if (request == NULL || response == NULL) {
|
|
ERROR("Invalid arguments");
|
|
return -1;
|
|
}
|
|
diff --git a/src/daemon/modules/image/oci/oci_image.c b/src/daemon/modules/image/oci/oci_image.c
|
|
index 4a48016b..f712a446 100644
|
|
--- a/src/daemon/modules/image/oci/oci_image.c
|
|
+++ b/src/daemon/modules/image/oci/oci_image.c
|
|
@@ -353,7 +353,7 @@ out:
|
|
return ret;
|
|
}
|
|
|
|
-void oci_exit()
|
|
+void oci_exit(void)
|
|
{
|
|
storage_module_exit();
|
|
free_oci_image_data();
|
|
@@ -396,7 +396,7 @@ int oci_prepare_rf(const im_prepare_request *request, char **real_rootfs)
|
|
{
|
|
int ret = 0;
|
|
|
|
- if (request == NULL) {
|
|
+ if (request == NULL || request->container_id == NULL) {
|
|
ERROR("Bim is NULL");
|
|
return -1;
|
|
}
|
|
@@ -457,7 +457,7 @@ int oci_mount_rf(const im_mount_request *request)
|
|
{
|
|
char *mount_point = NULL;
|
|
|
|
- if (request == NULL) {
|
|
+ if (request == NULL || request->name_id == NULL) {
|
|
ERROR("Invalid arguments");
|
|
return -1;
|
|
}
|
|
@@ -796,7 +796,7 @@ int oci_export_rf(const im_export_request *request)
|
|
{
|
|
int ret = 0;
|
|
|
|
- if (request == NULL) {
|
|
+ if (request == NULL || request->name_id == NULL) {
|
|
ERROR("Invalid input arguments");
|
|
return -1;
|
|
}
|
|
diff --git a/src/daemon/modules/image/oci/oci_image.h b/src/daemon/modules/image/oci/oci_image.h
|
|
index c52c8a7b..07f10c8d 100644
|
|
--- a/src/daemon/modules/image/oci/oci_image.h
|
|
+++ b/src/daemon/modules/image/oci/oci_image.h
|
|
@@ -41,7 +41,7 @@ struct oci_image_module_data {
|
|
struct oci_image_module_data *get_oci_image_data(void);
|
|
|
|
int oci_init(const isulad_daemon_configs *args);
|
|
-void oci_exit();
|
|
+void oci_exit(void);
|
|
|
|
int oci_pull_rf(const im_pull_request *request, im_pull_response *response);
|
|
int oci_rmi(const im_rmi_request *request);
|
|
diff --git a/src/daemon/modules/image/oci/oci_image_type.h b/src/daemon/modules/image/oci/oci_image_type.h
|
|
deleted file mode 100644
|
|
index f436a453..00000000
|
|
--- a/src/daemon/modules/image/oci/oci_image_type.h
|
|
+++ /dev/null
|
|
@@ -1,42 +0,0 @@
|
|
-/******************************************************************************
|
|
- * Copyright (c) Huawei Technologies Co., Ltd. 2018-2019. All rights reserved.
|
|
- * iSulad licensed under the Mulan PSL v2.
|
|
- * You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
- * You may obtain a copy of Mulan PSL v2 at:
|
|
- * http://license.coscl.org.cn/MulanPSL2
|
|
- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
|
- * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
|
- * PURPOSE.
|
|
- * See the Mulan PSL v2 for more details.
|
|
- * Author: lifeng
|
|
- * Create: 2018-11-08
|
|
- * Description: provide image type definition
|
|
- ******************************************************************************/
|
|
-
|
|
-#ifndef DAEMON_MODULES_IMAGE_OCI_OCI_IMAGE_TYPE_H
|
|
-#define DAEMON_MODULES_IMAGE_OCI_OCI_IMAGE_TYPE_H
|
|
-
|
|
-#ifdef __cplusplus
|
|
-extern "C" {
|
|
-#endif
|
|
-
|
|
-/* AuthConfig contains authorization information for connecting to a registry */
|
|
-typedef struct {
|
|
- char *username;
|
|
- char *password;
|
|
- char *auth;
|
|
- char *server_address;
|
|
-
|
|
- // IdentityToken is used to authenticate the user and get
|
|
- // an access token for the registry.
|
|
- char *identity_token;
|
|
-
|
|
- // RegistryToken is a bearer token to be sent to a registry
|
|
- char *registry_token;
|
|
-} auth_config;
|
|
-
|
|
-#ifdef __cplusplus
|
|
-}
|
|
-#endif
|
|
-
|
|
-#endif
|
|
diff --git a/src/daemon/modules/image/oci/oci_import.c b/src/daemon/modules/image/oci/oci_import.c
|
|
index 93179504..1e14a916 100644
|
|
--- a/src/daemon/modules/image/oci/oci_import.c
|
|
+++ b/src/daemon/modules/image/oci/oci_import.c
|
|
@@ -268,6 +268,7 @@ static int create_manifest(import_desc *desc)
|
|
manifest->layers[0]->size = desc->compressed_size;
|
|
manifest->layers[0]->digest = util_strdup_s(desc->compressed_digest);
|
|
|
|
+ // the image manifest schema version is v2
|
|
manifest->schema_version = 2;
|
|
manifest->media_type = util_strdup_s(DOCKER_MANIFEST_SCHEMA2_JSON);
|
|
|
|
diff --git a/src/daemon/modules/image/oci/oci_load.c b/src/daemon/modules/image/oci/oci_load.c
|
|
index 5e062d44..569c5346 100644
|
|
--- a/src/daemon/modules/image/oci/oci_load.c
|
|
+++ b/src/daemon/modules/image/oci/oci_load.c
|
|
@@ -851,20 +851,17 @@ static int64_t get_layer_size_from_storage(char *chain_id_pre)
|
|
id = oci_load_without_sha256_prefix(chain_id_pre);
|
|
if (id == NULL) {
|
|
ERROR("Get chain id failed from value:%s", chain_id_pre);
|
|
- size = -1;
|
|
- goto out;
|
|
+ return -1;
|
|
}
|
|
|
|
l = storage_layer_get(id);
|
|
if (l == NULL) {
|
|
ERROR("Layer with chain id:%s is not exist in store", id);
|
|
- size = -1;
|
|
- goto out;
|
|
+ return -1;
|
|
}
|
|
|
|
size = l->compress_size;
|
|
|
|
-out:
|
|
free_layer(l);
|
|
return size;
|
|
}
|
|
@@ -883,8 +880,7 @@ static int oci_load_set_manifest_info(load_image_t *im)
|
|
im->manifest = util_common_calloc_s(sizeof(oci_image_manifest));
|
|
if (im->manifest == NULL) {
|
|
ERROR("Out of memory");
|
|
- ret = -1;
|
|
- goto out;
|
|
+ return -1;
|
|
}
|
|
|
|
im->manifest->schema_version = OCI_SCHEMA_VERSION;
|
|
diff --git a/src/daemon/modules/image/oci/oci_load.h b/src/daemon/modules/image/oci/oci_load.h
|
|
index e1e09067..53ca87d2 100644
|
|
--- a/src/daemon/modules/image/oci/oci_load.h
|
|
+++ b/src/daemon/modules/image/oci/oci_load.h
|
|
@@ -1,5 +1,5 @@
|
|
/******************************************************************************
|
|
-* Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
|
|
+* Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
|
|
* iSulad licensed under the Mulan PSL v2.
|
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
* You may obtain a copy of Mulan PSL v2 at:
|
|
diff --git a/src/daemon/modules/image/oci/oci_login.c b/src/daemon/modules/image/oci/oci_login.c
|
|
index 22de9593..e9eec378 100644
|
|
--- a/src/daemon/modules/image/oci/oci_login.c
|
|
+++ b/src/daemon/modules/image/oci/oci_login.c
|
|
@@ -1,5 +1,5 @@
|
|
/******************************************************************************
|
|
-* Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
|
|
+* Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
|
|
* iSulad licensed under the Mulan PSL v2.
|
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
* You may obtain a copy of Mulan PSL v2 at:
|
|
diff --git a/src/daemon/modules/image/oci/oci_logout.c b/src/daemon/modules/image/oci/oci_logout.c
|
|
index 02fdb126..f8a63220 100644
|
|
--- a/src/daemon/modules/image/oci/oci_logout.c
|
|
+++ b/src/daemon/modules/image/oci/oci_logout.c
|
|
@@ -1,5 +1,5 @@
|
|
/******************************************************************************
|
|
-* Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
|
|
+* Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
|
|
* iSulad licensed under the Mulan PSL v2.
|
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
* You may obtain a copy of Mulan PSL v2 at:
|
|
diff --git a/src/daemon/modules/image/oci/oci_pull.c b/src/daemon/modules/image/oci/oci_pull.c
|
|
index 5b35ca2b..e7ff77df 100644
|
|
--- a/src/daemon/modules/image/oci/oci_pull.c
|
|
+++ b/src/daemon/modules/image/oci/oci_pull.c
|
|
@@ -1,5 +1,5 @@
|
|
/******************************************************************************
|
|
-* Copyright (c) Huawei Technologies Co., Ltd. 2019. All rights reserved.
|
|
+* Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
|
|
* iSulad licensed under the Mulan PSL v2.
|
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
* You may obtain a copy of Mulan PSL v2 at:
|
|
@@ -70,7 +70,7 @@ out:
|
|
return ret;
|
|
}
|
|
|
|
-static void update_option_insecure_registry(registry_pull_options *options, char **insecure_registries, char *host)
|
|
+static void update_option_insecure_registry(registry_pull_options *options, char **insecure_registries, const char *host)
|
|
{
|
|
char **registry = NULL;
|
|
|
|
diff --git a/src/daemon/modules/image/oci/registry/registry_apiv2.c b/src/daemon/modules/image/oci/registry/registry_apiv2.c
|
|
index 048fac94..db4d311e 100644
|
|
--- a/src/daemon/modules/image/oci/registry/registry_apiv2.c
|
|
+++ b/src/daemon/modules/image/oci/registry/registry_apiv2.c
|
|
@@ -632,7 +632,7 @@ static int split_head_body(char *file, char **http_head)
|
|
}
|
|
body += strlen(deli);
|
|
|
|
- ret = util_write_file(file, body, strlen(body), 0600);
|
|
+ ret = util_write_file(file, body, strlen(body), BODY_FILE_MODE);
|
|
if (ret != 0) {
|
|
ERROR("rewrite body to file failed");
|
|
ret = -1;
|
|
diff --git a/src/daemon/modules/image/oci/storage/image_store/image_store.c b/src/daemon/modules/image/oci/storage/image_store/image_store.c
|
|
index 55e3bb97..b7e0f0cc 100644
|
|
--- a/src/daemon/modules/image/oci/storage/image_store/image_store.c
|
|
+++ b/src/daemon/modules/image/oci/storage/image_store/image_store.c
|
|
@@ -146,7 +146,7 @@ static void free_image_store(image_store_t *store)
|
|
free(store);
|
|
}
|
|
|
|
-void image_store_free()
|
|
+void image_store_free(void)
|
|
{
|
|
free_image_store(g_image_store);
|
|
g_image_store = NULL;
|
|
@@ -1185,6 +1185,11 @@ int image_store_set_big_data(const char *id, const char *key, const char *data)
|
|
return -1;
|
|
}
|
|
|
|
+ if (id == NULL || data == NULL) {
|
|
+ ERROR("Empty id or data");
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
if (g_image_store == NULL) {
|
|
ERROR("Image store is not ready");
|
|
return -1;
|
|
@@ -1287,7 +1292,7 @@ int image_store_add_name(const char *id, const char *name)
|
|
size_t i;
|
|
|
|
if (id == NULL || name == NULL) {
|
|
- ERROR("Invalid input paratemer: id(%s), name(%s)", id, name);
|
|
+ ERROR("Invalid input paratemer");
|
|
return -1;
|
|
}
|
|
|
|
@@ -1515,7 +1520,7 @@ int image_store_set_metadata(const char *id, const char *metadata)
|
|
image_t *img = NULL;
|
|
|
|
if (id == NULL || metadata == NULL) {
|
|
- ERROR("Invalid paratemer: id(%s), metadata(%s)", id, metadata);
|
|
+ ERROR("Invalid paratemer");
|
|
return -1;
|
|
}
|
|
|
|
@@ -1664,7 +1669,6 @@ char *image_store_big_data(const char *id, const char *key)
|
|
}
|
|
|
|
ret = get_data_path(img->simage->id, key, filename, sizeof(filename));
|
|
-
|
|
if (ret != 0) {
|
|
ERROR("Failed to get big data file path: %s.", key);
|
|
goto out;
|
|
@@ -1809,7 +1813,7 @@ char *image_store_big_data_digest(const char *id, const char *key)
|
|
image_t *img = NULL;
|
|
char *digest = NULL;
|
|
|
|
- if (key == NULL || strlen(key) == 0) {
|
|
+ if (key == NULL || strlen(key) == 0 || id == NULL) {
|
|
ERROR("Not a valid name for a big data item, can't retrieve image big data value for empty name");
|
|
return NULL;
|
|
}
|
|
@@ -1854,8 +1858,8 @@ int image_store_big_data_names(const char *id, char ***names, size_t *names_len)
|
|
int ret = 0;
|
|
image_t *img = NULL;
|
|
|
|
- if (id == NULL) {
|
|
- ERROR("Invalid parameter, id is NULL");
|
|
+ if (id == NULL || names == NULL || names_len == NULL) {
|
|
+ ERROR("Invalid parameter");
|
|
return -1;
|
|
}
|
|
|
|
@@ -2724,7 +2728,7 @@ unlock:
|
|
return ret;
|
|
}
|
|
|
|
-size_t image_store_get_images_number()
|
|
+size_t image_store_get_images_number(void)
|
|
{
|
|
size_t number = 0;
|
|
|
|
@@ -3140,6 +3144,11 @@ int image_store_validate_manifest_schema_version_1(const char *path, bool *valid
|
|
char manifest_path[PATH_MAX] = { 0x00 };
|
|
bool valid_v2_config = false;
|
|
|
|
+ if (path == NULL || valid == NULL) {
|
|
+ ERROR("Empty path or valid");
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
*valid = false;
|
|
nret = snprintf(manifest_path, sizeof(manifest_path), "%s/%s", path, IMAGE_DIGEST_BIG_DATA_KEY);
|
|
if (nret < 0 || (size_t)nret >= sizeof(manifest_path)) {
|
|
@@ -3698,6 +3707,11 @@ int remote_append_image_by_directory_with_lock(const char *id)
|
|
return -1;
|
|
}
|
|
|
|
+ if (g_image_store == NULL) {
|
|
+ ERROR("Image store is not ready");
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
if (!image_store_lock(EXCLUSIVE)) {
|
|
ERROR("Failed to lock remote image store when handle: %s", id);
|
|
return -1;
|
|
@@ -3732,6 +3746,11 @@ int remote_remove_image_from_memory_with_lock(const char *id)
|
|
return -1;
|
|
}
|
|
|
|
+ if (g_image_store == NULL) {
|
|
+ ERROR("Image store is not ready");
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
if (!image_store_lock(EXCLUSIVE)) {
|
|
ERROR("Failed to lock remote image store when handle: %s", id);
|
|
return -1;
|
|
@@ -3758,6 +3777,16 @@ char *remote_image_get_top_layer_from_json(const char *img_id)
|
|
storage_image *im = NULL;
|
|
parser_error err = NULL;
|
|
|
|
+ if (img_id == NULL) {
|
|
+ ERROR("Empty img id");
|
|
+ return NULL;
|
|
+ }
|
|
+
|
|
+ if (g_image_store == NULL) {
|
|
+ ERROR("Image store is not ready");
|
|
+ return NULL;
|
|
+ }
|
|
+
|
|
nret = snprintf(image_path, sizeof(image_path), "%s/%s/%s", g_image_store->dir, img_id, IMAGE_JSON);
|
|
if (nret < 0 || (size_t)nret >= sizeof(image_path)) {
|
|
ERROR("Failed to get image path");
|
|
diff --git a/src/daemon/modules/image/oci/storage/image_store/image_store.h b/src/daemon/modules/image/oci/storage/image_store/image_store.h
|
|
index 5164cc73..019a2881 100644
|
|
--- a/src/daemon/modules/image/oci/storage/image_store/image_store.h
|
|
+++ b/src/daemon/modules/image/oci/storage/image_store/image_store.h
|
|
@@ -98,13 +98,13 @@ int image_store_set_image_size(const char *id, uint64_t size);
|
|
int image_store_get_all_images(imagetool_images_list *images_list);
|
|
|
|
// On success, the number of the known images is returned. On failure, (size_t)-1 is returned
|
|
-size_t image_store_get_images_number();
|
|
+size_t image_store_get_images_number(void);
|
|
|
|
// Retrieves image file system info
|
|
int image_store_get_fs_info(imagetool_fs_info *fs_info);
|
|
|
|
// Free memory of image store, but will not delete the persisted files
|
|
-void image_store_free();
|
|
+void image_store_free(void);
|
|
|
|
imagetool_image_summary *image_store_get_image_summary(const char *id);
|
|
|
|
diff --git a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/deviceset.c b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/deviceset.c
|
|
index 4f19c26d..79541e54 100644
|
|
--- a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/deviceset.c
|
|
+++ b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/deviceset.c
|
|
@@ -499,14 +499,14 @@ bool has_metadata(const char *hash, struct device_set *devset)
|
|
bool ret = true;
|
|
int nret = 0;
|
|
|
|
- if (hash == NULL) {
|
|
+ if (hash == NULL || devset == NULL) {
|
|
return true;
|
|
}
|
|
|
|
metadata_path = metadata_dir(devset);
|
|
if (metadata_path == NULL) {
|
|
ERROR("Failed to get meta data directory");
|
|
- goto out;
|
|
+ return false;
|
|
}
|
|
|
|
nret = snprintf(metadata_file, sizeof(metadata_file), "%s/%s", metadata_path, util_valid_str(hash) ? hash : "base");
|
|
@@ -541,7 +541,7 @@ static image_devmapper_device_info *load_metadata(const struct device_set *devse
|
|
metadata_path = metadata_dir(devset);
|
|
if (metadata_path == NULL) {
|
|
ERROR("Failed to get meta data directory");
|
|
- goto out;
|
|
+ return NULL;
|
|
}
|
|
|
|
nret = snprintf(metadata_file, sizeof(metadata_file), "%s/%s", metadata_path, util_valid_str(hash) ? hash : "base");
|
|
@@ -3076,7 +3076,7 @@ int mount_device(const char *hash, const char *path, const struct driver_mount_o
|
|
char *dev_fname = NULL;
|
|
char *options = NULL;
|
|
|
|
- if (hash == NULL || path == NULL) {
|
|
+ if (hash == NULL || path == NULL || devset == NULL) {
|
|
ERROR("devmapper: invalid input params to mount device");
|
|
return -1;
|
|
}
|
|
@@ -3236,7 +3236,7 @@ int export_device_metadata(struct device_metadata *dev_metadata, const char *has
|
|
char *dm_name = NULL;
|
|
devmapper_device_info_t *device_info = NULL;
|
|
|
|
- if (hash == NULL || dev_metadata == NULL) {
|
|
+ if (hash == NULL || dev_metadata == NULL || devset == NULL) {
|
|
ERROR("Invalid input params");
|
|
return -1;
|
|
}
|
|
diff --git a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/driver_devmapper.c b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/driver_devmapper.c
|
|
index ecb62f79..d62d3133 100644
|
|
--- a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/driver_devmapper.c
|
|
+++ b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/driver_devmapper.c
|
|
@@ -198,7 +198,7 @@ int devmapper_rm_layer(const char *id, const struct graphdriver *driver)
|
|
}
|
|
|
|
if (delete_device(id, false, driver->devset) != 0) {
|
|
- ERROR("failed to remove device %s", id);
|
|
+ ERROR("Failed to remove device %s", id);
|
|
return -1;
|
|
}
|
|
|
|
@@ -624,7 +624,7 @@ int devmapper_clean_up(struct graphdriver *driver)
|
|
{
|
|
int ret = 0;
|
|
|
|
- if (driver == NULL) {
|
|
+ if (driver == NULL || driver->devset == NULL || driver->home == NULL) {
|
|
ERROR("Invalid input param to cleanup devicemapper");
|
|
return -1;
|
|
}
|
|
diff --git a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/wrapper_devmapper.c b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/wrapper_devmapper.c
|
|
index e91ddd1e..e22311f1 100644
|
|
--- a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/wrapper_devmapper.c
|
|
+++ b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/wrapper_devmapper.c
|
|
@@ -192,7 +192,7 @@ cleanup:
|
|
return NULL;
|
|
}
|
|
|
|
-char *dev_get_driver_version()
|
|
+char *dev_get_driver_version(void)
|
|
{
|
|
struct dm_task *dmt = NULL;
|
|
char *version = NULL;
|
|
@@ -234,7 +234,7 @@ cleanup:
|
|
}
|
|
|
|
// dev_get_library_version return the device mapper library version
|
|
-char *dev_get_library_version()
|
|
+char *dev_get_library_version(void)
|
|
{
|
|
char version[128] = { 0 };
|
|
|
|
@@ -679,7 +679,7 @@ cleanup:
|
|
return ret;
|
|
}
|
|
|
|
-bool udev_sync_supported()
|
|
+bool udev_sync_supported(void)
|
|
{
|
|
return dm_udev_get_sync_support() != 0;
|
|
}
|
|
@@ -705,7 +705,8 @@ int dev_create_device(const char *pool_fname, int device_id)
|
|
int ret = 0;
|
|
int nret = 0;
|
|
uint64_t sector = 0;
|
|
- char message[PATH_MAX] = { 0 }; // 临时字符缓冲区上限
|
|
+ // temporary character buffer limit
|
|
+ char message[PATH_MAX] = { 0 };
|
|
struct dm_task *dmt = NULL;
|
|
|
|
if (pool_fname == NULL) {
|
|
@@ -1066,7 +1067,7 @@ static void log_cb(int level, const char *file, int line, int dm_errno_or_class,
|
|
free(buffer);
|
|
}
|
|
|
|
-void log_with_errno_init()
|
|
+void log_with_errno_init(void)
|
|
{
|
|
dm_log_with_errno_init(log_cb);
|
|
}
|
|
@@ -1136,7 +1137,8 @@ int dev_set_transaction_id(const char *pool_name, uint64_t old_id, uint64_t new_
|
|
int ret = 0;
|
|
int nret = 0;
|
|
uint64_t sector = 0;
|
|
- char message[PATH_MAX] = { 0 }; // 临时字符缓冲区上限
|
|
+ // temporary character buffer limit
|
|
+ char message[PATH_MAX] = { 0 };
|
|
struct dm_task *dmt = NULL;
|
|
|
|
if (pool_name == NULL) {
|
|
diff --git a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/wrapper_devmapper.h b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/wrapper_devmapper.h
|
|
index e8acebc0..01771a3b 100644
|
|
--- a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/wrapper_devmapper.h
|
|
+++ b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/wrapper_devmapper.h
|
|
@@ -96,11 +96,11 @@ int set_dev_dir(const char *dir);
|
|
|
|
struct dm_task* task_create_named(int type, const char *name);
|
|
|
|
-void log_with_errno_init();
|
|
+void log_with_errno_init(void);
|
|
|
|
-char *dev_get_driver_version();
|
|
+char *dev_get_driver_version(void);
|
|
|
|
-char *dev_get_library_version();
|
|
+char *dev_get_library_version(void);
|
|
|
|
int dev_get_status(uint64_t *start, uint64_t *length, char **target_type, char **params, const char *name);
|
|
|
|
@@ -112,7 +112,7 @@ int dev_remove_device_deferred(const char *name);
|
|
|
|
int dev_get_device_list(char ***list, size_t *length);
|
|
|
|
-bool udev_sync_supported();
|
|
+bool udev_sync_supported(void);
|
|
|
|
bool udev_set_sync_support(bool enable);
|
|
|
|
diff --git a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/overlay2/driver_overlay2.c b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/overlay2/driver_overlay2.c
|
|
index 3b27076c..ced30b96 100644
|
|
--- a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/overlay2/driver_overlay2.c
|
|
+++ b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/overlay2/driver_overlay2.c
|
|
@@ -405,12 +405,6 @@ out:
|
|
return ret;
|
|
}
|
|
|
|
-bool overlay2_is_quota_options(struct graphdriver *driver, const char *option)
|
|
-{
|
|
- return strncmp(option, QUOTA_SIZE_OPTION, strlen(QUOTA_SIZE_OPTION)) == 0 ||
|
|
- strncmp(option, QUOTA_BASESIZE_OPTIONS, strlen(QUOTA_BASESIZE_OPTIONS)) == 0;
|
|
-}
|
|
-
|
|
static int check_parent_valid(const char *parent, const struct graphdriver *driver)
|
|
{
|
|
int ret = 0;
|
|
@@ -1158,7 +1152,7 @@ int overlay2_rm_layer(const char *id, const struct graphdriver *driver)
|
|
struct stat stat_buf;
|
|
#endif
|
|
|
|
- if (id == NULL || driver == NULL) {
|
|
+ if (id == NULL || driver == NULL || driver->home == NULL) {
|
|
ERROR("Invalid input arguments");
|
|
return -1;
|
|
}
|
|
@@ -1844,6 +1838,11 @@ bool overlay2_layer_exists(const char *id, const struct graphdriver *driver)
|
|
char *layer_dir = NULL;
|
|
char *link_id = NULL;
|
|
|
|
+ if (id == NULL || driver == NULL || driver->home == NULL) {
|
|
+ ERROR("Failed to verify overlay2 layer exists for empty id or driver");
|
|
+ return false;
|
|
+ }
|
|
+
|
|
layer_dir = util_path_join(driver->home, id);
|
|
if (layer_dir == NULL) {
|
|
ERROR("Failed to join layer dir:%s", id);
|
|
@@ -2075,7 +2074,7 @@ int overlay2_get_driver_status(const struct graphdriver *driver, struct graphdri
|
|
int nret = 0;
|
|
char tmp[MAX_INFO_LENGTH] = { 0 };
|
|
|
|
- if (driver == NULL || status == NULL) {
|
|
+ if (driver == NULL || status == NULL || driver->backing_fs == NULL) {
|
|
ERROR("Invalid input arguments");
|
|
return -1;
|
|
}
|
|
@@ -2117,7 +2116,7 @@ int overlay2_clean_up(struct graphdriver *driver)
|
|
{
|
|
int ret = 0;
|
|
|
|
- if (driver == NULL) {
|
|
+ if (driver == NULL || driver->home == NULL) {
|
|
ERROR("Invalid input arguments");
|
|
ret = -1;
|
|
goto out;
|
|
diff --git a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/overlay2/driver_overlay2.h b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/overlay2/driver_overlay2.h
|
|
index e14271b1..438c508e 100644
|
|
--- a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/overlay2/driver_overlay2.h
|
|
+++ b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/overlay2/driver_overlay2.h
|
|
@@ -35,8 +35,6 @@ extern "C" {
|
|
|
|
int overlay2_init(struct graphdriver *driver, const char *driver_home, const char **options, size_t len);
|
|
|
|
-bool overlay2_is_quota_options(struct graphdriver *driver, const char *option);
|
|
-
|
|
int overlay2_create_rw(const char *id, const char *parent, const struct graphdriver *driver,
|
|
struct driver_create_opts *create_opts);
|
|
|
|
diff --git a/src/daemon/modules/image/oci/storage/layer_store/layer.c b/src/daemon/modules/image/oci/storage/layer_store/layer.c
|
|
index 4baeb7c2..4beb3d10 100644
|
|
--- a/src/daemon/modules/image/oci/storage/layer_store/layer.c
|
|
+++ b/src/daemon/modules/image/oci/storage/layer_store/layer.c
|
|
@@ -46,7 +46,7 @@ void free_layer_t(layer_t *ptr)
|
|
free(ptr);
|
|
}
|
|
|
|
-layer_t *create_empty_layer()
|
|
+layer_t *create_empty_layer(void)
|
|
{
|
|
layer_t *result = NULL;
|
|
int nret = 0;
|
|
diff --git a/src/daemon/modules/image/oci/storage/layer_store/layer.h b/src/daemon/modules/image/oci/storage/layer_store/layer.h
|
|
index f2dad648..9387efe0 100644
|
|
--- a/src/daemon/modules/image/oci/storage/layer_store/layer.h
|
|
+++ b/src/daemon/modules/image/oci/storage/layer_store/layer.h
|
|
@@ -43,7 +43,7 @@ typedef struct _layer_t_ {
|
|
uint64_t refcnt;
|
|
} layer_t;
|
|
|
|
-layer_t *create_empty_layer();
|
|
+layer_t *create_empty_layer(void);
|
|
|
|
void free_layer_t(layer_t *ptr);
|
|
void layer_ref_inc(layer_t *layer);
|
|
diff --git a/src/daemon/modules/image/oci/storage/layer_store/layer_store.c b/src/daemon/modules/image/oci/storage/layer_store/layer_store.c
|
|
index 6ea3c48b..3ffe0ca7 100644
|
|
--- a/src/daemon/modules/image/oci/storage/layer_store/layer_store.c
|
|
+++ b/src/daemon/modules/image/oci/storage/layer_store/layer_store.c
|
|
@@ -117,7 +117,7 @@ static inline void layer_store_unlock()
|
|
}
|
|
}
|
|
|
|
-void layer_store_cleanup()
|
|
+void layer_store_cleanup(void)
|
|
{
|
|
struct linked_list *item = NULL;
|
|
struct linked_list *next = NULL;
|
|
@@ -230,7 +230,7 @@ static inline void delete_g_layer_list_item(struct linked_list *item, bool rm_va
|
|
g_metadata.layers_list_len -= 1;
|
|
}
|
|
|
|
-void remove_layer_list_tail()
|
|
+void remove_layer_list_tail(void)
|
|
{
|
|
struct linked_list *item = NULL;
|
|
|
|
@@ -1231,18 +1231,6 @@ int layer_store_delete(const char *id)
|
|
return ret;
|
|
}
|
|
|
|
-bool layer_store_exists(const char *id)
|
|
-{
|
|
- layer_t *l = lookup_with_lock(id);
|
|
-
|
|
- if (l == NULL) {
|
|
- return false;
|
|
- }
|
|
-
|
|
- layer_ref_dec(l);
|
|
- return true;
|
|
-}
|
|
-
|
|
static void copy_json_to_layer(const layer_t *jl, struct layer *l)
|
|
{
|
|
if (jl->slayer == NULL) {
|
|
@@ -1354,7 +1342,7 @@ int layer_store_by_compress_digest(const char *digest, struct layer_list *resp)
|
|
{
|
|
int ret = 0;
|
|
|
|
- if (resp == NULL) {
|
|
+ if (digest == NULL || resp == NULL) {
|
|
return -1;
|
|
}
|
|
|
|
@@ -1367,22 +1355,6 @@ int layer_store_by_compress_digest(const char *digest, struct layer_list *resp)
|
|
return ret;
|
|
}
|
|
|
|
-int layer_store_by_uncompress_digest(const char *digest, struct layer_list *resp)
|
|
-{
|
|
- int ret = 0;
|
|
-
|
|
- if (resp == NULL) {
|
|
- return -1;
|
|
- }
|
|
- if (!layer_store_lock(false)) {
|
|
- return -1;
|
|
- }
|
|
-
|
|
- ret = layers_by_digest_map(g_metadata.by_uncompress_digest, digest, resp);
|
|
- layer_store_unlock();
|
|
- return ret;
|
|
-}
|
|
-
|
|
struct layer *layer_store_lookup(const char *name)
|
|
{
|
|
struct layer *ret = NULL;
|
|
@@ -1492,6 +1464,10 @@ int layer_store_try_repair_lowers(const char *id)
|
|
layer_t *l = NULL;
|
|
int ret = 0;
|
|
|
|
+ if (id == NULL) {
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
l = lookup_with_lock(id);
|
|
if (l == NULL) {
|
|
return -1;
|
|
@@ -1807,7 +1783,7 @@ free_out:
|
|
return -1;
|
|
}
|
|
|
|
-void layer_store_exit()
|
|
+void layer_store_exit(void)
|
|
{
|
|
graphdriver_cleanup();
|
|
}
|
|
@@ -2116,6 +2092,11 @@ int layer_store_check(const char *id)
|
|
int ret = 0;
|
|
char *rootfs = NULL;
|
|
|
|
+ if (id == NULL) {
|
|
+ ERROR("Failed to do layer store check for Empty id");
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
layer_t *l = lookup_with_lock(id);
|
|
if (l == NULL || l->slayer == NULL) {
|
|
ERROR("layer %s not found when checking integration", id);
|
|
@@ -2157,6 +2138,11 @@ int remote_layer_remove_memory_stores_with_lock(const char *id)
|
|
{
|
|
int ret = 0;
|
|
|
|
+ if (id == NULL) {
|
|
+ ERROR("Failed to lock layer store for empty id");
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
if (!layer_store_lock(true)) {
|
|
ERROR("Failed to lock layer store when handle: %s", id);
|
|
return -1;
|
|
@@ -2237,6 +2223,11 @@ int remote_load_one_layer(const char *id)
|
|
layer_t *tl = NULL;
|
|
size_t i = 0;
|
|
|
|
+ if (id == NULL) {
|
|
+ ERROR("Failed to do remote load one layer for empty id");
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
if (!layer_store_lock(true)) {
|
|
return -1;
|
|
}
|
|
diff --git a/src/daemon/modules/image/oci/storage/layer_store/layer_store.h b/src/daemon/modules/image/oci/storage/layer_store/layer_store.h
|
|
index be8c52dc..20287119 100644
|
|
--- a/src/daemon/modules/image/oci/storage/layer_store/layer_store.h
|
|
+++ b/src/daemon/modules/image/oci/storage/layer_store/layer_store.h
|
|
@@ -51,20 +51,18 @@ struct layer_opts {
|
|
};
|
|
|
|
int layer_store_init(const struct storage_module_init_options *conf);
|
|
-void layer_store_exit();
|
|
-void layer_store_cleanup();
|
|
+void layer_store_exit(void);
|
|
+void layer_store_cleanup(void);
|
|
|
|
-void remove_layer_list_tail();
|
|
+void remove_layer_list_tail(void);
|
|
int layer_store_create(const char *id, const struct layer_opts *opts, const struct io_read_wrapper *content,
|
|
char **new_id);
|
|
int layer_inc_hold_refs(const char *layer_id);
|
|
int layer_dec_hold_refs(const char *layer_id);
|
|
int layer_get_hold_refs(const char *layer_id, int *ref_num);
|
|
int layer_store_delete(const char *id);
|
|
-bool layer_store_exists(const char *id);
|
|
int layer_store_list(struct layer_list *resp);
|
|
int layer_store_by_compress_digest(const char *digest, struct layer_list *resp);
|
|
-int layer_store_by_uncompress_digest(const char *digest, struct layer_list *resp);
|
|
struct layer *layer_store_lookup(const char *name);
|
|
char *layer_store_mount(const char *id);
|
|
int layer_store_umount(const char *id, bool force);
|
|
diff --git a/src/daemon/modules/image/oci/storage/remote_layer_support/image_remote_impl.c b/src/daemon/modules/image/oci/storage/remote_layer_support/image_remote_impl.c
|
|
index b4a53ec1..07c4a5cc 100644
|
|
--- a/src/daemon/modules/image/oci/storage/remote_layer_support/image_remote_impl.c
|
|
+++ b/src/daemon/modules/image/oci/storage/remote_layer_support/image_remote_impl.c
|
|
@@ -1,5 +1,5 @@
|
|
/******************************************************************************
|
|
- * Copyright (c) Huawei Technologies Co., Ltd. 2020-2023. All rights reserved.
|
|
+ * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved.
|
|
* iSulad licensed under the Mulan PSL v2.
|
|
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
* You may obtain a copy of Mulan PSL v2 at:
|
|
@@ -31,6 +31,11 @@ static map_t *image_byid_new = NULL;
|
|
|
|
struct remote_image_data *remote_image_create(const char *remote_home, const char *remote_ro)
|
|
{
|
|
+ if (remote_home == NULL) {
|
|
+ ERROR("Empty remote home");
|
|
+ return NULL;
|
|
+ }
|
|
+
|
|
struct remote_image_data *data = util_common_calloc_s(sizeof(struct remote_image_data));
|
|
if (data == NULL) {
|
|
ERROR("Out of memory");
|
|
@@ -204,6 +209,11 @@ static int remote_image_add(void *data)
|
|
|
|
void remote_image_refresh(struct remote_image_data *data)
|
|
{
|
|
+ if (data == NULL) {
|
|
+ ERROR("Skip refresh remote image for empty data");
|
|
+ return;
|
|
+ }
|
|
+
|
|
if (remote_dir_scan(data) != 0) {
|
|
ERROR("remote overlay failed to scan dir, skip refresh");
|
|
return;
|
|
diff --git a/src/daemon/modules/image/oci/storage/remote_layer_support/layer_remote_impl.c b/src/daemon/modules/image/oci/storage/remote_layer_support/layer_remote_impl.c
|
|
index b1a1e944..7527f1e4 100644
|
|
--- a/src/daemon/modules/image/oci/storage/remote_layer_support/layer_remote_impl.c
|
|
+++ b/src/daemon/modules/image/oci/storage/remote_layer_support/layer_remote_impl.c
|
|
@@ -31,6 +31,11 @@ static map_t *layer_byid_new = NULL;
|
|
|
|
struct remote_layer_data *remote_layer_create(const char *layer_home, const char *layer_ro)
|
|
{
|
|
+ if (layer_home == NULL || layer_ro == NULL) {
|
|
+ ERROR("Empty layer home or layer ro");
|
|
+ return NULL;
|
|
+ }
|
|
+
|
|
struct remote_layer_data *data = util_common_calloc_s(sizeof(struct remote_layer_data));
|
|
if (data == NULL) {
|
|
ERROR("Out of memory");
|
|
@@ -232,6 +237,11 @@ static int remote_layer_add(struct remote_layer_data *data)
|
|
|
|
void remote_layer_refresh(struct remote_layer_data *data)
|
|
{
|
|
+ if (data == NULL) {
|
|
+ ERROR("Skip refresh remote layer for empty data");
|
|
+ return;
|
|
+ }
|
|
+
|
|
if (remote_dir_scan(data) != 0) {
|
|
ERROR("remote layer failed to scan dir, skip refresh");
|
|
return;
|
|
diff --git a/src/daemon/modules/image/oci/storage/remote_layer_support/overlay_remote_impl.c b/src/daemon/modules/image/oci/storage/remote_layer_support/overlay_remote_impl.c
|
|
index e44c64ef..38d9b0ce 100644
|
|
--- a/src/daemon/modules/image/oci/storage/remote_layer_support/overlay_remote_impl.c
|
|
+++ b/src/daemon/modules/image/oci/storage/remote_layer_support/overlay_remote_impl.c
|
|
@@ -37,6 +37,11 @@ static map_t *overlay_id_link = NULL;
|
|
|
|
struct remote_overlay_data *remote_overlay_create(const char *remote_home, const char *remote_ro)
|
|
{
|
|
+ if (remote_home == NULL || remote_ro == NULL) {
|
|
+ ERROR("Empty remote home or remote ro");
|
|
+ return NULL;
|
|
+ }
|
|
+
|
|
struct remote_overlay_data *data = util_common_calloc_s(sizeof(struct remote_overlay_data));
|
|
if (data == NULL) {
|
|
ERROR("Out of memory");
|
|
@@ -341,6 +346,11 @@ static int remote_overlay_add(struct remote_overlay_data *data)
|
|
|
|
void remote_overlay_refresh(struct remote_overlay_data *data)
|
|
{
|
|
+ if (data == NULL) {
|
|
+ ERROR("Skip refresh remote overlay for empty data");
|
|
+ return;
|
|
+ }
|
|
+
|
|
if (remote_dir_scan(data) != 0) {
|
|
ERROR("remote overlay failed to scan dir, skip refresh");
|
|
return;
|
|
diff --git a/src/daemon/modules/image/oci/storage/remote_layer_support/remote_support.c b/src/daemon/modules/image/oci/storage/remote_layer_support/remote_support.c
|
|
index 1bac8dd5..5bf9869b 100644
|
|
--- a/src/daemon/modules/image/oci/storage/remote_layer_support/remote_support.c
|
|
+++ b/src/daemon/modules/image/oci/storage/remote_layer_support/remote_support.c
|
|
@@ -87,6 +87,11 @@ int remote_start_refresh_thread(pthread_rwlock_t *remote_lock)
|
|
pthread_t a_thread;
|
|
maintain_context ctx = get_maintain_context();
|
|
|
|
+ if (remote_lock == NULL) {
|
|
+ ERROR("Invalid remote lock");
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
supporters.image_data = remote_image_create(ctx.image_home, NULL);
|
|
if (supporters.image_data == NULL) {
|
|
goto free_out;
|
|
diff --git a/src/daemon/modules/image/oci/storage/remote_layer_support/ro_symlink_maintain.c b/src/daemon/modules/image/oci/storage/remote_layer_support/ro_symlink_maintain.c
|
|
index 4d234aab..ea40ae45 100644
|
|
--- a/src/daemon/modules/image/oci/storage/remote_layer_support/ro_symlink_maintain.c
|
|
+++ b/src/daemon/modules/image/oci/storage/remote_layer_support/ro_symlink_maintain.c
|
|
@@ -37,6 +37,8 @@ static char *layer_home;
|
|
static char *overlay_ro_dir;
|
|
static char *overlay_home;
|
|
|
|
+#define LAYER_RO_DIR_MODE 0700
|
|
+
|
|
int remote_image_init(const char *root_dir)
|
|
{
|
|
if (root_dir == NULL) {
|
|
@@ -67,7 +69,7 @@ int remote_layer_init(const char *root_dir)
|
|
ERROR("Failed join path when init remote layer maintainer");
|
|
goto out;
|
|
}
|
|
- if (!util_file_exists(layer_ro_dir) && util_mkdir_p(layer_ro_dir, 0700) != 0) {
|
|
+ if (!util_file_exists(layer_ro_dir) && util_mkdir_p(layer_ro_dir, LAYER_RO_DIR_MODE) != 0) {
|
|
ERROR("Failed to create RO dir under overlay");
|
|
goto out;
|
|
}
|
|
@@ -127,6 +129,11 @@ static int do_build_ro_dir(const char *home, const char *id)
|
|
int nret = 0;
|
|
int ret = 0;
|
|
|
|
+ if (home == NULL || id == NULL) {
|
|
+ ERROR("Empty home or id");
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
nret = asprintf(&ro_symlink, "%s/%s", home, id);
|
|
if (nret < 0 || nret > PATH_MAX) {
|
|
SYSERROR("Failed create ro layer dir sym link path");
|
|
@@ -183,7 +190,7 @@ int do_remove_ro_dir(const char *home, const char *id)
|
|
int ret = 0;
|
|
int nret = 0;
|
|
|
|
- if (id == NULL) {
|
|
+ if (home == NULL || id == NULL) {
|
|
return 0;
|
|
}
|
|
|
|
diff --git a/src/daemon/modules/image/oci/storage/rootfs_store/rootfs_store.c b/src/daemon/modules/image/oci/storage/rootfs_store/rootfs_store.c
|
|
index ee1e15d0..7ed07029 100644
|
|
--- a/src/daemon/modules/image/oci/storage/rootfs_store/rootfs_store.c
|
|
+++ b/src/daemon/modules/image/oci/storage/rootfs_store/rootfs_store.c
|
|
@@ -121,7 +121,7 @@ static void free_rootfs_store(rootfs_store_t *store)
|
|
free(store);
|
|
}
|
|
|
|
-void rootfs_store_free()
|
|
+void rootfs_store_free(void)
|
|
{
|
|
free_rootfs_store(g_rootfs_store);
|
|
g_rootfs_store = NULL;
|
|
@@ -1085,7 +1085,7 @@ out:
|
|
return ret;
|
|
}
|
|
|
|
-int rootfs_store_wipe()
|
|
+int rootfs_store_wipe(void)
|
|
{
|
|
int ret = 0;
|
|
char *id = NULL;
|
|
@@ -1125,7 +1125,7 @@ int rootfs_store_set_metadata(const char *id, const char *metadata)
|
|
cntrootfs_t *cntr = NULL;
|
|
|
|
if (id == NULL || metadata == NULL) {
|
|
- ERROR("Invalid paratemer: id(%s), metadata(%s)", id, metadata);
|
|
+ ERROR("Invalid paratemer");
|
|
return -1;
|
|
}
|
|
|
|
@@ -1331,7 +1331,7 @@ out:
|
|
return ret;
|
|
}
|
|
|
|
-char *rootfs_store_get_data_dir()
|
|
+char *rootfs_store_get_data_dir(void)
|
|
{
|
|
return util_strdup_s(g_rootfs_store->dir);
|
|
}
|
|
\ No newline at end of file
|
|
diff --git a/src/daemon/modules/image/oci/storage/rootfs_store/rootfs_store.h b/src/daemon/modules/image/oci/storage/rootfs_store/rootfs_store.h
|
|
index c23af091..63f3294b 100644
|
|
--- a/src/daemon/modules/image/oci/storage/rootfs_store/rootfs_store.h
|
|
+++ b/src/daemon/modules/image/oci/storage/rootfs_store/rootfs_store.h
|
|
@@ -48,7 +48,7 @@ char *rootfs_store_lookup(const char *id);
|
|
int rootfs_store_delete(const char *id);
|
|
|
|
// Remove records of all containers
|
|
-int rootfs_store_wipe();
|
|
+int rootfs_store_wipe(void);
|
|
|
|
// Updates the metadata associated with the item with the specified ID.
|
|
int rootfs_store_set_metadata(const char *id, const char *metadata);
|
|
@@ -66,10 +66,10 @@ storage_rootfs *rootfs_store_get_rootfs(const char *id);
|
|
int rootfs_store_get_all_rootfs(struct rootfs_list *all_rootfs);
|
|
|
|
// Return rootfs store data dir
|
|
-char *rootfs_store_get_data_dir();
|
|
+char *rootfs_store_get_data_dir(void);
|
|
|
|
// Free memory of container store, but will not delete the persisted files
|
|
-void rootfs_store_free();
|
|
+void rootfs_store_free(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
diff --git a/src/daemon/modules/image/oci/storage/storage.c b/src/daemon/modules/image/oci/storage/storage.c
|
|
index 13f8bb53..255ec89c 100644
|
|
--- a/src/daemon/modules/image/oci/storage/storage.c
|
|
+++ b/src/daemon/modules/image/oci/storage/storage.c
|
|
@@ -194,6 +194,11 @@ int storage_inc_hold_refs(const char *layer_id)
|
|
{
|
|
int ret = 0;
|
|
|
|
+ if (layer_id == NULL) {
|
|
+ ERROR("Empty layer id");
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
if (!storage_lock(&g_storage_rwlock, true)) {
|
|
ERROR("Failed to lock image store when increase hold refs number for layer %s", layer_id);
|
|
return -1;
|
|
@@ -209,6 +214,11 @@ int storage_inc_hold_refs(const char *layer_id)
|
|
int storage_dec_hold_refs(const char *layer_id)
|
|
{
|
|
int ret = 0;
|
|
+
|
|
+ if (layer_id == NULL) {
|
|
+ ERROR("Empty layer id");
|
|
+ return -1;
|
|
+ }
|
|
|
|
if (!storage_lock(&g_storage_rwlock, true)) {
|
|
ERROR("Failed to lock image store when decrease hold refs number for layer %s", layer_id);
|
|
@@ -284,6 +294,11 @@ struct layer_list *storage_layers_get_by_compress_digest(const char *digest)
|
|
int ret = 0;
|
|
struct layer_list *layers = NULL;
|
|
|
|
+ if (digest == NULL) {
|
|
+ ERROR("Empty digest");
|
|
+ return NULL;
|
|
+ }
|
|
+
|
|
layers = util_common_calloc_s(sizeof(struct layer_list));
|
|
if (layers == NULL) {
|
|
ERROR("Out of memory");
|
|
@@ -539,7 +554,7 @@ char *storage_img_get_image_id(const char *img_name)
|
|
return image_store_lookup(img_name);
|
|
}
|
|
|
|
-bool is_top_layer_of_other_image(const char *img_id, const imagetool_images_list *all_images, const char *layer_id)
|
|
+static bool is_top_layer_of_other_image(const char *img_id, const imagetool_images_list *all_images, const char *layer_id)
|
|
{
|
|
size_t i = 0;
|
|
|
|
@@ -913,6 +928,11 @@ int storage_img_set_image_size(const char *image_id)
|
|
int ret = 0;
|
|
int64_t image_size = 0;
|
|
|
|
+ if (image_id == NULL) {
|
|
+ ERROR("Empty image id");
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
image_size = storage_img_cal_image_size(image_id);
|
|
if (image_size < 0) {
|
|
ERROR("Failed to get image %s size", image_id);
|
|
@@ -961,7 +981,7 @@ bool storage_image_exist(const char *image_or_id)
|
|
return image_store_exists(image_or_id);
|
|
}
|
|
|
|
-size_t storage_get_img_count()
|
|
+size_t storage_get_img_count(void)
|
|
{
|
|
return image_store_get_images_number();
|
|
}
|
|
@@ -1250,8 +1270,8 @@ int storage_rootfs_fs_usgae(const char *container_id, imagetool_fs_info *fs_info
|
|
}
|
|
|
|
rootfs_info = rootfs_store_get_rootfs(container_id);
|
|
- if (rootfs_info == NULL) {
|
|
- ERROR("Failed to get rootfs %s info", container_id);
|
|
+ if (rootfs_info == NULL || rootfs_info->layer == NULL) {
|
|
+ ERROR("Failed to get valid rootfs %s info", container_id);
|
|
ret = -1;
|
|
goto out;
|
|
}
|
|
@@ -1278,7 +1298,7 @@ char *storage_rootfs_mount(const char *container_id)
|
|
}
|
|
|
|
rootfs_info = rootfs_store_get_rootfs(container_id);
|
|
- if (rootfs_info == NULL) {
|
|
+ if (rootfs_info == NULL || rootfs_info->layer == NULL) {
|
|
ERROR("Failed to get rootfs %s info", container_id);
|
|
goto out;
|
|
}
|
|
@@ -1726,6 +1746,11 @@ container_inspect_graph_driver *storage_get_metadata_by_container_id(const char
|
|
storage_rootfs *rootfs_info = NULL;
|
|
container_inspect_graph_driver *container_metadata = NULL;
|
|
|
|
+ if (id == NULL) {
|
|
+ ERROR("Empty id");
|
|
+ return NULL;
|
|
+ }
|
|
+
|
|
rootfs_info = rootfs_store_get_rootfs(id);
|
|
if (rootfs_info == NULL) {
|
|
ERROR("Failed to get rootfs %s info", id);
|
|
diff --git a/src/daemon/modules/image/oci/storage/storage.h b/src/daemon/modules/image/oci/storage/storage.h
|
|
index a761938c..718f7eff 100644
|
|
--- a/src/daemon/modules/image/oci/storage/storage.h
|
|
+++ b/src/daemon/modules/image/oci/storage/storage.h
|
|
@@ -119,7 +119,7 @@ typedef struct storage_layer_create_opts {
|
|
|
|
int storage_module_init(struct storage_module_init_options *opts);
|
|
|
|
-void storage_module_exit();
|
|
+void storage_module_exit(void);
|
|
|
|
void free_storage_module_init_options(struct storage_module_init_options *opts);
|
|
|
|
@@ -153,7 +153,7 @@ int storage_img_set_image_size(const char *image_id);
|
|
|
|
char *storage_get_img_top_layer(const char *id);
|
|
|
|
-size_t storage_get_img_count();
|
|
+size_t storage_get_img_count(void);
|
|
|
|
char *storage_img_get_image_id(const char *img_name);
|
|
|
|
@@ -191,7 +191,7 @@ char *storage_rootfs_mount(const char *container_id);
|
|
|
|
int storage_rootfs_umount(const char *container_id, bool force);
|
|
|
|
-char *storage_rootfs_get_dir();
|
|
+char *storage_rootfs_get_dir(void);
|
|
|
|
container_inspect_graph_driver *storage_get_metadata_by_container_id(const char *id);
|
|
|
|
diff --git a/src/daemon/modules/image/oci/utils_images.c b/src/daemon/modules/image/oci/utils_images.c
|
|
index 2c5656c6..f8fd1e73 100644
|
|
--- a/src/daemon/modules/image/oci/utils_images.c
|
|
+++ b/src/daemon/modules/image/oci/utils_images.c
|
|
@@ -247,7 +247,7 @@ int oci_split_image_name(const char *image_name, char **host, char **name, char
|
|
return 0;
|
|
}
|
|
|
|
-char *get_hostname_to_strip()
|
|
+char *get_hostname_to_strip(void)
|
|
{
|
|
char *name = NULL;
|
|
|
|
@@ -320,6 +320,11 @@ char *make_big_data_base_name(const char *key)
|
|
char *base_name = NULL;
|
|
size_t name_size;
|
|
|
|
+ if (key == NULL) {
|
|
+ ERROR("Empty key");
|
|
+ return NULL;
|
|
+ }
|
|
+
|
|
if (should_use_origin_name(key)) {
|
|
return util_strdup_s(key);
|
|
}
|
|
diff --git a/src/daemon/modules/image/oci/utils_images.h b/src/daemon/modules/image/oci/utils_images.h
|
|
index 97879e41..2238bb91 100644
|
|
--- a/src/daemon/modules/image/oci/utils_images.h
|
|
+++ b/src/daemon/modules/image/oci/utils_images.h
|
|
@@ -57,7 +57,7 @@ int oci_split_search_name(const char *search_name, char **host, char **name);
|
|
|
|
char *oci_get_isulad_tmpdir(const char *root_dir);
|
|
int makesure_isulad_tmpdir_perm_right(const char *root_dir);
|
|
-char *get_hostname_to_strip();
|
|
+char *get_hostname_to_strip(void);
|
|
|
|
char *oci_image_digest_pos(const char *name);
|
|
|
|
diff --git a/src/utils/http/http.h b/src/utils/http/http.h
|
|
index cdd6d64f..02d56ba8 100644
|
|
--- a/src/utils/http/http.h
|
|
+++ b/src/utils/http/http.h
|
|
@@ -107,6 +107,8 @@ struct http_get_options {
|
|
#define AUTHZ_UNIX_SOCK "/run/isulad/plugins/authz-broker.sock"
|
|
#define AUTHZ_REQUEST_URL "http://localhost/isulad.auth"
|
|
|
|
+#define BODY_FILE_MODE 0600
|
|
+
|
|
/* http response code */
|
|
enum http_response_code {
|
|
StatusContinue = 100, // RFC 7231, 6.2.1
|
|
diff --git a/test/image/oci/storage/layers/storage_driver_ut.cc b/test/image/oci/storage/layers/storage_driver_ut.cc
|
|
index ae9f4df1..943fa073 100644
|
|
--- a/test/image/oci/storage/layers/storage_driver_ut.cc
|
|
+++ b/test/image/oci/storage/layers/storage_driver_ut.cc
|
|
@@ -269,12 +269,4 @@ TEST_F(StorageDriverUnitTest, test_graphdriver_try_repair_lowers)
|
|
|
|
std::string id { "1be74353c3d0fd55fb5638a52953e6f1bc441e5b1710921db9ec2aa202725569" };
|
|
ASSERT_EQ(graphdriver_try_repair_lowers(id.c_str(), nullptr), 0);
|
|
-}
|
|
-
|
|
-TEST(StorageOverlay2QuotaOptionsTest, test_overlay2_is_quota_options)
|
|
-{
|
|
- std::vector<std::string> options { "overlay2.size", "overlay2.basesize" };
|
|
- for (auto option : options) {
|
|
- ASSERT_TRUE(overlay2_is_quota_options(nullptr, option.c_str()));
|
|
- }
|
|
-}
|
|
+}
|
|
\ No newline at end of file
|
|
diff --git a/test/image/oci/storage/layers/storage_layers_ut.cc b/test/image/oci/storage/layers/storage_layers_ut.cc
|
|
index fca37e83..73611fdc 100644
|
|
--- a/test/image/oci/storage/layers/storage_layers_ut.cc
|
|
+++ b/test/image/oci/storage/layers/storage_layers_ut.cc
|
|
@@ -278,19 +278,6 @@ TEST_F(StorageLayersUnitTest, test_layers_load)
|
|
free_layer_list(layer_list);
|
|
}
|
|
|
|
-TEST_F(StorageLayersUnitTest, test_layer_store_exists)
|
|
-{
|
|
- if (!support_overlay) {
|
|
- return;
|
|
- }
|
|
-
|
|
- std::string id { "7db8f44a0a8e12ea4283e3180e98880007efbd5de2e7c98b67de9cdd4dfffb0b" };
|
|
- std::string incorrectId { "50551ff67da98ab8540d7132" };
|
|
-
|
|
- ASSERT_TRUE(layer_store_exists(id.c_str()));
|
|
- ASSERT_FALSE(layer_store_exists(incorrectId.c_str()));
|
|
-}
|
|
-
|
|
TEST_F(StorageLayersUnitTest, test_layer_store_create)
|
|
{
|
|
if (!support_overlay) {
|
|
@@ -337,24 +324,3 @@ TEST_F(StorageLayersUnitTest, test_layer_store_by_compress_digest)
|
|
|
|
free_layer_list(layer_list);
|
|
}
|
|
-
|
|
-TEST_F(StorageLayersUnitTest, test_layer_store_by_uncompress_digest)
|
|
-{
|
|
- if (!support_overlay) {
|
|
- return;
|
|
- }
|
|
-
|
|
- std::string uncompress { "sha256:9c27e219663c25e0f28493790cc0b88bc973ba3b1686355f221c38a36978ac63" };
|
|
- std::string id { "9c27e219663c25e0f28493790cc0b88bc973ba3b1686355f221c38a36978ac63" };
|
|
- struct layer_list *layer_list = (struct layer_list *)util_common_calloc_s(sizeof(struct layer_list));
|
|
-
|
|
- ASSERT_EQ(layer_store_by_uncompress_digest(uncompress.c_str(), layer_list), 0);
|
|
- ASSERT_EQ(layer_list->layers_len, 1);
|
|
-
|
|
- struct layer **layers = layer_list->layers;
|
|
- ASSERT_STREQ(layers[0]->id, id.c_str());
|
|
- ASSERT_STREQ(layers[0]->uncompressed_digest, uncompress.c_str());
|
|
- ASSERT_EQ(layers[0]->uncompress_size, 1672256);
|
|
-
|
|
- free_layer_list(layer_list);
|
|
-}
|
|
diff --git a/test/mocks/driver_overlay2_mock.cc b/test/mocks/driver_overlay2_mock.cc
|
|
index 6f24dbcf..6892539d 100644
|
|
--- a/test/mocks/driver_overlay2_mock.cc
|
|
+++ b/test/mocks/driver_overlay2_mock.cc
|
|
@@ -39,11 +39,3 @@ int overlay2_parse_options(struct graphdriver *driver, const char **options, siz
|
|
}
|
|
return -1;
|
|
}
|
|
-
|
|
-bool overlay2_is_quota_options(struct graphdriver *driver, const char *option)
|
|
-{
|
|
- if (g_driver_overlay2_mock != nullptr) {
|
|
- return g_driver_overlay2_mock->Overlay2IsQuotaOptions(driver, option);
|
|
- }
|
|
- return false;
|
|
-}
|
|
diff --git a/test/mocks/driver_overlay2_mock.h b/test/mocks/driver_overlay2_mock.h
|
|
index 071e6287..f09b715a 100644
|
|
--- a/test/mocks/driver_overlay2_mock.h
|
|
+++ b/test/mocks/driver_overlay2_mock.h
|
|
@@ -24,7 +24,6 @@ public:
|
|
virtual ~MockDriverOverlay2() = default;
|
|
MOCK_METHOD1(Overlay2Init, int(struct graphdriver *));
|
|
MOCK_METHOD3(Overlay2ParseOptions, int(struct graphdriver *, const char **, size_t));
|
|
- MOCK_METHOD2(Overlay2IsQuotaOptions, bool(struct graphdriver *, const char *));
|
|
};
|
|
|
|
void MockDriverOverlay2_SetMock(MockDriverOverlay2* mock);
|
|
--
|
|
2.40.1
|
|
|