$NetBSD: patch-bf,v 1.6 2011/07/23 01:14:44 manu Exp $

basename() and dirname() are not supposed to be thread-safe, and NetBSD's
implementation is not. glusterfs assume the functions are thread-safe. 
Borrow basename() and rdirname() form glibc and make NetBSD use them.

--- libglusterfs/src/compat.h.orig	2011-08-23 14:31:37.000000000 +0200
+++ libglusterfs/src/compat.h	2011-09-17 15:45:29.000000000 +0200
@@ -57,26 +57,31 @@
 #endif /* HAVE_LLISTXATTR */
 #endif /* GF_LINUX_HOST_OS */
 
 #ifdef GF_BSD_HOST_OS
-/* In case of FreeBSD */
+/* In case of FreeBSD and NetBSD */
 
 #define UNIX_PATH_MAX 104
 #include <sys/types.h>
 
 #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
 #define sighandler_t sig_t
@@ -110,8 +115,15 @@
 #define F_GETLK64       F_GETLK
 #define F_SETLK64       F_SETLK
 #define F_SETLKW64      F_SETLKW
 
+#ifdef __NetBSD__
+char *basename_r(const char *);
+char *dirname_r(char *);
+
+#define basename(path) basename_r(path)
+#define dirname(path) dirname_r(path)
+#endif /* __NetBSD__ */
 #endif /* GF_BSD_HOST_OS */
 
 #ifdef GF_DARWIN_HOST_OS
 
