summaryrefslogtreecommitdiffstats
path: root/xlators/storage
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/storage')
-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
5 files changed, 114 insertions, 113 deletions
diff --git a/xlators/storage/bd/src/bd-helper.c b/xlators/storage/bd/src/bd-helper.c
index 9532ad3cfd2..520ddd86c06 100644
--- a/xlators/storage/bd/src/bd-helper.c
+++ b/xlators/storage/bd/src/bd-helper.c
@@ -8,6 +8,7 @@
#include "bd-mem-types.h"
#include "run.h"
#include "lvm-defaults.h"
+#include "syscall.h"
int
bd_inode_ctx_set (inode_t *inode, xlator_t *this, bd_attr_t *ctx)
@@ -269,7 +270,7 @@ out:
GF_FREE (devpath);
if (ret) {
if (_fd >= 0)
- close (_fd);
+ sys_close (_fd);
GF_FREE (bdfd);
}
return ret;
@@ -338,7 +339,7 @@ bd_validate_bd_xattr (xlator_t *this, char *bd, char **type,
}
/* Destination file does not exist */
- if (stat (path, &stbuf)) {
+ if (sys_stat (path, &stbuf)) {
gf_log (this->name, GF_LOG_WARNING,
"lstat failed for path %s", path);
return -1;
@@ -400,7 +401,7 @@ create_thin_lv (char *vg, char *pool, char *lv, uint64_t extent)
ret = ENOMEM;
goto out;
}
- if (lstat (path, &stat) < 0)
+ if (sys_lstat (path, &stat) < 0)
ret = EAGAIN;
else
ret = 0;
@@ -612,7 +613,7 @@ bd_snapshot_create (bd_local_t *local, bd_priv_t *priv)
runner_start (&runner);
runner_end (&runner);
- if (lstat (path, &stat) < 0)
+ if (sys_lstat (path, &stat) < 0)
ret = EIO;
GF_FREE (path);
@@ -672,7 +673,7 @@ bd_clone (bd_local_t *local, bd_priv_t *priv)
}
while (1) {
- bytes = readv (fd1, vec, IOV_NR);
+ bytes = sys_readv (fd1, vec, IOV_NR);
if (bytes < 0) {
ret = errno;
gf_log (THIS->name, GF_LOG_WARNING, "read failed: %s",
@@ -681,7 +682,7 @@ bd_clone (bd_local_t *local, bd_priv_t *priv)
}
if (!bytes)
break;
- bytes = writev (fd2, vec, IOV_NR);
+ bytes = sys_writev (fd2, vec, IOV_NR);
if (bytes < 0) {
ret = errno;
gf_log (THIS->name, GF_LOG_WARNING,
@@ -697,9 +698,9 @@ out:
GF_FREE (vec);
if (fd1 != -1)
- close (fd1);
+ sys_close (fd1);
if (fd2 != -1)
- close (fd2);
+ sys_close (fd2);
GF_FREE (spath);
GF_FREE (dpath);
@@ -729,7 +730,7 @@ bd_merge (bd_priv_t *priv, uuid_t gfid)
runner_start (&runner);
runner_end (&runner);
- if (!lstat (path, &stat))
+ if (!sys_lstat (path, &stat))
ret = EIO;
GF_FREE (path);
@@ -847,18 +848,18 @@ bd_do_manual_zerofill (int fd, off_t offset, off_t len, int o_direct)
}
for (idx = 0; idx < num_loop; idx++) {
- op_ret = writev (fd, vector, num_vect);
+ op_ret = sys_writev (fd, vector, num_vect);
if (op_ret < 0)
goto err;
}
if (extra) {
- op_ret = writev (fd, vector, extra);
+ op_ret = sys_writev (fd, vector, extra);
if (op_ret < 0)
goto err;
}
if (remain) {
vector[0].iov_len = remain;
- op_ret = writev (fd, vector , 1);
+ op_ret = sys_writev (fd, vector , 1);
if (op_ret < 0)
goto err;
}
@@ -902,7 +903,7 @@ bd_do_ioctl_zerofill (bd_priv_t *priv, bd_attr_t *bdatt, int fd, char *vg,
uuid_utoa_r (bdatt->iatt.ia_gfid, uuid);
sprintf (lvname, "/dev/%s/%s", vg, uuid);
- readlink (lvname, dmname, sizeof (dmname) - 1);
+ sys_readlink (lvname, dmname, sizeof (dmname) - 1);
p = strrchr (dmname, '/');
if (p)
@@ -918,8 +919,8 @@ bd_do_ioctl_zerofill (bd_priv_t *priv, bd_attr_t *bdatt, int fd, char *vg,
goto skip;
}
- read (sysfd, buff, sizeof (buff));
- close (sysfd);
+ sys_read (sysfd, buff, sizeof (buff));
+ sys_close (sysfd);
max_bytes = atoll (buff);
@@ -1000,7 +1001,7 @@ bd_do_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd,
}
if (bd_fd->flag & (O_SYNC|O_DSYNC)) {
- ret = fsync (bd_fd->fd);
+ ret = sys_fsync (bd_fd->fd);
if (ret) {
gf_log (this->name, GF_LOG_ERROR,
"fsync() in writev on fd %d failed: %s",
diff --git a/xlators/storage/bd/src/bd.c b/xlators/storage/bd/src/bd.c
index f732b85f030..9599f4acbd5 100644
--- a/xlators/storage/bd/src/bd.c
+++ b/xlators/storage/bd/src/bd.c
@@ -614,7 +614,7 @@ bd_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
"bd_fd is NULL from fd=%p", fd);
goto out;
}
- close (bd_fd->fd);
+ sys_close (bd_fd->fd);
GF_FREE (bd_fd);
out:
@@ -690,7 +690,7 @@ out:
GF_FREE (devpath);
if (ret) {
if (_fd >= 0)
- close (_fd);
+ sys_close (_fd);
GF_FREE (bd_fd);
}
@@ -892,7 +892,7 @@ bd_release (xlator_t *this, fd_t *fd)
}
bd_fd = (bd_fd_t *)(long)tmp_bfd;
- close (bd_fd->fd);
+ sys_close (bd_fd->fd);
GF_FREE (bd_fd);
out:
return 0;
diff --git a/xlators/storage/posix/src/posix-handle.c b/xlators/storage/posix/src/posix-handle.c
index 331f7212614..9a521d019a4 100644
--- a/xlators/storage/posix/src/posix-handle.c
+++ b/xlators/storage/posix/src/posix-handle.c
@@ -145,7 +145,7 @@ posix_make_ancestryfromgfid (xlator_t *this, char *path, int pathsize,
priv_base_path, GF_HIDDEN_PATH, gfid[0], gfid[1],
uuid_utoa (gfid));
- len = readlink (dir_handle, linkname, PATH_MAX);
+ len = sys_readlink (dir_handle, linkname, PATH_MAX);
if (len < 0) {
gf_msg (this->name, (errno == ENOENT || errno == ESTALE)
? GF_LOG_DEBUG:GF_LOG_ERROR, errno,
@@ -278,7 +278,7 @@ posix_handle_pump (xlator_t *this, char *buf, int len, int maxlen,
int link_len = 0;
/* is a directory's symlink-handle */
- ret = readlink (base_str, linkname, 512);
+ ret = sys_readlink (base_str, linkname, 512);
if (ret == -1) {
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_READLINK_FAILED,
"internal readlink failed on %s ",
@@ -373,7 +373,7 @@ posix_handle_path (xlator_t *this, uuid_t gfid, const char *basename,
len = snprintf (buf, maxlen, "%s", base_str);
}
- ret = lstat (base_str, &stat);
+ ret = sys_lstat (base_str, &stat);
if (!(ret == 0 && S_ISLNK(stat.st_mode) && stat.st_nlink == 1))
goto out;
@@ -387,7 +387,7 @@ posix_handle_path (xlator_t *this, uuid_t gfid, const char *basename,
if (ret == -1)
break;
- ret = lstat (buf, &stat);
+ ret = sys_lstat (buf, &stat);
} while ((ret == -1) && errno == ELOOP);
out:
@@ -462,7 +462,7 @@ posix_handle_init (xlator_t *this)
priv = this->private;
- ret = stat (priv->base_path, &exportbuf);
+ ret = sys_stat (priv->base_path, &exportbuf);
if (ret || !S_ISDIR (exportbuf.st_mode)) {
gf_msg (this->name, GF_LOG_ERROR, 0,
P_MSG_HANDLE_CREATE,
@@ -475,11 +475,11 @@ posix_handle_init (xlator_t *this)
sprintf (handle_pfx, "%s/%s", priv->base_path, GF_HIDDEN_PATH);
- ret = stat (handle_pfx, &stbuf);
+ ret = sys_stat (handle_pfx, &stbuf);
switch (ret) {
case -1:
if (errno == ENOENT) {
- ret = mkdir (handle_pfx, 0600);
+ ret = sys_mkdir (handle_pfx, 0600);
if (ret != 0) {
gf_msg (this->name, GF_LOG_ERROR, errno,
P_MSG_HANDLE_CREATE,
@@ -508,11 +508,11 @@ posix_handle_init (xlator_t *this)
break;
}
- stat (handle_pfx, &priv->handledir);
+ sys_stat (handle_pfx, &priv->handledir);
MAKE_HANDLE_ABSPATH(rootstr, this, gfid);
- ret = stat (rootstr, &rootbuf);
+ ret = sys_stat (rootstr, &rootbuf);
switch (ret) {
case -1:
if (errno != ENOENT) {
@@ -530,7 +530,7 @@ posix_handle_init (xlator_t *this)
return -1;
}
- ret = symlink ("../../..", rootstr);
+ ret = sys_symlink ("../../..", rootstr);
if (ret) {
gf_msg (this->name, GF_LOG_ERROR, errno,
P_MSG_HANDLE_CREATE,
@@ -566,7 +566,7 @@ posix_does_old_trash_exists (char *old_trash)
struct stat stbuf = {0};
int ret = 0;
- ret = lstat (old_trash, &stbuf);
+ ret = sys_lstat (old_trash, &stbuf);
if ((ret == 0) && S_ISDIR (stbuf.st_mode)) {
ret = sys_lgetxattr (old_trash, "trusted.gfid", gfid, 16);
if ((ret < 0) && (errno == ENODATA || errno == ENOATTR) )
@@ -581,11 +581,11 @@ posix_handle_new_trash_init (xlator_t *this, char *trash)
int ret = 0;
struct stat stbuf = {0};
- ret = lstat (trash, &stbuf);
+ ret = sys_lstat (trash, &stbuf);
switch (ret) {
case -1:
if (errno == ENOENT) {
- ret = mkdir (trash, 0755);
+ ret = sys_mkdir (trash, 0755);
if (ret != 0) {
gf_msg (this->name, GF_LOG_ERROR, errno,
P_MSG_HANDLE_TRASH_CREATE,
@@ -624,7 +624,7 @@ posix_mv_old_trash_into_new_trash (xlator_t *this, char *old, char *new)
gf_uuid_generate (dest_name);
snprintf (dest_old, sizeof (dest_old), "%s/%s", new,
uuid_utoa (dest_name));
- ret = rename (old, dest_old);
+ ret = sys_rename (old, dest_old);
if (ret < 0) {
gf_msg (this->name, GF_LOG_ERROR, errno,
P_MSG_HANDLE_TRASH_CREATE,
@@ -675,7 +675,7 @@ posix_handle_mkdir_hashes (xlator_t *this, const char *newpath)
parpath = dirname (duppath);
parpath = dirname (duppath);
- ret = mkdir (parpath, 0700);
+ ret = sys_mkdir (parpath, 0700);
if (ret == -1 && errno != EEXIST) {
gf_msg (this->name, GF_LOG_ERROR, errno,
P_MSG_HANDLE_CREATE,
@@ -686,7 +686,7 @@ posix_handle_mkdir_hashes (xlator_t *this, const char *newpath)
strcpy (duppath, newpath);
parpath = dirname (duppath);
- ret = mkdir (parpath, 0700);
+ ret = sys_mkdir (parpath, 0700);
if (ret == -1 && errno != EEXIST) {
gf_msg (this->name, GF_LOG_ERROR, errno,
P_MSG_HANDLE_CREATE,
@@ -708,7 +708,7 @@ posix_handle_hard (xlator_t *this, const char *oldpath, uuid_t gfid, struct stat
MAKE_HANDLE_ABSPATH (newpath, this, gfid);
- ret = lstat (newpath, &newbuf);
+ ret = sys_lstat (newpath, &newbuf);
if (ret == -1 && errno != ENOENT) {
gf_msg (this->name, GF_LOG_WARNING, errno,
P_MSG_HANDLE_CREATE,
@@ -734,7 +734,7 @@ posix_handle_hard (xlator_t *this, const char *oldpath, uuid_t gfid, struct stat
return -1;
}
- ret = lstat (newpath, &newbuf);
+ ret = sys_lstat (newpath, &newbuf);
if (ret) {
gf_msg (this->name, GF_LOG_WARNING, errno,
P_MSG_HANDLE_CREATE,
@@ -770,7 +770,7 @@ posix_handle_soft (xlator_t *this, const char *real_path, loc_t *loc,
MAKE_HANDLE_ABSPATH (newpath, this, gfid);
MAKE_HANDLE_RELPATH (oldpath, this, loc->pargfid, loc->name);
- ret = lstat (newpath, &newbuf);
+ ret = sys_lstat (newpath, &newbuf);
if (ret == -1 && errno != ENOENT) {
gf_msg (this->name, GF_LOG_WARNING, errno,
P_MSG_HANDLE_CREATE, "%s", newpath);
@@ -792,7 +792,7 @@ posix_handle_soft (xlator_t *this, const char *real_path, loc_t *loc,
return -1;
}
- ret = symlink (oldpath, newpath);
+ ret = sys_symlink (oldpath, newpath);
if (ret) {
gf_msg (this->name, GF_LOG_WARNING, errno,
P_MSG_HANDLE_CREATE,
@@ -801,7 +801,7 @@ posix_handle_soft (xlator_t *this, const char *real_path, loc_t *loc,
return -1;
}
- ret = lstat (newpath, &newbuf);
+ ret = sys_lstat (newpath, &newbuf);
if (ret) {
gf_msg (this->name, GF_LOG_WARNING, errno,
P_MSG_HANDLE_CREATE,
@@ -810,7 +810,7 @@ posix_handle_soft (xlator_t *this, const char *real_path, loc_t *loc,
}
}
- ret = stat (real_path, &newbuf);
+ ret = sys_stat (real_path, &newbuf);
if (ret) {
gf_msg (this->name, GF_LOG_WARNING, errno,
P_MSG_HANDLE_CREATE,
@@ -845,7 +845,7 @@ posix_handle_unset_gfid (xlator_t *this, uuid_t gfid)
MAKE_HANDLE_GFID_PATH (path, this, gfid, NULL);
- ret = lstat (path, &stat);
+ ret = sys_lstat (path, &stat);
if (ret == -1) {
if (errno != ENOENT) {
@@ -855,7 +855,7 @@ posix_handle_unset_gfid (xlator_t *this, uuid_t gfid)
goto out;
}
- ret = unlink (path);
+ ret = sys_unlink (path);
if (ret == -1) {
gf_msg (this->name, GF_LOG_WARNING, errno,
P_MSG_HANDLE_DELETE, "unlink %s failed ", path);
@@ -917,7 +917,7 @@ posix_create_link_if_gfid_exists (xlator_t *this, uuid_t gfid,
return ret;
}
- ret = lstat (newpath, &stbuf);
+ ret = sys_lstat (newpath, &stbuf);
if (!ret) {
ret = sys_link (newpath, real_path);
}
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
index 0353788740e..f7fc57fef67 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -401,7 +401,7 @@ _posix_xattr_get_set (dict_t *xattr_req, char *key, data_t *data,
goto err;
}
- ret = read (_fd, databuf, filler->stbuf->ia_size);
+ ret = sys_read (_fd, databuf, filler->stbuf->ia_size);
if (ret == -1) {
gf_msg (filler->this->name, GF_LOG_ERROR, errno,
P_MSG_XDATA_GETXATTR,
@@ -410,7 +410,7 @@ _posix_xattr_get_set (dict_t *xattr_req, char *key, data_t *data,
goto err;
}
- ret = close (_fd);
+ ret = sys_close (_fd);
_fd = -1;
if (ret == -1) {
gf_msg (filler->this->name, GF_LOG_ERROR, errno,
@@ -435,7 +435,7 @@ _posix_xattr_get_set (dict_t *xattr_req, char *key, data_t *data,
databuf = NULL;
err:
if (_fd != -1)
- close (_fd);
+ sys_close (_fd);
GF_FREE (databuf);
}
} else if (!strcmp (key, GLUSTERFS_OPEN_FD_COUNT)) {
@@ -552,7 +552,7 @@ posix_fdstat (xlator_t *this, int fd, struct iatt *stbuf_p)
struct stat fstatbuf = {0, };
struct iatt stbuf = {0, };
- ret = fstat (fd, &fstatbuf);
+ ret = sys_fstat (fd, &fstatbuf);
if (ret == -1)
goto out;
@@ -596,7 +596,7 @@ posix_istat (xlator_t *this, uuid_t gfid, const char *basename,
goto out;
}
- ret = lstat (real_path, &lstatbuf);
+ ret = sys_lstat (real_path, &lstatbuf);
if (ret != 0) {
if (ret == -1) {
@@ -886,7 +886,7 @@ posix_set_file_contents (xlator_t *this, const char *path, char *keyp,
}
if (value->len) {
- ret = write (file_fd, value->data, value->len);
+ ret = sys_write (file_fd, value->data, value->len);
if (ret == -1) {
op_ret = -errno;
gf_msg (this->name, GF_LOG_ERROR, errno,
@@ -896,7 +896,7 @@ posix_set_file_contents (xlator_t *this, const char *path, char *keyp,
goto out;
}
- ret = close (file_fd);
+ ret = sys_close (file_fd);
if (ret == -1) {
op_ret = -errno;
gf_msg (this->name, GF_LOG_ERROR, errno,
@@ -919,7 +919,7 @@ posix_set_file_contents (xlator_t *this, const char *path, char *keyp,
goto out;
}
- ret = write (file_fd, value->data, value->len);
+ ret = sys_write (file_fd, value->data, value->len);
if (ret == -1) {
op_ret = -errno;
gf_msg (this->name, GF_LOG_ERROR, errno,
@@ -928,7 +928,7 @@ posix_set_file_contents (xlator_t *this, const char *path, char *keyp,
goto out;
}
- ret = close (file_fd);
+ ret = sys_close (file_fd);
if (ret == -1) {
op_ret = -errno;
gf_msg (this->name, GF_LOG_ERROR, errno,
@@ -989,7 +989,7 @@ posix_get_file_contents (xlator_t *this, uuid_t pargfid,
goto out;
}
- ret = read (file_fd, *contents, stbuf.ia_size);
+ ret = sys_read (file_fd, *contents, stbuf.ia_size);
if (ret <= 0) {
op_ret = -1;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_XDATA_GETXATTR,
@@ -999,7 +999,7 @@ posix_get_file_contents (xlator_t *this, uuid_t pargfid,
*contents[stbuf.ia_size] = '\0';
- op_ret = close (file_fd);
+ op_ret = sys_close (file_fd);
file_fd = -1;
if (op_ret == -1) {
op_ret = -errno;
@@ -1012,7 +1012,7 @@ out:
if (op_ret < 0) {
GF_FREE (*contents);
if (file_fd != -1)
- close (file_fd);
+ sys_close (file_fd);
}
return op_ret;
@@ -1313,7 +1313,7 @@ janitor_walker (const char *fpath, const struct stat *sb,
case S_IFSOCK:
gf_msg_trace (THIS->name, 0,
"unlinking %s", fpath);
- unlink (fpath);
+ sys_unlink (fpath);
if (stbuf.ia_nlink == 1)
posix_handle_unset (this, stbuf.ia_gfid, NULL);
break;
@@ -1323,7 +1323,7 @@ janitor_walker (const char *fpath, const struct stat *sb,
gf_msg_debug (THIS->name, 0,
"removing directory %s", fpath);
- rmdir (fpath);
+ sys_rmdir (fpath);
del_stale_dir_handle (this, stbuf.ia_gfid);
}
break;
@@ -1402,11 +1402,11 @@ posix_janitor_thread_proc (void *data)
if (pfd->dir == NULL) {
gf_msg_trace (this->name, 0,
"janitor: closing file fd=%d", pfd->fd);
- close (pfd->fd);
+ sys_close (pfd->fd);
} else {
gf_msg_debug (this->name, 0, "janitor: closing"
" dir fd=%p", pfd->dir);
- closedir (pfd->dir);
+ sys_closedir (pfd->dir);
}
GF_FREE (pfd);
@@ -1647,7 +1647,7 @@ __posix_fd_ctx_get (fd_t *fd, xlator_t *this, struct posix_fd **pfd_p)
pfd->fd = -1;
if (fd->inode->ia_type == IA_IFDIR) {
- dir = opendir (real_path);
+ dir = sys_opendir (real_path);
if (!dir) {
GF_FREE (pfd);
pfd = NULL;
@@ -1675,9 +1675,9 @@ __posix_fd_ctx_get (fd_t *fd, xlator_t *this, struct posix_fd **pfd_p)
ret = __fd_ctx_set (fd, this, (uint64_t) (long) pfd);
if (ret != 0) {
if (_fd != -1)
- close (_fd);
+ sys_close (_fd);
if (dir)
- closedir (dir);
+ sys_closedir (dir);
GF_FREE (pfd);
pfd = NULL;
goto out;
@@ -1738,7 +1738,7 @@ posix_fs_health_check (xlator_t *this)
"open() on %s returned", file_path);
goto out;
}
- nofbytes = write (fd, timestamp, timelen);
+ nofbytes = sys_write (fd, timestamp, timelen);
if (nofbytes != timelen) {
gf_msg (this->name, GF_LOG_WARNING, errno,
P_MSG_HEALTHCHECK_FAILED,
@@ -1747,8 +1747,8 @@ posix_fs_health_check (xlator_t *this)
}
/* Seek the offset to the beginning of the file, so that the offset for
read is from beginning of file */
- lseek(fd, 0, SEEK_SET);
- nofbytes = read (fd, buff, timelen);
+ sys_lseek(fd, 0, SEEK_SET);
+ nofbytes = sys_read (fd, buff, timelen);
if (nofbytes == -1) {
gf_msg (this->name, GF_LOG_WARNING, errno,
P_MSG_HEALTHCHECK_FAILED,
@@ -1758,7 +1758,7 @@ posix_fs_health_check (xlator_t *this)
ret = 0;
out:
if (fd != -1) {
- close (fd);
+ sys_close (fd);
}
return ret;
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index b544e3739c6..e2fe081f86d 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -293,7 +293,7 @@ posix_do_chmod (xlator_t *this, const char *path, struct iatt *stbuf)
goto out;
}
- ret = chmod (path, mode);
+ ret = sys_chmod (path, mode);
}
out:
return ret;
@@ -315,7 +315,7 @@ posix_do_chown (xlator_t *this,
if (valid & GF_SET_ATTR_GID)
gid = stbuf->ia_gid;
- ret = lchown (path, uid, gid);
+ ret = sys_lchown (path, uid, gid);
return ret;
}
@@ -354,7 +354,7 @@ posix_do_utimes (xlator_t *this,
goto out;
}
- ret = utimes (path, tv);
+ ret = sys_utimes (path, tv);
}
out:
@@ -423,7 +423,7 @@ posix_setattr (call_frame_t *frame, xlator_t *this,
}
if (!valid) {
- op_ret = lchown (real_path, -1, -1);
+ op_ret = sys_lchown (real_path, -1, -1);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno,
@@ -474,7 +474,7 @@ posix_do_fchown (xlator_t *this,
if (valid & GF_SET_ATTR_GID)
gid = stbuf->ia_gid;
- ret = fchown (fd, uid, gid);
+ ret = sys_fchown (fd, uid, gid);
return ret;
}
@@ -487,7 +487,7 @@ posix_do_fchmod (xlator_t *this,
mode_t mode = 0;
mode = st_mode_from_ia (stbuf->ia_prot, stbuf->ia_type);
- return fchmod (fd, mode);
+ return sys_fchmod (fd, mode);
}
static int
@@ -572,7 +572,7 @@ posix_fsetattr (call_frame_t *frame, xlator_t *this,
}
if (!valid) {
- op_ret = fchown (pfd->fd, -1, -1);
+ op_ret = sys_fchown (pfd->fd, -1, -1);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno,
@@ -724,24 +724,24 @@ _posix_do_zerofill(int fd, off_t offset, off_t len, int o_direct)
vector[idx].iov_base = iov_base;
vector[idx].iov_len = vect_size;
}
- if (lseek(fd, offset, SEEK_SET) < 0) {
+ if (sys_lseek (fd, offset, SEEK_SET) < 0) {
op_ret = -1;
goto err;
}
for (idx = 0; idx < num_loop; idx++) {
- op_ret = writev(fd, vector, num_vect);
+ op_ret = sys_writev (fd, vector, num_vect);
if (op_ret < 0)
goto err;
}
if (extra) {
- op_ret = writev(fd, vector, extra);
+ op_ret = sys_writev (fd, vector, extra);
if (op_ret < 0)
goto err;
}
if (remain) {
vector[0].iov_len = remain;
- op_ret = writev(fd, vector , 1);
+ op_ret = sys_writev (fd, vector , 1);
if (op_ret < 0)
goto err;
}
@@ -792,7 +792,7 @@ posix_do_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd,
goto out;
}
if (pfd->flags & (O_SYNC|O_DSYNC)) {
- ret = fsync (pfd->fd);
+ ret = sys_fsync (pfd->fd);
if (ret) {
gf_msg (this->name, GF_LOG_ERROR, 0,
P_MSG_WRITEV_FAILED, "fsync() in writev on fd"
@@ -932,7 +932,7 @@ posix_opendir (call_frame_t *frame, xlator_t *this,
}
op_ret = -1;
- dir = opendir (real_path);
+ dir = sys_opendir (real_path);
if (dir == NULL) {
op_errno = errno;
@@ -970,7 +970,7 @@ posix_opendir (call_frame_t *frame, xlator_t *this,
out:
if (op_ret == -1) {
if (dir) {
- closedir (dir);
+ sys_closedir (dir);
dir = NULL;
}
if (pfd) {
@@ -1150,21 +1150,21 @@ real_op:
op_ret = mkfifo (real_path, mode);
else
#endif /* __NetBSD__ */
- op_ret = mknod (real_path, mode, dev);
+ op_ret = sys_mknod (real_path, mode, dev);
if (op_ret == -1) {
op_errno = errno;
if ((op_errno == EINVAL) && S_ISREG (mode)) {
/* Over Darwin, mknod with (S_IFREG|mode)
doesn't work */
- tmp_fd = creat (real_path, mode);
+ tmp_fd = sys_creat (real_path, mode);
if (tmp_fd == -1) {
gf_msg (this->name, GF_LOG_ERROR, errno,
P_MSG_CREATE_FAILED, "create failed on"
"%s", real_path);
goto out;
}
- close (tmp_fd);
+ sys_close (tmp_fd);
} else {
gf_msg (this->name, GF_LOG_ERROR, errno,
@@ -1177,7 +1177,7 @@ real_op:
entry_created = _gf_true;
#ifndef HAVE_SET_FSID
- op_ret = lchown (real_path, frame->root->uid, gid);
+ op_ret = sys_lchown (real_path, frame->root->uid, gid);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LCHOWN_FAILED,
@@ -1348,7 +1348,7 @@ posix_mkdir (call_frame_t *frame, xlator_t *this,
mode |= S_ISGID;
}
- op_ret = mkdir (real_path, mode);
+ op_ret = sys_mkdir (real_path, mode);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_MKDIR_FAILED,
@@ -1359,7 +1359,7 @@ posix_mkdir (call_frame_t *frame, xlator_t *this,
entry_created = _gf_true;
#ifndef HAVE_SET_FSID
- op_ret = chown (real_path, frame->root->uid, gid);
+ op_ret = sys_chown (real_path, frame->root->uid, gid);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_CHOWN_FAILED,
@@ -1662,7 +1662,7 @@ out:
&preparent, &postparent, unwind_dict);
if (fd != -1) {
- close (fd);
+ sys_close (fd);
}
/* unref unwind_dict*/
@@ -1732,17 +1732,17 @@ posix_rmdir (call_frame_t *frame, xlator_t *this,
strlen ("/") +
strlen (gfid_str) + 1);
- op_ret = mkdir (priv->trash_path, 0755);
+ op_ret = sys_mkdir (priv->trash_path, 0755);
if (errno != EEXIST && op_ret == -1) {
gf_msg (this->name, GF_LOG_ERROR, errno,
P_MSG_MKDIR_FAILED,
"mkdir of %s failed", priv->trash_path);
} else {
sprintf (tmp_path, "%s/%s", priv->trash_path, gfid_str);
- op_ret = rename (real_path, tmp_path);
+ op_ret = sys_rename (real_path, tmp_path);
}
} else {
- op_ret = rmdir (real_path);
+ op_ret = sys_rmdir (real_path);
}
op_errno = errno;
@@ -1842,7 +1842,7 @@ posix_symlink (call_frame_t *frame, xlator_t *this,
gid = preparent.ia_gid;
}
- op_ret = symlink (linkname, real_path);
+ op_ret = sys_symlink (linkname, real_path);
if (op_ret == -1) {
op_errno = errno;
@@ -1855,7 +1855,7 @@ posix_symlink (call_frame_t *frame, xlator_t *this,
entry_created = _gf_true;
#ifndef HAVE_SET_FSID
- op_ret = lchown (real_path, frame->root->uid, gid);
+ op_ret = sys_lchown (real_path, frame->root->uid, gid);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_LCHOWN_FAILED,
@@ -2295,7 +2295,7 @@ posix_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset,
goto out;
}
- op_ret = truncate (real_path, offset);
+ op_ret = sys_truncate (real_path, offset);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_TRUNCATE_FAILED,
@@ -2415,7 +2415,7 @@ posix_create (call_frame_t *frame, xlator_t *this,
goto fill_stat;
#ifndef HAVE_SET_FSID
- op_ret = chown (real_path, frame->root->uid, gid);
+ op_ret = sys_chown (real_path, frame->root->uid, gid);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_CHOWN_FAILED,
@@ -2497,7 +2497,7 @@ out:
SET_TO_OLD_FS_ID ();
if ((-1 == op_ret) && (_fd != -1)) {
- close (_fd);
+ sys_close (_fd);
}
STACK_UNWIND_STRICT (create, frame, op_ret, op_errno,
@@ -2593,7 +2593,7 @@ posix_open (call_frame_t *frame, xlator_t *this,
out:
if (op_ret == -1) {
if (_fd != -1) {
- close (_fd);
+ sys_close (_fd);
}
}
@@ -2940,7 +2940,7 @@ posix_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
}
if (flags & (O_SYNC|O_DSYNC)) {
- ret = fsync (_fd);
+ ret = sys_fsync (_fd);
if (ret) {
gf_msg (this->name, GF_LOG_ERROR, errno,
P_MSG_WRITEV_FAILED,
@@ -2998,7 +2998,7 @@ posix_statfs (call_frame_t *frame, xlator_t *this,
priv = this->private;
- op_ret = statvfs (real_path, &buf);
+ op_ret = sys_statvfs (real_path, &buf);
if (op_ret == -1) {
op_errno = errno;
@@ -3457,24 +3457,24 @@ posix_xattr_get_real_filename (call_frame_t *frame, xlator_t *this, loc_t *loc,
return -ESTALE;
}
- fd = opendir (real_path);
+ fd = sys_opendir (real_path);
if (!fd)
return -errno;
fname = key + strlen (GF_XATTR_GET_REAL_FILENAME_KEY);
- while ((dirent = readdir (fd))) {
+ while ((dirent = sys_readdir (fd))) {
if (strcasecmp (dirent->d_name, fname) == 0) {
found = gf_strdup (dirent->d_name);
if (!found) {
- closedir (fd);
+ sys_closedir (fd);
return -ENOMEM;
}
break;
}
}
- closedir (fd);
+ sys_closedir (fd);
if (!found)
return -ENOENT;
@@ -3549,7 +3549,7 @@ posix_links_in_same_directory (char *dirpath, int count, inode_t *leaf_inode,
priv = this->private;
- dirp = opendir (dirpath);
+ dirp = sys_opendir (dirpath);
if (!dirp) {
*op_errno = errno;
gf_msg (this->name, GF_LOG_WARNING, errno, P_MSG_OPEN_FAILED,
@@ -3629,7 +3629,7 @@ posix_links_in_same_directory (char *dirpath, int count, inode_t *leaf_inode,
op_ret = 0;
out:
if (dirp) {
- op_ret = closedir (dirp);
+ op_ret = sys_closedir (dirp);
if (op_ret == -1) {
*op_errno = errno;
gf_msg (this->name, GF_LOG_WARNING, errno,
@@ -4523,7 +4523,7 @@ posix_fsetxattr (call_frame_t *frame, xlator_t *this,
}
if (!ret && xdata && dict_get (xdata, GLUSTERFS_DURABLE_OP)) {
- op_ret = fsync (_fd);
+ op_ret = sys_fsync (_fd);
if (op_ret < 0) {
op_ret = -1;
op_errno = errno;
@@ -5252,7 +5252,7 @@ posix_access (call_frame_t *frame, xlator_t *this,
goto out;
}
- op_ret = access (real_path, mask & 07);
+ op_ret = sys_access (real_path, mask & 07);
if (op_ret == -1) {
op_errno = errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_ACCESS_FAILED,
@@ -5310,7 +5310,7 @@ posix_ftruncate (call_frame_t *frame, xlator_t *this,
goto out;
}
- op_ret = ftruncate (_fd, offset);
+ op_ret = sys_ftruncate (_fd, offset);
if (op_ret == -1) {
op_errno = errno;
@@ -5585,7 +5585,7 @@ posix_fill_readdir (fd_t *fd, DIR *dir, off_t off, size_t size,
continue;
} else if (hpath) {
strcpy (&hpath[len+1],entry->d_name);
- ret = lstat (hpath, &stbuf);
+ ret = sys_lstat (hpath, &stbuf);
if (!ret && S_ISDIR (stbuf.st_mode))
continue;
}
@@ -5640,7 +5640,7 @@ posix_fill_readdir (fd_t *fd, DIR *dir, off_t off, size_t size,
count ++;
}
- if ((!readdir (dir) && (errno == 0))) {
+ if ((!sys_readdir (dir) && (errno == 0))) {
/* Indicate EOF */
errno = ENOENT;
/* Remember EOF offset for later detection */
@@ -6219,7 +6219,7 @@ init (xlator_t *this)
umask (000); // umask `masking' is done at the client side
/* Check whether the specified directory exists, if not log it. */
- op_ret = stat (dir_data->data, &buf);
+ op_ret = sys_stat (dir_data->data, &buf);
if ((op_ret != 0) || !S_ISDIR (buf.st_mode)) {
gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_DIR_OPERATION_FAILED,
"Directory '%s' doesn't exist, exiting.",
@@ -6526,7 +6526,7 @@ init (xlator_t *this)
/* performing open dir on brick dir locks the brick dir
* and prevents it from being unmounted
*/
- _private->mount_lock = opendir (dir_data->data);
+ _private->mount_lock = sys_opendir (dir_data->data);
if (!_private->mount_lock) {
ret = -1;
gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_DIR_OPERATION_FAILED,
@@ -6672,7 +6672,7 @@ fini (xlator_t *this)
this->private = NULL;
/*unlock brick dir*/
if (priv->mount_lock)
- closedir (priv->mount_lock);
+ sys_closedir (priv->mount_lock);
GF_FREE (priv);
return;
}