diff options
| author | Kaleb S. KEITHLEY <kkeithle@redhat.com> | 2015-10-01 16:31:19 -0400 | 
|---|---|---|
| committer | Jeff Darcy <jdarcy@redhat.com> | 2015-10-28 13:38:42 -0700 | 
| commit | 3066a21caafab6305527991de11c8eb43ec0044c (patch) | |
| tree | 5efc91272ac76ff1613cee1e8a41aeb32aa92d73 | |
| parent | 063d4ead61ee47433793de81a1c77e0ba69e6e07 (diff) | |
core: use syscall wrappers instead of direct syscalls - miscellaneous
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: I1f47820534c890a00b452fa61f7438eb2b3f667c
BUG: 1267967
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
Reviewed-on: http://review.gluster.org/12276
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
24 files changed, 263 insertions, 245 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index 73579a5581b..4cff9e9e7c0 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -1123,7 +1123,7 @@ gf_cli_create_auxiliary_mount (char *volname)          }          GLUSTERD_GET_QUOTA_AUX_MOUNT_PATH (mountdir, volname, "/"); -        ret = mkdir (mountdir, 0777); +        ret = sys_mkdir (mountdir, 0777);          if (ret && errno != EEXIST) {                  gf_log ("cli", GF_LOG_ERROR, "Failed to create auxiliary mount "                          "directory %s. Reason : %s", mountdir, @@ -1253,9 +1253,10 @@ _limits_set_on_volume (char *volname, int type) {          /* TODO: fix hardcoding; Need to perform an RPC call to glusterd           * to fetch working directory           */ -        sprintf (quota_conf_file, "%s/vols/%s/quota.conf", -                 GLUSTERD_DEFAULT_WORKDIR, -                 volname); +        snprintf (quota_conf_file, sizeof quota_conf_file, +                  "%s/vols/%s/quota.conf", +                  GLUSTERD_DEFAULT_WORKDIR, +                  volname);          fd = open (quota_conf_file, O_RDONLY);          if (fd == -1)                  goto out; @@ -1283,7 +1284,7 @@ _limits_set_on_volume (char *volname, int type) {          }  out:          if (fd != -1) -                close (fd); +                sys_close (fd);          return limits_set;  } @@ -1421,9 +1422,10 @@ cli_cmd_quota_handle_list_all (const char **words, dict_t *options)          //TODO: fix hardcoding; Need to perform an RPC call to glusterd          //to fetch working directory -        sprintf (quota_conf_file, "%s/vols/%s/quota.conf", -                 GLUSTERD_DEFAULT_WORKDIR, -                 volname); +        snprintf (quota_conf_file, sizeof quota_conf_file, +                  "%s/vols/%s/quota.conf", +                  GLUSTERD_DEFAULT_WORKDIR, +                  volname);          fd = open (quota_conf_file, O_RDONLY);          if (fd == -1) {                  //This may because no limits were yet set on the volume @@ -1504,7 +1506,7 @@ out:          }          if (fd != -1) { -                close (fd); +                sys_close (fd);          }          GF_FREE (gfid_str); diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 553a94a219a..562c176a2f9 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -5280,7 +5280,7 @@ write_contents_to_common_pem_file (dict_t *dict, int output_count)                    "%s/geo-replication/common_secret.pem.pub",                    workdir); -        unlink (common_pem_file); +        sys_unlink (common_pem_file);          fd = open (common_pem_file, O_WRONLY | O_CREAT, 0600);          if (fd == -1) { @@ -5302,7 +5302,7 @@ write_contents_to_common_pem_file (dict_t *dict, int output_count)                          cli_out ("Unable to fetch output.");                  }                  if (output) { -                        bytes_written = write (fd, output, strlen(output)); +                        bytes_written = sys_write (fd, output, strlen(output));                          if (bytes_written != strlen(output)) {                                  gf_log ("", GF_LOG_ERROR, "Failed to write "                                          "to %s", common_pem_file); @@ -5310,7 +5310,7 @@ write_contents_to_common_pem_file (dict_t *dict, int output_count)                                  goto out;                          }                          /* Adding the new line character */ -                        bytes_written = write (fd, "\n", strlen("\n")); +                        bytes_written = sys_write (fd, "\n", strlen("\n"));                          if (bytes_written != strlen("\n")) {                                  gf_log ("", GF_LOG_ERROR,                                          "Failed to add new line char"); @@ -5325,7 +5325,7 @@ write_contents_to_common_pem_file (dict_t *dict, int output_count)          ret = 0;  out:          if (fd >= 0) -                close (fd); +                sys_close (fd);          gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);          return ret; @@ -10488,7 +10488,7 @@ gf_cli_get_vol_opt_cbk (struct rpc_req *req, struct iovec *iov, int count,          cli_out ("%-40s%-40s", "Option", "Value");          cli_out ("%-40s%-40s", "------", "-----");          for (i=1; i<=count; i++) { -                sprintf (dict_key, "key%d", i); +                snprintf (dict_key, sizeof dict_key, "key%d", i);                  ret = dict_get_str (dict, dict_key, &key);                  if (ret) {                          gf_log ("cli", GF_LOG_ERROR, "Failed to" @@ -10496,7 +10496,7 @@ gf_cli_get_vol_opt_cbk (struct rpc_req *req, struct iovec *iov, int count,                                  "dictionary", dict_key);                          goto out;                  } -                sprintf (dict_key, "value%d", i); +                snprintf (dict_key, sizeof dict_key, "value%d", i);                  ret = dict_get_str (dict, dict_key, &value);                  if (ret) {                          gf_log ("cli", GF_LOG_ERROR, "Failed to " diff --git a/cli/src/cli.c b/cli/src/cli.c index 5707d3fbdd7..46736bbf76d 100644 --- a/cli/src/cli.c +++ b/cli/src/cli.c @@ -405,7 +405,7 @@ parse_cmdline (int argc, char *argv[], struct cli_state *state)          state->argv=&argv[1];          /* Do this first so that an option can override. */ -        if (access(SECURE_ACCESS_FILE,F_OK) == 0) { +        if (sys_access (SECURE_ACCESS_FILE, F_OK) == 0) {                  state->ctx->secure_mgmt = 1;          } diff --git a/geo-replication/src/gsyncd.c b/geo-replication/src/gsyncd.c index c9c863ca2fd..1beeda1380c 100644 --- a/geo-replication/src/gsyncd.c +++ b/geo-replication/src/gsyncd.c @@ -7,6 +7,8 @@     later), or the GNU General Public License, version 2 (GPLv2), in all     cases as published by the Free Software Foundation.  */ +#include "compat.h" +#include "syscall.h"  #include <stdlib.h>  #include <stdio.h> @@ -189,12 +191,12 @@ find_gsyncd (pid_t pid, pid_t ppid, char *name, void *data)          if (ppid != pida[0])                  return 0; -        sprintf (path, PROC"/%d/cmdline", pid); +        snprintf (path, sizeof path, PROC"/%d/cmdline", pid);          fd = open (path, O_RDONLY);          if (fd == -1)                  return 0; -        ret = read (fd, buf, sizeof (buf)); -        close (fd); +        ret = sys_read (fd, buf, sizeof (buf)); +        sys_close (fd);          if (ret == -1)                  return 0;          for (zeros = 0, p = buf; zeros < 2 && p < buf + ret; p++) @@ -270,8 +272,8 @@ invoke_rsync (int argc, char **argv)                  goto error;          }          /* check if rsync target matches gsyncd target */ -        sprintf (path, PROC"/%d/cwd", pida[1]); -        ret = readlink (path, buf, sizeof (buf)); +        snprintf (path, sizeof path, PROC"/%d/cwd", pida[1]); +        ret = sys_readlink (path, buf, sizeof (buf));          if (ret == -1 || ret == sizeof (buf))                  goto error;          if (strcmp (argv[argc - 1], "/") == 0 /* root dir cannot be a target */ || diff --git a/geo-replication/src/procdiggy.c b/geo-replication/src/procdiggy.c index d9253bbb89e..1ea52c1a6a1 100644 --- a/geo-replication/src/procdiggy.c +++ b/geo-replication/src/procdiggy.c @@ -16,6 +16,7 @@  #include <sys/param.h> /* for PATH_MAX */  #include "common-utils.h" +#include "syscall.h"  #include "procdiggy.h"  pid_t @@ -27,7 +28,7 @@ pidinfo (pid_t pid, char **name)          char *p                = NULL;          int ret                = 0; -        sprintf (path, PROC"/%d/status", pid); +        snprintf (path, sizeof path, PROC"/%d/status", pid);          f = fopen (path, "r");          if (!f) @@ -89,10 +90,10 @@ prociter (int (*proch) (pid_t pid, pid_t ppid, char *tmpname, void *data),          pid_t ppid        = -1;          int ret           = 0; -        d = opendir (PROC); +        d = sys_opendir (PROC);          if (!d)                  return -1; -        while (errno = 0, de = readdir (d)) { +        while (errno = 0, de = sys_readdir (d)) {                  if (gf_string2int (de->d_name, &pid) != -1 && pid >= 0) {                          ppid = pidinfo (pid, &name);                          switch (ppid) { @@ -105,7 +106,7 @@ prociter (int (*proch) (pid_t pid, pid_t ppid, char *tmpname, void *data),                                  break;                  }          } -        closedir (d); +        sys_closedir (d);          if (!de && errno) {                  fprintf (stderr, "failed to traverse "PROC" (%s)\n",                           strerror (errno)); diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c index 81c18ffc715..749873872d2 100644 --- a/glusterfsd/src/glusterfsd-mgmt.c +++ b/glusterfsd/src/glusterfsd-mgmt.c @@ -31,6 +31,7 @@  #include "statedump.h"  #include "syncop.h"  #include "xlator.h" +#include "syscall.h"  static gf_boolean_t is_mgmt_rpc_reconnect = _gf_false;  int need_emancipate = 0; @@ -399,12 +400,12 @@ glusterfs_volume_top_write_perf (uint32_t blk_size, uint32_t blk_count,          gettimeofday (&begin, NULL);          for (iter = 0; iter < blk_count; iter++) { -                ret = read (input_fd, buf, blk_size); +                ret = sys_read (input_fd, buf, blk_size);                  if (ret != blk_size) {                          ret = -1;                          goto out;                  } -                ret = write (fd, buf, blk_size); +                ret = sys_write (fd, buf, blk_size);                  if (ret != blk_size) {                          ret = -1;                          goto out; @@ -427,11 +428,11 @@ glusterfs_volume_top_write_perf (uint32_t blk_size, uint32_t blk_count,  out:          if (fd >= 0) -                close (fd); +                sys_close (fd);          if (input_fd >= 0) -                close (input_fd); +                sys_close (input_fd);          GF_FREE (buf); -        unlink (export_path); +        sys_unlink (export_path);          return ret;  } @@ -488,24 +489,24 @@ glusterfs_volume_top_read_perf (uint32_t blk_size, uint32_t blk_count,          }          for (iter = 0; iter < blk_count; iter++) { -                ret = read (input_fd, buf, blk_size); +                ret = sys_read (input_fd, buf, blk_size);                  if (ret != blk_size) {                          ret = -1;                          goto out;                  } -                ret = write (fd, buf, blk_size); +                ret = sys_write (fd, buf, blk_size);                  if (ret != blk_size) {                          ret = -1;                          goto out;                  }          } -        ret = fsync (fd); +        ret = sys_fsync (fd);          if (ret) {                  gf_log ("glusterd", GF_LOG_ERROR, "could not flush cache");                  goto out;          } -        ret = lseek (fd, 0L, 0); +        ret = sys_lseek (fd, 0L, 0);          if (ret != 0) {                  gf_log ("glusterd", GF_LOG_ERROR,                          "could not seek back to start"); @@ -514,12 +515,12 @@ glusterfs_volume_top_read_perf (uint32_t blk_size, uint32_t blk_count,          }          gettimeofday (&begin, NULL);          for (iter = 0; iter < blk_count; iter++) { -                ret = read (fd, buf, blk_size); +                ret = sys_read (fd, buf, blk_size);                  if (ret != blk_size) {                          ret = -1;                          goto out;                  } -                ret = write (output_fd, buf, blk_size); +                ret = sys_write (output_fd, buf, blk_size);                  if (ret != blk_size) {                          ret = -1;                          goto out; @@ -542,13 +543,13 @@ glusterfs_volume_top_read_perf (uint32_t blk_size, uint32_t blk_count,  out:          if (fd >= 0) -                close (fd); +                sys_close (fd);          if (input_fd >= 0) -                close (input_fd); +                sys_close (input_fd);          if (output_fd >= 0) -                close (output_fd); +                sys_close (output_fd);          GF_FREE (buf); -        unlink (export_path); +        sys_unlink (export_path);          return ret;  } @@ -1973,7 +1974,7 @@ glusterfs_listener_stop (glusterfs_ctx_t *ctx)          cmd_args = &ctx->cmd_args;          if (cmd_args->sock_file) { -                ret = unlink (cmd_args->sock_file); +                ret = sys_unlink (cmd_args->sock_file);                  if (ret && (ENOENT == errno)) {                          ret = 0;                  } diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c index 6ebcd6ce8c4..f767e28b18d 100644 --- a/glusterfsd/src/glusterfsd.c +++ b/glusterfsd/src/glusterfsd.c @@ -1322,8 +1322,8 @@ emancipate (glusterfs_ctx_t *ctx, int ret)  {          /* break free from the parent */          if (ctx->daemon_pipe[1] != -1) { -                write (ctx->daemon_pipe[1], (void *) &ret, sizeof (ret)); -                close (ctx->daemon_pipe[1]); +                sys_write (ctx->daemon_pipe[1], (void *) &ret, sizeof (ret)); +                sys_close (ctx->daemon_pipe[1]);                  ctx->daemon_pipe[1] = -1;          }  } @@ -1766,7 +1766,7 @@ parse_cmdline (int argc, char *argv[], glusterfs_ctx_t *ctx)          cmd_args = &ctx->cmd_args;          /* Do this before argp_parse so it can be overridden. */ -        if (access(SECURE_ACCESS_FILE,F_OK) == 0) { +        if (sys_access (SECURE_ACCESS_FILE, F_OK) == 0) {                  cmd_args->secure_mgmt = 1;          } @@ -1818,7 +1818,7 @@ parse_cmdline (int argc, char *argv[], glusterfs_ctx_t *ctx)                  /* Check if the volfile exists, if not give usage output                     and exit */ -                ret = stat (cmd_args->volfile, &stbuf); +                ret = sys_stat (cmd_args->volfile, &stbuf);                  if (ret) {                          gf_msg ("glusterfs", GF_LOG_CRITICAL, errno,                                  glusterfsd_msg_16); @@ -1923,7 +1923,7 @@ glusterfs_pidfile_cleanup (glusterfs_ctx_t *ctx)                        cmd_args->pid_file);          if (ctx->cmd_args.pid_file) { -                unlink (ctx->cmd_args.pid_file); +                sys_unlink (ctx->cmd_args.pid_file);                  ctx->cmd_args.pid_file = NULL;          } @@ -1954,7 +1954,7 @@ glusterfs_pidfile_update (glusterfs_ctx_t *ctx)                  return ret;          } -        ret = ftruncate (fileno (pidfp), 0); +        ret = sys_ftruncate (fileno (pidfp), 0);          if (ret) {                  gf_msg ("glusterfsd", GF_LOG_ERROR, errno, glusterfsd_msg_20,                          cmd_args->pid_file); @@ -2113,8 +2113,8 @@ daemonize (glusterfs_ctx_t *ctx)          switch (ret) {          case -1:                  if (ctx->daemon_pipe[0] != -1) { -                        close (ctx->daemon_pipe[0]); -                        close (ctx->daemon_pipe[1]); +                        sys_close (ctx->daemon_pipe[0]); +                        sys_close (ctx->daemon_pipe[1]);                  }                  gf_msg ("daemonize", GF_LOG_ERROR, errno, glusterfsd_msg_24); @@ -2122,12 +2122,12 @@ daemonize (glusterfs_ctx_t *ctx)          case 0:                  /* child */                  /* close read */ -                close (ctx->daemon_pipe[0]); +                sys_close (ctx->daemon_pipe[0]);                  break;          default:                  /* parent */                  /* close write */ -                close (ctx->daemon_pipe[1]); +                sys_close (ctx->daemon_pipe[1]);                  if (ctx->mnt_pid > 0) {                          ret = waitpid (ctx->mnt_pid, &cstatus, 0); @@ -2139,7 +2139,7 @@ daemonize (glusterfs_ctx_t *ctx)                  }                  err = 1; -                read (ctx->daemon_pipe[0], (void *)&err, sizeof (err)); +                sys_read (ctx->daemon_pipe[0], (void *)&err, sizeof (err));                  _exit (err);          } diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c index e57bea4a749..4d4d74af024 100644 --- a/rpc/rpc-transport/socket/src/socket.c +++ b/rpc/rpc-transport/socket/src/socket.c @@ -15,6 +15,7 @@  #include "rpc-transport.h"  #include "logging.h"  #include "xlator.h" +#include "syscall.h"  #include "byte-order.h"  #include "common-utils.h"  #include "compat-errno.h" @@ -380,7 +381,7 @@ __socket_ssl_readv (rpc_transport_t *this, struct iovec *opvector, int opcount)  	if (priv->use_ssl) {  		ret = ssl_read_one (this, opvector->iov_base, opvector->iov_len);  	} else { -		ret = readv (sock, opvector, IOV_MIN(opcount)); +		ret = sys_readv (sock, opvector, IOV_MIN(opcount));  	}  	return ret; @@ -538,7 +539,7 @@ __socket_rwv (rpc_transport_t *this, struct iovec *vector, int count,                                  ret = ssl_write_one (this, opvector->iov_base,                                                       opvector->iov_len);  			} else { -				ret = writev (sock, opvector, IOV_MIN(opcount)); +				ret = sys_writev (sock, opvector, IOV_MIN(opcount));  			}                          if (ret == 0 || (ret == -1 && errno == EAGAIN)) { @@ -701,7 +702,7 @@ __socket_disconnect (rpc_transport_t *this)                           * Without this, reconnect (= disconnect + connect)                           * won't work except by accident.                           */ -                        close(priv->sock); +                        sys_close (priv->sock);                          priv->sock = -1;                          gf_log (this->name, GF_LOG_TRACE,                                  "OT_PLEASE_DIE on %p", this); @@ -749,9 +750,9 @@ __socket_server_bind (rpc_transport_t *this)                          ret = connect (reuse_check_sock, SA (&unix_addr),                                         this->myinfo.sockaddr_len);                          if ((ret == -1) && (ECONNREFUSED == errno)) { -                                unlink (((struct sockaddr_un*)&unix_addr)->sun_path); +                                sys_unlink (((struct sockaddr_un *)&unix_addr)->sun_path);                          } -                        close (reuse_check_sock); +                        sys_close (reuse_check_sock);                  }          } @@ -1081,7 +1082,7 @@ __socket_ioq_churn_entry (rpc_transport_t *this, struct ioq *entry, int direct)  			 * more entries after this, so drain the byte  			 * representing this entry.  			 */ -			if (!direct && read(priv->pipe[0],&a_byte,1) < 1) { +			if (!direct && sys_read (priv->pipe[0], &a_byte, 1) < 1) {  				gf_log(this->name,GF_LOG_WARNING,  				       "read error on pipe");  			} @@ -2516,7 +2517,7 @@ err:                  ssl_teardown_connection(priv);          }          __socket_shutdown(this); -        close(priv->sock); +        sys_close (priv->sock);          priv->sock = -1;          priv->ot_state = OT_IDLE;          pthread_mutex_unlock(&priv->lock); @@ -2617,7 +2618,7 @@ socket_server_event_handler (int fd, int idx, void *data,                          new_trans = GF_CALLOC (1, sizeof (*new_trans),                                                 gf_common_mt_rpc_trans_t);                          if (!new_trans) { -                                close (new_sock); +                                sys_close (new_sock);                                  goto unlock;                          } @@ -2626,7 +2627,7 @@ socket_server_event_handler (int fd, int idx, void *data,                                  gf_log (this->name, GF_LOG_WARNING,                                          "pthread_mutex_init() failed: %s",                                          strerror (errno)); -                                close (new_sock); +                                sys_close (new_sock);                                  GF_FREE (new_trans);                                  goto unlock;                          } @@ -2648,7 +2649,7 @@ socket_server_event_handler (int fd, int idx, void *data,                                  gf_log (this->name, GF_LOG_WARNING,                                          "getsockname on %d failed (%s)",                                          new_sock, strerror (errno)); -                                close (new_sock); +                                sys_close (new_sock);                                  GF_FREE (new_trans->name);                                  GF_FREE (new_trans);                                  goto unlock; @@ -2657,7 +2658,7 @@ socket_server_event_handler (int fd, int idx, void *data,                          get_transport_identifiers (new_trans);                          ret = socket_init(new_trans);                          if (ret != 0) { -                                close(new_sock); +                                sys_close (new_sock);                                  GF_FREE (new_trans->name);                                  GF_FREE (new_trans);                                  goto unlock; @@ -2699,7 +2700,7 @@ socket_server_event_handler (int fd, int idx, void *data,                                  if (!cname) {  					gf_log(this->name,GF_LOG_ERROR,  					       "server setup failed"); -					close(new_sock); +					sys_close (new_sock);                                          GF_FREE (new_trans->name);                                          GF_FREE (new_trans);  					goto unlock; @@ -2715,7 +2716,7 @@ socket_server_event_handler (int fd, int idx, void *data,                                                  "NBIO on %d failed (%s)",                                                  new_sock, strerror (errno)); -                                        close (new_sock); +                                        sys_close (new_sock);                                          GF_FREE (new_trans->name);                                          GF_FREE (new_trans);                                          goto unlock; @@ -2756,7 +2757,7 @@ socket_server_event_handler (int fd, int idx, void *data,                          if (ret == -1) {                                  gf_log (this->name, GF_LOG_WARNING,                                          "failed to register the socket with event"); -                                close (new_sock); +                                sys_close (new_sock);                                  rpc_transport_unref (new_trans);                                  goto unlock;                          } @@ -3051,7 +3052,7 @@ socket_connect (rpc_transport_t *this, int port)  handler:                  if (ret < 0) {                          if (priv->own_thread) { -                                close(priv->sock); +                                sys_close (priv->sock);                                  priv->sock = -1;                          }                          else { @@ -3088,7 +3089,7 @@ handler:                          if (priv->idx == -1) {                                  gf_log ("", GF_LOG_WARNING,                                          "failed to register the event"); -                                close(priv->sock); +                                sys_close (priv->sock);                                  priv->sock = -1;                                  ret = -1;                          } @@ -3224,7 +3225,7 @@ socket_listen (rpc_transport_t *this)                                  gf_log (this->name, GF_LOG_ERROR,                                          "NBIO on %d failed (%s)",                                          priv->sock, strerror (errno)); -                                close (priv->sock); +                                sys_close (priv->sock);                                  priv->sock = -1;                                  goto unlock;                          } @@ -3234,7 +3235,7 @@ socket_listen (rpc_transport_t *this)                  if (ret == -1) {                          /* logged inside __socket_server_bind() */ -                        close (priv->sock); +                        sys_close (priv->sock);                          priv->sock = -1;                          goto unlock;                  } @@ -3248,7 +3249,7 @@ socket_listen (rpc_transport_t *this)                          gf_log (this->name, GF_LOG_ERROR,                                  "could not set socket %d to listen mode (%s)",                                  priv->sock, strerror (errno)); -                        close (priv->sock); +                        sys_close (priv->sock);                          priv->sock = -1;                          goto unlock;                  } @@ -3264,7 +3265,7 @@ socket_listen (rpc_transport_t *this)                                  "could not register socket %d with events",                                  priv->sock);                          ret = -1; -                        close (priv->sock); +                        sys_close (priv->sock);                          priv->sock = -1;                          goto unlock;                  } @@ -3329,7 +3330,7 @@ socket_submit_request (rpc_transport_t *this, rpc_transport_req_t *req)  				 * Make sure the polling thread wakes up, by  				 * writing a byte to represent this entry.  				 */ -				if (write(priv->pipe[1],&a_byte,1) < 1) { +				if (sys_write (priv->pipe[1], &a_byte, 1) < 1) {  					gf_log(this->name,GF_LOG_WARNING,  					       "write error on pipe");  				} @@ -3403,7 +3404,7 @@ socket_submit_reply (rpc_transport_t *this, rpc_transport_reply_t *reply)  				 * Make sure the polling thread wakes up, by  				 * writing a byte to represent this entry.  				 */ -				if (write(priv->pipe[1],&a_byte,1) < 1) { +				if (sys_write (priv->pipe[1], &a_byte, 1) < 1) {  					gf_log(this->name,GF_LOG_WARNING,  					       "write error on pipe");  				} diff --git a/tools/gfind_missing_files/gcrawler.c b/tools/gfind_missing_files/gcrawler.c index 6be8e48364d..35772b51582 100644 --- a/tools/gfind_missing_files/gcrawler.c +++ b/tools/gfind_missing_files/gcrawler.c @@ -364,7 +364,7 @@ xworker_do_crawl (struct xwork *xwork, struct dirjob *job)                  strcpy (gfid_path, slavemnt);                  strcat (gfid_path, "/.gfid/");                  strcat (gfid_path, result->d_name); -                ret = lstat (gfid_path, &statbuf); +                ret = sys_lstat (gfid_path, &statbuf);                  if (ret && errno == ENOENT) {                          out ("%s\n", result->d_name); diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c index fab4e2f0ece..c0e10f2dbc6 100644 --- a/xlators/cluster/dht/src/dht-rebalance.c +++ b/xlators/cluster/dht/src/dht-rebalance.c @@ -11,6 +11,7 @@  #include "dht-common.h"  #include "xlator.h" +#include "syscall.h"  #include <signal.h>  #include <fnmatch.h>  #include <signal.h> @@ -1718,7 +1719,7 @@ gf_listener_stop (xlator_t *this)          GF_ASSERT (ctx);          cmd_args = &ctx->cmd_args;          if (cmd_args->sock_file) { -                ret = unlink (cmd_args->sock_file); +                ret = sys_unlink (cmd_args->sock_file);                  if (ret && (ENOENT == errno)) {                          ret = 0;                  } diff --git a/xlators/cluster/dht/src/tier.c b/xlators/cluster/dht/src/tier.c index bd78e7849d0..9930fe063e1 100644 --- a/xlators/cluster/dht/src/tier.c +++ b/xlators/cluster/dht/src/tier.c @@ -12,6 +12,7 @@  #include "dht-common.h"  #include "tier.h" +#include "syscall.h"  /*Hard coded DB info*/  static gfdb_db_type_t dht_tier_db_type = GFDB_SQLITE3; @@ -1088,8 +1089,8 @@ tier_migrate_files_using_qfile (demotion_args_t *comp,          fclose (query_cbk_args->queryFILE);          query_cbk_args->queryFILE = NULL;          if (ret) { -                sprintf (renamed_file, "%s.err", qfile); -                rename (qfile, renamed_file); +                snprintf (renamed_file, sizeof renamed_file, "%s.err", qfile); +                sys_rename (qfile, renamed_file);          }  out:          return ret; @@ -1224,7 +1225,7 @@ tier_get_bricklist (xlator_t *xl, struct list_head *local_bricklist_head)                                  goto out;                          } -                        sprintf(local_brick->brick_db_path, "%s/%s/%s", rv, +                        snprintf(local_brick->brick_db_path, PATH_MAX, "%s/%s/%s", rv,                                  GF_HIDDEN_PATH,                                  db_name); @@ -1855,8 +1856,8 @@ tier_init (xlator_t *this)                  goto out;          } -        unlink (promotion_qfile); -        unlink (demotion_qfile); +        sys_unlink(promotion_qfile); +        sys_unlink(demotion_qfile);          gf_msg (this->name, GF_LOG_INFO, 0,                  DHT_MSG_LOG_TIER_STATUS, diff --git a/xlators/features/compress/src/cdc-helper.c b/xlators/features/compress/src/cdc-helper.c index 21f529c2652..0a9a0e3d29c 100644 --- a/xlators/features/compress/src/cdc-helper.c +++ b/xlators/features/compress/src/cdc-helper.c @@ -10,6 +10,7 @@  #include "glusterfs.h"  #include "logging.h" +#include "syscall.h"  #include "cdc.h"  #include "cdc-mem-types.h" @@ -166,17 +167,17 @@ cdc_dump_iovec_to_disk (xlator_t *this, cdc_info_t *ci, const char *file)                  return;          } -        written = write (fd, (char *) gzip_header, 10); +        written = sys_write (fd, (char *) gzip_header, 10);          total_written += written;          for (i = 0; i < ci->ncount; i++) { -                written = write (fd, (char *) ci->vec[i].iov_base, ci->vec[i].iov_len); +                written = sys_write (fd, (char *) ci->vec[i].iov_base, ci->vec[i].iov_len);                  total_written += written;          }          gf_log (this->name, GF_LOG_DEBUG,                          "dump'd %zu bytes to %s", total_written, GF_CDC_DEBUG_DUMP_FILE ); -        close (fd); +        sys_close (fd);  }  static int32_t diff --git a/xlators/features/index/src/index.c b/xlators/features/index/src/index.c index 2bba6630bde..5de8d9b4668 100644 --- a/xlators/features/index/src/index.c +++ b/xlators/features/index/src/index.c @@ -144,7 +144,7 @@ index_dir_create (xlator_t *this, const char *subdir)          priv = this->private;          make_index_dir_path (priv->index_basepath, subdir, fullpath,                               sizeof (fullpath)); -        ret = stat (fullpath, &st); +        ret = sys_stat (fullpath, &st);          if (!ret) {                  if (!S_ISDIR (st.st_mode))                          ret = -2; @@ -163,7 +163,7 @@ index_dir_create (xlator_t *this, const char *subdir)                          len = pathlen;                  strncpy (path, fullpath, len);                  path[len] = '\0'; -                ret = mkdir (path, 0600); +                ret = sys_mkdir (path, 0600);                  if (ret && (errno != EEXIST))                          goto out;          } @@ -236,9 +236,10 @@ make_file_path (char *base, const char *subdir, const char *filename,  static int  is_index_file_current (char *filename, uuid_t priv_index)  { -        char *current_index = alloca (strlen ("xattrop-") + GF_UUID_BUF_SIZE); +        char current_index[GF_UUID_BUF_SIZE + 16] = {0, }; -        sprintf (current_index, "xattrop-%s", uuid_utoa(priv_index)); +        snprintf (current_index, sizeof current_index, +                  "xattrop-%s", uuid_utoa(priv_index));          return (!strcmp(filename, current_index));  } @@ -257,9 +258,9 @@ check_delete_stale_index_file (xlator_t *this, char *filename)          make_file_path (priv->index_basepath, XATTROP_SUBDIR,                          filename, filepath, sizeof (filepath)); -        ret = stat (filepath, &st); +        ret = sys_stat (filepath, &st);          if (!ret && st.st_nlink == 1) -                unlink (filepath); +                sys_unlink (filepath);  }  static int @@ -370,7 +371,7 @@ index_fill_readdir (fd_t *fd, index_fd_ctx_t *fctx, DIR *dir, off_t off,                  count ++;          } -        if ((!readdir (dir) && (errno == 0))) { +        if ((!sys_readdir (dir) && (errno == 0))) {                  /* Indicate EOF */                  errno = ENOENT;                  /* Remember EOF offset for later detection */ @@ -399,7 +400,7 @@ index_add (xlator_t *this, uuid_t gfid, const char *subdir)          make_gfid_path (priv->index_basepath, subdir, gfid,                          gfid_path, sizeof (gfid_path)); -        ret = stat (gfid_path, &st); +        ret = sys_stat (gfid_path, &st);          if (!ret)                  goto out;          index_get_index (priv, index); @@ -424,7 +425,7 @@ index_add (xlator_t *this, uuid_t gfid, const char *subdir)                  goto out;          } -        fd = creat (index_path, 0); +        fd = sys_creat (index_path, 0);          if ((fd < 0) && (errno != EEXIST)) {                  ret = -1;                  gf_log (this->name, GF_LOG_ERROR, "%s: Not able to " @@ -434,7 +435,7 @@ index_add (xlator_t *this, uuid_t gfid, const char *subdir)          }          if (fd >= 0) -                close (fd); +                sys_close (fd);          ret = sys_link (index_path, gfid_path);          if (ret && (errno != EEXIST)) { @@ -462,7 +463,7 @@ index_del (xlator_t *this, uuid_t gfid, const char *subdir)                                         out, op_errno, EINVAL);          make_gfid_path (priv->index_basepath, subdir, gfid,                          gfid_path, sizeof (gfid_path)); -        ret = unlink (gfid_path); +        ret = sys_unlink (gfid_path);          if (ret && (errno != ENOENT)) {                  gf_log (this->name, GF_LOG_ERROR,                          "%s: failed to delete from index (%s)", @@ -590,7 +591,7 @@ __index_fd_ctx_get (fd_t *fd, xlator_t *this, index_fd_ctx_t **ctx)          make_index_dir_path (priv->index_basepath, XATTROP_SUBDIR,                               index_dir, sizeof (index_dir)); -        fctx->dir = opendir (index_dir); +        fctx->dir = sys_opendir (index_dir);          if (!fctx->dir) {                  ret = -errno;                  GF_FREE (fctx); @@ -601,7 +602,7 @@ __index_fd_ctx_get (fd_t *fd, xlator_t *this, index_fd_ctx_t **ctx)          ret = __fd_ctx_set (fd, this, (uint64_t)(long)fctx);          if (ret) { -                closedir (fctx->dir); +                sys_closedir (fctx->dir);                  GF_FREE (fctx);                  fctx = NULL;                  ret = -EINVAL; @@ -822,7 +823,7 @@ index_entry_count (xlator_t *this, char *subdir)  	make_index_dir_path (priv->index_basepath, subdir,  			     index_dir, sizeof (index_dir)); -	dirp = opendir (index_dir); +	dirp = sys_opendir (index_dir);  	if (!dirp)  		return 0; @@ -836,7 +837,7 @@ index_entry_count (xlator_t *this, char *subdir)  			continue;  		count++;  	} -	closedir (dirp); +	sys_closedir (dirp);  	return count;  } @@ -918,7 +919,7 @@ index_lookup_wrapper (call_frame_t *frame, xlator_t *this,                                  loc->name, path, sizeof (path));          } -        ret = lstat (path, &lstatbuf); +        ret = sys_lstat (path, &lstatbuf);          if (ret) {                  gf_log (this->name, GF_LOG_DEBUG, "Stat failed on index dir "                          "(%s)", strerror (errno)); @@ -1010,7 +1011,7 @@ index_unlink_wrapper (call_frame_t *frame, xlator_t *this, loc_t *loc, int flag,          priv = this->private;          make_index_dir_path (priv->index_basepath, XATTROP_SUBDIR,                               index_dir, sizeof (index_dir)); -        ret = lstat (index_dir, &lstatbuf); +        ret = sys_lstat (index_dir, &lstatbuf);          if (ret < 0) {                  op_ret = -1;                  op_errno = errno; @@ -1028,7 +1029,7 @@ index_unlink_wrapper (call_frame_t *frame, xlator_t *this, loc_t *loc, int flag,                  goto done;          }          memset (&lstatbuf, 0, sizeof (lstatbuf)); -        ret = lstat (index_dir, &lstatbuf); +        ret = sys_lstat (index_dir, &lstatbuf);          if (ret < 0) {                  op_ret = -1;                  op_errno = errno; @@ -1380,7 +1381,7 @@ index_releasedir (xlator_t *this, fd_t *fd)          fctx = (index_fd_ctx_t*) (long) ctx;          if (fctx->dir) { -                ret = closedir (fctx->dir); +                ret = sys_closedir (fctx->dir);                  if (ret)                          gf_log (this->name, GF_LOG_ERROR, "closedir error: %s", strerror (errno));          } diff --git a/xlators/features/marker/src/marker.c b/xlators/features/marker/src/marker.c index 4e4a280ba31..e579417810f 100644 --- a/xlators/features/marker/src/marker.c +++ b/xlators/features/marker/src/marker.c @@ -17,6 +17,7 @@  #include "marker-common.h"  #include "byte-order.h"  #include "syncop.h" +#include "syscall.h"  #include <fnmatch.h> @@ -178,7 +179,7 @@ marker_error_handler (xlator_t *this, marker_local_t *local, int32_t op_errno)                   "Indexing gone corrupt at %s (reason: %s)."                   " Geo-replication slave content needs to be revalidated",                   path, strerror (op_errno)); -        unlink (priv->timestamp_file); +        sys_unlink (priv->timestamp_file);          return 0;  } @@ -235,7 +236,7 @@ stat_stampfile (xlator_t *this, marker_conf_t *priv,          GF_ASSERT (sizeof (priv->volume_uuid_bin) == 16);          memcpy (vol_mark->uuid, priv->volume_uuid_bin, 16); -        if (stat (priv->timestamp_file, &buf) != -1) { +        if (sys_stat (priv->timestamp_file, &buf) != -1) {                  vol_mark->retval = 0;                  vol_mark->sec = htonl (buf.st_mtime);                  vol_mark->usec = htonl (ST_MTIM_NSEC (&buf)/1000); @@ -2101,7 +2102,7 @@ call_from_sp_client_to_reset_tmfile (call_frame_t *frame,                          /* TODO check  whether the O_TRUNC would update the                           * timestamps on a zero length file on all machies.                           */ -                        close (fd); +                        sys_close (fd);                  }                  if (fd != -1 || errno == ENOENT) { diff --git a/xlators/features/trash/src/trash.c b/xlators/features/trash/src/trash.c index 18e36e7d6d9..35712f98aff 100644 --- a/xlators/features/trash/src/trash.c +++ b/xlators/features/trash/src/trash.c @@ -9,6 +9,7 @@  */  #include "trash.h"  #include "trash-mem-types.h" +#include "syscall.h"  #define root_gfid        (uuid_t){0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}  #define trash_gfid       (uuid_t){0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5} @@ -48,7 +49,7 @@ get_permission (char *path)          struct iatt             ibuf                    = {0,};          int                     ret                     = 0; -        ret = stat (path, &sbuf); +        ret = sys_stat (path, &sbuf);          if (!ret) {                  iatt_from_stat (&ibuf, &sbuf);                  mode = st_mode_from_ia (ibuf.ia_prot, ibuf.ia_type); diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index 81c247a1953..4b390ee9d69 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -15,6 +15,7 @@  #include "byte-order.h"  #include "compat-errno.h"  #include "glusterfs-acl.h" +#include "syscall.h"  #ifdef __NetBSD__  #undef open /* in perfuse.h, pulled from mount-gluster-compat.h */ @@ -155,7 +156,7 @@ send_fuse_iov (xlator_t *this, fuse_in_header_t *finh, struct iovec *iov_out,                  fouh->len += iov_out[i].iov_len;          fouh->unique = finh->unique; -        res = writev (priv->fd, iov_out, count); +        res = sys_writev (priv->fd, iov_out, count);          gf_log ("glusterfs-fuse", GF_LOG_TRACE, "writev() result %d/%d %s",                  res, fouh->len, res == -1 ? strerror (errno) : ""); @@ -168,9 +169,9 @@ send_fuse_iov (xlator_t *this, fuse_in_header_t *finh, struct iovec *iov_out,                  char w = 'W';                  pthread_mutex_lock (&priv->fuse_dump_mutex); -                res = write (priv->fuse_dump_fd, &w, 1); +                res = sys_write (priv->fuse_dump_fd, &w, 1);                  if (res != -1) -                        res = writev (priv->fuse_dump_fd, iov_out, count); +                        res = sys_writev (priv->fuse_dump_fd, iov_out, count);                  pthread_mutex_unlock (&priv->fuse_dump_mutex);                  if (res == -1) @@ -3863,7 +3864,7 @@ notify_kernel_loop (void *data)                  fouh = (struct fuse_out_header *)node->inval_buf; -                rv = write (priv->fd, node->inval_buf, fouh->len); +                rv = sys_write (priv->fd, node->inval_buf, fouh->len);                  GF_FREE (node); @@ -3895,7 +3896,7 @@ fuse_init (xlator_t *this, fuse_in_header_t *finh, void *msg)                  gf_log ("glusterfs-fuse", GF_LOG_ERROR,                          "got INIT after first message"); -                close (priv->fd); +                sys_close (priv->fd);                  goto out;          } @@ -3906,7 +3907,7 @@ fuse_init (xlator_t *this, fuse_in_header_t *finh, void *msg)                          "unsupported FUSE protocol version %d.%d",                          fini->major, fini->minor); -                close (priv->fd); +                sys_close (priv->fd);                  goto out;          }          priv->proto_minor = fini->minor; @@ -3945,7 +3946,7 @@ fuse_init (xlator_t *this, fuse_in_header_t *finh, void *msg)                                  "failed to start messenger daemon (%s)",                                  strerror(errno)); -                        close (priv->fd); +                        sys_close (priv->fd);                          goto out;                  }                  priv->reverse_fuse_thread_started = _gf_true; @@ -4032,7 +4033,7 @@ fuse_init (xlator_t *this, fuse_in_header_t *finh, void *msg)                  gf_log ("glusterfs-fuse", GF_LOG_ERROR,                          "FUSE init failed (%s)", strerror (ret)); -                close (priv->fd); +                sys_close (priv->fd);          }   out: @@ -4762,14 +4763,14 @@ fuse_get_mount_status (xlator_t *this)          int             kid_status = -1;          fuse_private_t *priv = this->private; -        if (read(priv->status_pipe[0],&kid_status, sizeof(kid_status)) < 0) { +        if (sys_read (priv->status_pipe[0], &kid_status, sizeof(kid_status)) < 0) {                  gf_log (this->name, GF_LOG_ERROR, "could not get mount status");                  kid_status = -1;          }          gf_log (this->name, GF_LOG_DEBUG, "mount status is %d", kid_status); -        close(priv->status_pipe[0]); -        close(priv->status_pipe[1]); +        sys_close(priv->status_pipe[0]); +        sys_close(priv->status_pipe[1]);          return kid_status;  } @@ -4870,7 +4871,7 @@ fuse_thread_proc (void *data)                  iov_in[1].iov_base = iobuf->ptr; -                res = readv (priv->fd, iov_in, 2); +                res = sys_readv (priv->fd, iov_in, 2);                  if (res == -1) {                          if (errno == ENODEV || errno == EBADF) { @@ -5321,7 +5322,7 @@ fuse_dumper (xlator_t *this, fuse_in_header_t *finh, void *msg)          diov[2].iov_len  = finh->len - sizeof (*finh);          pthread_mutex_lock (&priv->fuse_dump_mutex); -        ret = writev (priv->fuse_dump_fd, diov, 3); +        ret = sys_writev (priv->fuse_dump_fd, diov, 3);          pthread_mutex_unlock (&priv->fuse_dump_mutex);          if (ret == -1)                  gf_log ("glusterfs-fuse", GF_LOG_ERROR, @@ -5398,7 +5399,7 @@ init (xlator_t *this_xl)                  goto cleanup_exit;          } -        if (stat (value_string, &stbuf) != 0) { +        if (sys_stat (value_string, &stbuf) != 0) {                  if (errno == ENOENT) {                          gf_log (this_xl->name, GF_LOG_ERROR,                                  "%s %s does not exist", @@ -5473,7 +5474,7 @@ init (xlator_t *this_xl)          priv->fuse_dump_fd = -1;          ret = dict_get_str (options, "dump-fuse", &value_string);          if (ret == 0) { -                ret = unlink (value_string); +                ret = sys_unlink (value_string);                  if (ret != -1 || errno == ENOENT)                          ret = open (value_string, O_RDWR|O_CREAT|O_EXCL,                                      S_IRUSR|S_IWUSR); @@ -5642,9 +5643,9 @@ cleanup_exit:          if (priv) {                  GF_FREE (priv->mount_point);                  if (priv->fd != -1) -                        close (priv->fd); +                        sys_close (priv->fd);                  if (priv->fuse_dump_fd != -1) -                        close (priv->fuse_dump_fd); +                        sys_close (priv->fuse_dump_fd);                  GF_FREE (priv);          }          GF_FREE (mnt_args); @@ -5683,7 +5684,7 @@ fini (xlator_t *this_xl)                          "Unmounting '%s'.", mount_point);                  gf_fuse_unmount (mount_point, priv->fd); -                close (priv->fuse_dump_fd); +                sys_close (priv->fuse_dump_fd);                  dict_del (this_xl->options, ZR_MOUNTPOINT_OPT);          }          /* Process should terminate once fuse xlator is finished. diff --git a/xlators/nfs/server/src/nlm4.c b/xlators/nfs/server/src/nlm4.c index 26c45e089b0..3da3b2d1c05 100644 --- a/xlators/nfs/server/src/nlm4.c +++ b/xlators/nfs/server/src/nlm4.c @@ -15,6 +15,7 @@  #include "nfs.h"  #include "mem-pool.h"  #include "logging.h" +#include "syscall.h"  #include "nfs-fops.h"  #include "inode.h"  #include "mount3.h" @@ -2505,7 +2506,7 @@ nlm4svc_init(xlator_t *nfsx)             instead. This is still a theory but we need to thoroughly test it             out. Until then NLM support is non-existent on OSX.          */ -        ret = unlink (GF_SM_NOTIFY_PIDFILE); +        ret = sys_unlink (GF_SM_NOTIFY_PIDFILE);          if (ret == -1 && errno != ENOENT) {                  gf_msg (GF_NLM, GF_LOG_ERROR, errno, NFS_MSG_UNLINK_ERROR,                          "unable to unlink %s: %d", @@ -2542,7 +2543,7 @@ nlm4svc_init(xlator_t *nfsx)                  ret = runcmd (KILLALL_CMD, "-9", "rpc.statd", NULL);          } -        ret = unlink (GF_RPC_STATD_PIDFILE); +        ret = sys_unlink (GF_RPC_STATD_PIDFILE);          if (ret == -1 && errno != ENOENT) {                  gf_msg (GF_NLM, GF_LOG_ERROR, errno, NFS_MSG_UNLINK_ERROR,                          "unable to unlink %s", pid_file); diff --git a/xlators/protocol/server/src/server-handshake.c b/xlators/protocol/server/src/server-handshake.c index 62d9368e33a..293509c5d3f 100644 --- a/xlators/protocol/server/src/server-handshake.c +++ b/xlators/protocol/server/src/server-handshake.c @@ -17,6 +17,7 @@  #include "glusterfs3.h"  #include "authenticate.h"  #include "server-messages.h" +#include "syscall.h"  struct __get_xl_struct {          const char *name; @@ -208,7 +209,7 @@ _validate_volfile_checksum (xlator_t *this, char *key,                  }                  get_checksum_for_file (fd, &local_checksum);                  _volfile_update_checksum (this, key, local_checksum); -                close (fd); +                sys_close (fd);          }          temp_volfile = conf->volfile; @@ -267,7 +268,7 @@ server_getspec (rpcsvc_request_t *req)                                            filename, sizeof (filename));          if (ret > 0) {                  /* to allocate the proper buffer to hold the file data */ -                ret = stat (filename, &stbuf); +                ret = sys_stat (filename, &stbuf);                  if (ret < 0){                          gf_msg (this->name, GF_LOG_ERROR, errno,                                  PS_MSG_STAT_ERROR, "Unable to stat %s (%s)", @@ -302,7 +303,7 @@ server_getspec (rpcsvc_request_t *req)                          op_errno = ENOMEM;                          goto fail;                  } -                ret = read (spec_fd, rsp.spec, file_len); +                ret = sys_read (spec_fd, rsp.spec, file_len);          }          /* convert to XDR */ @@ -314,7 +315,7 @@ fail:          rsp.op_ret   = ret;          if (spec_fd != -1) -                close (spec_fd); +                sys_close (spec_fd);          server_submit_reply (NULL, req, &rsp, NULL, 0, NULL,                               (xdrproc_t)xdr_gf_getspec_rsp); diff --git a/xlators/protocol/server/src/server-helpers.c b/xlators/protocol/server/src/server-helpers.c index 0971e84298c..bcd1fed8b84 100644 --- a/xlators/protocol/server/src/server-helpers.c +++ b/xlators/protocol/server/src/server-helpers.c @@ -12,6 +12,7 @@  #include "server-helpers.h"  #include "gidcache.h"  #include "server-messages.h" +#include "syscall.h"  #include <fnmatch.h>  #include <pwd.h> @@ -556,7 +557,7 @@ server_build_config (xlator_t *this, server_conf_t *conf)          if (data) {                  /* Check whether the specified directory exists,                     or directory specified is non standard */ -                ret = stat (data->data, &buf); +                ret = sys_stat (data->data, &buf);                  if ((ret != 0) || !S_ISDIR (buf.st_mode)) {                          gf_msg (this->name, GF_LOG_ERROR, 0,                                  PS_MSG_DIR_NOT_FOUND, "Directory '%s' doesn't " diff --git a/xlators/storage/bd/src/bd-helper.c b/xlators/storage/bd/src/bd-helper.c index 9532ad3cfd2..520ddd86c06 100644 --- a/xlators/storage/bd/src/bd-helper.c +++ b/xlators/storage/bd/src/bd-helper.c @@ -8,6 +8,7 @@  #include "bd-mem-types.h"  #include "run.h"  #include "lvm-defaults.h" +#include "syscall.h"  int  bd_inode_ctx_set (inode_t *inode, xlator_t *this, bd_attr_t *ctx) @@ -269,7 +270,7 @@ out:          GF_FREE (devpath);          if (ret) {                  if (_fd >= 0) -                        close (_fd); +                        sys_close (_fd);                  GF_FREE (bdfd);          }          return ret; @@ -338,7 +339,7 @@ bd_validate_bd_xattr (xlator_t *this, char *bd, char **type,          }          /* Destination file does not exist */ -        if (stat (path, &stbuf)) { +        if (sys_stat (path, &stbuf)) {                  gf_log (this->name, GF_LOG_WARNING,                          "lstat failed for path %s", path);                  return -1; @@ -400,7 +401,7 @@ create_thin_lv (char *vg, char *pool, char *lv, uint64_t extent)                  ret = ENOMEM;                  goto out;          } -        if (lstat (path, &stat) < 0) +        if (sys_lstat (path, &stat) < 0)                  ret = EAGAIN;          else                  ret = 0; @@ -612,7 +613,7 @@ bd_snapshot_create (bd_local_t *local, bd_priv_t *priv)          runner_start (&runner);          runner_end (&runner); -        if (lstat (path, &stat) < 0) +        if (sys_lstat (path, &stat) < 0)                  ret = EIO;          GF_FREE (path); @@ -672,7 +673,7 @@ bd_clone (bd_local_t *local, bd_priv_t *priv)          }          while (1) { -                bytes = readv (fd1, vec, IOV_NR); +                bytes = sys_readv (fd1, vec, IOV_NR);                  if (bytes < 0) {                          ret = errno;                          gf_log (THIS->name, GF_LOG_WARNING, "read failed: %s", @@ -681,7 +682,7 @@ bd_clone (bd_local_t *local, bd_priv_t *priv)                  }                  if (!bytes)                          break; -                bytes = writev (fd2, vec, IOV_NR); +                bytes = sys_writev (fd2, vec, IOV_NR);                  if (bytes < 0) {                          ret = errno;                          gf_log (THIS->name, GF_LOG_WARNING, @@ -697,9 +698,9 @@ out:          GF_FREE (vec);          if (fd1 != -1) -                close (fd1); +                sys_close (fd1);          if (fd2 != -1) -                close (fd2); +                sys_close (fd2);          GF_FREE (spath);          GF_FREE (dpath); @@ -729,7 +730,7 @@ bd_merge (bd_priv_t *priv, uuid_t gfid)          runner_start (&runner);          runner_end (&runner); -        if (!lstat (path, &stat)) +        if (!sys_lstat (path, &stat))                  ret = EIO;          GF_FREE (path); @@ -847,18 +848,18 @@ bd_do_manual_zerofill (int fd, off_t offset, off_t len, int o_direct)          }          for (idx = 0; idx < num_loop; idx++) { -                op_ret = writev (fd, vector, num_vect); +                op_ret = sys_writev (fd, vector, num_vect);                  if (op_ret < 0)                          goto err;          }          if (extra) { -                op_ret = writev (fd, vector, extra); +                op_ret = sys_writev (fd, vector, extra);                  if (op_ret < 0)                          goto err;          }          if (remain) {                  vector[0].iov_len = remain; -                op_ret = writev (fd, vector , 1); +                op_ret = sys_writev (fd, vector , 1);                  if (op_ret < 0)                          goto err;          } @@ -902,7 +903,7 @@ bd_do_ioctl_zerofill (bd_priv_t *priv, bd_attr_t *bdatt, int fd, char *vg,          uuid_utoa_r (bdatt->iatt.ia_gfid, uuid);          sprintf (lvname, "/dev/%s/%s", vg, uuid); -        readlink (lvname, dmname, sizeof (dmname) - 1); +        sys_readlink (lvname, dmname, sizeof (dmname) - 1);          p = strrchr (dmname, '/');          if (p) @@ -918,8 +919,8 @@ bd_do_ioctl_zerofill (bd_priv_t *priv, bd_attr_t *bdatt, int fd, char *vg,                  goto skip;          } -        read (sysfd, buff, sizeof (buff)); -        close (sysfd); +        sys_read (sysfd, buff, sizeof (buff)); +        sys_close (sysfd);          max_bytes = atoll (buff); @@ -1000,7 +1001,7 @@ bd_do_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd,          }          if (bd_fd->flag & (O_SYNC|O_DSYNC)) { -                ret = fsync (bd_fd->fd); +                ret = sys_fsync (bd_fd->fd);                  if (ret) {                          gf_log (this->name, GF_LOG_ERROR,                                  "fsync() in writev on fd %d failed: %s", diff --git a/xlators/storage/bd/src/bd.c b/xlators/storage/bd/src/bd.c index f732b85f030..9599f4acbd5 100644 --- a/xlators/storage/bd/src/bd.c +++ b/xlators/storage/bd/src/bd.c @@ -614,7 +614,7 @@ bd_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this,                          "bd_fd is NULL from fd=%p", fd);                  goto out;          } -        close (bd_fd->fd); +        sys_close (bd_fd->fd);          GF_FREE (bd_fd);  out: @@ -690,7 +690,7 @@ out:          GF_FREE (devpath);          if (ret) {                  if (_fd >= 0) -                        close (_fd); +                        sys_close (_fd);                  GF_FREE (bd_fd);          } @@ -892,7 +892,7 @@ bd_release (xlator_t *this, fd_t *fd)          }          bd_fd = (bd_fd_t *)(long)tmp_bfd; -        close (bd_fd->fd); +        sys_close (bd_fd->fd);          GF_FREE (bd_fd);  out:          return 0; diff --git a/xlators/storage/posix/src/posix-handle.c b/xlators/storage/posix/src/posix-handle.c index 331f7212614..9a521d019a4 100644 --- a/xlators/storage/posix/src/posix-handle.c +++ b/xlators/storage/posix/src/posix-handle.c @@ -145,7 +145,7 @@ posix_make_ancestryfromgfid (xlator_t *this, char *path, int pathsize,                    priv_base_path, GF_HIDDEN_PATH, gfid[0], gfid[1],                    uuid_utoa (gfid)); -        len = readlink (dir_handle, linkname, PATH_MAX); +        len = sys_readlink (dir_handle, linkname, PATH_MAX);          if (len < 0) {                  gf_msg (this->name, (errno == ENOENT || errno == ESTALE)                          ? GF_LOG_DEBUG:GF_LOG_ERROR, errno, @@ -278,7 +278,7 @@ posix_handle_pump (xlator_t *this, char *buf, int len, int maxlen,          int        link_len = 0;          /* is a directory's symlink-handle */ -        ret = readlink (base_str, linkname, 512); +        ret = sys_readlink (base_str, linkname, 512);          if (ret == -1) {                  gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_READLINK_FAILED,                          "internal readlink failed on %s ", @@ -373,7 +373,7 @@ posix_handle_path (xlator_t *this, uuid_t gfid, const char *basename,                  len = snprintf (buf, maxlen, "%s", base_str);          } -        ret = lstat (base_str, &stat); +        ret = sys_lstat (base_str, &stat);          if (!(ret == 0 && S_ISLNK(stat.st_mode) && stat.st_nlink == 1))                  goto out; @@ -387,7 +387,7 @@ posix_handle_path (xlator_t *this, uuid_t gfid, const char *basename,                  if (ret == -1)                          break; -                ret = lstat (buf, &stat); +                ret = sys_lstat (buf, &stat);          } while ((ret == -1) && errno == ELOOP);  out: @@ -462,7 +462,7 @@ posix_handle_init (xlator_t *this)          priv = this->private; -        ret = stat (priv->base_path, &exportbuf); +        ret = sys_stat (priv->base_path, &exportbuf);          if (ret || !S_ISDIR (exportbuf.st_mode)) {                  gf_msg (this->name, GF_LOG_ERROR, 0,                          P_MSG_HANDLE_CREATE, @@ -475,11 +475,11 @@ posix_handle_init (xlator_t *this)          sprintf (handle_pfx, "%s/%s", priv->base_path, GF_HIDDEN_PATH); -        ret = stat (handle_pfx, &stbuf); +        ret = sys_stat (handle_pfx, &stbuf);          switch (ret) {          case -1:                  if (errno == ENOENT) { -                        ret = mkdir (handle_pfx, 0600); +                        ret = sys_mkdir (handle_pfx, 0600);                          if (ret != 0) {                                  gf_msg (this->name, GF_LOG_ERROR, errno,                                          P_MSG_HANDLE_CREATE, @@ -508,11 +508,11 @@ posix_handle_init (xlator_t *this)                  break;          } -        stat (handle_pfx, &priv->handledir); +        sys_stat (handle_pfx, &priv->handledir);          MAKE_HANDLE_ABSPATH(rootstr, this, gfid); -        ret = stat (rootstr, &rootbuf); +        ret = sys_stat (rootstr, &rootbuf);          switch (ret) {          case -1:                  if (errno != ENOENT) { @@ -530,7 +530,7 @@ posix_handle_init (xlator_t *this)                          return -1;                  } -                ret = symlink ("../../..", rootstr); +                ret = sys_symlink ("../../..", rootstr);                  if (ret) {                          gf_msg (this->name, GF_LOG_ERROR, errno,                                  P_MSG_HANDLE_CREATE, @@ -566,7 +566,7 @@ posix_does_old_trash_exists (char *old_trash)          struct stat           stbuf = {0};          int                   ret = 0; -        ret = lstat (old_trash, &stbuf); +        ret = sys_lstat (old_trash, &stbuf);          if ((ret == 0) && S_ISDIR (stbuf.st_mode)) {                  ret = sys_lgetxattr (old_trash, "trusted.gfid", gfid, 16);                  if ((ret < 0) && (errno == ENODATA || errno == ENOATTR) ) @@ -581,11 +581,11 @@ posix_handle_new_trash_init (xlator_t *this, char *trash)          int                     ret = 0;          struct stat             stbuf = {0}; -        ret = lstat (trash, &stbuf); +        ret = sys_lstat (trash, &stbuf);          switch (ret) {          case -1:                  if (errno == ENOENT) { -                        ret = mkdir (trash, 0755); +                        ret = sys_mkdir (trash, 0755);                          if (ret != 0) {                                  gf_msg (this->name, GF_LOG_ERROR, errno,                                          P_MSG_HANDLE_TRASH_CREATE, @@ -624,7 +624,7 @@ posix_mv_old_trash_into_new_trash (xlator_t *this, char *old, char *new)          gf_uuid_generate (dest_name);          snprintf (dest_old, sizeof (dest_old), "%s/%s", new,                    uuid_utoa (dest_name)); -        ret = rename (old, dest_old); +        ret = sys_rename (old, dest_old);          if (ret < 0) {                  gf_msg (this->name, GF_LOG_ERROR, errno,                          P_MSG_HANDLE_TRASH_CREATE, @@ -675,7 +675,7 @@ posix_handle_mkdir_hashes (xlator_t *this, const char *newpath)          parpath = dirname (duppath);          parpath = dirname (duppath); -        ret = mkdir (parpath, 0700); +        ret = sys_mkdir (parpath, 0700);          if (ret == -1 && errno != EEXIST) {                  gf_msg (this->name, GF_LOG_ERROR, errno,                          P_MSG_HANDLE_CREATE, @@ -686,7 +686,7 @@ posix_handle_mkdir_hashes (xlator_t *this, const char *newpath)          strcpy (duppath, newpath);          parpath = dirname (duppath); -        ret = mkdir (parpath, 0700); +        ret = sys_mkdir (parpath, 0700);          if (ret == -1 && errno != EEXIST) {                  gf_msg (this->name, GF_LOG_ERROR, errno,                          P_MSG_HANDLE_CREATE, @@ -708,7 +708,7 @@ posix_handle_hard (xlator_t *this, const char *oldpath, uuid_t gfid, struct stat          MAKE_HANDLE_ABSPATH (newpath, this, gfid); -        ret = lstat (newpath, &newbuf); +        ret = sys_lstat (newpath, &newbuf);          if (ret == -1 && errno != ENOENT) {                  gf_msg (this->name, GF_LOG_WARNING, errno,                          P_MSG_HANDLE_CREATE, @@ -734,7 +734,7 @@ posix_handle_hard (xlator_t *this, const char *oldpath, uuid_t gfid, struct stat                          return -1;                  } -                ret = lstat (newpath, &newbuf); +                ret = sys_lstat (newpath, &newbuf);                  if (ret) {                          gf_msg (this->name, GF_LOG_WARNING, errno,                                  P_MSG_HANDLE_CREATE, @@ -770,7 +770,7 @@ posix_handle_soft (xlator_t *this, const char *real_path, loc_t *loc,          MAKE_HANDLE_ABSPATH (newpath, this, gfid);          MAKE_HANDLE_RELPATH (oldpath, this, loc->pargfid, loc->name); -        ret = lstat (newpath, &newbuf); +        ret = sys_lstat (newpath, &newbuf);          if (ret == -1 && errno != ENOENT) {                  gf_msg (this->name, GF_LOG_WARNING, errno,                          P_MSG_HANDLE_CREATE, "%s", newpath); @@ -792,7 +792,7 @@ posix_handle_soft (xlator_t *this, const char *real_path, loc_t *loc,                          return -1;                  } -                ret = symlink (oldpath, newpath); +                ret = sys_symlink (oldpath, newpath);                  if (ret) {                          gf_msg (this->name, GF_LOG_WARNING, errno,                                  P_MSG_HANDLE_CREATE, @@ -801,7 +801,7 @@ posix_handle_soft (xlator_t *this, const char *real_path, loc_t *loc,                          return -1;                  } -                ret = lstat (newpath, &newbuf); +                ret = sys_lstat (newpath, &newbuf);                  if (ret) {                          gf_msg (this->name, GF_LOG_WARNING, errno,                                  P_MSG_HANDLE_CREATE, @@ -810,7 +810,7 @@ posix_handle_soft (xlator_t *this, const char *real_path, loc_t *loc,                  }          } -        ret = stat (real_path, &newbuf); +        ret = sys_stat (real_path, &newbuf);          if (ret) {                  gf_msg (this->name, GF_LOG_WARNING, errno,                          P_MSG_HANDLE_CREATE, @@ -845,7 +845,7 @@ posix_handle_unset_gfid (xlator_t *this, uuid_t gfid)          MAKE_HANDLE_GFID_PATH (path, this, gfid, NULL); -        ret = lstat (path, &stat); +        ret = sys_lstat (path, &stat);          if (ret == -1) {                  if (errno != ENOENT) { @@ -855,7 +855,7 @@ posix_handle_unset_gfid (xlator_t *this, uuid_t gfid)                  goto out;          } -        ret = unlink (path); +        ret = sys_unlink (path);          if (ret == -1) {                  gf_msg (this->name, GF_LOG_WARNING, errno,                          P_MSG_HANDLE_DELETE, "unlink %s failed ", path); @@ -917,7 +917,7 @@ posix_create_link_if_gfid_exists (xlator_t *this, uuid_t gfid,                  return ret;          } -        ret = lstat (newpath, &stbuf); +        ret = sys_lstat (newpath, &stbuf);          if (!ret) {                  ret = sys_link (newpath, real_path);          } diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c index 0353788740e..f7fc57fef67 100644 --- a/xlators/storage/posix/src/posix-helpers.c +++ b/xlators/storage/posix/src/posix-helpers.c @@ -401,7 +401,7 @@ _posix_xattr_get_set (dict_t *xattr_req, char *key, data_t *data,                                  goto err;                          } -                        ret = read (_fd, databuf, filler->stbuf->ia_size); +                        ret = sys_read (_fd, databuf, filler->stbuf->ia_size);                          if (ret == -1) {                                  gf_msg (filler->this->name, GF_LOG_ERROR, errno,                                           P_MSG_XDATA_GETXATTR, @@ -410,7 +410,7 @@ _posix_xattr_get_set (dict_t *xattr_req, char *key, data_t *data,                                  goto err;                          } -                        ret = close (_fd); +                        ret = sys_close (_fd);                          _fd = -1;                          if (ret == -1) {                                  gf_msg (filler->this->name, GF_LOG_ERROR, errno, @@ -435,7 +435,7 @@ _posix_xattr_get_set (dict_t *xattr_req, char *key, data_t *data,                          databuf = NULL;                  err:                          if (_fd != -1) -                                close (_fd); +                                sys_close (_fd);                          GF_FREE (databuf);                  }          } else if (!strcmp (key, GLUSTERFS_OPEN_FD_COUNT)) { @@ -552,7 +552,7 @@ posix_fdstat (xlator_t *this, int fd, struct iatt *stbuf_p)          struct stat            fstatbuf = {0, };          struct iatt            stbuf = {0, }; -        ret = fstat (fd, &fstatbuf); +        ret = sys_fstat (fd, &fstatbuf);          if (ret == -1)                  goto out; @@ -596,7 +596,7 @@ posix_istat (xlator_t *this, uuid_t gfid, const char *basename,                  goto out;          } -        ret = lstat (real_path, &lstatbuf); +        ret = sys_lstat (real_path, &lstatbuf);          if (ret != 0) {                  if (ret == -1) { @@ -886,7 +886,7 @@ posix_set_file_contents (xlator_t *this, const char *path, char *keyp,                  }                  if (value->len) { -                        ret = write (file_fd, value->data, value->len); +                        ret = sys_write (file_fd, value->data, value->len);                          if (ret == -1) {                                  op_ret = -errno;                                  gf_msg (this->name, GF_LOG_ERROR, errno, @@ -896,7 +896,7 @@ posix_set_file_contents (xlator_t *this, const char *path, char *keyp,                                  goto out;                          } -                        ret = close (file_fd); +                        ret = sys_close (file_fd);                          if (ret == -1) {                                  op_ret = -errno;                                  gf_msg (this->name, GF_LOG_ERROR, errno, @@ -919,7 +919,7 @@ posix_set_file_contents (xlator_t *this, const char *path, char *keyp,                          goto out;                  } -                ret = write (file_fd, value->data, value->len); +                ret = sys_write (file_fd, value->data, value->len);                  if (ret == -1) {                          op_ret = -errno;                          gf_msg (this->name, GF_LOG_ERROR, errno, @@ -928,7 +928,7 @@ posix_set_file_contents (xlator_t *this, const char *path, char *keyp,                          goto out;                  } -                ret = close (file_fd); +                ret = sys_close (file_fd);                  if (ret == -1) {                          op_ret = -errno;                          gf_msg (this->name, GF_LOG_ERROR, errno, @@ -989,7 +989,7 @@ posix_get_file_contents (xlator_t *this, uuid_t pargfid,                  goto out;          } -        ret = read (file_fd, *contents, stbuf.ia_size); +        ret = sys_read (file_fd, *contents, stbuf.ia_size);          if (ret <= 0) {                  op_ret = -1;                  gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_XDATA_GETXATTR, @@ -999,7 +999,7 @@ posix_get_file_contents (xlator_t *this, uuid_t pargfid,          *contents[stbuf.ia_size] = '\0'; -        op_ret = close (file_fd); +        op_ret = sys_close (file_fd);          file_fd = -1;          if (op_ret == -1) {                  op_ret = -errno; @@ -1012,7 +1012,7 @@ out:          if (op_ret < 0) {                  GF_FREE (*contents);                  if (file_fd != -1) -                        close (file_fd); +                        sys_close (file_fd);          }          return op_ret; @@ -1313,7 +1313,7 @@ janitor_walker (const char *fpath, const struct stat *sb,          case S_IFSOCK:                  gf_msg_trace (THIS->name, 0,                          "unlinking %s", fpath); -                unlink (fpath); +                sys_unlink (fpath);                  if (stbuf.ia_nlink == 1)                          posix_handle_unset (this, stbuf.ia_gfid, NULL);                  break; @@ -1323,7 +1323,7 @@ janitor_walker (const char *fpath, const struct stat *sb,                          gf_msg_debug (THIS->name, 0,                                  "removing directory %s", fpath); -                        rmdir (fpath); +                        sys_rmdir (fpath);                          del_stale_dir_handle (this, stbuf.ia_gfid);                  }                  break; @@ -1402,11 +1402,11 @@ posix_janitor_thread_proc (void *data)                          if (pfd->dir == NULL) {                                  gf_msg_trace (this->name, 0,                                          "janitor: closing file fd=%d", pfd->fd); -                                close (pfd->fd); +                                sys_close (pfd->fd);                          } else {                                  gf_msg_debug (this->name, 0, "janitor: closing"                                                " dir fd=%p", pfd->dir); -                                closedir (pfd->dir); +                                sys_closedir (pfd->dir);                          }                          GF_FREE (pfd); @@ -1647,7 +1647,7 @@ __posix_fd_ctx_get (fd_t *fd, xlator_t *this, struct posix_fd **pfd_p)          pfd->fd = -1;          if (fd->inode->ia_type == IA_IFDIR) { -                dir = opendir (real_path); +                dir = sys_opendir (real_path);                  if (!dir) {                          GF_FREE (pfd);                          pfd = NULL; @@ -1675,9 +1675,9 @@ __posix_fd_ctx_get (fd_t *fd, xlator_t *this, struct posix_fd **pfd_p)          ret = __fd_ctx_set (fd, this, (uint64_t) (long) pfd);          if (ret != 0) {                  if (_fd != -1) -                        close (_fd); +                        sys_close (_fd);                  if (dir) -                        closedir (dir); +                        sys_closedir (dir);                  GF_FREE (pfd);                  pfd = NULL;                  goto out; @@ -1738,7 +1738,7 @@ posix_fs_health_check (xlator_t *this)                          "open() on %s returned", file_path);                  goto out;          } -        nofbytes = write (fd, timestamp, timelen); +        nofbytes = sys_write (fd, timestamp, timelen);          if (nofbytes != timelen) {                  gf_msg (this->name, GF_LOG_WARNING, errno,                          P_MSG_HEALTHCHECK_FAILED, @@ -1747,8 +1747,8 @@ posix_fs_health_check (xlator_t *this)          }          /* Seek the offset to the beginning of the file, so that the offset for          read is from beginning of file */ -        lseek(fd, 0, SEEK_SET); -        nofbytes = read (fd, buff, timelen); +        sys_lseek(fd, 0, SEEK_SET); +        nofbytes = sys_read (fd, buff, timelen);          if (nofbytes == -1) {                  gf_msg (this->name, GF_LOG_WARNING, errno,                          P_MSG_HEALTHCHECK_FAILED, @@ -1758,7 +1758,7 @@ posix_fs_health_check (xlator_t *this)          ret = 0;  out:          if (fd != -1) { -                close (fd); +                sys_close (fd);          }          return ret; diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index b544e3739c6..e2fe081f86d 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -293,7 +293,7 @@ posix_do_chmod (xlator_t *this, const char *path, struct iatt *stbuf)                          goto out;                  } -                ret = chmod (path, mode); +                ret = sys_chmod (path, mode);          }  out:          return ret; @@ -315,7 +315,7 @@ posix_do_chown (xlator_t *this,          if (valid & GF_SET_ATTR_GID)                  gid = stbuf->ia_gid; -        ret = lchown (path, uid, gid); +        ret = sys_lchown (path, uid, gid);          return ret;  } @@ -354,7 +354,7 @@ posix_do_utimes (xlator_t *this,                          goto out;                  } -                ret = utimes (path, tv); +                ret = sys_utimes (path, tv);          }  out: @@ -423,7 +423,7 @@ posix_setattr (call_frame_t *frame, xlator_t *this,          }          if (!valid) { -                op_ret = lchown (real_path, -1, -1); +                op_ret = sys_lchown (real_path, -1, -1);                  if (op_ret == -1) {                          op_errno = errno;                          gf_msg (this->name, GF_LOG_ERROR, errno, @@ -474,7 +474,7 @@ posix_do_fchown (xlator_t *this,          if (valid & GF_SET_ATTR_GID)                  gid = stbuf->ia_gid; -        ret = fchown (fd, uid, gid); +        ret = sys_fchown (fd, uid, gid);          return ret;  } @@ -487,7 +487,7 @@ posix_do_fchmod (xlator_t *this,          mode_t  mode = 0;          mode = st_mode_from_ia (stbuf->ia_prot, stbuf->ia_type); -        return fchmod (fd, mode); +        return sys_fchmod (fd, mode);  }  static int @@ -572,7 +572,7 @@ posix_fsetattr (call_frame_t *frame, xlator_t *this,          }          if (!valid) { -                op_ret = fchown (pfd->fd, -1, -1); +                op_ret = sys_fchown (pfd->fd, -1, -1);                  if (op_ret == -1) {                          op_errno = errno;                          gf_msg (this->name, GF_LOG_ERROR, errno, @@ -724,24 +724,24 @@ _posix_do_zerofill(int fd, off_t offset, off_t len, int o_direct)                  vector[idx].iov_base = iov_base;                  vector[idx].iov_len  = vect_size;          } -        if (lseek(fd, offset, SEEK_SET) < 0) { +        if (sys_lseek (fd, offset, SEEK_SET) < 0) {                  op_ret = -1;                  goto err;          }          for (idx = 0; idx < num_loop; idx++) { -                op_ret = writev(fd, vector, num_vect); +                op_ret = sys_writev (fd, vector, num_vect);                  if (op_ret < 0)                          goto err;          }          if (extra) { -                op_ret = writev(fd, vector, extra); +                op_ret = sys_writev (fd, vector, extra);                  if (op_ret < 0)                          goto err;          }          if (remain) {                  vector[0].iov_len = remain; -                op_ret = writev(fd, vector , 1); +                op_ret = sys_writev (fd, vector , 1);                  if (op_ret < 0)                          goto err;          } @@ -792,7 +792,7 @@ posix_do_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd,                  goto out;          }          if (pfd->flags & (O_SYNC|O_DSYNC)) { -                ret = fsync (pfd->fd); +                ret = sys_fsync (pfd->fd);                  if (ret) {                          gf_msg (this->name, GF_LOG_ERROR, 0,                                  P_MSG_WRITEV_FAILED, "fsync() in writev on fd" @@ -932,7 +932,7 @@ posix_opendir (call_frame_t *frame, xlator_t *this,          }          op_ret = -1; -        dir = opendir (real_path); +        dir = sys_opendir (real_path);          if (dir == NULL) {                  op_errno = errno; @@ -970,7 +970,7 @@ posix_opendir (call_frame_t *frame, xlator_t *this,  out:          if (op_ret == -1) {                  if (dir) { -                        closedir (dir); +                        sys_closedir (dir);                          dir = NULL;                  }                  if (pfd) { @@ -1150,21 +1150,21 @@ real_op:  		op_ret = mkfifo (real_path, mode);  	else  #endif /* __NetBSD__ */ -        op_ret = mknod (real_path, mode, dev); +        op_ret = sys_mknod (real_path, mode, dev);          if (op_ret == -1) {                  op_errno = errno;                  if ((op_errno == EINVAL) && S_ISREG (mode)) {                          /* Over Darwin, mknod with (S_IFREG|mode)                             doesn't work */ -                        tmp_fd = creat (real_path, mode); +                        tmp_fd = sys_creat (real_path, mode);                          if (tmp_fd == -1) {                                  gf_msg (this->name, GF_LOG_ERROR, errno,                                          P_MSG_CREATE_FAILED, "create failed on"                                          "%s", real_path);                                  goto out;                          } -                        close (tmp_fd); +                        sys_close (tmp_fd);                  } else {                          gf_msg (this->name, GF_LOG_ERROR, errno, @@ -1177,7 +1177,7 @@ real_op:          entry_created = _gf_true;  #ifndef HAVE_SET_FSID -        op_ret = lchown (real_path, frame->root->uid, gid); +        op_ret = sys_lchown (real_path, frame->root->uid, gid);          if (op_ret == -1) {                  op_errno = errno;                  gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LCHOWN_FAILED, @@ -1348,7 +1348,7 @@ posix_mkdir (call_frame_t *frame, xlator_t *this,                  mode |= S_ISGID;          } -        op_ret = mkdir (real_path, mode); +        op_ret = sys_mkdir (real_path, mode);          if (op_ret == -1) {                  op_errno = errno;                  gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_MKDIR_FAILED, @@ -1359,7 +1359,7 @@ posix_mkdir (call_frame_t *frame, xlator_t *this,          entry_created = _gf_true;  #ifndef HAVE_SET_FSID -        op_ret = chown (real_path, frame->root->uid, gid); +        op_ret = sys_chown (real_path, frame->root->uid, gid);          if (op_ret == -1) {                  op_errno = errno;                  gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_CHOWN_FAILED, @@ -1662,7 +1662,7 @@ out:                               &preparent, &postparent, unwind_dict);          if (fd != -1) { -                close (fd); +                sys_close (fd);          }          /* unref unwind_dict*/ @@ -1732,17 +1732,17 @@ posix_rmdir (call_frame_t *frame, xlator_t *this,                                           strlen ("/") +                                           strlen (gfid_str) + 1); -                op_ret = mkdir (priv->trash_path, 0755); +                op_ret = sys_mkdir (priv->trash_path, 0755);                  if (errno != EEXIST && op_ret == -1) {                          gf_msg (this->name, GF_LOG_ERROR, errno,                                  P_MSG_MKDIR_FAILED,                                  "mkdir of %s failed", priv->trash_path);                  } else {                          sprintf (tmp_path, "%s/%s", priv->trash_path, gfid_str); -                        op_ret = rename (real_path, tmp_path); +                        op_ret = sys_rename (real_path, tmp_path);                  }          } else { -                op_ret = rmdir (real_path); +                op_ret = sys_rmdir (real_path);          }          op_errno = errno; @@ -1842,7 +1842,7 @@ posix_symlink (call_frame_t *frame, xlator_t *this,                  gid = preparent.ia_gid;          } -        op_ret = symlink (linkname, real_path); +        op_ret = sys_symlink (linkname, real_path);          if (op_ret == -1) {                  op_errno = errno; @@ -1855,7 +1855,7 @@ posix_symlink (call_frame_t *frame, xlator_t *this,          entry_created = _gf_true;  #ifndef HAVE_SET_FSID -        op_ret = lchown (real_path, frame->root->uid, gid); +        op_ret = sys_lchown (real_path, frame->root->uid, gid);          if (op_ret == -1) {                  op_errno = errno;                  gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LCHOWN_FAILED, @@ -2295,7 +2295,7 @@ posix_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset,                  goto out;          } -        op_ret = truncate (real_path, offset); +        op_ret = sys_truncate (real_path, offset);          if (op_ret == -1) {                  op_errno = errno;                  gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_TRUNCATE_FAILED, @@ -2415,7 +2415,7 @@ posix_create (call_frame_t *frame, xlator_t *this,                  goto fill_stat;  #ifndef HAVE_SET_FSID -        op_ret = chown (real_path, frame->root->uid, gid); +        op_ret = sys_chown (real_path, frame->root->uid, gid);          if (op_ret == -1) {                  op_errno = errno;                  gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_CHOWN_FAILED, @@ -2497,7 +2497,7 @@ out:          SET_TO_OLD_FS_ID ();          if ((-1 == op_ret) && (_fd != -1)) { -                close (_fd); +                sys_close (_fd);          }          STACK_UNWIND_STRICT (create, frame, op_ret, op_errno, @@ -2593,7 +2593,7 @@ posix_open (call_frame_t *frame, xlator_t *this,  out:          if (op_ret == -1) {                  if (_fd != -1) { -                        close (_fd); +                        sys_close (_fd);                  }          } @@ -2940,7 +2940,7 @@ posix_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,  	}          if (flags & (O_SYNC|O_DSYNC)) { -                ret = fsync (_fd); +                ret = sys_fsync (_fd);                  if (ret) {                          gf_msg (this->name, GF_LOG_ERROR, errno,                                  P_MSG_WRITEV_FAILED, @@ -2998,7 +2998,7 @@ posix_statfs (call_frame_t *frame, xlator_t *this,          priv = this->private; -        op_ret = statvfs (real_path, &buf); +        op_ret = sys_statvfs (real_path, &buf);          if (op_ret == -1) {                  op_errno = errno; @@ -3457,24 +3457,24 @@ posix_xattr_get_real_filename (call_frame_t *frame, xlator_t *this, loc_t *loc,                  return -ESTALE;          } -	fd = opendir (real_path); +	fd = sys_opendir (real_path);  	if (!fd)  		return -errno;  	fname = key + strlen (GF_XATTR_GET_REAL_FILENAME_KEY); -	while ((dirent = readdir (fd))) { +	while ((dirent = sys_readdir (fd))) {  		if (strcasecmp (dirent->d_name, fname) == 0) {  			found = gf_strdup (dirent->d_name);  			if (!found) { -				closedir (fd); +				sys_closedir (fd);  				return -ENOMEM;  			}  			break;  		}  	} -	closedir (fd); +	sys_closedir (fd);  	if (!found)  		return -ENOENT; @@ -3549,7 +3549,7 @@ posix_links_in_same_directory (char *dirpath, int count, inode_t *leaf_inode,          priv = this->private; -        dirp = opendir (dirpath); +        dirp = sys_opendir (dirpath);          if (!dirp) {                  *op_errno = errno;                  gf_msg (this->name, GF_LOG_WARNING, errno, P_MSG_OPEN_FAILED, @@ -3629,7 +3629,7 @@ posix_links_in_same_directory (char *dirpath, int count, inode_t *leaf_inode,          op_ret = 0;  out:          if (dirp) { -                op_ret = closedir (dirp); +                op_ret = sys_closedir (dirp);                  if (op_ret == -1) {                          *op_errno = errno;                          gf_msg (this->name, GF_LOG_WARNING, errno, @@ -4523,7 +4523,7 @@ posix_fsetxattr (call_frame_t *frame, xlator_t *this,          }          if (!ret && xdata && dict_get (xdata, GLUSTERFS_DURABLE_OP)) { -                op_ret = fsync (_fd); +                op_ret = sys_fsync (_fd);                  if (op_ret < 0) {                          op_ret = -1;                          op_errno = errno; @@ -5252,7 +5252,7 @@ posix_access (call_frame_t *frame, xlator_t *this,                  goto out;          } -        op_ret = access (real_path, mask & 07); +        op_ret = sys_access (real_path, mask & 07);          if (op_ret == -1) {                  op_errno = errno;                  gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_ACCESS_FAILED, @@ -5310,7 +5310,7 @@ posix_ftruncate (call_frame_t *frame, xlator_t *this,                  goto out;          } -        op_ret = ftruncate (_fd, offset); +        op_ret = sys_ftruncate (_fd, offset);          if (op_ret == -1) {                  op_errno = errno; @@ -5585,7 +5585,7 @@ posix_fill_readdir (fd_t *fd, DIR *dir, off_t off, size_t size,                                  continue;                          } else if (hpath) {                                  strcpy (&hpath[len+1],entry->d_name); -                                ret = lstat (hpath, &stbuf); +                                ret = sys_lstat (hpath, &stbuf);                                  if (!ret && S_ISDIR (stbuf.st_mode))                                          continue;                          } @@ -5640,7 +5640,7 @@ posix_fill_readdir (fd_t *fd, DIR *dir, off_t off, size_t size,                  count ++;          } -        if ((!readdir (dir) && (errno == 0))) { +        if ((!sys_readdir (dir) && (errno == 0))) {                  /* Indicate EOF */                  errno = ENOENT;                  /* Remember EOF offset for later detection */ @@ -6219,7 +6219,7 @@ init (xlator_t *this)          umask (000); // umask `masking' is done at the client side          /* Check whether the specified directory exists, if not log it. */ -        op_ret = stat (dir_data->data, &buf); +        op_ret = sys_stat (dir_data->data, &buf);          if ((op_ret != 0) || !S_ISDIR (buf.st_mode)) {                  gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_DIR_OPERATION_FAILED,                          "Directory '%s' doesn't exist, exiting.", @@ -6526,7 +6526,7 @@ init (xlator_t *this)          /* performing open dir on brick dir locks the brick dir           * and prevents it from being unmounted           */ -        _private->mount_lock = opendir (dir_data->data); +        _private->mount_lock = sys_opendir (dir_data->data);          if (!_private->mount_lock) {                  ret = -1;                  gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_DIR_OPERATION_FAILED, @@ -6672,7 +6672,7 @@ fini (xlator_t *this)          this->private = NULL;          /*unlock brick dir*/          if (priv->mount_lock) -                closedir (priv->mount_lock); +                sys_closedir (priv->mount_lock);          GF_FREE (priv);          return;  }  | 
