]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: add ceph_stat/ceph_lstat/ceph_fstat api 25650/head
authorWei Qiaomiao <wei.qiaomiao@zte.com.cn>
Tue, 15 Jan 2019 02:41:14 +0000 (10:41 +0800)
committerWei Qiaomiao <wei.qiaomiao@zte.com.cn>
Wed, 16 Jan 2019 00:46:23 +0000 (08:46 +0800)
This partial reverts from commit ce8c6f3c9f9f35b7458ab95d9affc9ed4712d0eb

The purpose of take these api back is maked the application based on UNIX system easier move on Ceph

Signed-off-by: Wei Qiaomiao <wei.qiaomiao@zte.com.cn>
src/include/cephfs/libcephfs.h [changed mode: 0644->0755]
src/libcephfs.cc [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index dbb84a1..36f4c03
@@ -746,6 +746,37 @@ int ceph_fstatx(struct ceph_mount_info *cmount, int fd, struct ceph_statx *stx,
 int ceph_statx(struct ceph_mount_info *cmount, const char *path, struct ceph_statx *stx,
               unsigned int want, unsigned int flags);
 
+/**
+ * Get a file's statistics and attributes.
+ *
+ * @param cmount the ceph mount handle to use for performing the stat.
+ * @param path the file or directory to get the statistics of.
+ * @param stbuf the stat struct that will be filled in with the file's statistics.
+ * @returns 0 on success or negative error code on failure.
+ */
+int ceph_stat(struct ceph_mount_info *cmount, const char *path, struct stat *stbuf);
+
+/**
+ * Get a file's statistics and attributes, without following symlinks.
+ *
+ * @param cmount the ceph mount handle to use for performing the stat.
+ * @param path the file or directory to get the statistics of.
+ * @param stbuf the stat struct that will be filled in with the file's statistics.
+ * @returns 0 on success or negative error code on failure.
+ */
+int ceph_lstat(struct ceph_mount_info *cmount, const char *path, struct stat *stbuf);
+
+/**
+ * Get the open file's statistics.
+ *
+ * @param cmount the ceph mount handle to use for performing the fstat.
+ * @param fd the file descriptor of the file to get statistics of.
+ * @param stbuf the stat struct of the file's statistics, filled in by the
+ *    function.
+ * @returns 0 on success or a negative error code on failure
+ */
+int ceph_fstat(struct ceph_mount_info *cmount, int fd, struct stat *stbuf);
+
 /**
  * Set a file's attributes.
  *
old mode 100644 (file)
new mode 100755 (executable)
index 38f9fc7..a6b8edf
@@ -852,6 +852,27 @@ extern "C" int ceph_fsetxattr(struct ceph_mount_info *cmount, int fd, const char
 }
 /* end xattr support */
 
+extern "C" int ceph_stat(struct ceph_mount_info *cmount, const char *path, struct stat *stbuf)
+{
+  if (!cmount->is_mounted())
+    return -ENOTCONN;
+  return cmount->get_client()->stat(path, stbuf, cmount->default_perms);
+}
+
+extern "C" int ceph_fstat(struct ceph_mount_info *cmount, int fd, struct stat *stbuf)
+{
+  if (!cmount->is_mounted())
+    return -ENOTCONN;
+  return cmount->get_client()->fstat(fd, stbuf, cmount->default_perms);
+}
+
+extern int ceph_lstat(struct ceph_mount_info *cmount, const char *path, struct stat *stbuf)
+{
+   if (!cmount->is_mounted())
+    return -ENOTCONN;
+  return cmount->get_client()->lstat(path, stbuf, cmount->default_perms);
+}
+
 extern "C" int ceph_chmod(struct ceph_mount_info *cmount, const char *path, mode_t mode)
 {
   if (!cmount->is_mounted())
@@ -1060,7 +1081,6 @@ extern "C" int ceph_sync_fs(struct ceph_mount_info *cmount)
   return cmount->get_client()->sync_fs();
 }
 
-
 extern "C" int ceph_get_file_stripe_unit(struct ceph_mount_info *cmount, int fh)
 {
   file_layout_t l;