summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorKaleb S. KEITHLEY <kkeithle@redhat.com>2015-10-01 16:31:19 -0400
committerJeff Darcy <jdarcy@redhat.com>2015-10-28 13:38:42 -0700
commit3066a21caafab6305527991de11c8eb43ec0044c (patch)
tree5efc91272ac76ff1613cee1e8a41aeb32aa92d73 /xlators
parent063d4ead61ee47433793de81a1c77e0ba69e6e07 (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>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/cluster/dht/src/dht-rebalance.c3
-rw-r--r--xlators/cluster/dht/src/tier.c11
-rw-r--r--xlators/features/compress/src/cdc-helper.c7
-rw-r--r--xlators/features/index/src/index.c39
-rw-r--r--xlators/features/marker/src/marker.c7
-rw-r--r--xlators/features/trash/src/trash.c3
-rw-r--r--xlators/mount/fuse/src/fuse-bridge.c37
-rw-r--r--xlators/nfs/server/src/nlm4.c5
-rw-r--r--xlators/protocol/server/src/server-handshake.c9
-rw-r--r--xlators/protocol/server/src/server-helpers.c3
-rw-r--r--xlators/storage/bd/src/bd-helper.c33
-rw-r--r--xlators/storage/bd/src/bd.c6
-rw-r--r--xlators/storage/posix/src/posix-handle.c50
-rw-r--r--xlators/storage/posix/src/posix-helpers.c46
-rw-r--r--xlators/storage/posix/src/posix.c92
15 files changed, 181 insertions, 170 deletions
diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c
index fab4e2f..c0e10f2 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 bd78e78..9930fe0 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 21f529c..0a9a0e3 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 2bba663..5de8d9b 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 4e4a280..e579417 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 18e36e7..35712f9 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 81c247a..4b390ee 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 26c45e0..3da3b2d 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 62d9368..293509c 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 0971e84..bcd1fed 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 9532ad3..520ddd8 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 f732b85..9599f4a 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 331f721..9a521d0 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 0353788..f7fc57f 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 b544e37..e2fe081 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;
}