summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/run.c
diff options
context:
space:
mode:
authorKaleb S. KEITHLEY <kkeithle@redhat.com>2015-10-01 16:28:58 -0400
committerJeff Darcy <jdarcy@redhat.com>2015-11-16 06:18:10 -0800
commit2099cc875a4d20ab1bb12b1c33da16c95968e202 (patch)
tree78b611ee025511a06f28e8d5e63453f1dc5d8f1d /libglusterfs/src/run.c
parent3f0c70f2d56743707699f6a5b62a1c2c2d5c6f85 (diff)
core: use syscall wrappers instead of direct syscalls - libglusterfs
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: Ieeca2d36adbc884e4cfa0026dba40df70310d40b BUG: 1267967 Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com> Reviewed-on: http://review.gluster.org/12275 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Diffstat (limited to 'libglusterfs/src/run.c')
-rw-r--r--libglusterfs/src/run.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/libglusterfs/src/run.c b/libglusterfs/src/run.c
index 6018a58ad5f..cb709546637 100644
--- a/libglusterfs/src/run.c
+++ b/libglusterfs/src/run.c
@@ -24,6 +24,7 @@
#include <signal.h>
#include <sys/wait.h>
#include <sys/resource.h>
+#include "syscall.h"
#ifdef RUN_STANDALONE
#define GF_CALLOC(n, s, t) calloc(n, s)
@@ -241,18 +242,18 @@ runner_start (runner_t *runner)
switch (runner->chpid) {
case -1:
errno_priv = errno;
- close (xpi[0]);
- close (xpi[1]);
+ sys_close (xpi[0]);
+ sys_close (xpi[1]);
for (i = 0; i < 3; i++) {
- close (pi[i][0]);
- close (pi[i][1]);
+ sys_close (pi[i][0]);
+ sys_close (pi[i][1]);
}
errno = errno_priv;
return -1;
case 0:
for (i = 0; i < 3; i++)
- close (pi[i][i ? 0 : 1]);
- close (xpi[0]);
+ sys_close (pi[i][i ? 0 : 1]);
+ sys_close (xpi[0]);
ret = 0;
for (i = 0; i < 3; i++) {
@@ -278,15 +279,15 @@ runner_start (runner_t *runner)
struct dirent *de = NULL;
char *e = NULL;
- d = opendir ("/proc/self/fd");
+ d = sys_opendir ("/proc/self/fd");
if (d) {
- while ((de = readdir (d))) {
+ while ((de = sys_readdir (d))) {
i = strtoul (de->d_name, &e, 10);
if (*e == '\0' && i > 2 &&
i != dirfd (d) && i != xpi[1])
- close (i);
+ sys_close (i);
}
- closedir (d);
+ sys_closedir (d);
} else
ret = -1;
#else /* !GF_LINUX_HOST_OS */
@@ -296,7 +297,7 @@ runner_start (runner_t *runner)
for (i = 3; i < rl.rlim_cur; i++) {
if (i != xpi[1])
- close (i);
+ sys_close (i);
}
#endif /* !GF_LINUX_HOST_OS */
}
@@ -308,14 +309,14 @@ runner_start (runner_t *runner)
execvp (runner->argv[0], runner->argv);
}
- ret = write (xpi[1], &errno, sizeof (errno));
+ ret = sys_write (xpi[1], &errno, sizeof (errno));
_exit (1);
}
errno_priv = errno;
for (i = 0; i < 3; i++)
- close (pi[i][i ? 1 : 0]);
- close (xpi[1]);
+ sys_close (pi[i][i ? 1 : 0]);
+ sys_close (xpi[1]);
if (ret == -1) {
for (i = 0; i < 3; i++) {
if (runner->chio[i]) {
@@ -324,8 +325,8 @@ runner_start (runner_t *runner)
}
}
} else {
- ret = read (xpi[0], (char *)&errno_priv, sizeof (errno_priv));
- close (xpi[0]);
+ ret = sys_read (xpi[0], (char *)&errno_priv, sizeof (errno_priv));
+ sys_close (xpi[0]);
if (ret <= 0)
return 0;
GF_ASSERT (ret == sizeof (errno_priv));
@@ -371,7 +372,7 @@ runner_end (runner_t *runner)
GF_FREE (runner->argv);
}
for (i = 0; i < 3; i++)
- close (runner->chfd[i]);
+ sys_close (runner->chfd[i]);
return ret;
}