int ceph_mount(struct ceph_mount_info *cmount, const char *root);
/**
- * Destroy the ceph mount handle. This should be called on completion of all
- * libcephfs functions.
+ * Unmount a mount handle.
+ *
+ * @param cmount the mount handle
+ * @return 0 on success, negative error code on failure
+ */
+int ceph_unmount(struct ceph_mount_info *cmount);
+
+/**
+ * Destroy the mount handle.
+ *
+ * The handle should not be mounted. This should be called on completion of
+ * all libcephfs functions.
+ *
+ * @param cmount the mount handle
+ * @return 0 on success, negative error code on failure.
+ */
+int ceph_release(struct ceph_mount_info *cmount);
+
+/**
+ * Deprecated. Unmount and destroy the ceph mount handle. This should be
+ * called on completion of all libcephfs functions.
+ *
+ * Equivalent to ceph_unmount() + ceph_release() without error handling.
*
* @param cmount the mount handle to shutdown
*/
ceph_shutdown(cmount);
}
+TEST(LibCephFS, Mount_remount) {
+
+ struct ceph_mount_info *cmount;
+
+ ASSERT_EQ(0, ceph_create(&cmount, NULL));
+ ASSERT_EQ(0, ceph_conf_read_file(cmount, NULL));
+
+ CephContext *cct = ceph_get_mount_context(cmount);
+ ASSERT_EQ(0, ceph_mount(cmount, "/"));
+ ASSERT_EQ(0, ceph_unmount(cmount));
+
+ ASSERT_EQ(0, ceph_mount(cmount, "/"));
+ ASSERT_EQ(cct, ceph_get_mount_context(cmount));
+
+ ceph_shutdown(cmount);
+}
+
+TEST(LibCephFS, Unmount_unmounted) {
+
+ struct ceph_mount_info *cmount;
+
+ ASSERT_EQ(0, ceph_create(&cmount, NULL));
+ ASSERT_EQ(0, ceph_conf_read_file(cmount, NULL));
+ ASSERT_EQ(-ENOTCONN, ceph_unmount(cmount));
+}
+
+TEST(LibCephFS, Release_unmounted) {
+
+ struct ceph_mount_info *cmount;
+
+ ASSERT_EQ(0, ceph_create(&cmount, NULL));
+ ASSERT_EQ(0, ceph_conf_read_file(cmount, NULL));
+ ASSERT_EQ(0, ceph_release(cmount));
+}
+
+TEST(LibCephFS, Release_mounted) {
+
+ struct ceph_mount_info *cmount;
+
+ ASSERT_EQ(0, ceph_create(&cmount, NULL));
+ ASSERT_EQ(0, ceph_conf_read_file(cmount, NULL));
+ ASSERT_EQ(0, ceph_mount(cmount, "/"));
+ ASSERT_EQ(-EISCONN, ceph_release(cmount));
+ ceph_shutdown(cmount);
+}
+
+TEST(LibCephFS, Unmount_release) {
+
+ struct ceph_mount_info *cmount;
+
+ ASSERT_EQ(0, ceph_create(&cmount, NULL));
+ ASSERT_EQ(0, ceph_conf_read_file(cmount, NULL));
+ ASSERT_EQ(0, ceph_mount(cmount, "/"));
+ ASSERT_EQ(0, ceph_unmount(cmount));
+ ASSERT_EQ(0, ceph_release(cmount));
+}
+
TEST(LibCephFS, Mount) {
struct ceph_mount_info *cmount;
ASSERT_EQ(ceph_create(&cmount, NULL), 0);