09 Feb 2026 14:47:24 GMT Expires: Thu, 07 Feb 2036 14:47:24 GMT ETag: "ef29d9983bd7e7b14aa90db2593f510d67f8cf74" /* Copyright (c) 2008-2012 Red Hat, Inc. This file is part of GlusterFS. This file is licensed to you under your choice of the GNU Lesser General Public License, version 3 or any later version (LGPLv3 or later), or the GNU General Public License, version 2 (GPLv2), in all cases as published by the Free Software Foundation. */ #ifndef _CONFIG_H #define _CONFIG_H #include "config.h" #endif #ifdef HAVE_BACKTRACE #include #else #include "execinfo_compat.h" #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* for dirname() */ #if defined(GF_BSD_HOST_OS) || defined(GF_DARWIN_HOST_OS) #include #endif #include "compat-errno.h" #include "logging.h" #include "common-utils.h" #include "revision.h" #include "glusterfs.h" #include "stack.h" #include "globals.h" #include "lkowner.h" #include "syscall.h" #include #include "libglusterfs-messages.h" #ifndef AI_ADDRCONFIG #define AI_ADDRCONFIG 0 #endif /* AI_ADDRCONFIG */ typedef int32_t (*rw_op_t)(int32_t fd, char *buf, int32_t size); typedef int32_t (*rwv_op_t)(int32_t fd, const struct iovec *buf, int32_t size); struct dnscache6 { struct addrinfo *first; struct addrinfo *next; }; void md5_wrapper(const unsigned char *data, size_t len, char *md5) { unsigned short i = 0; unsigned short lim = MD5_DIGEST_LENGTH*2+1; unsigned char scratch[MD5_DIGEST_LENGTH] = {0,}; MD5(data, len, scratch); for (; i < MD5_DIGEST_LENGTH; i++) snprintf(md5 + i * 2, lim-i*2, "%02x", scratch[i]); } /* works similar to mkdir(1) -p. */ int mkdir_p (char *path, mode_t mode, gf_boolean_t allow_symlinks) { int i = 0; int ret = -1; char dir[PATH_MAX] = {0,}; struct stat stbuf = {0,}; strncpy (dir, path, (PATH_MAX - 1)); dir[PATH_MAX - 1] = '\0'; i = (dir[0] == '/')? 1: 0; do { if (path[i] != '/' && path[i] != '\0') continue; dir[i] = '\0'; ret = mkdir (dir, mode); if (ret && errno != EEXIST) { gf_msg ("", GF_LOG_ERROR, errno, LG_MSG_DIR_OP_FAILED, "Failed due to reason"); goto out; } if (ret && errno == EEXIST && !allow_symlinks) { ret = lstat (dir, &stbuf); if (ret) goto out; if (S_ISLNK (stbuf.st_mode)) { ret = -1; gf_msg ("", GF_LOG_ERROR, 0, LG_MSG_DIR_IS_SYMLINK, "%s is a " "symlink", dir); goto out; } } dir[i] = '/'; } while (path[i++] != '\0'); ret = stat (dir, &stbuf); if (ret || !S_ISDIR (stbuf.st_mode)) { if (ret == 0) errno = 0; ret = -1; gf_msg ("", GF_LOG_ERROR, errno, LG_MSG_DIR_OP_FAILED, "Failed" " to create directory, possibly some of the components"