private static synchronized native int native_ceph_open(long mountp, String path, int flags, int mode);
+ /**
+ * Open a file with a specific file layout.
+ *
+ * @param path Path of file to open or create.
+ * @param flags Open flags.
+ * @param mode Permission mode.
+ * @param stripe_unit File layout stripe unit size.
+ * @param stripe_count File layout stripe count.
+ * @param object_size Size of each object.
+ * @param data_pool The target data pool.
+ * @return File descriptor.
+ */
+ public int open(String path, int flags, int mode, int stripe_unit, int stripe_count,
+ int object_size, String data_pool) throws FileNotFoundException {
+ return native_ceph_open_layout(instance_ptr, path, flags, mode, stripe_unit,
+ stripe_count, object_size, data_pool);
+ }
+
+ private static synchronized native int native_ceph_open_layout(long mountp, String path,
+ int flags, int mode, int stripe_unit, int stripe_count, int object_size, String data_pool);
+
/**
* Close an open file.
*
return ret;
}
+/*
+ * Class: com_ceph_fs_CephMount
+ * Method: native_ceph_open_layout
+ * Signature: (JLjava/lang/String;IIIIILjava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL Java_com_ceph_fs_CephMount_native_1ceph_1open_1layout
+ (JNIEnv *env, jclass clz, jlong j_mntp, jstring j_path, jint j_flags, jint j_mode,
+ jint stripe_unit, jint stripe_count, jint object_size, jstring j_data_pool)
+{
+ struct ceph_mount_info *cmount = get_ceph_mount(j_mntp);
+ CephContext *cct = ceph_get_mount_context(cmount);
+ const char *c_path, *c_data_pool = NULL;
+ int ret, flags = fixup_open_flags(j_flags);
+
+ CHECK_ARG_NULL(j_path, "@path is null", -1);
+ CHECK_MOUNTED(cmount, -1);
+
+ c_path = env->GetStringUTFChars(j_path, NULL);
+ if (!c_path) {
+ cephThrowInternal(env, "Failed to pin memory");
+ return -1;
+ }
+
+ if (j_data_pool) {
+ c_data_pool = env->GetStringUTFChars(j_data_pool, NULL);
+ if (!c_data_pool) {
+ env->ReleaseStringUTFChars(j_path, c_path);
+ cephThrowInternal(env, "Failed to pin memory");
+ return -1;
+ }
+ }
+
+ ldout(cct, 10) << "jni: open_layout: path " << c_path << " flags " << flags
+ << " mode " << (int)j_mode << " stripe_unit " << stripe_unit
+ << " stripe_count " << stripe_count << " object_size " << object_size
+ << " data_pool " << (c_data_pool ? c_data_pool : "<NULL>") << dendl;
+
+ ret = ceph_open_layout(cmount, c_path, flags, (int)j_mode,
+ (int)stripe_unit, (int)stripe_count, (int)object_size, c_data_pool);
+
+ ldout(cct, 10) << "jni: open_layout: exit ret " << ret << dendl;
+
+ env->ReleaseStringUTFChars(j_path, c_path);
+ if (j_data_pool)
+ env->ReleaseStringUTFChars(j_data_pool, c_data_pool);
+
+ if (ret < 0)
+ handle_error(env, ret);
+
+ return ret;
+}
+
/*
* Class: com_ceph_fs_CephMount
* Method: native_ceph_close