summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
Diffstat (limited to 'xlators')
-rw-r--r--xlators/features/index/src/index.c32
-rw-r--r--xlators/storage/posix/src/posix-handle.c23
-rw-r--r--xlators/storage/posix/src/posix.c15
3 files changed, 13 insertions, 57 deletions
diff --git a/xlators/features/index/src/index.c b/xlators/features/index/src/index.c
index 4ba72c022..db592719b 100644
--- a/xlators/features/index/src/index.c
+++ b/xlators/features/index/src/index.c
@@ -16,6 +16,7 @@
#include "options.h"
#include "glusterfs3-xdr.h"
#include "syncop.h"
+#include "syscall.h"
#define XATTROP_SUBDIR "xattrop"
#define BASE_INDICES_HOLDER_SUBDIR "base_indices_holder"
@@ -407,13 +408,8 @@ 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
+ ret = sys_link (xattrop_index_path, base_index_path);
+
if (ret && errno != EEXIST)
goto out;
@@ -549,12 +545,8 @@ 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
+
+ ret = sys_link (index_path, gfid_path);
if (!ret || (errno == EEXIST)) {
ret = 0;
index_created = 1;
@@ -587,12 +579,7 @@ 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
+ ret = sys_link (index_path, gfid_path);
if (ret && (errno != EEXIST)) {
gf_log (this->name, GF_LOG_ERROR, "%s: Not able to "
"add to index (%s)", uuid_utoa (gfid),
@@ -606,12 +593,7 @@ 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
+ ret = sys_link (index_path, base_path);
if (ret)
goto out;
}
diff --git a/xlators/storage/posix/src/posix-handle.c b/xlators/storage/posix/src/posix-handle.c
index 1d8e98631..613709fc8 100644
--- a/xlators/storage/posix/src/posix-handle.c
+++ b/xlators/storage/posix/src/posix-handle.c
@@ -701,16 +701,8 @@ posix_handle_hard (xlator_t *this, const char *oldpath, uuid_t gfid, struct stat
return -1;
}
-#ifdef HAVE_LINKAT
- /*
- * Use linkat if the target may be a symlink to a directory
- * or without an existing target. See comment about linkat()
- * usage in posix_link() in posix.c for details
- */
- ret = linkat (AT_FDCWD, oldpath, AT_FDCWD, newpath, 0);
-#else
- ret = link (oldpath, newpath);
-#endif
+ ret = sys_link (oldpath, newpath);
+
if (ret) {
gf_log (this->name, GF_LOG_WARNING,
"link %s -> %s failed (%s)",
@@ -882,16 +874,7 @@ posix_create_link_if_gfid_exists (xlator_t *this, uuid_t gfid,
MAKE_HANDLE_PATH (newpath, this, gfid, NULL);
ret = lstat (newpath, &stbuf);
if (!ret) {
-#ifdef HAVE_LINKAT
- /*
- * Use linkat if the target may be a symlink to a directory
- * or without an existing target. See comment about linkat()
- * usage in posix_link() in posix.c for details
- */
- ret = linkat (AT_FDCWD, newpath, AT_FDCWD, real_path, 0);
-#else
- ret = link (newpath, real_path);
-#endif
+ ret = sys_link (newpath, real_path);
}
return ret;
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index dc4af1b92..83b689d06 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -1930,18 +1930,9 @@ posix_link (call_frame_t *frame, xlator_t *this,
goto out;
}
-#ifdef HAVE_LINKAT
- /*
- * On most systems (Linux being the notable exception), link(2)
- * first resolves symlinks. If the target is a directory or
- * is nonexistent, it will fail. linkat(2) operates on the
- * symlink instead of its target when the AT_SYMLINK_FOLLOW
- * flag is not supplied.
- */
- op_ret = linkat (AT_FDCWD, real_oldpath, AT_FDCWD, real_newpath, 0);
-#else
- op_ret = link (real_oldpath, real_newpath);
-#endif
+
+ op_ret = sys_link (real_oldpath, real_newpath);
+
if (op_ret == -1) {
op_errno = errno;
gf_log (this->name, GF_LOG_ERROR,