]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
java: add AlreadyMounted exception
authorNoah Watkins <noahwatkins@gmail.com>
Thu, 25 Oct 2012 22:09:54 +0000 (15:09 -0700)
committerNoah Watkins <noahwatkins@gmail.com>
Fri, 26 Oct 2012 20:58:20 +0000 (13:58 -0700)
Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
src/java/Makefile.am
src/java/java/com/ceph/fs/CephAlreadyMountedException.java [new file with mode: 0644]
src/java/native/libcephfs_jni.cc

index 48266653b0afaa9ccd892334f4e7e6916bef3aac..d05df99d18690b20e2253ce2982cacd751de1aa4 100644 (file)
@@ -6,7 +6,8 @@ JAVA_SRC = \
        java/com/ceph/fs/CephStatVFS.java \
        java/com/ceph/fs/CephNativeLoader.java \
        java/com/ceph/fs/CephNotMountedException.java \
-       java/com/ceph/fs/CephFileAlreadyExistsException.java
+       java/com/ceph/fs/CephFileAlreadyExistsException.java \
+       java/com/ceph/fs/CephAlreadyMountedException.java
 
 EXTRA_DIST = $(JAVA_SRC) test
 
diff --git a/src/java/java/com/ceph/fs/CephAlreadyMountedException.java b/src/java/java/com/ceph/fs/CephAlreadyMountedException.java
new file mode 100644 (file)
index 0000000..394eec8
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package com.ceph.fs;
+
+import java.io.IOException;
+
+/**
+ * Ceph is already mounted.
+ */
+public class CephAlreadyMountedException extends IOException {
+
+  /**
+   * Construct CephAlreadyMountedException.
+   */
+  public CephAlreadyMountedException() {
+    super();
+  }
+
+  /**
+   * Construct CephAlreadyMountedException with message.
+   */
+  public CephAlreadyMountedException(String s) {
+    super(s);
+  }
+}
index 87c6098289f7c50fbaae1f3797280cea9a97fbeb..64240b7fe7c37f3d3b1a400b01064244be7c2a39 100644 (file)
@@ -37,6 +37,7 @@
 #define CEPH_MOUNT_CP "com/ceph/fs/CephMount"
 #define CEPH_NOTMOUNTED_CP "com/ceph/fs/CephNotMountedException"
 #define CEPH_FILEEXISTS_CP "com/ceph/fs/CephFileAlreadyExistsException"
+#define CEPH_ALREADYMOUNTED_CP "com/ceph/fs/CephAlreadyMountedException"
 
 /*
  * Flags to open(). must be synchronized with CephMount.java
@@ -369,6 +370,14 @@ JNIEXPORT jint JNICALL Java_com_ceph_fs_CephMount_native_1ceph_1mount
        const char *c_root = NULL;
        int ret;
 
+       /*
+        * Toss a message up if we are already mounted.
+        */
+       if (ceph_is_mounted(cmount)) {
+               THROW(env, CEPH_ALREADYMOUNTED_CP, "");
+               return -1;
+       }
+
        if (j_root) {
                c_root = env->GetStringUTFChars(j_root, NULL);
                if (!c_root) {