Ethanlm commented on a change in pull request #3366: URL: https://github.com/apache/storm/pull/3366#discussion_r669940544
########## File path: storm-core/src/native/worker-launcher/impl/oci/oci.c ########## @@ -0,0 +1,881 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include <linux/loop.h> +#include <sys/types.h> +#include <sys/mount.h> +#include <sys/stat.h> +#include <sys/time.h> +#include <dirent.h> +#include <errno.h> +#include <fcntl.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <time.h> +#include <openssl/evp.h> + +// LOOP_CTL_GET_FREE ioctl is supported since linux kernel 3.1 +//Add this so it can compile on older version of linux kernel, +//but certain runc related functionalities will not work during runtime. +#ifndef LOOP_CTL_GET_FREE +#define LOOP_CTL_GET_FREE 0x4C82 +#endif + +#include "utils/string-utils.h" +#include "configuration.h" +#include "worker-launcher.h" + +#include "oci.h" +#include "oci_base_ctx.h" +#include "oci_config.h" +#include "oci_launch_cmd.h" +#include "oci_reap.h" +#include "oci_write_config.h" + + + +// NOTE: Update init_oci_mount_context and destroy_oci_mount_context +// when this is changed. +typedef struct oci_mount_context_struct { + char* src_path; // path to raw layer data + char* layer_path; // path under layer database for this layer + char* mount_path; // mount point of filesystem under layer_path + int fd; // opened file descriptor or -1 +} oci_mount_ctx; + +// NOTE: Update init_oci_launch_cmd_ctx and destroy_oci_launch_cmd_ctx +// when this is changed. +typedef struct oci_launch_cmd_context_struct { + oci_base_ctx base_ctx; // run root and layer lock + oci_overlay_desc upper; // writable upper layer descriptor + oci_mount_ctx* layers; // layer mount info + unsigned int num_layers; // number of layer mount contexts +} oci_launch_cmd_ctx; + +void init_oci_overlay_desc(oci_overlay_desc* desc) { + memset(desc, 0, sizeof(oci_overlay_desc)); +} + +void destroy_oci_overlay_desc(oci_overlay_desc* desc) { + if (desc != NULL) { + free(desc->top_path); + free(desc->mount_path); + free(desc->upper_path); + free(desc->work_path); + } +} + +static void init_oci_mount_ctx(oci_mount_ctx* ctx) { + memset(ctx, 0, sizeof(*ctx)); + ctx->fd = -1; +} + +static void destroy_oci_mount_ctx(oci_mount_ctx* ctx) { + if (ctx != NULL) { + free(ctx->src_path); Review comment: `free(null)` is okay. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@storm.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org