summaryrefslogtreecommitdiffstats
path: root/xlators/storage
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/storage')
-rw-r--r--xlators/storage/bdb/src/bdb.c274
-rw-r--r--xlators/storage/posix/src/posix.c596
2 files changed, 382 insertions, 488 deletions
diff --git a/xlators/storage/bdb/src/bdb.c b/xlators/storage/bdb/src/bdb.c
index 2b1208b97..bb6d3a434 100644
--- a/xlators/storage/bdb/src/bdb.c
+++ b/xlators/storage/bdb/src/bdb.c
@@ -1867,23 +1867,79 @@ out:
return 0;
} /* bdb_symlink */
+static int
+bdb_do_chmod (xlator_t *this,
+ const char *path,
+ struct stat *stbuf)
+{
+ int32_t ret = -1;
+
+ ret = lchmod (path, stbuf->st_mode);
+ if ((ret == -1) && (errno == ENOSYS)) {
+ ret = chmod (path, stbuf->st_mode);
+ }
+
+ return ret;
+}
+
+static int
+bdb_do_chown (xlator_t *this,
+ const char *path,
+ struct stat *stbuf,
+ int32_t valid)
+{
+ int32_t ret = -1;
+ uid_t uid = -1;
+ gid_t gid = -1;
+
+ if (valid & GF_SET_ATTR_UID)
+ uid = stbuf->st_uid;
+
+ if (valid & GF_SET_ATTR_GID)
+ gid = stbuf->st_gid;
+
+ ret = lchown (path, uid, gid);
+
+ return ret;
+}
+
+static int
+bdb_do_utimes (xlator_t *this,
+ const char *path,
+ struct stat *stbuf)
+{
+ int32_t ret = -1;
+ struct timeval tv[2] = {{0,},{0,}};
+
+ tv[0].tv_sec = stbuf->st_atime;
+ tv[0].tv_usec = ST_ATIM_NSEC (stbuf) / 1000;
+ tv[1].tv_sec = stbuf->st_mtime;
+ tv[1].tv_usec = ST_ATIM_NSEC (stbuf) / 1000;
+
+ ret = lutimes (path, tv);
+
+ return ret;
+}
+
int32_t
-bdb_chmod (call_frame_t *frame,
- xlator_t *this,
- loc_t *loc,
- mode_t mode)
+bdb_setattr (call_frame_t *frame,
+ xlator_t *this,
+ loc_t *loc,
+ struct stat *stbuf,
+ int32_t valid)
{
int32_t op_ret = -1;
int32_t op_errno = EINVAL;
char *real_path = NULL;
- struct stat stbuf = {0,};
+ struct stat preop = {0,};
+ struct stat postop = {0,};
GF_VALIDATE_OR_GOTO ("bdb", frame, out);
GF_VALIDATE_OR_GOTO ("bdb", this, out);
GF_VALIDATE_OR_GOTO (this->name, loc, out);
MAKE_REAL_PATH (real_path, this, loc->path);
- op_ret = lstat (real_path, &stbuf);
+ op_ret = lstat (real_path, &preop);
op_errno = errno;
if (op_ret != 0) {
if (op_errno == ENOENT) {
@@ -1891,62 +1947,77 @@ bdb_chmod (call_frame_t *frame,
} else {
gf_log (this->name, GF_LOG_DEBUG,
"CHMOD %"PRId64" (%s): %s"
- "(lstat failed)",
+ "(pre-op lstat failed)",
loc->ino, loc->path, strerror (op_errno));
}
goto out;
}
/* directory or symlink */
- op_ret = chmod (real_path, mode);
+ if (valid & GF_SET_ATTR_MODE) {
+ op_ret = bdb_do_chmod (this, real_path, stbuf);
+ if (op_ret == -1) {
+ op_errno = errno;
+ gf_log (this->name, GF_LOG_ERROR,
+ "setattr (chmod) on %s failed: %s", loc->path,
+ strerror (op_errno));
+ goto out;
+ }
+ }
+
+ if (valid & (GF_SET_ATTR_UID | GF_SET_ATTR_GID)){
+ op_ret = bdb_do_chown (this, real_path, stbuf, valid);
+ if (op_ret == -1) {
+ op_errno = errno;
+ gf_log (this->name, GF_LOG_ERROR,
+ "setattr (chown) on %s failed: %s", loc->path,
+ strerror (op_errno));
+ goto out;
+ }
+ }
+
+ if (valid & (GF_SET_ATTR_ATIME | GF_SET_ATTR_MTIME)) {
+ op_ret = bdb_do_utimes (this, real_path, stbuf);
+ if (op_ret == -1) {
+ op_errno = errno;
+ gf_log (this->name, GF_LOG_ERROR,
+ "setattr (utimes) on %s failed: %s", loc->path,
+ strerror (op_errno));
+ goto out;
+ }
+ }
+
+ op_ret = lstat (real_path, &postop);
op_errno = errno;
+ if (op_ret != 0) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "CHMOD %"PRId64" (%s): %s"
+ "(post-op lstat failed)",
+ loc->ino, loc->path, strerror (op_errno));
+ }
out:
- STACK_UNWIND (frame, op_ret, op_errno, &stbuf);
+ STACK_UNWIND (frame, op_ret, op_errno, &preop, &postop);
return 0;
-}/* bdb_chmod */
-
+}/* bdb_setattr */
int32_t
-bdb_chown (call_frame_t *frame,
- xlator_t *this,
- loc_t *loc,
- uid_t uid,
- gid_t gid)
+bdb_fsetattr (call_frame_t *frame,
+ xlator_t *this,
+ fd_t *fd,
+ struct stat *stbuf,
+ int32_t valid)
{
int32_t op_ret = -1;
- int32_t op_errno = EINVAL;
- char *real_path = NULL;
- struct stat stbuf = {0,};
-
- GF_VALIDATE_OR_GOTO ("bdb", frame, out);
- GF_VALIDATE_OR_GOTO ("bdb", this, out);
- GF_VALIDATE_OR_GOTO (this->name, loc, out);
-
- MAKE_REAL_PATH (real_path, this, loc->path);
- op_ret = lstat (real_path, &stbuf);
- if (op_ret != 0) {
- op_errno = errno;
- if (op_errno == ENOENT) {
- op_errno = EPERM;
- } else {
- gf_log (this->name, GF_LOG_DEBUG,
- "CHOWN %"PRId64" (%s): %s"
- "(lstat failed)",
- loc->ino, loc->path, strerror (op_errno));
- }
- goto out;
- }
+ int32_t op_errno = EPERM;
+ struct stat preop = {0,};
+ struct stat postop = {0,};
- /* directory or symlink */
- op_ret = lchown (real_path, uid, gid);
- op_errno = errno;
-out:
- STACK_UNWIND (frame, op_ret, op_errno, &stbuf);
+ STACK_UNWIND (frame, op_ret, op_errno, &preop, &postop);
return 0;
-}/* bdb_chown */
+}/* bdb_fsetattr */
int32_t
@@ -2024,72 +2095,6 @@ out:
int32_t
-bdb_utimens (call_frame_t *frame,
- xlator_t *this,
- loc_t *loc,
- struct timespec ts[2])
-{
- int32_t op_ret = -1;
- int32_t op_errno = EPERM;
- char *real_path = NULL;
- struct stat stbuf = {0,};
- struct timeval tv[2] = {{0,},};
-
- GF_VALIDATE_OR_GOTO ("bdb", frame, out);
- GF_VALIDATE_OR_GOTO ("bdb", this, out);
- GF_VALIDATE_OR_GOTO (this->name, loc, out);
-
- MAKE_REAL_PATH (real_path, this, loc->path);
- op_ret = sys_lstat (real_path, &stbuf);
- if (op_ret != 0) {
- op_errno = errno;
- if (op_errno == ENOENT) {
- op_errno = EPERM;
- } else {
- gf_log (this->name, GF_LOG_DEBUG,
- "UTIMENS %"PRId64" (%s): %s",
- loc->ino, loc->path, strerror (op_errno));
- }
- goto out;
- }
-
- /* directory or symlink */
- tv[0].tv_sec = ts[0].tv_sec;
- tv[0].tv_usec = ts[0].tv_nsec / 1000;
- tv[1].tv_sec = ts[1].tv_sec;
- tv[1].tv_usec = ts[1].tv_nsec / 1000;
-
- op_ret = lutimes (real_path, tv);
- if ((op_ret == -1) && (errno == ENOSYS)) {
- op_ret = sys_utimes (real_path, tv);
- }
-
- if (op_ret == -1) {
- op_errno = errno;
- gf_log (this->name, GF_LOG_DEBUG,
- "UTIMENS %"PRId64" (%s): %s",
- loc->ino, loc->path, strerror (op_errno));
- goto out;
- }
-
- op_ret = sys_lstat (real_path, &stbuf);
- if (op_ret != 0) {
- op_errno = errno;
- gf_log (this->name, GF_LOG_DEBUG,
- "UTIMENS %"PRId64" (%s): %s",
- loc->ino, loc->path, strerror (op_errno));
- goto out;
- }
-
- stbuf.st_ino = loc->inode->ino;
-
-out:
- STACK_UNWIND (frame, op_ret, op_errno, &stbuf);
-
- return 0;
-}/* bdb_utimens */
-
-int32_t
bdb_statfs (call_frame_t *frame,
xlator_t *this,
loc_t *loc)
@@ -2578,49 +2583,7 @@ out:
return 0;
}
-int32_t
-bdb_fchown (call_frame_t *frame,
- xlator_t *this,
- fd_t *fd,
- uid_t uid,
- gid_t gid)
-{
- int32_t op_ret = -1;
- int32_t op_errno = EPERM;
- struct stat buf = {0,};
-
- GF_VALIDATE_OR_GOTO ("bdb", frame, out);
- GF_VALIDATE_OR_GOTO ("bdb", this, out);
- GF_VALIDATE_OR_GOTO (this->name, fd, out);
- /* TODO: implement */
-out:
- STACK_UNWIND (frame, op_ret, op_errno, &buf);
-
- return 0;
-}
-
-
-int32_t
-bdb_fchmod (call_frame_t *frame,
- xlator_t *this,
- fd_t *fd,
- mode_t mode)
-{
- int32_t op_ret = -1;
- int32_t op_errno = EPERM;
- struct stat buf = {0,};
-
- GF_VALIDATE_OR_GOTO ("bdb", frame, out);
- GF_VALIDATE_OR_GOTO ("bdb", this, out);
- GF_VALIDATE_OR_GOTO (this->name, fd, out);
-
- /* TODO: impelement */
-out:
- STACK_UNWIND (frame, op_ret, op_errno, &buf);
-
- return 0;
-}
int32_t
bdb_setdents (call_frame_t *frame,
@@ -3503,10 +3466,7 @@ struct xlator_fops fops = {
.symlink = bdb_symlink,
.rename = bdb_rename,
.link = bdb_link,
- .chmod = bdb_chmod,
- .chown = bdb_chown,
.truncate = bdb_truncate,
- .utimens = bdb_utimens,
.create = bdb_create,
.open = bdb_open,
.readv = bdb_readv,
@@ -3526,11 +3486,11 @@ struct xlator_fops fops = {
.finodelk = bdb_finodelk,
.entrylk = bdb_entrylk,
.fentrylk = bdb_fentrylk,
- .fchown = bdb_fchown,
- .fchmod = bdb_fchmod,
.setdents = bdb_setdents,
.getdents = bdb_getdents,
.checksum = bdb_checksum,
+ .setattr = bdb_setattr,
+ .fsetattr = bdb_fsetattr,
};
struct xlator_cbks cbks = {
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index d022e4c28..c4f47049c 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -416,6 +416,269 @@ posix_stat (call_frame_t *frame,
return 0;
}
+static int
+posix_do_chmod (xlator_t *this,
+ const char *path,
+ struct stat *stbuf)
+{
+ int32_t ret = -1;
+
+ ret = chmod (path, stbuf->st_mode);
+ if ((ret == -1) && (errno == ENOSYS)) {
+ ret = chmod (path, stbuf->st_mode);
+ }
+
+ return ret;
+}
+
+static int
+posix_do_chown (xlator_t *this,
+ const char *path,
+ struct stat *stbuf,
+ int32_t valid)
+{
+ int32_t ret = -1;
+ uid_t uid = -1;
+ gid_t gid = -1;
+
+ if (valid & GF_SET_ATTR_UID)
+ uid = stbuf->st_uid;
+
+ if (valid & GF_SET_ATTR_GID)
+ gid = stbuf->st_gid;
+
+ ret = chown (path, uid, gid);
+
+ return ret;
+}
+
+static int
+posix_do_utimes (xlator_t *this,
+ const char *path,
+ struct stat *stbuf)
+{
+ int32_t ret = -1;
+ struct timeval tv[2] = {{0,},{0,}};
+
+ tv[0].tv_sec = stbuf->st_atime;
+ tv[0].tv_usec = ST_ATIM_NSEC (stbuf) / 1000;
+ tv[1].tv_sec = stbuf->st_mtime;
+ tv[1].tv_usec = ST_ATIM_NSEC (stbuf) / 1000;
+
+ ret = utimes (path, tv);
+
+ return ret;
+}
+
+int
+posix_setattr (call_frame_t *frame, xlator_t *this,
+ loc_t *loc, struct stat *stbuf, int32_t valid)
+{
+ int32_t op_ret = -1;
+ int32_t op_errno = 0;
+ char * real_path = 0;
+ struct stat statpre = {0,};
+ struct stat statpost = {0,};
+
+ DECLARE_OLD_FS_ID_VAR;
+
+ VALIDATE_OR_GOTO (frame, out);
+ VALIDATE_OR_GOTO (this, out);
+ VALIDATE_OR_GOTO (loc, out);
+
+ SET_FS_ID (frame->root->uid, frame->root->gid);
+ MAKE_REAL_PATH (real_path, this, loc->path);
+
+ op_ret = lstat (real_path, &statpre);
+ if (op_ret == -1) {
+ op_errno = errno;
+ gf_log (this->name, GF_LOG_ERROR,
+ "setattr (lstat) on %s failed: %s", real_path,
+ strerror (op_errno));
+ goto out;
+ }
+
+ if (valid & GF_SET_ATTR_MODE) {
+ op_ret = posix_do_chmod (this, real_path, stbuf);
+ if (op_ret == -1) {
+ op_errno = errno;
+ gf_log (this->name, GF_LOG_ERROR,
+ "setattr (chmod) on %s failed: %s", real_path,
+ strerror (op_errno));
+ goto out;
+ }
+ }
+
+ if (valid & (GF_SET_ATTR_UID | GF_SET_ATTR_GID)){
+ op_ret = posix_do_chown (this, real_path, stbuf, valid);
+ if (op_ret == -1) {
+ op_errno = errno;
+ gf_log (this->name, GF_LOG_ERROR,
+ "setattr (chown) on %s failed: %s", real_path,
+ strerror (op_errno));
+ goto out;
+ }
+ }
+
+ if (valid & (GF_SET_ATTR_ATIME | GF_SET_ATTR_MTIME)) {
+ op_ret = posix_do_utimes (this, real_path, stbuf);
+ if (op_ret == -1) {
+ op_errno = errno;
+ gf_log (this->name, GF_LOG_ERROR,
+ "setattr (utimes) on %s failed: %s", real_path,
+ strerror (op_errno));
+ goto out;
+ }
+ }
+
+ op_ret = lstat (real_path, &statpost);
+ if (op_ret == -1) {
+ op_errno = errno;
+ gf_log (this->name, GF_LOG_ERROR,
+ "setattr (lstat) on %s failed: %s", real_path,
+ strerror (op_errno));
+ goto out;
+ }
+
+ op_ret = 0;
+
+out:
+ SET_TO_OLD_FS_ID ();
+
+ STACK_UNWIND (frame, op_ret, op_errno, &statpre, &statpost);
+
+ return 0;
+}
+
+int32_t
+posix_do_fchown (xlator_t *this,
+ int fd,
+ struct stat *stbuf,
+ int32_t valid)
+{
+ int ret = -1;
+ uid_t uid = -1;
+ gid_t gid = -1;
+
+ if (valid & GF_SET_ATTR_UID)
+ uid = stbuf->st_uid;
+
+ if (valid & GF_SET_ATTR_GID)
+ gid = stbuf->st_gid;
+
+ ret = fchown (fd, uid, gid);
+
+ return ret;
+}
+
+
+int32_t
+posix_do_fchmod (xlator_t *this,
+ int fd, struct stat *stbuf)
+{
+ return fchmod (fd, stbuf->st_mode);
+}
+
+static int
+posix_do_futimes (xlator_t *this,
+ int fd,
+ struct stat *stbuf)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+int
+posix_fsetattr (call_frame_t *frame, xlator_t *this,
+ fd_t *fd, struct stat *stbuf, int32_t valid)
+{
+ int32_t op_ret = -1;
+ int32_t op_errno = 0;
+ struct stat statpre = {0,};
+ struct stat statpost = {0,};
+ struct posix_fd *pfd = NULL;
+ uint64_t tmp_pfd = 0;
+ int32_t ret = -1;
+
+ DECLARE_OLD_FS_ID_VAR;
+
+ SET_FS_ID (frame->root->uid, frame->root->gid);
+
+ VALIDATE_OR_GOTO (frame, out);
+ VALIDATE_OR_GOTO (this, out);
+ VALIDATE_OR_GOTO (fd, out);
+
+ ret = fd_ctx_get (fd, this, &tmp_pfd);
+ if (ret < 0) {
+ op_errno = -ret;
+ gf_log (this->name, GF_LOG_DEBUG,
+ "pfd is NULL from fd=%p", fd);
+ goto out;
+ }
+ pfd = (struct posix_fd *)(long)tmp_pfd;
+
+ op_ret = fstat (pfd->fd, &statpre);
+ if (op_ret == -1) {
+ op_errno = errno;
+ gf_log (this->name, GF_LOG_ERROR,
+ "fsetattr (fstat) failed on fd=%p: %s", fd,
+ strerror (op_errno));
+ goto out;
+ }
+
+ if (valid & GF_SET_ATTR_MODE) {
+ op_ret = posix_do_fchmod (this, pfd->fd, stbuf);
+ if (op_ret == -1) {
+ op_errno = errno;
+ gf_log (this->name, GF_LOG_ERROR,
+ "fsetattr (fchmod) failed on fd=%p: %s",
+ fd, strerror (op_errno));
+ goto out;
+ }
+ }
+
+ if (valid & (GF_SET_ATTR_UID | GF_SET_ATTR_GID)) {
+ op_ret = posix_do_fchown (this, pfd->fd, stbuf, valid);
+ if (op_ret == -1) {
+ op_errno = errno;
+ gf_log (this->name, GF_LOG_ERROR,
+ "fsetattr (fchown) failed on fd=%p: %s",
+ fd, strerror (op_errno));
+ goto out;
+ }
+
+ }
+
+ if (valid & (GF_SET_ATTR_ATIME | GF_SET_ATTR_MTIME)) {
+ op_ret = posix_do_futimes (this, pfd->fd, stbuf);
+ if (op_ret == -1) {
+ op_errno = errno;
+ gf_log (this->name, GF_LOG_ERROR,
+ "fsetattr (futimes) on failed fd=%p: %s", fd,
+ strerror (op_errno));
+ goto out;
+ }
+ }
+
+ op_ret = fstat (pfd->fd, &statpost);
+ if (op_ret == -1) {
+ op_errno = errno;
+ gf_log (this->name, GF_LOG_ERROR,
+ "fsetattr (fstat) failed on fd=%p: %s", fd,
+ strerror (op_errno));
+ goto out;
+ }
+
+ op_ret = 0;
+
+out:
+ SET_TO_OLD_FS_ID ();
+
+ STACK_UNWIND (frame, op_ret, op_errno, &statpre, &statpost);
+
+ return 0;
+}
+
int32_t
posix_opendir (call_frame_t *frame, xlator_t *this,
loc_t *loc, fd_t *fd)
@@ -1360,139 +1623,6 @@ posix_link (call_frame_t *frame, xlator_t *this,
}
-int
-posix_chmod (call_frame_t *frame, xlator_t *this,
- loc_t *loc, mode_t mode)
-{
- int32_t op_ret = -1;
- int32_t op_errno = 0;
- char *real_path = 0;
- struct stat stbuf = {0,};
- struct posix_private *priv = NULL;
-
- DECLARE_OLD_FS_ID_VAR;
-
- VALIDATE_OR_GOTO (frame, out);
- VALIDATE_OR_GOTO (this, out);
- VALIDATE_OR_GOTO (loc, out);
-
- priv = this->private;
- VALIDATE_OR_GOTO (priv, out);
-
- SET_FS_ID (frame->root->uid, frame->root->gid);
- MAKE_REAL_PATH (real_path, this, loc->path);
-
- if (S_ISLNK (loc->inode->st_mode)) {
- /* chmod on a link should always succeed */
- op_ret = lstat (real_path, &stbuf);
- if (op_ret == -1) {
- op_errno = errno;
- gf_log (this->name, GF_LOG_ERROR,
- "lstat on %s failed: %s",
- real_path, strerror (op_errno));
- goto out;
- }
-
- if (priv->span_devices) {
- posix_scale_st_ino (priv, &stbuf);
- }
-
- op_ret = 0;
- goto out;
- }
-
- op_ret = lchmod (real_path, mode);
- if ((op_ret == -1) && (errno == ENOSYS)) {
- gf_log (this->name, GF_LOG_TRACE,
- "lchmod not implemented, falling back to chmod");
- op_ret = chmod (real_path, mode);
- }
-
- if (op_ret == -1) {
- op_errno = errno;
- gf_log (this->name, GF_LOG_ERROR, "chmod on %s failed: %s",
- loc->path, strerror (op_errno));
- goto out;
- }
-
- op_ret = lstat (real_path, &stbuf);
- if (op_ret == -1) {
- op_errno = errno;
- gf_log (this->name, GF_LOG_ERROR, "lstat on %s failed: %s",
- real_path, strerror (op_errno));
- goto out;
- }
-
- if (priv->span_devices) {
- posix_scale_st_ino (priv, &stbuf);
- }
-
- op_ret = 0;
-
- out:
- SET_TO_OLD_FS_ID ();
-
- STACK_UNWIND (frame, op_ret, op_errno, &stbuf);
-
- return 0;
-}
-
-
-int
-posix_chown (call_frame_t *frame, xlator_t *this,
- loc_t *loc, uid_t uid, gid_t gid)
-{
- int32_t op_ret = -1;
- int32_t op_errno = 0;
- char *real_path = 0;
- struct stat stbuf = {0,};
- struct posix_private *priv = NULL;
-
- DECLARE_OLD_FS_ID_VAR;
-
- VALIDATE_OR_GOTO (frame, out);
- VALIDATE_OR_GOTO (this, out);
- VALIDATE_OR_GOTO (loc, out);
-
- priv = this->private;
- VALIDATE_OR_GOTO (priv, out);
-
- SET_FS_ID (frame->root->uid, frame->root->gid);
- MAKE_REAL_PATH (real_path, this, loc->path);
-
- op_ret = lchown (real_path, uid, gid);
- if (op_ret == -1) {
- op_errno = errno;
- gf_log (this->name, GF_LOG_ERROR,
- "lchown on %s failed: %s",
- loc->path, strerror (op_errno));
- goto out;
- }
-
- op_ret = lstat (real_path, &stbuf);
- if (op_ret == -1) {
- op_errno = errno;
- gf_log (this->name, GF_LOG_ERROR,
- "lstat on %s failed: %s",
- real_path, strerror (op_errno));
- goto out;
- }
-
- if (priv->span_devices) {
- posix_scale_st_ino (priv, &stbuf);
- }
-
- op_ret = 0;
-
- out:
- SET_TO_OLD_FS_ID ();
-
- STACK_UNWIND (frame, op_ret, op_errno, &stbuf);
-
- return 0;
-}
-
-
int32_t
posix_truncate (call_frame_t *frame,
xlator_t *this,
@@ -1549,70 +1679,6 @@ posix_truncate (call_frame_t *frame,
}
-int
-posix_utimens (call_frame_t *frame, xlator_t *this,
- loc_t *loc, struct timespec ts[2])
-{
- int32_t op_ret = -1;
- int32_t op_errno = 0;
- char *real_path = 0;
- struct stat stbuf = {0,};
- struct timeval tv[2] = {{0,},{0,}};
- struct posix_private *priv = NULL;
-
- DECLARE_OLD_FS_ID_VAR;
-
- VALIDATE_OR_GOTO (frame, out);
- VALIDATE_OR_GOTO (this, out);
- VALIDATE_OR_GOTO (loc, out);
-
- priv = this->private;
- VALIDATE_OR_GOTO (priv, out);
-
- SET_FS_ID (frame->root->uid, frame->root->gid);
- MAKE_REAL_PATH (real_path, this, loc->path);
-
- tv[0].tv_sec = ts[0].tv_sec;
- tv[0].tv_usec = ts[0].tv_nsec / 1000;
- tv[1].tv_sec = ts[1].tv_sec;
- tv[1].tv_usec = ts[1].tv_nsec / 1000;
-
- op_ret = lutimes (real_path, tv);
- if ((op_ret == -1) && (errno == ENOSYS)) {
- op_ret = utimes (real_path, tv);
- }
-
- if (op_ret == -1) {
- op_errno = errno;
- gf_log (this->name, GF_LOG_ERROR,
- "utimes on %s failed: %s", real_path,
- strerror (op_errno));
- goto out;
- }
-
- op_ret = lstat (real_path, &stbuf);
- if (op_ret == -1) {
- op_errno = errno;
- gf_log (this->name, GF_LOG_ERROR,
- "lstat on %s failed: %s", real_path,
- strerror (op_errno));
- goto out;
- }
-
- if (priv->span_devices) {
- posix_scale_st_ino (priv, &stbuf);
- }
-
- op_ret = 0;
-
- out:
- SET_TO_OLD_FS_ID ();
-
- STACK_UNWIND (frame, op_ret, op_errno, &stbuf);
-
- return 0;
-}
-
int32_t
posix_create (call_frame_t *frame, xlator_t *this,
loc_t *loc, int32_t flags, mode_t mode,
@@ -3382,135 +3448,6 @@ posix_ftruncate (call_frame_t *frame, xlator_t *this,
return 0;
}
-int32_t
-posix_fchown (call_frame_t *frame, xlator_t *this,
- fd_t *fd, uid_t uid, gid_t gid)
-{
- int32_t op_ret = -1;
- int32_t op_errno = 0;
- int _fd = -1;
- struct stat buf = {0,};
- struct posix_fd *pfd = NULL;
- int ret = -1;
- uint64_t tmp_pfd = 0;
- struct posix_private *priv = NULL;
-
- DECLARE_OLD_FS_ID_VAR;
-
- SET_FS_ID (frame->root->uid, frame->root->gid);
-
- VALIDATE_OR_GOTO (frame, out);
- VALIDATE_OR_GOTO (this, out);
- VALIDATE_OR_GOTO (fd, out);
-
- priv = this->private;
- VALIDATE_OR_GOTO (priv, out);
-
- ret = fd_ctx_get (fd, this, &tmp_pfd);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_DEBUG,
- "pfd is NULL, fd=%p", fd);
- op_errno = -ret;
- goto out;
- }
- pfd = (struct posix_fd *)(long)tmp_pfd;
-
- _fd = pfd->fd;
-
- op_ret = fchown (_fd, uid, gid);
- if (op_ret == -1) {
- op_errno = errno;
- gf_log (this->name, GF_LOG_ERROR, "fchown failed on fd=%p: %s",
- fd, strerror (op_errno));
- goto out;
- }
-
- op_ret = fstat (_fd, &buf);
- if (op_ret == -1) {
- op_errno = errno;
- gf_log (this->name, GF_LOG_ERROR, "fstat failed on fd=%p: %s",
- fd, strerror (op_errno));
- goto out;
- }
-
- if (priv->span_devices) {
- posix_scale_st_ino (priv, &buf);
- }
-
- op_ret = 0;
-
- out:
- SET_TO_OLD_FS_ID ();
-
- STACK_UNWIND (frame, op_ret, op_errno, &buf);
-
- return 0;
-}
-
-
-int32_t
-posix_fchmod (call_frame_t *frame, xlator_t *this,
- fd_t *fd, mode_t mode)
-{
- int32_t op_ret = -1;
- int32_t op_errno = 0;
- int _fd = -1;
- struct stat buf = {0,};
- struct posix_fd *pfd = NULL;
- int ret = -1;
- uint64_t tmp_pfd = 0;
- struct posix_private *priv = NULL;
-
- DECLARE_OLD_FS_ID_VAR;
-
- SET_FS_ID (frame->root->uid, frame->root->gid);
-
- VALIDATE_OR_GOTO (frame, out);
- VALIDATE_OR_GOTO (this, out);
- VALIDATE_OR_GOTO (fd, out);
-
- priv = this->private;
- VALIDATE_OR_GOTO (priv, out);
-
- ret = fd_ctx_get (fd, this, &tmp_pfd);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_DEBUG,
- "pfd is NULL fd=%p", fd);
- op_errno = -ret;
- goto out;
- }
- pfd = (struct posix_fd *)(long)tmp_pfd;
-
- _fd = pfd->fd;
-
- op_ret = fchmod (_fd, mode);
-
- if (op_ret == -1) {
- op_errno = errno;
- gf_log (this->name, GF_LOG_ERROR,
- "fchmod failed on fd=%p: %s", fd, strerror (errno));
- goto out;
- }
-
- op_ret = fstat (_fd, &buf);
- if (op_ret == -1) {
- op_errno = errno;
- gf_log (this->name, GF_LOG_ERROR,
- "fstat failed on fd=%p: %s",
- fd, strerror (errno));
- goto out;
- }
-
- op_ret = 0;
-
- out:
- SET_TO_OLD_FS_ID ();
-
- STACK_UNWIND (frame, op_ret, op_errno, &buf);
-
- return 0;
-}
-
static int
same_file_type (mode_t m1, mode_t m2)
@@ -4638,10 +4575,7 @@ struct xlator_fops fops = {
.symlink = posix_symlink,
.rename = posix_rename,
.link = posix_link,
- .chmod = posix_chmod,
- .chown = posix_chown,
.truncate = posix_truncate,
- .utimens = posix_utimens,
.create = posix_create,
.open = posix_open,
.readv = posix_readv,
@@ -4663,14 +4597,14 @@ struct xlator_fops fops = {
.finodelk = posix_finodelk,
.entrylk = posix_entrylk,
.fentrylk = posix_fentrylk,
- .fchown = posix_fchown,
- .fchmod = posix_fchmod,
.setdents = posix_setdents,
.getdents = posix_getdents,
.checksum = posix_checksum,
.rchecksum = posix_rchecksum,
.xattrop = posix_xattrop,
.fxattrop = posix_fxattrop,
+ .setattr = posix_setattr,
+ .fsetattr = posix_fsetattr,
};
struct xlator_cbks cbks = {