diff mbox

[samba,RFC,2/6] vfs:ceph: add init_stat_ex_from_ceph_statx

Message ID 1472648474-3131-3-git-send-email-jlayton@samba.org (mailing list archive)
State New, archived
Headers show

Commit Message

Jeff Layton Aug. 31, 2016, 1:01 p.m. UTC
Add a helper function that will convert a ceph_statx structure to a
stat_ex. The main difference is that we can now get a proper btime.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
 source3/modules/vfs_ceph.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
diff mbox

Patch

diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c
index 59e9b9cf9b3e..62ed469843de 100644
--- a/source3/modules/vfs_ceph.c
+++ b/source3/modules/vfs_ceph.c
@@ -535,6 +535,37 @@  static int cephwrap_fsync(struct vfs_handle_struct *handle, files_struct *fsp)
 	WRAP_RETURN(result);
 }
 
+#ifdef HAVE_CEPH_STATX
+#define	MINORBITS	(20)
+#define	MINORMASK	((1U << MINORBITS) - 1)
+#define	MAJOR(dev)	((unsigned int) ((dev) >> MINORBITS))
+#define	MINOR(dev)	((unsigned int) ((dev) & MINORMASK))
+#define	MKDEV(ma,mi)	(((ma) << MINORBITS) | (mi))
+
+static void init_stat_ex_from_ceph_statx(struct stat_ex *dst, const struct ceph_statx *stx)
+{
+	dst->st_ex_dev = MKDEV(stx->stx_dev_major, stx->stx_dev_minor);
+	dst->st_ex_rdev = MKDEV(stx->stx_rdev_major, stx->stx_rdev_minor);
+	dst->st_ex_ino = stx->stx_ino;
+	dst->st_ex_mode = stx->stx_mode;
+	dst->st_ex_uid = stx->stx_uid;
+	dst->st_ex_gid = stx->stx_gid;
+	dst->st_ex_size = stx->stx_size;
+	dst->st_ex_nlink = stx->stx_nlink;
+	dst->st_ex_atime.tv_sec = stx->stx_atime;
+	dst->st_ex_atime.tv_nsec = stx->stx_atime_ns;
+	dst->st_ex_btime.tv_sec = stx->stx_btime;
+	dst->st_ex_btime.tv_nsec = stx->stx_btime_ns;
+	dst->st_ex_ctime.tv_sec = stx->stx_ctime;
+	dst->st_ex_ctime.tv_nsec = stx->stx_ctime_ns;
+	dst->st_ex_mtime.tv_sec = stx->stx_mtime;
+	dst->st_ex_mtime.tv_nsec = stx->stx_mtime_ns;
+	dst->st_ex_calculated_birthtime = false;
+	dst->st_ex_blksize = stx->stx_blksize;
+	dst->st_ex_blocks = stx->stx_blocks;
+}
+#endif /* HAVE_CEPH_STATX */
+
 static int cephwrap_stat(struct vfs_handle_struct *handle,
 			struct smb_filename *smb_fname)
 {