/* Copyright (c) 2010-2011 Gluster, Inc. This file is part of GlusterFS. GlusterFS is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. GlusterFS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef _GRAPH_H_ #define _GRAPH_H_ int glusterfs_graph_print_file (FILE *file, glusterfs_graph_t *graph); char *glusterfs_graph_print_buf (glusterfs_graph_t *graph); int glusterfs_xlator_link (xlator_t *pxl, xlator_t *cxl); void glusterfs_graph_set_first (glusterfs_graph_t *graph, xlator_t *xl); #endif lude "globals.h" #include "lkowner.h" #include "syscall.h" #include "cli1-xdr.h" #include #include "libglusterfs-messages.h" #ifndef AI_ADDRCONFIG #define AI_ADDRCONFIG 0 #endif /* AI_ADDRCONFIG */ char *vol_type_str[] = {"Distribute", "Stripe", "Replicate", "Striped-Replicate", "Disperse", "Tier", "Distributed-Stripe", "Distributed-Replicate", "Distributed-Striped-Replicate", "Distributed-Disperse", }; 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); 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 = sys_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 = sys_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+