]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
client: add a ceph_fstatx
authorJeff Layton <jlayton@redhat.com>
Mon, 29 Aug 2016 11:16:41 +0000 (07:16 -0400)
committerJeff Layton <jlayton@redhat.com>
Mon, 29 Aug 2016 14:33:46 +0000 (10:33 -0400)
Signed-off-by: Jeff Layton <jlayton@redhat.com>
src/client/Client.cc
src/client/Client.h
src/include/cephfs/libcephfs.h
src/libcephfs.cc

index 16b4ffaf33f1ae60c7ab52b04f57422283a7eaf3..9c15f17a3bfeb0095aa732d7e66f8959d6561b02 100644 (file)
@@ -9030,6 +9030,31 @@ int Client::fstat(int fd, struct stat *stbuf, int mask)
   return r;
 }
 
+int Client::fstatx(int fd, struct ceph_statx *stx, unsigned int want, unsigned int flags)
+{
+  Mutex::Locker lock(client_lock);
+  tout(cct) << "fstatx flags " << hex << flags << " want " << want << dec << std::endl;
+  tout(cct) << fd << std::endl;
+
+  Fh *f = get_filehandle(fd);
+  if (!f)
+    return -EBADF;
+
+  unsigned mask = statx_to_mask(flags, want);
+
+  int r = 0;
+  if (mask && !f->inode->caps_issued_mask(mask)) {
+    r = _getattr(f->inode, mask);
+    if (r < 0) {
+      ldout(cct, 3) << "fstatx exit on error!" << dendl;
+      return r;
+    }
+  }
+
+  fill_statx(f->inode, mask, stx);
+  ldout(cct, 3) << "fstatx(" << fd << ", " << stx << ") = " << r << dendl;
+  return r;
+}
 
 // not written yet, but i want to link!
 
index e5c655c4fbdea8b193a7be0de3deec16ec703ba5..8b674464a900c6534e726c531639aff17bf0aea3 100644 (file)
@@ -1034,6 +1034,7 @@ public:
   int ftruncate(int fd, loff_t size);
   int fsync(int fd, bool syncdataonly);
   int fstat(int fd, struct stat *stbuf, int mask=CEPH_STAT_CAP_INODE_ALL);
+  int fstatx(int fd, struct ceph_statx *stx, unsigned int want, unsigned int flags);
   int fallocate(int fd, int mode, loff_t offset, loff_t length);
 
   // full path xattr ops
index 688702130b621895270fb22a6d420447d5c39b67..bf38b2b8f22038321f435a6926f8fda632b9766b 100644 (file)
@@ -928,6 +928,19 @@ int ceph_fallocate(struct ceph_mount_info *cmount, int fd, int mode,
  */
 int ceph_fstat(struct ceph_mount_info *cmount, int fd, struct stat *stbuf);
 
+/**
+ * Get an open file's extended statistics and attributes.
+ *
+ * @param cmount the ceph mount handle to use for performing the stat.
+ * @param fd the file descriptor of the file to get statistics of.
+ * @param stx the ceph_statx struct that will be filled in with the file's statistics.
+ * @param want bitfield of CEPH_STATX_* flags showing designed attributes
+ * @param flags bitfield that can be used to set AT_* modifier flags (only AT_NO_ATTR_SYNC and AT_SYMLINK_NOFOLLOW)
+ * @returns 0 on success or negative error code on failure.
+ */
+int ceph_fstatx(struct ceph_mount_info *cmount, int fd, struct ceph_statx *stx,
+               unsigned int want, unsigned int flags);
+
 /** @} file */
 
 /**
index 05ddf8e82b47f59d1b2c2f90bfbef4c330160adf..9e65bff95d298757c979c09c821f878eac66dbc7 100644 (file)
@@ -890,6 +890,14 @@ extern "C" int ceph_fstat(struct ceph_mount_info *cmount, int fd, struct stat *s
   return cmount->get_client()->fstat(fd, stbuf);
 }
 
+extern "C" int ceph_fstatx(struct ceph_mount_info *cmount, int fd, struct ceph_statx *stx,
+                           unsigned int want, unsigned int flags)
+{
+  if (!cmount->is_mounted())
+    return -ENOTCONN;
+  return cmount->get_client()->fstatx(fd, stx, want, flags);
+}
+
 extern "C" int ceph_sync_fs(struct ceph_mount_info *cmount)
 {
   if (!cmount->is_mounted())