summaryrefslogtreecommitdiffstats
path: root/libglusterfsclient/src
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfsclient/src')
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.c48
1 files changed, 29 insertions, 19 deletions
diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c
index 7066390be57..fbdec326734 100755
--- a/libglusterfsclient/src/libglusterfsclient.c
+++ b/libglusterfsclient/src/libglusterfsclient.c
@@ -484,13 +484,20 @@ out:
}
int
-libgf_transform_devnum (libglusterfs_client_ctx_t *libctx, struct stat *buf)
+libgf_transform_iattr (libglusterfs_client_ctx_t *libctx, inode_t *inode,
+ struct stat *buf)
{
- if ((!libctx) || (!buf))
+ if ((!libctx) || (!buf) || (!inode))
return -1;
buf->st_dev = libctx->fake_fsid;
+ /* If the inode is root, the inode number must be 1 not the
+ * ino received from the file system.
+ */
+ if ((inode->ino == 1) && (buf))
+ buf->st_ino = 1;
+
return 0;
}
@@ -1999,7 +2006,7 @@ libgf_client_lookup_cbk (call_frame_t *frame,
}
parent = local->fop.lookup.loc->parent;
- libgf_transform_devnum (ctx, buf);
+ libgf_transform_iattr (ctx, inode, buf);
if (inode->ino != 1) {
inode_link (inode, parent, local->fop.lookup.loc->name, buf);
}
@@ -2105,7 +2112,7 @@ libgf_client_lookup (libglusterfs_client_ctx_t *ctx,
inode = stub->args.lookup_cbk.inode;
if (!(libgf_get_inode_ctx (inode)))
libgf_alloc_inode_ctx (ctx, inode);
- libgf_transform_devnum (ctx, &stub->args.lookup_cbk.buf);
+ libgf_transform_iattr (ctx, inode, &stub->args.lookup_cbk.buf);
libgf_update_iattr_cache (inode, LIBGF_UPDATE_ALL,
&stub->args.lookup_cbk.buf);
if (stbuf)
@@ -2259,7 +2266,7 @@ libgf_client_lookup_async_cbk (call_frame_t *frame,
if (op_ret == 0) {
parent = local->fop.lookup_cbk.loc->parent;
- libgf_transform_devnum (ctx, stbuf);
+ libgf_transform_iattr (ctx, inode, stbuf);
inode_link (inode, parent, local->fop.lookup_cbk.loc->name,
stbuf);
@@ -2800,7 +2807,7 @@ libgf_client_creat (libglusterfs_client_ctx_t *ctx,
goto out;
libgf_inode = stub->args.create_cbk.inode;
- libgf_transform_devnum (ctx, &stub->args.create_cbk.buf);
+ libgf_transform_iattr (ctx, libgf_inode, &stub->args.create_cbk.buf);
inode_link (libgf_inode, loc->parent, loc->name,
&stub->args.create_cbk.buf);
@@ -3599,7 +3606,7 @@ libgf_client_read (libglusterfs_client_ctx_t *ctx,
op_ret += len;
}
stbuf = &stub->args.readv_cbk.stbuf;
- libgf_transform_devnum (ctx, stbuf);
+ libgf_transform_iattr (ctx, fd->inode, stbuf);
libgf_invalidate_iattr_cache (fd->inode, LIBGF_INVALIDATE_STAT);
}
@@ -3728,7 +3735,7 @@ libgf_client_readv (libglusterfs_client_ctx_t *ctx,
}
stbuf = &stub->args.readv_cbk.stbuf;
- libgf_transform_devnum (ctx, stbuf);
+ libgf_transform_iattr (ctx, fd->inode, stbuf);
libgf_invalidate_iattr_cache (fd->inode, LIBGF_UPDATE_STAT);
}
@@ -4668,7 +4675,7 @@ libgf_client_stat (libglusterfs_client_ctx_t *ctx,
op_ret = stub->args.stat_cbk.op_ret;
errno = stub->args.stat_cbk.op_errno;
- libgf_transform_devnum (ctx, &stub->args.stat_cbk.buf);
+ libgf_transform_iattr (ctx, loc->inode, &stub->args.stat_cbk.buf);
if (stbuf)
*stbuf = stub->args.stat_cbk.buf;
@@ -4896,7 +4903,7 @@ libgf_client_fstat (libglusterfs_client_ctx_t *ctx,
op_ret = stub->args.fstat_cbk.op_ret;
errno = stub->args.fstat_cbk.op_errno;
- libgf_transform_devnum (ctx, &stub->args.fstat_cbk.buf);
+ libgf_transform_iattr (ctx, fd->inode, &stub->args.fstat_cbk.buf);
if (buf)
*buf = stub->args.fstat_cbk.buf;
@@ -4977,7 +4984,7 @@ libgf_client_mkdir (libglusterfs_client_ctx_t *ctx,
goto out;
libgf_inode = stub->args.mkdir_cbk.inode;
- libgf_transform_devnum (ctx, &stub->args.mkdir_cbk.buf);
+ libgf_transform_iattr (ctx, libgf_inode, &stub->args.mkdir_cbk.buf);
inode_link (libgf_inode, loc->parent, loc->name,
&stub->args.mkdir_cbk.buf);
@@ -5217,7 +5224,8 @@ libgf_client_setattr (libglusterfs_client_ctx_t *ctx, loc_t * loc,
if (op_ret == -1)
goto out;
- libgf_transform_devnum (ctx, &stub->args.setattr_cbk.statpost);
+ libgf_transform_iattr (ctx, loc->inode,
+ &stub->args.setattr_cbk.statpost);
libgf_update_iattr_cache (loc->inode, LIBGF_UPDATE_STAT,
&stub->args.setattr_cbk.statpost);
out:
@@ -5554,7 +5562,8 @@ libgf_client_fsetattr (libglusterfs_client_ctx_t *ctx, fd_t *fd,
if (op_ret == -1)
goto out;
- libgf_transform_devnum (ctx, &stub->args.fsetattr_cbk.statpost);
+ libgf_transform_iattr (ctx, fd->inode,
+ &stub->args.fsetattr_cbk.statpost);
libgf_update_iattr_cache (fd->inode, LIBGF_UPDATE_STAT,
&stub->args.fsetattr_cbk.statpost);
out:
@@ -5709,7 +5718,8 @@ libgf_client_ftruncate (libglusterfs_client_ctx_t *ctx, fd_t *fd,
if (op_ret == -1)
goto out;
- libgf_transform_devnum (ctx, &stub->args.ftruncate_cbk.postbuf);
+ libgf_transform_iattr (ctx, fd->inode,
+ &stub->args.ftruncate_cbk.postbuf);
libgf_update_iattr_cache (fd->inode, LIBGF_UPDATE_STAT,
&stub->args.ftruncate_cbk.postbuf);
@@ -5790,7 +5800,7 @@ libgf_client_link (libglusterfs_client_ctx_t *ctx, loc_t *old, loc_t *new)
inode = stub->args.link_cbk.inode;
sbuf = &stub->args.link_cbk.buf;
- libgf_transform_devnum (ctx, sbuf);
+ libgf_transform_iattr (ctx, inode, sbuf);
inode_link (inode, new->parent, basename ((char *)new->path), sbuf);
inode_lookup (inode);
libgf_update_iattr_cache (inode, LIBGF_UPDATE_STAT, sbuf);
@@ -6086,7 +6096,7 @@ glusterfs_glh_statvfs (glusterfs_handle_t handle, const char *path,
op_ret = libgf_client_statvfs (ctx, &loc, buf);
if (op_ret != -1)
- /* Should've been a call to libgf_transform_devnum but
+ /* Should've been a call to libgf_transform_iattr but
* that only handles struct stat
*/
buf->f_fsid = (unsigned long)ctx->fake_fsid;
@@ -6158,7 +6168,7 @@ libgf_client_rename (libglusterfs_client_ctx_t *ctx, loc_t *oldloc,
if (!libgf_get_inode_ctx (newloc->inode))
libgf_alloc_inode_ctx (ctx, newloc->inode);
- libgf_transform_devnum (ctx, &stub->args.rename_cbk.buf);
+ libgf_transform_iattr (ctx, newloc->inode, &stub->args.rename_cbk.buf);
libgf_update_iattr_cache (newloc->inode, LIBGF_UPDATE_STAT,
&stub->args.rename_cbk.buf);
@@ -6466,7 +6476,7 @@ libgf_client_mknod (libglusterfs_client_ctx_t *ctx, loc_t *loc, mode_t mode,
gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "path %s, status %d, errno %d",
loc->path, op_ret, errno);
inode = stub->args.mknod_cbk.inode;
- libgf_transform_devnum (ctx, &stub->args.mknod_cbk.buf);
+ libgf_transform_iattr (ctx, inode, &stub->args.mknod_cbk.buf);
inode_link (inode, loc->parent, loc->name, &stub->args.mknod_cbk.buf);
inode_lookup (inode);
@@ -6770,7 +6780,7 @@ libgf_client_symlink (libglusterfs_client_ctx_t *ctx, const char *linkpath,
gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "target: %s, link: %s, status %d"
" errno %d", linkpath, loc->path, op_ret, errno);
inode = stub->args.symlink_cbk.inode;
- libgf_transform_devnum (ctx, &stub->args.symlink_cbk.buf);
+ libgf_transform_iattr (ctx, inode, &stub->args.symlink_cbk.buf);
inode_link (inode, loc->parent, loc->name,
&stub->args.symlink_cbk.buf);
inode_lookup (inode);