1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| JNIEXPORT jint JNICALL Java_MyFS_initFuseDriver
(JNIEnv *env, jobject thisObj, jstring mountPoint) {
const char *mountPointNativeString = (*env)->GetStringUTFChars(env, mountPoint, 0);
printf( "Mounting MyFS on [%s]...\n", mountPointNativeString );
const char* argv[2];
argv[0] = mountPointNativeString;
argv[1] = mountPointNativeString;
//Load libfuse and retrieve a pointer to fuse_main function.
void *libFuseHandle = dlopen("libfuse.so",RTLD_NOW);
int (*fuseMain)(int, const char *[], const struct fuse_operations *, void *);
fuseMain = (int (*) (int, const char *[], const struct fuse_operations *, void *)) dlsym(libFuseHandle, "fuse_main" );
printf( "%u\n", fuseMain );
if (fuseMain == NULL) {
printf("Function fuse_main() not found in libfuse : %s\n", dlerror());
exit (-1);
}
int result = fuseMain( 2, argv, &operations, NULL );
printf( "Done with result [%i].\n", result );
dlclose(libFuseHandle);
(*env)->ReleaseStringUTFChars(env, mountPoint, mountPointNativeString);
return 0;
} |
Partager