summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/compat.h
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfs/src/compat.h')
-rw-r--r--libglusterfs/src/compat.h108
1 files changed, 70 insertions, 38 deletions
diff --git a/libglusterfs/src/compat.h b/libglusterfs/src/compat.h
index 690b4f9e6..2bd982541 100644
--- a/libglusterfs/src/compat.h
+++ b/libglusterfs/src/compat.h
@@ -1,20 +1,11 @@
/*
- Copyright (c) 2006-2010 Gluster, Inc. <http://www.gluster.com>
- This file is part of GlusterFS.
-
- GlusterFS is free software; you can redistribute it and/or modify
- it under the terms of the GNU Affero 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
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see
- <http://www.gnu.org/licenses/>.
+ Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com>
+ 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 __COMPAT_H__
@@ -41,11 +32,17 @@
#include <linux/limits.h>
#include <sys/xattr.h>
#include <endian.h>
+#ifdef HAVE_FALLOC_H
+#include <linux/falloc.h>
+#else
+#define FALLOC_FL_KEEP_SIZE 0x01 /* default is extend size */
+#define FALLOC_FL_PUNCH_HOLE 0x02 /* de-allocates range */
+#endif
#ifndef HAVE_LLISTXATTR
-/* This part is valid only incase of old glibc which doesn't support
+/* This part is valid only incase of old glibc which doesn't support
* 'llistxattr()' system calls.
*/
@@ -57,8 +54,8 @@
#endif /* HAVE_LLISTXATTR */
#endif /* GF_LINUX_HOST_OS */
-#ifdef GF_BSD_HOST_OS
-/* In case of FreeBSD */
+#ifdef GF_BSD_HOST_OS
+/* In case of FreeBSD and NetBSD */
#define UNIX_PATH_MAX 104
#include <sys/types.h>
@@ -66,16 +63,21 @@
#include <sys/un.h>
#include <sys/endian.h>
#include <sys/extattr.h>
+#ifdef HAVE_SYS_XATTR_H
+#include <sys/xattr.h>
+#endif /* HAVE_SYS_XATTR_H */
#include <limits.h>
#include <libgen.h>
+#ifndef XATTR_CREATE
enum {
ATTR_CREATE = 1,
#define XATTR_CREATE ATTR_CREATE
ATTR_REPLACE = 2
#define XATTR_REPLACE ATTR_REPLACE
};
+#endif /* XATTR_CREATE */
#ifndef sighandler_t
@@ -88,7 +90,7 @@ enum {
#ifndef EUCLEAN
#define EUCLEAN 0
-#endif
+#endif
#include <netinet/in.h>
#ifndef s6_addr16
@@ -96,7 +98,7 @@ enum {
#endif
#ifndef s6_addr32
#define s6_addr32 __u6_addr.__u6_addr32
-#endif
+#endif
/* Posix dictates NAME_MAX to be used */
# ifndef NAME_MAX
@@ -106,7 +108,7 @@ enum {
# define NAME_MAX 255
# endif
# endif
-
+
#define F_GETLK64 F_GETLK
#define F_SETLK64 F_SETLK
#define F_SETLKW64 F_SETLKW
@@ -146,10 +148,10 @@ enum {
#include <netinet/in.h>
#ifndef s6_addr16
#define s6_addr16 __u6_addr.__u6_addr16
-#endif
+#endif
#ifndef s6_addr32
#define s6_addr32 __u6_addr.__u6_addr32
-#endif
+#endif
/* Posix dictates NAME_MAX to be used */
# ifndef NAME_MAX
@@ -177,7 +179,7 @@ int32_t gf_darwin_compat_setxattr (dict_t *dict);
#ifdef GF_SOLARIS_HOST_OS
#define UNIX_PATH_MAX 108
-#define EUCLEAN 117
+#define EUCLEAN 117
#include <sys/un.h>
#include <limits.h>
@@ -189,7 +191,7 @@ int32_t gf_darwin_compat_setxattr (dict_t *dict);
#ifndef lchmod
#define lchmod chmod
-#endif
+#endif
#define lgetxattr(path, key, value, size) solaris_getxattr(path,key,value,size)
enum {
@@ -208,10 +210,10 @@ enum {
# ifndef NAME_MAX
# ifdef MAXNAMLEN
# define NAME_MAX MAXNAMLEN
-# else
+# else
# define NAME_MAX 255
# endif
-# endif
+# endif
#include <netinet/in.h>
#ifndef s6_addr16
@@ -264,22 +266,32 @@ enum {
#define FTW_CONTINUE 0
#endif
-int asprintf(char **string_ptr, const char *format, ...);
+int asprintf(char **string_ptr, const char *format, ...);
int vasprintf (char **result, const char *format, va_list args);
char* strsep(char** str, const char* delims);
int solaris_listxattr(const char *path, char *list, size_t size);
int solaris_removexattr(const char *path, const char* key);
-int solaris_getxattr(const char *path, const char* key,
+int solaris_getxattr(const char *path, const char* key,
char *value, size_t size);
-int solaris_setxattr(const char *path, const char* key, const char *value,
+int solaris_setxattr(const char *path, const char* key, const char *value,
size_t size, int flags);
int solaris_fgetxattr(int fd, const char* key,
char *value, size_t size);
-int solaris_fsetxattr(int fd, const char* key, const char *value,
+int solaris_fsetxattr(int fd, const char* key, const char *value,
size_t size, int flags);
int solaris_flistxattr(int fd, char *list, size_t size);
+int solaris_rename (const char *oldpath, const char *newpath);
+
+int solaris_unlink (const char *pathname);
+
+char *mkdtemp (char *temp);
+
+#define GF_SOLARIS_XATTR_DIR ".glusterfs_xattr_inode"
+
+int solaris_xattr_resolve_path (const char *real_path, char **path);
+
#endif /* GF_SOLARIS_HOST_OS */
#ifndef HAVE_ARGP
@@ -289,7 +301,7 @@ int solaris_flistxattr(int fd, char *list, size_t size);
#endif /* HAVE_ARGP */
#ifndef HAVE_STRNLEN
-size_t strnlen(const char *string, size_t maxlen);
+size_t strnlen(const char *string, size_t maxlen);
#endif /* STRNLEN */
#ifndef strdupa
@@ -301,7 +313,7 @@ size_t strnlen(const char *string, size_t maxlen);
char *__new = (char *) __builtin_alloca (__len); \
(char *) memcpy (__new, __old, __len); \
}))
-#endif
+#endif
#define GF_DIR_ALIGN(x) (((x) + sizeof (uint64_t) - 1) & ~(sizeof (uint64_t) - 1))
@@ -311,20 +323,35 @@ size_t strnlen(const char *string, size_t maxlen);
static inline int32_t
dirent_size (struct dirent *entry)
{
+ int32_t size = -1;
+
#ifdef GF_BSD_HOST_OS
- return GF_DIR_ALIGN (24 /* FIX MEEEE!!! */ + entry->d_namlen);
+ size = GF_DIR_ALIGN (24 /* FIX MEEEE!!! */ + entry->d_namlen);
#endif
#ifdef GF_DARWIN_HOST_OS
- return GF_DIR_ALIGN (24 /* FIX MEEEE!!! */ + entry->d_namlen);
+ size = GF_DIR_ALIGN (24 /* FIX MEEEE!!! */ + entry->d_namlen);
#endif
#ifdef GF_LINUX_HOST_OS
- return GF_DIR_ALIGN (24 /* FIX MEEEE!!! */ + entry->d_reclen);
+ size = GF_DIR_ALIGN (24 /* FIX MEEEE!!! */ + entry->d_reclen);
#endif
#ifdef GF_SOLARIS_HOST_OS
- return GF_DIR_ALIGN (24 /* FIX MEEEE!!! */ + entry->d_reclen);
+ size = GF_DIR_ALIGN (24 /* FIX MEEEE!!! */ + entry->d_reclen);
#endif
+ return size;
}
+#ifdef THREAD_UNSAFE_BASENAME
+char *basename_r(const char *);
+#define basename(path) basename_r(path)
+#endif /* THREAD_UNSAFE_BASENAME */
+
+#ifdef THREAD_UNSAFE_DIRNAME
+char *dirname_r(char *path);
+#define dirname(path) dirname_r(path)
+#endif /* THREAD_UNSAFE_DIRNAME */
+
+int gf_mkostemp (char *tmpl, int suffixlen, int flags);
+#define mkostemp(tmpl, flags) gf_mkostemp(tmpl, 0, flags);
#ifdef HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC
/* Linux, Solaris, Cygwin */
@@ -367,4 +394,9 @@ dirent_size (struct dirent *entry)
#define IXDR_PUT_U_LONG(buf, v) IXDR_PUT_LONG(buf, (long)(v))
#endif
+#if defined(__GNUC__) && !defined(RELAX_POISONING)
+/* Use run API, see run.h */
+#pragma GCC poison system popen
+#endif
+
#endif /* __COMPAT_H__ */