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.
+ * Get the file replication information 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 replication information of.
* @returns the replication factor of the file.
*/
int ceph_get_file_replication(struct ceph_mount_info *cmount, int fh);
+/**
+ * Get the file replication information.
+ *
+ * @param cmount the ceph mount handle to use.
+ * @param path the path of the file/directory get the replication information of.
+ * @returns the replication factor of the file.
+ */
+int ceph_get_path_replication(struct ceph_mount_info *cmount, const char *path);
+
/**
* Get the id of the named pool.
*
return rep;
}
+extern "C" int ceph_get_path_replication(struct ceph_mount_info *cmount, const char *path)
+{
+ 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;
+ int rep = cmount->get_client()->get_pool_replication(l.fl_pg_pool);
+ return rep;
+}
+
extern "C" int ceph_set_default_file_stripe_unit(struct ceph_mount_info *cmount,
int stripe)
{