[samba RFC PATCH 5/6] vfs:ceph: convert cephwrap_lstat to use ceph_statx

Jeff Layton jlayton at samba.org
Wed Aug 31 13:01:13 UTC 2016


We can use AT_SYMLINK_NOFOLLOW flag to get the right lookup semantics.

Signed-off-by: Jeff Layton <jlayton at redhat.com>
---
 source3/modules/vfs_ceph.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c
index a1480201c628..b3c26ad4f4c1 100644
--- a/source3/modules/vfs_ceph.c
+++ b/source3/modules/vfs_ceph.c
@@ -624,6 +624,30 @@ static int cephwrap_fstat(struct vfs_handle_struct *handle, files_struct *fsp, S
 	return result;
 }
 
+static int cephwrap_lstat(struct vfs_handle_struct *handle,
+			 struct smb_filename *smb_fname)
+{
+	int result = -1;
+	struct ceph_statx stx;
+
+	DEBUG(10, ("[CEPH] lstat(%p, %s)\n", handle, smb_fname_str_dbg(smb_fname)));
+
+	if (smb_fname->stream_name) {
+		errno = ENOENT;
+		return result;
+	}
+
+	result = ceph_statx(handle->data, smb_fname->base_name, &stx,
+				CEPH_STATX_BASIC_STATS|CEPH_STATX_BTIME,
+				AT_SYMLINK_NOFOLLOW);
+	DEBUG(10, ("[CEPH] lstat(...) = %d\n", result));
+	if (result < 0) {
+		WRAP_RETURN(result);
+	}
+	init_stat_ex_from_ceph_statx(&smb_fname->st, &stx);
+	return result;
+}
+
 #else /* HAVE_CEPH_STATX */
 
 static int cephwrap_stat(struct vfs_handle_struct *handle,
@@ -683,7 +707,6 @@ static int cephwrap_fstat(struct vfs_handle_struct *handle, files_struct *fsp, S
 	DEBUG(10, ("[CEPH] mode = 0x%x\n", sbuf->st_ex_mode));
 	return result;
 }
-#endif /* HAVE_CEPH_STATX */
 
 static int cephwrap_lstat(struct vfs_handle_struct *handle,
 			 struct smb_filename *smb_fname)
@@ -708,6 +731,7 @@ static int cephwrap_lstat(struct vfs_handle_struct *handle,
 			lp_fake_directory_create_times(SNUM(handle->conn)));
 	return result;
 }
+#endif /* HAVE_CEPH_STATX */
 
 static int cephwrap_unlink(struct vfs_handle_struct *handle,
 			  const struct smb_filename *smb_fname)
-- 
2.7.4




More information about the samba-technical mailing list