GMT Expires: Thu, 27 Mar 2036 13:23:57 GMT ETag: "3d668f9cf9b98d5a514060a3317bc04b38fc8d62" /* 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 #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined GF_BSD_HOST_OS || defined GF_DARWIN_HOST_OS #include #endif #include "logging.h" #include "common-utils.h" #include "revision.h" #include "glusterfs.h" #include "stack.h" #include "globals.h" #include "lkowner.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; }; /* 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,}; strcpy (dir, path); 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_log ("", GF_LOG_ERROR, "Failed due to reason %s", strerror (errno)); 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_log ("", GF_LOG_ERROR, "%s is a symlink", dir); goto out; } } dir[i] = '/'; } while (path[i++] != '\0'); ret = stat (dir, &stbuf); if (ret || !S_ISDIR (stbuf.st_mode)) { ret = -1; gf_log ("", GF_LOG_ERROR, "Failed to create directory, " "possibly some of the components were not directories"); goto out; } ret = 0; out: return ret; } int log_base2 (unsigned long x) { int val = 0; while (x > 1) { x /= 2; val++; } return val; } int32_t gf_resolve_ip6 (const char *hostname, uint16_t port, int family, void **dnscache, struct addrinfo **addr_info) { int32_t ret = 0; struct addrinfo hints; struct dnscache6 *cache = NULL; char service[NI_MAXSERV], host[NI_MAXHOST]; if (!hostname) { gf_log_callingfn ("resolver", GF_LOG_WARNING, "hostname is NULL"); return -1; } i