diff options
21 files changed, 199 insertions, 183 deletions
diff --git a/libglusterfs/src/syscall.h b/libglusterfs/src/syscall.h index bbf23bef07b..037f6c64acb 100644 --- a/libglusterfs/src/syscall.h +++ b/libglusterfs/src/syscall.h @@ -11,6 +11,10 @@  #ifndef __SYSCALL_H__  #define __SYSCALL_H__ +#include <dirent.h> +#include <sys/uio.h> +#include <sys/statvfs.h> +  /* GF follows the Linux XATTR definition, which differs in Darwin. */  #define GF_XATTR_CREATE  0x1 /* set value, fail if attr already exists */  #define GF_XATTR_REPLACE 0x2 /* set value, fail if attr does not exist */ diff --git a/xlators/mgmt/glusterd/src/glusterd-ganesha.c b/xlators/mgmt/glusterd/src/glusterd-ganesha.c index 4e2008b9c69..efc6b50db14 100644 --- a/xlators/mgmt/glusterd/src/glusterd-ganesha.c +++ b/xlators/mgmt/glusterd/src/glusterd-ganesha.c @@ -17,6 +17,7 @@  #include "glusterd-nfs-svc.h"  #include "glusterd-volgen.h"  #include "glusterd-messages.h" +#include "syscall.h"  #define MAXBUF 1024  #define DELIM "=\""  #define SHARED_STORAGE_MNT "/var/run/gluster/shared_storage/nfs-ganesha" @@ -74,7 +75,7 @@ manage_service (char *action)          };          while (sc_list[i].binary != NULL) { -                ret = stat (sc_list[i].binary, &stbuf); +                ret = sys_stat (sc_list[i].binary, &stbuf);                  if (ret == 0) {                          gf_msg_debug (THIS->name, 0,                                  "%s found.", sc_list[i].binary); @@ -695,7 +696,7 @@ pre_setup (char **op_errstr)  {          int    ret = 0; -        ret = mkdir (SHARED_STORAGE_MNT, 0775); +        ret = sys_mkdir (SHARED_STORAGE_MNT, 0775);          if ((-1 == ret) && (EEXIST != errno)) {                  gf_msg ("THIS->name", GF_LOG_ERROR, errno, diff --git a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c index d30929eade6..c5194b35864 100644 --- a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c +++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c @@ -856,7 +856,7 @@ gsyncd_getpidfile (char *master, char *slave, char *pidfile,          snprintf (temp_conf_path, sizeof(temp_conf_path) - 1,                    "%s/"GSYNC_CONF_TEMPLATE, priv->workdir); -        ret = lstat (conf_path, &stbuf); +        ret = sys_lstat (conf_path, &stbuf);          if (!ret) {                  gf_msg_debug (this->name, 0, "Using passed config template(%s).",                          conf_path); @@ -866,7 +866,7 @@ gsyncd_getpidfile (char *master, char *slave, char *pidfile,                          GD_MSG_FILE_OP_FAILED,                          "Config file (%s) missing. Looking for template "                          "config file (%s)", conf_path, temp_conf_path); -                ret = lstat (temp_conf_path, &stbuf); +                ret = sys_lstat (temp_conf_path, &stbuf);                  if (ret) {                          gf_msg (this->name, GF_LOG_ERROR, ENOENT,                                  GD_MSG_FILE_OP_FAILED, @@ -1485,7 +1485,7 @@ glusterd_op_verify_gsync_start_options (glusterd_volinfo_t *volinfo,                  goto out;          } -        ret = lstat (statefile, &stbuf); +        ret = sys_lstat (statefile, &stbuf);          if (ret) {                  snprintf (msg, sizeof (msg), "Session between %s and %s has"                            " not been created. Please create session and retry.", @@ -2021,10 +2021,10 @@ glusterd_op_stage_sys_exec (dict_t *dict, char **op_errstr)          sprintf (command_path, GSYNCD_PREFIX"/peer_%s", command);          /* check if it's executable */ -        ret = access (command_path, X_OK); +        ret = sys_access (command_path, X_OK);          if (!ret)                  /* check if it's a regular file */ -                ret = stat (command_path, &st); +                ret = sys_stat (command_path, &st);          if (!ret && !S_ISREG (st.st_mode))                  ret = -1; @@ -2105,7 +2105,7 @@ glusterd_op_stage_copy_file (dict_t *dict, char **op_errstr)                  snprintf (abs_filename, sizeof(abs_filename),                            "%s/%s", priv->workdir, filename); -                ret = lstat (abs_filename, &stbuf); +                ret = sys_lstat (abs_filename, &stbuf);                  if (ret) {                          snprintf (errmsg, sizeof (errmsg), "Source file"                                    " does not exist in %s", priv->workdir); @@ -2168,7 +2168,7 @@ glusterd_get_statefile_name (glusterd_volinfo_t *volinfo, char *slave,          snprintf (temp_conf_path, sizeof(temp_conf_path) - 1,                    "%s/"GSYNC_CONF_TEMPLATE, priv->workdir); -        ret = lstat (conf_path, &stbuf); +        ret = sys_lstat (conf_path, &stbuf);          if (!ret) {                  gf_msg (this->name, GF_LOG_INFO, 0, GD_MSG_CONFIG_INFO,                          "Using passed config template(%s).", @@ -2179,7 +2179,7 @@ glusterd_get_statefile_name (glusterd_volinfo_t *volinfo, char *slave,                          GD_MSG_FILE_OP_FAILED,                          "Config file (%s) missing. Looking for template config"                          " file (%s)", conf_path, temp_conf_path); -                ret = lstat (temp_conf_path, &stbuf); +                ret = sys_lstat (temp_conf_path, &stbuf);                  if (ret) {                          gf_msg (this->name, GF_LOG_ERROR, ENOENT,                                  GD_MSG_FILE_OP_FAILED, "Template " @@ -2399,7 +2399,7 @@ glusterd_verify_slave (char *volname, char *slave_url, char *slave_vol,          ret = 0;  out:          GF_FREE (slave_url_buf); -        unlink (log_file_path); +        sys_unlink (log_file_path);          gf_msg_debug (this->name, 0, "Returning %d", ret);          return ret;  } @@ -2636,7 +2636,7 @@ glusterd_op_stage_gsync_create (dict_t *dict, char **op_errstr)                                          conf->workdir);                          hook_script[ret] = '\0'; -                        ret = lstat (common_pem_file, &stbuf); +                        ret = sys_lstat (common_pem_file, &stbuf);                          if (ret) {                                  snprintf (errmsg, sizeof (errmsg), "%s"                                            " required for push-pem is" @@ -2651,7 +2651,7 @@ glusterd_op_stage_gsync_create (dict_t *dict, char **op_errstr)                                  goto out;                          } -                        ret = lstat (hook_script, &stbuf); +                        ret = sys_lstat (hook_script, &stbuf);                          if (ret) {                                  snprintf (errmsg, sizeof (errmsg),                                            "The hook-script (%s) required " @@ -2703,7 +2703,7 @@ glusterd_op_stage_gsync_create (dict_t *dict, char **op_errstr)                  goto out;          } -        ret = lstat (statefile, &stbuf); +        ret = sys_lstat (statefile, &stbuf);          if (!ret && !is_force) {                  snprintf (errmsg, sizeof (errmsg), "Session between %s"                            " and %s is already created.", @@ -2909,7 +2909,7 @@ glusterd_op_stage_gsync_set (dict_t *dict, char **op_errstr)           * as this command acts as a fail safe method to stop geo-rep           * session. */          if (!((type == GF_GSYNC_OPTION_TYPE_STOP) && is_force)) { -                ret = lstat (statefile, &stbuf); +                ret = sys_lstat (statefile, &stbuf);                  if (ret) {                          snprintf (errmsg, sizeof(errmsg), "Geo-replication"                                    " session between %s and %s does not exist.", @@ -3181,7 +3181,7 @@ gd_pause_or_resume_gsync (dict_t *dict, char *master, char *slave,                  goto out;          } -        ret = read (pfd, buf, 1024); +        ret = sys_read (pfd, buf, 1024);          if (ret > 0) {                  pid = strtol (buf, NULL, 10);                  if (is_pause) { @@ -3317,7 +3317,7 @@ stop_gsync (char *master, char *slave, char **msg,          if (pfd < 0)                  goto out; -        ret = read (pfd, buf, 1024); +        ret = sys_read (pfd, buf, 1024);          if (ret > 0) {                  pid = strtol (buf, NULL, 10);                  ret = kill (-pid, SIGTERM); @@ -3339,7 +3339,7 @@ stop_gsync (char *master, char *slave, char **msg,                          usleep (50000);                  }                  kill (-pid, SIGKILL); -                unlink (pidfile); +                sys_unlink (pidfile);          }          ret = 0; @@ -3557,7 +3557,7 @@ glusterd_gsync_configure (glusterd_volinfo_t *volinfo, char *slave,          if ((!strcmp (op_name, "state_file")) && (op_value)) { -                ret = lstat (op_value, &stbuf); +                ret = sys_lstat (op_value, &stbuf);                  if (ret) {                          ret = dict_get_str (dict, "slave_host", &slave_host);                          if (ret) { @@ -3580,7 +3580,7 @@ glusterd_gsync_configure (glusterd_volinfo_t *volinfo, char *slave,                                                             slave_vol,                                                             "Switching Status "                                                             "File"); -                        if (ret || lstat (op_value, &stbuf)) { +                        if (ret || sys_lstat (op_value, &stbuf)) {                                  gf_msg (this->name, GF_LOG_ERROR, errno,                                          GD_MSG_FILE_OP_FAILED, "Unable to "                                          "create %s. Error : %s", op_value, @@ -3635,7 +3635,7 @@ glusterd_gsync_read_frm_status (char *path, char *buf, size_t blen)                          "Unable to read gsyncd status file");                  return -1;          } -        ret = read (status_fd, buf, blen - 1); +        ret = sys_read (status_fd, buf, blen - 1);          if (ret > 0) {                  size_t len = strnlen (buf, ret);                  /* Ensure there is a NUL byte and that it's not the first.  */ @@ -3650,7 +3650,7 @@ glusterd_gsync_read_frm_status (char *path, char *buf, size_t blen)                  gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_GSYNCD_ERROR,                          "Status file of gsyncd is corrupt"); -        close (status_fd); +        sys_close (status_fd);          return ret;  } @@ -3811,7 +3811,7 @@ glusterd_read_status_file (glusterd_volinfo_t *volinfo, char *slave,          snprintf (temp_conf_path, sizeof(temp_conf_path) - 1,                    "%s/"GSYNC_CONF_TEMPLATE, priv->workdir); -        ret = lstat (conf_path, &stbuf); +        ret = sys_lstat (conf_path, &stbuf);          if (!ret) {                  gf_msg (this->name, GF_LOG_INFO, 0, GD_MSG_CONFIG_INFO,                          "Using passed config template(%s).", @@ -3822,7 +3822,7 @@ glusterd_read_status_file (glusterd_volinfo_t *volinfo, char *slave,                          GD_MSG_FILE_OP_FAILED,                          "Config file (%s) missing. Looking for template "                          "config file (%s)", conf_path, temp_conf_path); -                ret = lstat (temp_conf_path, &stbuf); +                ret = sys_lstat (temp_conf_path, &stbuf);                  if (ret) {                          gf_msg (this->name, GF_LOG_ERROR, ENOENT,                                  GD_MSG_FILE_OP_FAILED, "Template " @@ -4231,7 +4231,7 @@ glusterd_get_gsync_status_mst_slv (glusterd_volinfo_t *volinfo,                          goto out;                  } -                ret = lstat (statefile, &stbuf); +                ret = sys_lstat (statefile, &stbuf);                  if (ret) {                          gf_msg (this->name, GF_LOG_INFO, ENOENT,                                  GD_MSG_FILE_OP_FAILED, @@ -4433,7 +4433,7 @@ glusterd_gsync_delete (glusterd_volinfo_t *volinfo, char *slave,                          volinfo->volname, slave_host, slave_vol);          geo_rep_dir[ret] = '\0'; -        ret = rmdir (geo_rep_dir); +        ret = sys_rmdir (geo_rep_dir);          if (ret) {                  if (errno == ENOENT)                          gf_msg_debug (this->name, 0, "Geo Rep Dir(%s) Not Present.", @@ -4656,7 +4656,7 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr)          uuid_utoa_r (MY_UUID, uuid_str);          if (!strcmp (uuid_str, host_uuid)) { -                ret = lstat (abs_filename, &stbuf); +                ret = sys_lstat (abs_filename, &stbuf);                  if (ret) {                          snprintf (errmsg, sizeof (errmsg), "Source file"                                   " does not exist in %s", priv->workdir); @@ -4691,7 +4691,7 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr)                  }                  do { -                        ret = read (fd, buf, sizeof(buf)); +                        ret = sys_read (fd, buf, sizeof(buf));                          if (ret > 0) {                                  memcpy (contents+bytes_read, buf, ret);                                  bytes_read += ret; @@ -4785,7 +4785,7 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr)                          goto out;                  } -                bytes_writen = write (fd, contents, contents_size); +                bytes_writen = sys_write (fd, contents, contents_size);                  if (bytes_writen != contents_size) {                          snprintf (errmsg, sizeof (errmsg), "Failed to write" @@ -4797,13 +4797,13 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr)                          goto out;                  } -                fchmod (fd, file_mode); +                sys_fchmod (fd, file_mode);          }          ret = 0;  out:          if (fd != -1) -                close (fd); +                sys_close (fd);          if (free_contents)                  GF_FREE(contents); @@ -5541,13 +5541,13 @@ glusterd_create_essential_dir_files (glusterd_volinfo_t *volinfo, dict_t *dict,                  goto out;          } -        ret = lstat (conf_path, &stbuf); +        ret = sys_lstat (conf_path, &stbuf);          if (!ret) {                  gf_msg_debug (this->name, 0, "Session already running."                                " Not creating config file again.");          } else {                  ret = create_conf_file (conf, conf_path); -                if (ret || lstat (conf_path, &stbuf)) { +                if (ret || sys_lstat (conf_path, &stbuf)) {                          snprintf (errmsg, sizeof (errmsg), "Failed to create"                                    " config file(%s).", conf_path);                          gf_msg (this->name, GF_LOG_ERROR, errno, @@ -5556,7 +5556,7 @@ glusterd_create_essential_dir_files (glusterd_volinfo_t *volinfo, dict_t *dict,                  }          } -        ret = lstat (statefile, &stbuf); +        ret = sys_lstat (statefile, &stbuf);          if (!ret) {                  gf_msg_debug (this->name, 0, "Session already running."                                " Not creating status file again."); @@ -5565,7 +5565,7 @@ glusterd_create_essential_dir_files (glusterd_volinfo_t *volinfo, dict_t *dict,                  ret = glusterd_create_status_file (volinfo->volname, slave,                                                     slave_host, slave_vol,                                                     "Created"); -                if (ret || lstat (statefile, &stbuf)) { +                if (ret || sys_lstat (statefile, &stbuf)) {                          snprintf (errmsg, sizeof (errmsg), "Unable to create %s"                                    ". Error : %s", statefile, strerror (errno));                          *op_errstr = gf_strdup (errmsg); diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index b01a70d62c4..24e0084a093 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -16,6 +16,7 @@  #include "protocol-common.h"  #include "xlator.h"  #include "logging.h" +#include "syscall.h"  #include "timer.h"  #include "defaults.h"  #include "compat.h" @@ -3215,12 +3216,12 @@ __glusterd_handle_umount (rpcsvc_request_t *req)          synclock_lock (&priv->big_lock);          if (rsp.op_ret == 0) {                  if (realpath (umnt_req.path, mntp)) -                        rmdir (mntp); +                        sys_rmdir (mntp);                  else {                          rsp.op_ret = -1;                          rsp.op_errno = errno;                  } -                if (unlink (umnt_req.path) != 0) { +                if (sys_unlink (umnt_req.path) != 0) {                          rsp.op_ret = -1;                          rsp.op_errno = errno;                  } diff --git a/xlators/mgmt/glusterd/src/glusterd-handshake.c b/xlators/mgmt/glusterd/src/glusterd-handshake.c index 7e3955465a4..e3f949aed0b 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handshake.c +++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c @@ -11,6 +11,7 @@  #include "xlator.h"  #include "defaults.h"  #include "glusterfs.h" +#include "syscall.h"  #include "compat-errno.h"  #include "glusterd.h" @@ -306,7 +307,7 @@ gotvolinfo:          if (ret == -1)                  goto out; -        ret = stat (path, &stbuf); +        ret = sys_stat (path, &stbuf);          if ((ret == -1) && (errno == ENOENT)) {                  strncpy (dup_volid, volid_ptr, (PATH_MAX - 1)); @@ -330,7 +331,7 @@ gotvolinfo:                            path_prefix, volinfo->volname,                            (trusted_str ? trusted_str : ""),                            dup_volid); -                ret = stat (path, &stbuf); +                ret = sys_stat (path, &stbuf);          }  out:          if (dup_volname) @@ -798,7 +799,7 @@ __server_getspec (rpcsvc_request_t *req)          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 ("glusterd", GF_LOG_ERROR, errno,                                  GD_MSG_FILE_OP_FAILED, @@ -828,7 +829,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);          }          if (brick_name) { @@ -847,7 +848,7 @@ __server_getspec (rpcsvc_request_t *req)          /* convert to XDR */  fail:          if (spec_fd > 0) -                close (spec_fd); +                sys_close (spec_fd);          rsp.op_ret   = ret; diff --git a/xlators/mgmt/glusterd/src/glusterd-hooks.c b/xlators/mgmt/glusterd/src/glusterd-hooks.c index 4db5460c798..45a5912a1eb 100644 --- a/xlators/mgmt/glusterd/src/glusterd-hooks.c +++ b/xlators/mgmt/glusterd/src/glusterd-hooks.c @@ -15,6 +15,7 @@  #include "logging.h"  #include "run.h"  #include "defaults.h" +#include "syscall.h"  #include "compat.h"  #include "compat-errno.h"  #include "glusterd.h" @@ -343,7 +344,7 @@ glusterd_hooks_run_hooks (char *hooks_path, glusterd_op_t op, dict_t *op_ctx,                  goto out;          } -        hookdir = opendir (hooks_path); +        hookdir = sys_opendir (hooks_path);          if (!hookdir) {                  ret = -1;                  gf_msg (this->name, GF_LOG_ERROR, errno, @@ -420,7 +421,7 @@ out:          }          if (hookdir) -                closedir (hookdir); +                sys_closedir (hookdir);          return ret;  } diff --git a/xlators/mgmt/glusterd/src/glusterd-log-ops.c b/xlators/mgmt/glusterd/src/glusterd-log-ops.c index 938a066e9a0..e1bb755fd3b 100644 --- a/xlators/mgmt/glusterd/src/glusterd-log-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-log-ops.c @@ -16,6 +16,7 @@  #include "glusterd-utils.h"  #include "glusterd-volgen.h"  #include "glusterd-messages.h" +#include "syscall.h"  #include <signal.h> @@ -253,7 +254,7 @@ cont:                  snprintf (logfile, PATH_MAX, "%s.%"PRIu64,                            brickinfo->logfile, key); -                ret = rename (brickinfo->logfile, logfile); +                ret = sys_rename (brickinfo->logfile, logfile);                  if (ret)                          gf_msg ("glusterd", GF_LOG_WARNING, errno,                                  GD_MSG_FILE_OP_FAILED, "rename failed"); diff --git a/xlators/mgmt/glusterd/src/glusterd-mountbroker.c b/xlators/mgmt/glusterd/src/glusterd-mountbroker.c index 4ed2fb7035d..3125612d2cf 100644 --- a/xlators/mgmt/glusterd/src/glusterd-mountbroker.c +++ b/xlators/mgmt/glusterd/src/glusterd-mountbroker.c @@ -17,6 +17,7 @@  #include "dict.h"  #include "list.h"  #include "logging.h" +#include "syscall.h"  #include "defaults.h"  #include "compat.h"  #include "compat-errno.h" @@ -587,16 +588,16 @@ glusterd_do_mount (char *label, dict_t *argdict, char **path, int *op_errno)          sla = strrchr (mtptemp, '/');          *sla = '\0'; -        ret = mkdir (mtptemp, 0700); +        ret = sys_mkdir (mtptemp, 0700);          if (ret == 0) -                ret = chown (mtptemp, uid, 0); +                ret = sys_chown (mtptemp, uid, 0);          else if (errno == EEXIST)                  ret = 0;          if (ret == -1) {                  *op_errno = errno;                  goto out;          } -        ret = lstat (mtptemp, &st); +        ret = sys_lstat (mtptemp, &st);          if (ret == -1) {                  *op_errno = errno;                  goto out; @@ -628,7 +629,7 @@ glusterd_do_mount (char *label, dict_t *argdict, char **path, int *op_errno)                  *op_errno = errno;                  goto out;          } -        close (ret); +        sys_close (ret);          /*** assembly the path from cookie to mountpoint */          sla = strchr (sla - 1, '/'); @@ -642,9 +643,9 @@ glusterd_do_mount (char *label, dict_t *argdict, char **path, int *op_errno)          /*** create cookie link in (to-be) mountpoint,               move it over to the final place */          *cookieswitch = '/'; -        ret = symlink (mntlink, mtptemp); +        ret = sys_symlink (mntlink, mtptemp);          if (ret != -1) -                ret = rename (mtptemp, cookie); +                ret = sys_rename (mtptemp, cookie);          *cookieswitch = '\0';          if (ret == -1) {                  *op_errno = errno; @@ -674,12 +675,12 @@ glusterd_do_mount (char *label, dict_t *argdict, char **path, int *op_errno)                          strerror (*op_errno));                  if (mtptemp) {                          *cookieswitch = '/'; -                        unlink (mtptemp); +                        sys_unlink (mtptemp);                          *cookieswitch = '\0'; -                        rmdir (mtptemp); +                        sys_rmdir (mtptemp);                  }                  if (cookie) { -                        unlink (cookie); +                        sys_unlink (cookie);                          GF_FREE (cookie);                  } diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index 39c989fa53e..ed8fae1dc4b 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -1220,7 +1220,7 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)                                          /* Checks whether a directory with                                             given option exists or not */ -                                        if (!stat(trash_path, &stbuf)) { +                                        if (!sys_stat (trash_path, &stbuf)) {                                                  snprintf (errstr,                                                            sizeof (errstr),                                                            "Path %s exists", @@ -2487,12 +2487,12 @@ glusterd_op_set_volume (dict_t *dict, char **errstr)          for (count = 1; ret != -1 ; count++) { -                sprintf (str, "key%d", count); +                snprintf (str, sizeof str, "key%d", count);                  ret = dict_get_str (dict, str, &key);                  if (ret)                          break; -                sprintf (str, "value%d", count); +                snprintf (str, sizeof str, "value%d", count);                  ret = dict_get_str (dict, str, &value);                  if (ret) {                          gf_msg (this->name, GF_LOG_ERROR, 0, diff --git a/xlators/mgmt/glusterd/src/glusterd-pmap.c b/xlators/mgmt/glusterd/src/glusterd-pmap.c index b95f73ea5a6..5fc7f2c48b5 100644 --- a/xlators/mgmt/glusterd/src/glusterd-pmap.c +++ b/xlators/mgmt/glusterd/src/glusterd-pmap.c @@ -10,6 +10,7 @@  #include "xlator.h"  #include "glusterfs.h" +#include "syscall.h"  #include "compat-errno.h"  #include "glusterd.h" @@ -42,7 +43,7 @@ pmap_port_isfree (int port)                  return -1;          ret = bind (sock, (struct sockaddr *)&sin, sizeof (sin)); -        close (sock); +        sys_close (sock);          return (ret == 0) ? 1 : 0;  } diff --git a/xlators/mgmt/glusterd/src/glusterd-quota.c b/xlators/mgmt/glusterd/src/glusterd-quota.c index 074c767654b..863c87e40bf 100644 --- a/xlators/mgmt/glusterd/src/glusterd-quota.c +++ b/xlators/mgmt/glusterd/src/glusterd-quota.c @@ -764,7 +764,7 @@ glusterd_copy_to_tmp_file (int src_fd, int dst_fd)          this = THIS;          GF_ASSERT (this); -        while ((bytes_read = read (src_fd, (void *)&buf, entry_sz)) > 0) { +        while ((bytes_read = sys_read (src_fd, (void *)&buf, entry_sz)) > 0) {                  if (bytes_read % 16 != 0) {                          gf_msg (this->name, GF_LOG_ERROR, 0,                                  GD_MSG_QUOTA_CONF_CORRUPT, "quota.conf " @@ -772,7 +772,7 @@ glusterd_copy_to_tmp_file (int src_fd, int dst_fd)                          ret = -1;                          goto out;                  } -                ret = write (dst_fd, (void *) buf, bytes_read); +                ret = sys_write (dst_fd, (void *) buf, bytes_read);                  if (ret == -1) {                          gf_msg (this->name, GF_LOG_ERROR, errno,                                  GD_MSG_QUOTA_CONF_WRITE_FAIL, @@ -834,7 +834,7 @@ glusterd_store_quota_conf_upgrade (glusterd_volinfo_t *volinfo)  out:          if (conf_fd != -1) -                close (conf_fd); +                sys_close (conf_fd);          if (ret && (fd > 0)) {                  gf_store_unlink_tmppath (volinfo->quota_conf_shandle); @@ -906,7 +906,7 @@ glusterd_store_quota_config (glusterd_volinfo_t *volinfo, char *path,          if (version < 1.2f && conf->op_version >= GD_OP_VERSION_3_7_0) {                  /* Upgrade quota.conf file to newer format */ -                close (conf_fd); +                sys_close (conf_fd);                  ret = glusterd_store_quota_conf_upgrade(volinfo);                  if (ret)                          goto out; @@ -959,7 +959,7 @@ glusterd_store_quota_config (glusterd_volinfo_t *volinfo, char *path,                  type = GF_QUOTA_CONF_TYPE_USAGE;          for (;;) { -                bytes_read = read (conf_fd, (void *)&buf, sizeof (buf)); +                bytes_read = sys_read (conf_fd, (void *)&buf, sizeof (buf));                  if (bytes_read <= 0) {                          /*The flag @is_first_read is TRUE when the loop is                           * entered, and is set to false if the first read @@ -983,7 +983,7 @@ glusterd_store_quota_config (glusterd_volinfo_t *volinfo, char *path,                  found = glusterd_find_gfid_match (gfid, type, buf, bytes_read,                                                    opcode, &bytes_to_write); -                ret = write (fd, (void *) buf, bytes_to_write); +                ret = sys_write (fd, (void *) buf, bytes_to_write);                  if (ret == -1) {                          gf_msg (this->name, GF_LOG_ERROR, errno,                                  GD_MSG_QUOTA_CONF_WRITE_FAIL, @@ -1065,7 +1065,7 @@ glusterd_store_quota_config (glusterd_volinfo_t *volinfo, char *path,          ret = 0;  out:          if (conf_fd != -1) { -                close (conf_fd); +                sys_close (conf_fd);          }          if (ret && (fd > 0)) { diff --git a/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c b/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c index 2ec7200d1da..764af57cd09 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c @@ -20,6 +20,7 @@  #include "glusterd-snapd-svc.h"  #include "glusterd-snapd-svc-helper.h"  #include "glusterd-snapshot-utils.h" +#include "syscall.h"  char *snapd_svc_name = "snapd"; @@ -251,7 +252,7 @@ glusterd_snapdsvc_start (glusterd_svc_t *svc, int flags)                  goto out;          } -        ret = access (svc->proc.volfile, F_OK); +        ret = sys_access (svc->proc.volfile, F_OK);          if (ret) {                  gf_msg (this->name, GF_LOG_DEBUG, 0,                          GD_MSG_VOLINFO_GET_FAIL, diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c index 1d64e6e980c..13cc1a7785a 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c @@ -3218,7 +3218,7 @@ glusterd_copy_file (const char *source, const char *destination)          GF_ASSERT (destination);          /* Here is stat is made to get the file permission of source file*/ -        ret = lstat (source, &stbuf); +        ret = sys_lstat (source, &stbuf);          if (ret) {                  gf_msg (this->name, GF_LOG_ERROR, errno,                          GD_MSG_FILE_OP_FAILED, "%s not found", source); @@ -3236,7 +3236,7 @@ glusterd_copy_file (const char *source, const char *destination)                  goto out;          } -        dest_fd = creat (destination, dest_mode); +        dest_fd = sys_creat (destination, dest_mode);          if (dest_fd < 0) {                  ret = -1;                  gf_msg (this->name, GF_LOG_ERROR, 0, @@ -3246,7 +3246,7 @@ glusterd_copy_file (const char *source, const char *destination)          }          do { -                ret = read (src_fd, buffer, sizeof (buffer)); +                ret = sys_read (src_fd, buffer, sizeof (buffer));                  if (ret ==  -1) {                          gf_msg (this->name, GF_LOG_ERROR, errno,                                  GD_MSG_FILE_OP_FAILED, "Error reading file " @@ -3257,7 +3257,7 @@ glusterd_copy_file (const char *source, const char *destination)                  if (read_len == 0)                          break; -                ret = write (dest_fd, buffer, read_len); +                ret = sys_write (dest_fd, buffer, read_len);                  if (ret != read_len) {                          gf_msg (this->name, GF_LOG_ERROR, 0,                                  GD_MSG_FILE_OP_FAILED, "Error writing in " @@ -3267,10 +3267,10 @@ glusterd_copy_file (const char *source, const char *destination)          } while (ret > 0);  out:          if (src_fd > 0) -                close (src_fd); +                sys_close (src_fd);          if (dest_fd > 0) -                close (dest_fd); +                sys_close (dest_fd);          return ret;  } @@ -3290,14 +3290,14 @@ glusterd_copy_folder (const char *source, const char *destination)          GF_ASSERT (source);          GF_ASSERT (destination); -        dir_ptr = opendir (source); +        dir_ptr = sys_opendir (source);          if (!dir_ptr) {                  gf_msg (this->name, GF_LOG_ERROR, errno,                          GD_MSG_DIR_OP_FAILED,  "Unable to open %s", source);                  goto out;          } -        while ((direntp = readdir (dir_ptr)) != NULL) { +        while ((direntp = sys_readdir (dir_ptr)) != NULL) {                  if (strcmp (direntp->d_name, ".") == 0 ||                      strcmp (direntp->d_name, "..") == 0)                          continue; @@ -3321,7 +3321,7 @@ glusterd_copy_folder (const char *source, const char *destination)          }  out:          if (dir_ptr) -                closedir (dir_ptr); +                sys_closedir (dir_ptr);          return ret;  } @@ -3463,7 +3463,7 @@ glusterd_copy_quota_files (glusterd_volinfo_t *src_vol,          /* quota.conf is not present if quota is not enabled, Hence ignoring           * the absence of this file           */ -        ret = lstat (src_path, &stbuf); +        ret = sys_lstat (src_path, &stbuf);          if (ret) {                  ret = 0;                  gf_msg_debug (this->name, 0, "%s not found", src_path); diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c index 90dac9e45de..e75e5722138 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c @@ -613,7 +613,7 @@ glusterd_snapshot_backup_vol (glusterd_volinfo_t *volinfo)                    priv->workdir);          /* Create trash folder if it is not there */ -        ret = mkdir (trashdir, 0777); +        ret = sys_mkdir (trashdir, 0777);          if (ret && errno != EEXIST) {                  gf_msg (this->name, GF_LOG_ERROR, errno,                          GD_MSG_DIR_OP_FAILED, @@ -624,7 +624,7 @@ glusterd_snapshot_backup_vol (glusterd_volinfo_t *volinfo)          }          /* Move the origin volume volder to the backup location */ -        ret = rename (pathname, delete_path); +        ret = sys_rename (pathname, delete_path);          if (ret) {                  gf_msg (this->name, GF_LOG_ERROR, errno,                          GD_MSG_FILE_OP_FAILED, @@ -635,7 +635,7 @@ glusterd_snapshot_backup_vol (glusterd_volinfo_t *volinfo)          /* Re-create an empty origin volume folder so that restore can           * happen. */ -        ret = mkdir (pathname, 0777); +        ret = sys_mkdir (pathname, 0777);          if (ret && errno != EEXIST) {                  gf_msg (this->name, GF_LOG_ERROR, errno,                          GD_MSG_DIR_OP_FAILED, @@ -652,14 +652,14 @@ out:          op_ret = ret;          if (ret) {                  /* Revert the changes in case of failure */ -                ret = rmdir (pathname); +                ret = sys_rmdir (pathname);                  if (ret) {                          gf_msg_debug (this->name, 0,                                  "Failed to rmdir: %s,err: %s",                                  pathname, strerror (errno));                  } -                ret = rename (delete_path, pathname); +                ret = sys_rename (delete_path, pathname);                  if (ret) {                          gf_msg (this->name, GF_LOG_ERROR, errno,                                  GD_MSG_FILE_OP_FAILED, @@ -667,7 +667,7 @@ out:                                  delete_path, pathname);                  } -                ret = rmdir (trashdir); +                ret = sys_rmdir (trashdir);                  if (ret) {                          gf_msg_debug (this->name, 0,                                  "Failed to rmdir: %s, Reason: %s", @@ -712,7 +712,7 @@ glusterd_copy_geo_rep_files (glusterd_volinfo_t *origin_vol,          GLUSTERD_GET_SNAP_GEO_REP_DIR(snapgeo_dir, snap_vol->snapshot, priv); -        ret = mkdir (snapgeo_dir, 0777); +        ret = sys_mkdir (snapgeo_dir, 0777);          if (ret) {                  gf_msg (this->name, GF_LOG_ERROR, errno,                          GD_MSG_DIR_OP_FAILED, @@ -2878,7 +2878,7 @@ glusterd_lvm_snapshot_remove (dict_t *rsp_dict, glusterd_volinfo_t *snap_vol)                          continue;                  } -                ret = lstat (brick_mount_path, &stbuf); +                ret = sys_lstat (brick_mount_path, &stbuf);                  if (ret) {                          gf_msg_debug (this->name, 0,                                  "Brick %s:%s already deleted.", @@ -2928,7 +2928,7 @@ glusterd_lvm_snapshot_remove (dict_t *rsp_dict, glusterd_volinfo_t *snap_vol)                  }                  /* Verify if the device path exists or not */ -                ret = stat (brickinfo->device_path, &stbuf); +                ret = sys_stat (brickinfo->device_path, &stbuf);                  if (ret) {                          gf_msg_debug (this->name, 0,                                  "LV (%s) for brick (%s:%s) not present. " @@ -4769,7 +4769,7 @@ glusterd_snap_brick_create (glusterd_volinfo_t *snap_volinfo,                  goto out;          } -        ret = stat (brickinfo->path, &statbuf); +        ret = sys_stat (brickinfo->path, &statbuf);          if (ret) {                  gf_msg (this->name, GF_LOG_WARNING, errno,                          GD_MSG_FILE_OP_FAILED, @@ -8574,7 +8574,7 @@ glusterd_snapshot_revert_partial_restored_vol (glusterd_volinfo_t *volinfo)          /* Now move the backup copy of the vols to its original           * location.*/ -        ret = rename (trash_path, pathname); +        ret = sys_rename (trash_path, pathname);          if (ret) {                  gf_msg (this->name, GF_LOG_ERROR, errno,                          GD_MSG_DIR_OP_FAILED, "Failed to rename folder " @@ -8905,7 +8905,7 @@ glusterd_is_lvm_cmd_available (char *lvm_cmd)          if (!lvm_cmd)                  return _gf_false; -        ret = stat (lvm_cmd, &buf); +        ret = sys_stat (lvm_cmd, &buf);          if (ret != 0) {                  gf_msg (THIS->name, GF_LOG_ERROR, errno,                          GD_MSG_FILE_OP_FAILED, 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; diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c index 18136fb6838..7cb44ba688f 100644 --- a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c +++ b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c @@ -20,6 +20,7 @@  #include "glusterd-bitd-svc.h"  #include "glusterd-scrub-svc.h"  #include "glusterd-svc-helper.h" +#include "syscall.h"  int  glusterd_svcs_reconfigure () @@ -194,10 +195,10 @@ glusterd_svc_check_volfile_identical (char *svc_name,  out:          if (need_unlink) -                unlink (tmpvol); +                sys_unlink (tmpvol);          if (tmp_fd >= 0) -                close (tmp_fd); +                sys_close (tmp_fd);          return ret;  } @@ -247,8 +248,8 @@ glusterd_svc_check_topology_identical (char *svc_name,                                                   identical);  out:          if (tmpfd >= 0) -                close (tmpfd); +                sys_close (tmpfd);          if (tmpclean) -                unlink (tmpvol); +                sys_unlink (tmpvol);          return ret;  } diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c index 17179aed609..1238990e632 100644 --- a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c +++ b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c @@ -17,6 +17,7 @@  #include "glusterd-proc-mgmt.h"  #include "glusterd-conn-mgmt.h"  #include "glusterd-messages.h" +#include "syscall.h"  int  glusterd_svc_create_rundir (char *rundir) @@ -161,7 +162,7 @@ glusterd_svc_start (glusterd_svc_t *svc, int flags, dict_t *cmdline)                  goto out;          } -        ret = access (svc->proc.volfile, F_OK); +        ret = sys_access (svc->proc.volfile, F_OK);          if (ret) {                  gf_msg (this->name, GF_LOG_ERROR, 0,                          GD_MSG_VOLFILE_NOT_FOUND, "Volfile %s is not present", diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index e368147584f..e42f119099b 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -130,7 +130,7 @@ glusterd_is_fuse_available ()          fd = open ("/dev/fuse", O_RDWR);  #endif -        if (fd > -1 && !close (fd)) +        if (fd > -1 && !sys_close (fd))                  return _gf_true;          else                  return _gf_false; @@ -1194,7 +1194,7 @@ glusterd_validate_and_create_brickpath (glusterd_brickinfo_t *brickinfo,          char         msg[2048]           = {0,};          gf_boolean_t is_created          = _gf_false; -        ret = mkdir (brickinfo->path, 0777); +        ret = sys_mkdir (brickinfo->path, 0777);          if (ret) {                  if (errno != EEXIST) {                          snprintf (msg, sizeof (msg), "Failed to create brick " @@ -1207,7 +1207,7 @@ glusterd_validate_and_create_brickpath (glusterd_brickinfo_t *brickinfo,                  is_created = _gf_true;          } -        ret = lstat (brickinfo->path, &brick_st); +        ret = sys_lstat (brickinfo->path, &brick_st);          if (ret) {                  snprintf (msg, sizeof (msg), "lstat failed on %s. Reason : %s",                            brickinfo->path, strerror (errno)); @@ -1224,14 +1224,14 @@ glusterd_validate_and_create_brickpath (glusterd_brickinfo_t *brickinfo,          snprintf (parentdir, sizeof (parentdir), "%s/..", brickinfo->path); -        ret = lstat ("/", &root_st); +        ret = sys_lstat ("/", &root_st);          if (ret) {                  snprintf (msg, sizeof (msg), "lstat failed on /. Reason : %s",                            strerror (errno));                  goto out;          } -        ret = lstat (parentdir, &parent_st); +        ret = sys_lstat (parentdir, &parent_st);          if (ret) {                  snprintf (msg, sizeof (msg), "lstat failed on %s. Reason : %s",                            parentdir, strerror (errno)); @@ -1281,7 +1281,7 @@ glusterd_validate_and_create_brickpath (glusterd_brickinfo_t *brickinfo,  out:          if (ret && is_created) -                rmdir (brickinfo->path); +                sys_rmdir (brickinfo->path);          if (ret && !*op_errstr && msg[0] != '\0')                  *op_errstr = gf_strdup (msg); @@ -1940,7 +1940,7 @@ glusterd_sort_and_redirect (const char *src_filepath, int dest_fd)          for (counter = 0; lines[counter]; counter++) { -                ret = write (dest_fd, lines[counter], +                ret = sys_write (dest_fd, lines[counter],                               strlen (lines[counter]));                  if (ret < 0)                          goto out; @@ -2011,7 +2011,7 @@ glusterd_volume_compute_cksum (glusterd_volinfo_t  *volinfo, char *cksum_path,                          goto out;                  } -                ret = close (sort_fd); +                ret = sys_close (sort_fd);                  if (ret)                          goto out;          } @@ -2027,7 +2027,7 @@ glusterd_volume_compute_cksum (glusterd_volinfo_t  *volinfo, char *cksum_path,          }          if (!is_quota_conf) {                  snprintf (buf, sizeof (buf), "%s=%u\n", "info", cksum); -                ret = write (fd, buf, strlen (buf)); +                ret = sys_write (fd, buf, strlen (buf));                  if (ret <= 0) {                          ret = -1;                          goto out; @@ -2042,9 +2042,9 @@ glusterd_volume_compute_cksum (glusterd_volinfo_t  *volinfo, char *cksum_path,  out:          if (fd > 0) -               close (fd); +               sys_close (fd);          if (unlink_sortfile) -               unlink (sort_filepath); +               sys_unlink (sort_filepath);          gf_msg_debug (this->name, 0, "Returning with %d", ret);          return ret; @@ -2578,7 +2578,7 @@ glusterd_vol_add_quota_conf_to_dict (glusterd_volinfo_t *volinfo, dict_t* load,          ret = 0;  out:          if (fd != -1) -                close (fd); +                sys_close (fd);          return ret;  } @@ -3755,7 +3755,7 @@ glusterd_delete_stale_volume (glusterd_volinfo_t *stale_volinfo,           */          (void) glusterd_delete_all_bricks (stale_volinfo);          if (stale_volinfo->shandle) { -                unlink (stale_volinfo->shandle->path); +                sys_unlink (stale_volinfo->shandle->path);                  (void) gf_store_handle_destroy (stale_volinfo->shandle);                  stale_volinfo->shandle = NULL;          } @@ -4157,7 +4157,7 @@ glusterd_unlink_file (char *sockfpath)  {          int             ret = 0; -        ret = unlink (sockfpath); +        ret = sys_unlink (sockfpath);          if (ret) {                  if (ENOENT == errno)                          ret = 0; @@ -4904,14 +4904,14 @@ glusterd_get_brick_root (char *path, char **mount_point)          mnt_pt = gf_strdup (path);          if (!mnt_pt)                  goto err; -        if (stat (mnt_pt, &brickstat)) +        if (sys_stat (mnt_pt, &brickstat))                  goto err;          while ((ptr = strrchr (mnt_pt, '/')) &&                 ptr != mnt_pt) {                  *ptr = '\0'; -                if (stat (mnt_pt, &buf)) { +                if (sys_stat (mnt_pt, &buf)) {                          gf_msg (THIS->name, GF_LOG_ERROR, errno,                                  GD_MSG_FILE_OP_FAILED, "error in "                                  "stat: %s", strerror (errno)); @@ -4925,7 +4925,7 @@ glusterd_get_brick_root (char *path, char **mount_point)          }          if (ptr == mnt_pt) { -                if (stat ("/", &buf)) { +                if (sys_stat ("/", &buf)) {                          gf_msg (THIS->name, GF_LOG_ERROR, errno,                                  GD_MSG_FILE_OP_FAILED, "error in "                                  "stat: %s", strerror (errno)); @@ -5022,12 +5022,12 @@ glusterd_add_inode_size_to_dict (dict_t *dict, int count)                  if (strcmp (fs_name, fs->fs_type_name) == 0) {                          snprintf (fs_tool_name, sizeof (fs_tool_name),                                    "/usr/sbin/%s", fs->fs_tool_name); -                        if (access (fs_tool_name, R_OK|X_OK) == 0) +                        if (sys_access (fs_tool_name, R_OK|X_OK) == 0)                                  runner_add_arg (&runner, fs_tool_name);                          else {                                  snprintf (fs_tool_name, sizeof (fs_tool_name),                                            "/sbin/%s", fs->fs_tool_name); -                                if (access (fs_tool_name, R_OK|X_OK) == 0) +                                if (sys_access (fs_tool_name, R_OK|X_OK) == 0)                                          runner_add_arg (&runner, fs_tool_name);                          }                          break; @@ -5266,7 +5266,7 @@ glusterd_add_brick_detail_to_dict (glusterd_volinfo_t *volinfo,          snprintf (base_key, sizeof (base_key), "brick%d", count); -        ret = statvfs (brickinfo->path, &brickstat); +        ret = sys_statvfs (brickinfo->path, &brickstat);          if (ret) {                  gf_msg (this->name, GF_LOG_ERROR, errno,                          GD_MSG_FILE_OP_FAILED, "statfs error: %s ", @@ -6456,7 +6456,7 @@ glusterd_set_dump_options (char *dumpoptions_path, char *options,          while (option) {                  if (!strcmp (option, priv->nfs_svc.name)) {                          if (nfs_cnt > 0) { -                                unlink (dumpoptions_path); +                                sys_unlink (dumpoptions_path);                                  ret = 0;                                  goto out;                          } @@ -6551,7 +6551,7 @@ glusterd_brick_statedump (glusterd_volinfo_t *volinfo,          sleep (1);          ret = 0;  out: -        unlink (dumpoptions_path); +        sys_unlink (dumpoptions_path);          if (pidfile)                  fclose (pidfile);          return ret; @@ -6634,7 +6634,7 @@ glusterd_nfs_statedump (char *options, int option_cnt, char **op_errstr)  out:          if (pidfile)                  fclose (pidfile); -        unlink (dumpoptions_path); +        sys_unlink (dumpoptions_path);          GF_FREE (dup_options);          return ret;  } @@ -6715,7 +6715,7 @@ glusterd_quotad_statedump (char *options, int option_cnt, char **op_errstr)  out:          if (pidfile)                  fclose (pidfile); -        unlink (dumpoptions_path); +        sys_unlink (dumpoptions_path);          GF_FREE (dup_options);          return ret;  } @@ -7252,7 +7252,7 @@ glusterd_check_files_identical (char *filename1, char *filename2,          this = THIS; -        ret = stat (filename1, &buf1); +        ret = sys_stat (filename1, &buf1);          if (ret) {                  gf_msg (this->name, GF_LOG_ERROR, errno, @@ -7262,7 +7262,7 @@ glusterd_check_files_identical (char *filename1, char *filename2,                  goto out;          } -        ret = stat (filename2, &buf2); +        ret = sys_stat (filename2, &buf2);          if (ret) {                  gf_msg (this->name, GF_LOG_ERROR, errno, @@ -9545,8 +9545,8 @@ glusterd_clean_up_quota_store (glusterd_volinfo_t *volinfo)          snprintf (cksum_path, sizeof (cksum_path), "%s/%s", voldir,                    GLUSTERD_VOL_QUOTA_CKSUM_FILE); -        unlink (quota_confpath); -        unlink (cksum_path); +        sys_unlink (quota_confpath); +        sys_unlink (cksum_path);          gf_store_handle_destroy (volinfo->quota_conf_shandle);          volinfo->quota_conf_shandle = NULL; diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index aa6aa169ed2..e837b2fc83a 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -16,6 +16,7 @@  #include "xlator.h"  #include "glusterd.h"  #include "defaults.h" +#include "syscall.h"  #include "logging.h"  #include "dict.h"  #include "graph-utils.h" @@ -915,7 +916,7 @@ volgen_apply_filters (char *orig_volfile)          char          *filterpath = NULL;          struct stat    statbuf = {0,}; -        filterdir = opendir(FILTERDIR); +        filterdir = sys_opendir (FILTERDIR);          if (!filterdir) {                  return;          } @@ -936,7 +937,7 @@ volgen_apply_filters (char *orig_volfile)                          continue;                  }                  /* Deliberately use stat instead of lstat to allow symlinks. */ -                if (stat(filterpath,&statbuf) == (-1)) { +                if (sys_stat(filterpath, &statbuf) == (-1)) {                          goto free_fp;                  }                  if (!S_ISREG(statbuf.st_mode)) { @@ -947,7 +948,7 @@ volgen_apply_filters (char *orig_volfile)                   * this entirely and check for EPERM after exec fails, but this                   * is cleaner.                   */ -                if (access(filterpath,X_OK) != 0) { +                if (sys_access(filterpath, X_OK) != 0) {                          goto free_fp;                  }                  if (runcmd(filterpath,orig_volfile,NULL)) { @@ -960,7 +961,7 @@ free_fp:                  GF_FREE(filterpath);          } -        closedir (filterdir); +        sys_closedir (filterdir);  }  static int @@ -979,14 +980,14 @@ volgen_write_volfile (volgen_graph_t *graph, char *filename)                  goto error;          } -        fd = creat (ftmp, S_IRUSR | S_IWUSR); +        fd = sys_creat (ftmp, S_IRUSR | S_IWUSR);          if (fd < 0) {                  gf_msg (this->name, GF_LOG_ERROR, errno,                          GD_MSG_FILE_OP_FAILED, "file creation failed");                  goto error;          } -        close (fd); +        sys_close (fd);          f = fopen (ftmp, "w");          if (!f) @@ -1011,7 +1012,7 @@ volgen_write_volfile (volgen_graph_t *graph, char *filename)          f = NULL; -        if (rename (ftmp, filename) == -1) +        if (sys_rename (ftmp, filename) == -1)                  goto error;          GF_FREE (ftmp); @@ -5058,7 +5059,7 @@ generate_brick_volfiles (glusterd_volinfo_t *volinfo)                          return -1;                  }                  if (ret >= 0) { -                        close (ret); +                        sys_close (ret);                          /* If snap_volume, retain timestamp for marker.tstamp                           * from parent. Geo-replication depends on mtime of                           * 'marker.tstamp' to decide the volume-mark, i.e., @@ -5080,7 +5081,7 @@ generate_brick_volfiles (glusterd_volinfo_t *volinfo)                          }                  }          } else { -                ret = unlink (tstamp_file); +                ret = sys_unlink (tstamp_file);                  if (ret == -1 && errno == ENOENT)                          ret = 0;                  if (ret == -1) { @@ -5747,7 +5748,7 @@ glusterd_delete_volfile (glusterd_volinfo_t *volinfo,          GF_ASSERT (brickinfo);          get_brick_filepath (filename, volinfo, brickinfo); -        ret = unlink (filename); +        ret = sys_unlink (filename);          if (ret)                  gf_msg ("glusterd", GF_LOG_ERROR, errno,                          GD_MSG_FILE_OP_FAILED, diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c index b00539d4efa..a20036af89f 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c @@ -2781,7 +2781,7 @@ glusterd_clearlocks_rmdir_mount (glusterd_volinfo_t *volinfo, char *mntpt)          priv = THIS->private; -        ret = rmdir (mntpt); +        ret = sys_rmdir (mntpt);          if (ret) {                  gf_msg_debug (THIS->name, 0, "rmdir failed");                  goto out; diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c index e52dbf8aa46..aaffebd7291 100644 --- a/xlators/mgmt/glusterd/src/glusterd.c +++ b/xlators/mgmt/glusterd/src/glusterd.c @@ -473,16 +473,16 @@ group_write_allow (char *path, gid_t gid)          struct stat st = {0,};          int ret        = 0; -        ret = stat (path, &st); +        ret = sys_stat (path, &st);          if (ret == -1)                  goto out;          GF_ASSERT (S_ISDIR (st.st_mode)); -        ret = chown (path, -1, gid); +        ret = sys_chown (path, -1, gid);          if (ret == -1)                  goto out; -        ret = chmod (path, (st.st_mode & ~S_IFMT) | S_IWGRP|S_IXGRP|S_ISVTX); +        ret = sys_chmod (path, (st.st_mode & ~S_IFMT) | S_IWGRP|S_IXGRP|S_ISVTX);   out:          if (ret == -1) @@ -847,7 +847,7 @@ check_prepare_mountbroker_root (char *mountbroker_root)          ret = open (mountbroker_root, O_RDONLY);          if (ret != -1) {                  dfd = ret; -                ret = fstat (dfd, &st); +                ret = sys_fstat (dfd, &st);          }          if (ret == -1 || !S_ISDIR (st.st_mode)) {                  gf_msg ("glusterd", GF_LOG_ERROR, errno, @@ -879,7 +879,7 @@ check_prepare_mountbroker_root (char *mountbroker_root)                  ret = sys_openat (dfd, "..", O_RDONLY);                  if (ret != -1) {                          dfd2 = ret; -                        ret = fstat (dfd2, &st2); +                        ret = sys_fstat (dfd2, &st2);                  }                  if (ret == -1) {                          gf_msg ("glusterd", GF_LOG_ERROR, errno, @@ -909,7 +909,7 @@ check_prepare_mountbroker_root (char *mountbroker_root)                                  "directory are probably too strict");                  } -                close (dfd); +                sys_close (dfd);                  dfd = dfd2;                  st = st2;          } @@ -932,11 +932,11 @@ check_prepare_mountbroker_root (char *mountbroker_root)   out:          if (dfd0 != -1) -                close (dfd0); +                sys_close (dfd0);          if (dfd != -1) -                close (dfd); +                sys_close (dfd);          if (dfd2 != -1) -                close (dfd2); +                sys_close (dfd2);          return ret;  } @@ -1149,7 +1149,7 @@ glusterd_stop_uds_listener (xlator_t *this)          } else {                  strncpy (sockfile, sock_data->data, UNIX_PATH_MAX);          } -        unlink (sockfile); +        sys_unlink (sockfile);          return;  } @@ -1201,7 +1201,7 @@ glusterd_find_correct_var_run_dir (xlator_t *this, char *var_run_dir)           * and glusterd maintained entry point will be different. Therefore           * identify the correct run dir and use it           */ -        ret = lstat (GLUSTERD_VAR_RUN_DIR, &buf); +        ret = sys_lstat (GLUSTERD_VAR_RUN_DIR, &buf);          if (ret != 0) {                  gf_msg (this->name, GF_LOG_ERROR, errno,                          GD_MSG_FILE_OP_FAILED, @@ -1237,7 +1237,7 @@ glusterd_init_var_run_dirs (xlator_t *this, char *var_run_dir,          snprintf (abs_path, sizeof(abs_path), "%s%s",                    var_run_dir, dir_to_be_created); -        ret = stat (abs_path, &buf); +        ret = sys_stat (abs_path, &buf);          if ((ret != 0) && (ENOENT != errno)) {                  gf_msg (this->name, GF_LOG_ERROR, errno,                          GD_MSG_FILE_OP_FAILED, @@ -1357,7 +1357,7 @@ init (xlator_t *this)                  strncpy (workdir, dir_data->data, PATH_MAX);          } -        ret = stat (workdir, &buf); +        ret = sys_stat (workdir, &buf);          if ((ret != 0) && (ENOENT != errno)) {                  gf_msg (this->name, GF_LOG_ERROR, errno,                          GD_MSG_DIR_OP_FAILED, @@ -1436,7 +1436,7 @@ init (xlator_t *this)          snprintf (storedir, PATH_MAX, "%s/vols", workdir); -        ret = mkdir (storedir, 0777); +        ret = sys_mkdir (storedir, 0777);          if ((-1 == ret) && (errno != EEXIST)) {                  gf_msg (this->name, GF_LOG_CRITICAL, errno, @@ -1448,7 +1448,7 @@ init (xlator_t *this)          snprintf (storedir, PATH_MAX, "%s/snaps", workdir); -        ret = mkdir (storedir, 0777); +        ret = sys_mkdir (storedir, 0777);          if ((-1 == ret) && (errno != EEXIST)) {                  gf_msg (this->name, GF_LOG_CRITICAL, errno, @@ -1460,7 +1460,7 @@ init (xlator_t *this)          snprintf (storedir, PATH_MAX, "%s/peers", workdir); -        ret = mkdir (storedir, 0777); +        ret = sys_mkdir (storedir, 0777);          if ((-1 == ret) && (errno != EEXIST)) {                  gf_msg (this->name, GF_LOG_CRITICAL, errno, @@ -1471,7 +1471,7 @@ init (xlator_t *this)          }          snprintf (storedir, PATH_MAX, "%s/bricks", DEFAULT_LOG_FILE_DIRECTORY); -        ret = mkdir (storedir, 0777); +        ret = sys_mkdir (storedir, 0777);          if ((-1 == ret) && (errno != EEXIST)) {                  gf_msg (this->name, GF_LOG_CRITICAL, errno,                          GD_MSG_CREATE_DIR_FAILED, @@ -1481,7 +1481,7 @@ init (xlator_t *this)          }          snprintf (storedir, PATH_MAX, "%s/nfs", workdir); -        ret = mkdir (storedir, 0777); +        ret = sys_mkdir (storedir, 0777);          if ((-1 == ret) && (errno != EEXIST)) {                  gf_msg (this->name, GF_LOG_CRITICAL, errno,                          GD_MSG_CREATE_DIR_FAILED, @@ -1491,7 +1491,7 @@ init (xlator_t *this)          }          snprintf (storedir, PATH_MAX, "%s/bitd", workdir); -        ret = mkdir (storedir, 0777); +        ret = sys_mkdir (storedir, 0777);          if ((-1 == ret) && (errno != EEXIST)) {                  gf_msg (this->name, GF_LOG_CRITICAL, errno,                          GD_MSG_CREATE_DIR_FAILED, @@ -1501,7 +1501,7 @@ init (xlator_t *this)          }          snprintf (storedir, PATH_MAX, "%s/scrub", workdir); -        ret = mkdir (storedir, 0777); +        ret = sys_mkdir (storedir, 0777);          if ((-1 == ret) && (errno != EEXIST)) {                  gf_msg (this->name, GF_LOG_CRITICAL, errno,                          GD_MSG_CREATE_DIR_FAILED, @@ -1511,7 +1511,7 @@ init (xlator_t *this)          }          snprintf (storedir, PATH_MAX, "%s/glustershd", workdir); -        ret = mkdir (storedir, 0777); +        ret = sys_mkdir (storedir, 0777);          if ((-1 == ret) && (errno != EEXIST)) {                  gf_msg (this->name, GF_LOG_CRITICAL, errno,                          GD_MSG_CREATE_DIR_FAILED, @@ -1521,7 +1521,7 @@ init (xlator_t *this)          }          snprintf (storedir, PATH_MAX, "%s/quotad", workdir); -        ret = mkdir (storedir, 0777); +        ret = sys_mkdir (storedir, 0777);          if ((-1 == ret) && (errno != EEXIST)) {                  gf_msg (this->name, GF_LOG_CRITICAL, errno,                          GD_MSG_CREATE_DIR_FAILED, @@ -1531,7 +1531,7 @@ init (xlator_t *this)          }          snprintf (storedir, PATH_MAX, "%s/groups", workdir); -        ret = mkdir (storedir, 0777); +        ret = sys_mkdir (storedir, 0777);          if ((-1 == ret) && (errno != EEXIST)) {                  gf_msg (this->name, GF_LOG_CRITICAL, errno,                          GD_MSG_CREATE_DIR_FAILED,  | 
