summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-store.c
diff options
context:
space:
mode:
authorKaleb S. KEITHLEY <kkeithle@redhat.com>2015-10-16 13:52:28 -0400
committerJeff Darcy <jdarcy@redhat.com>2015-10-28 06:55:04 -0700
commit063d4ead61ee47433793de81a1c77e0ba69e6e07 (patch)
tree484f5fe3093d7eec12a282f77e2df496afff6ee2 /xlators/mgmt/glusterd/src/glusterd-store.c
parent641b3a9164227db52df1aab05795c90d06b315f2 (diff)
core: use syscall wrappers instead of direct syscalls -- glusterd
various xlators and other components are invoking system calls directly instead of using the libglusterfs/syscall.[ch] wrappers. If not using the system call wrappers there should be a comment in the source explaining why the wrapper isn't used. Change-Id: I28bf2a5f7730b35914e7ab57fed91e1966b30073 BUG: 1267967 Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com> Reviewed-on: http://review.gluster.org/12379 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-store.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c57
1 files changed, 29 insertions, 28 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index d93f51bf63e..75131b28cbf 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -20,6 +20,7 @@
#include "xlator.h"
#include "logging.h"
#include "timer.h"
+#include "syscall.h"
#include "defaults.h"
#include "compat.h"
#include "compat-errno.h"
@@ -596,7 +597,7 @@ glusterd_store_delete_brick (glusterd_brickinfo_t *brickinfo, char *delete_path)
GF_FREE (tmppath);
- ret = unlink (brickpath);
+ ret = sys_unlink (brickpath);
if ((ret < 0) && (errno != ENOENT)) {
gf_msg_debug (this->name, 0, "Unlink failed on %s",
@@ -645,14 +646,14 @@ glusterd_store_remove_bricks (glusterd_volinfo_t *volinfo, char *delete_path)
snprintf (brickdir, sizeof (brickdir), "%s/%s", delete_path,
GLUSTERD_BRICK_INFO_DIR);
- dir = opendir (brickdir);
+ dir = sys_opendir (brickdir);
GF_FOR_EACH_ENTRY_IN_DIR (entry, dir);
while (entry) {
snprintf (path, sizeof (path), "%s/%s",
brickdir, entry->d_name);
- ret = unlink (path);
+ ret = sys_unlink (path);
if (ret && errno != ENOENT) {
gf_msg_debug (this->name, 0, "Unable to unlink %s",
path);
@@ -660,9 +661,9 @@ glusterd_store_remove_bricks (glusterd_volinfo_t *volinfo, char *delete_path)
GF_FOR_EACH_ENTRY_IN_DIR (entry, dir);
}
- closedir (dir);
+ sys_closedir (dir);
- ret = rmdir (brickdir);
+ ret = sys_rmdir (brickdir);
out:
gf_msg_debug (this->name, 0, "Returning with %d", ret);
@@ -1659,7 +1660,7 @@ glusterd_store_delete_volume (glusterd_volinfo_t *volinfo)
snprintf (trashdir, sizeof (trashdir), "%s/"GLUSTERD_TRASH,
priv->workdir);
- ret = mkdir (trashdir, 0777);
+ ret = sys_mkdir (trashdir, 0777);
if (ret && errno != EEXIST) {
gf_msg (this->name, GF_LOG_ERROR, errno,
GD_MSG_CREATE_DIR_FAILED, "Failed to create trash "
@@ -1668,7 +1669,7 @@ glusterd_store_delete_volume (glusterd_volinfo_t *volinfo)
goto out;
}
- ret = rename (pathname, delete_path);
+ ret = sys_rename (pathname, delete_path);
if (ret) {
gf_msg (this->name, GF_LOG_ERROR, errno,
GD_MSG_DIR_OP_FAILED, "Failed to rename volume "
@@ -1725,7 +1726,7 @@ glusterd_store_delete_snap (glusterd_snap_t *snap)
snprintf (trashdir, sizeof (trashdir), "%s/"GLUSTERD_TRASH,
priv->workdir);
- ret = mkdir (trashdir, 0777);
+ ret = sys_mkdir (trashdir, 0777);
if (ret && errno != EEXIST) {
gf_msg (this->name, GF_LOG_ERROR, errno,
GD_MSG_CREATE_DIR_FAILED, "Failed to create trash "
@@ -1734,7 +1735,7 @@ glusterd_store_delete_snap (glusterd_snap_t *snap)
goto out;
}
- ret = rename (pathname, delete_path);
+ ret = sys_rename (pathname, delete_path);
if (ret) {
gf_msg (this->name, GF_LOG_ERROR, errno,
GD_MSG_DIR_OP_FAILED, "Failed to rename snap "
@@ -1743,7 +1744,7 @@ glusterd_store_delete_snap (glusterd_snap_t *snap)
goto out;
}
- dir = opendir (delete_path);
+ dir = sys_opendir (delete_path);
if (!dir) {
gf_msg_debug (this->name, 0, "Failed to open directory %s.",
delete_path);
@@ -1754,7 +1755,7 @@ glusterd_store_delete_snap (glusterd_snap_t *snap)
GF_FOR_EACH_ENTRY_IN_DIR (entry, dir);
while (entry) {
snprintf (path, PATH_MAX, "%s/%s", delete_path, entry->d_name);
- ret = stat (path, &st);
+ ret = sys_stat (path, &st);
if (ret == -1) {
gf_msg_debug (this->name, 0, "Failed to stat "
"entry %s", path);
@@ -1762,9 +1763,9 @@ glusterd_store_delete_snap (glusterd_snap_t *snap)
}
if (S_ISDIR (st.st_mode))
- ret = rmdir (path);
+ ret = sys_rmdir (path);
else
- ret = unlink (path);
+ ret = sys_unlink (path);
if (ret) {
gf_msg_debug (this->name, 0, " Failed to remove "
@@ -1779,18 +1780,18 @@ stat_failed:
GF_FOR_EACH_ENTRY_IN_DIR (entry, dir);
}
- ret = closedir (dir);
+ ret = sys_closedir (dir);
if (ret) {
gf_msg_debug (this->name, 0, "Failed to close dir %s.",
delete_path);
}
- ret = rmdir (delete_path);
+ ret = sys_rmdir (delete_path);
if (ret) {
gf_msg_debug (this->name, 0, "Failed to rmdir: %s",
delete_path);
}
- ret = rmdir (trashdir);
+ ret = sys_rmdir (trashdir);
if (ret) {
gf_msg_debug (this->name, 0, "Failed to rmdir: %s",
trashdir);
@@ -1840,7 +1841,7 @@ glusterd_store_global_info (xlator_t *this)
handle = conf->handle;
/* These options need to be available for all users */
- ret = chmod (handle->path, 0644);
+ ret = sys_chmod (handle->path, 0644);
if (ret) {
gf_msg (this->name, GF_LOG_ERROR, errno,
GD_MSG_FILE_OP_FAILED, "chmod error for %s",
@@ -2993,7 +2994,7 @@ glusterd_store_retrieve_volumes (xlator_t *this, glusterd_snap_t *snap)
snprintf (path, PATH_MAX, "%s/%s", priv->workdir,
GLUSTERD_VOLUME_DIR_PREFIX);
- dir = opendir (path);
+ dir = sys_opendir (path);
if (!dir) {
gf_msg (this->name, GF_LOG_ERROR, errno,
@@ -3036,7 +3037,7 @@ next:
out:
if (dir)
- closedir (dir);
+ sys_closedir (dir);
gf_msg_debug (this->name, 0, "Returning with %d", ret);
return ret;
@@ -3201,7 +3202,7 @@ glusterd_recreate_vol_brick_mounts (xlator_t *this,
/* Check if the brickinfo path is present.
* If not create the brick_mount_path */
- ret = lstat (brickinfo->path, &st_buf);
+ ret = sys_lstat (brickinfo->path, &st_buf);
if (ret) {
if (errno == ENOENT) {
ret = mkdir_p (brick_mount_path, 0777,
@@ -3536,7 +3537,7 @@ glusterd_store_retrieve_snaps (xlator_t *this)
snprintf (path, PATH_MAX, "%s/snaps", priv->workdir);
- dir = opendir (path);
+ dir = sys_opendir (path);
if (!dir) {
/* If snaps dir doesn't exists ignore the error for
@@ -3576,7 +3577,7 @@ glusterd_store_retrieve_snaps (xlator_t *this)
out:
if (dir)
- closedir (dir);
+ sys_closedir (dir);
gf_msg_debug (this->name, 0, "Returning with %d", ret);
return ret;
@@ -3732,13 +3733,13 @@ glusterd_store_delete_peerinfo (glusterd_peerinfo_t *peerinfo)
snprintf (hostname_path, PATH_MAX, "%s/%s",
peerdir, peerinfo->hostname);
- ret = unlink (hostname_path);
+ ret = sys_unlink (hostname_path);
if (!ret)
goto out;
}
- ret = unlink (filepath);
+ ret = sys_unlink (filepath);
if (ret && (errno == ENOENT))
ret = 0;
@@ -3841,12 +3842,12 @@ glusterd_peerinfo_hostname_shandle_check_destroy (glusterd_peerinfo_t *peerinfo)
glusterd_store_hostname_peerpath_set (peerinfo, peerfpath,
sizeof (peerfpath));
- ret = stat (peerfpath, &stbuf);
+ ret = sys_stat (peerfpath, &stbuf);
if (!ret) {
if (peerinfo->shandle)
gf_store_handle_destroy (peerinfo->shandle);
peerinfo->shandle = NULL;
- ret = unlink (peerfpath);
+ ret = sys_unlink (peerfpath);
}
return ret;
}
@@ -3979,7 +3980,7 @@ glusterd_store_retrieve_peers (xlator_t *this)
snprintf (path, PATH_MAX, "%s/%s", priv->workdir,
GLUSTERD_PEER_DIR_PREFIX);
- dir = opendir (path);
+ dir = sys_opendir (path);
if (!dir) {
gf_msg (this->name, GF_LOG_ERROR, errno,
@@ -4087,7 +4088,7 @@ out:
glusterd_peerinfo_cleanup (peerinfo);
if (dir)
- closedir (dir);
+ sys_closedir (dir);
gf_msg_debug (this->name, 0, "Returning with %d", ret);
return ret;