diff options
| -rw-r--r-- | configure.ac | 2 | ||||
| -rw-r--r-- | libglusterfs/src/syscall.c | 5 | ||||
| -rw-r--r-- | xlators/features/index/src/index.c | 20 | 
3 files changed, 26 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index 7bfee047ae2..be1ec7ab670 100644 --- a/configure.ac +++ b/configure.ac @@ -598,7 +598,7 @@ dnl FreeBSD, NetBSD  AC_CHECK_MEMBERS([struct stat.st_atimespec.tv_nsec])  case $host_os in          *netbsd*) -        CFLAGS+=" -D_INCOMPLETE_XOPEN_C063" +        CFLAGS="${CFLAGS} -D_INCOMPLETE_XOPEN_C063"          ;;  esac  AC_CHECK_FUNC([linkat], [have_linkat=yes]) diff --git a/libglusterfs/src/syscall.c b/libglusterfs/src/syscall.c index e8954cc237c..a619f9c41a6 100644 --- a/libglusterfs/src/syscall.c +++ b/libglusterfs/src/syscall.c @@ -120,7 +120,12 @@ sys_rename (const char *oldpath, const char *newpath)  int  sys_link (const char *oldpath, const char *newpath)  { +#ifdef HAVE_LINKAT  +        /* see HAVE_LINKAT in xlators/storage/posix/src/posix.c */ +        return linkat (AT_FDCWD, oldpath, AT_FDCWD, newpath, 0); +#else          return link (oldpath, newpath); +#endif  } diff --git a/xlators/features/index/src/index.c b/xlators/features/index/src/index.c index fde0893ec48..6c634dd9ad1 100644 --- a/xlators/features/index/src/index.c +++ b/xlators/features/index/src/index.c @@ -407,7 +407,12 @@ sync_base_indices (void *index_priv)                      snprintf (base_index_path, PATH_MAX, "%s/%s",                                base_indices_holder, entry->d_name); +#ifdef HAVE_LINKAT +                    /* see HAVE_LINKAT in xlators/storage/posix/src/posix.c */ +                    ret = linkat (AT_FDCWD, xattrop_index_path, AT_FDCWD, base_index_path, 0); +#else                      ret = link (xattrop_index_path, base_index_path); +#endif                      if (ret && errno != EEXIST)                          goto out; @@ -543,7 +548,12 @@ index_add (xlator_t *this, uuid_t gfid, const char *subdir)          index_get_index (priv, index);          make_index_path (priv->index_basepath, subdir,                           index, index_path, sizeof (index_path)); +#ifdef HAVE_LINKAT +        /* see HAVE_LINKAT in xlators/storage/posix/src/posix.c */ +        ret = linkat (AT_FDCWD, index_path, AT_FDCWD, gfid_path, 0); +#else          ret = link (index_path, gfid_path); +#endif          if (!ret || (errno == EEXIST))  {                  ret = 0;                  index_created = 1; @@ -576,7 +586,12 @@ index_add (xlator_t *this, uuid_t gfid, const char *subdir)          if (fd >= 0)                  close (fd); +#ifdef HAVE_LINKAT +        /* see HAVE_LINKAT in xlators/storage/posix/src/posix.c */ +        ret = linkat (AT_FDCWD, index_path, AT_FDCWD, gfid_path, 0); +#else          ret = link (index_path, gfid_path); +#endif          if (ret && (errno != EEXIST)) {                  gf_log (this->name, GF_LOG_ERROR, "%s: Not able to "                          "add to index (%s)", uuid_utoa (gfid), @@ -590,7 +605,12 @@ index_add (xlator_t *this, uuid_t gfid, const char *subdir)                   make_index_path (priv->index_basepath,                                    GF_BASE_INDICES_HOLDER_GFID,                                    index, base_path, sizeof (base_path)); +#ifdef HAVE_LINKAT +                 /* see HAVE_LINKAT in xlators/storage/posix/src/posix.c */ +                 ret = linkat (AT_FDCWD, index_path, AT_FDCWD, base_path, 0); +#else                   ret = link (index_path, base_path); +#endif                   if (ret)                           goto out;          }  | 
