*/
int ceph_get_file_pool_name(struct ceph_mount_info *cmount, int fh, char *buf, size_t buflen);
+/**
+ * Get the file layout from an open file descriptor.
+ *
+ * @param cmount the ceph mount handle to use.
+ * @param fh the open file descriptor referring to the file to get the layout of.
+ * @param stripe_unit where to store the striping unit of the file
+ * @param stripe_count where to store the striping count of the file
+ * @param object_size where to store the object size of the file
+ * @param pg_pool where to store the ceph pool id that the file is in
+ * @returns 0 on success or a negative error code on failure.
+ */
+int ceph_get_file_layout(struct ceph_mount_info *cmount, int fh, int *stripe_unit, int *stripe_count, int *object_size, int *pg_pool);
+
+/**
+ * Get the file layout.
+ *
+ * @param cmount the ceph mount handle to use.
+ * @param path the path of the file/directory get the layout of.
+ * @param stripe_unit where to store the striping unit of the file
+ * @param stripe_count where to store the striping count of the file
+ * @param object_size where to store the object size of the file
+ * @param pg_pool where to store the ceph pool id that the file is in
+ * @returns 0 on success or a negative error code on failure.
+ */
+int ceph_get_path_layout(struct ceph_mount_info *cmount, const char *path, int *stripe_unit, int *stripe_count, int *object_size, int *pg_pool);
+
/**
* Get the file replication information.
* @param cmount the ceph mount handle to use.
return name.length();
}
+extern "C" int ceph_get_file_layout(struct ceph_mount_info *cmount, int fh, int *stripe_unit, int *stripe_count, int *object_size, int *pg_pool)
+{
+ struct ceph_file_layout l;
+ int r;
+
+ if (!cmount->is_mounted())
+ return -ENOTCONN;
+ r = cmount->get_client()->fdescribe_layout(fh, &l);
+ if (r < 0)
+ return r;
+ if (stripe_unit)
+ *stripe_unit = l.fl_stripe_unit;
+ if (stripe_count)
+ *stripe_count = l.fl_stripe_count;
+ if (object_size)
+ *object_size = l.fl_object_size;
+ if (pg_pool)
+ *pg_pool = l.fl_pg_pool;
+ return 0;
+}
+
+extern "C" int ceph_get_path_layout(struct ceph_mount_info *cmount, const char *path, int *stripe_unit, int *stripe_count, int *object_size, int *pg_pool)
+{
+ struct ceph_file_layout l;
+ int r;
+
+ if (!cmount->is_mounted())
+ return -ENOTCONN;
+ r = cmount->get_client()->describe_layout(path, &l);
+ if (r < 0)
+ return r;
+ if (stripe_unit)
+ *stripe_unit = l.fl_stripe_unit;
+ if (stripe_count)
+ *stripe_count = l.fl_stripe_count;
+ if (object_size)
+ *object_size = l.fl_object_size;
+ if (pg_pool)
+ *pg_pool = l.fl_pg_pool;
+ return 0;
+}
+
extern "C" int ceph_get_file_replication(struct ceph_mount_info *cmount, int fh)
{
struct ceph_file_layout l;