Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed platform support for Mac M1 #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ repositories {
}

dependencies {
compile 'com.github.jnr:jnr-ffi:2.0.3'
compile 'com.github.jnr:jnr-posix:3.0.17'
compile 'com.github.jnr:jnr-ffi:2.2.12'
compile 'com.github.jnr:jnr-posix:3.1.15'

testCompile 'junit:junit:4.12'
testCompile 'org.truth0:truth:0.23'
testCompile 'com.google.jimfs:jimfs:1.0'
testCompile 'com.google.jimfs:jimfs:1.2'
}

tasks.withType(JavaExec) {
Expand Down Expand Up @@ -120,11 +120,6 @@ uploadArchives {
}
}

task wrapper(type: Wrapper) {
gradleVersion = '2.4'
}


task('run', type: JavaExec, dependsOn:[testClasses]) {
classpath = sourceSets.main.runtimeClasspath + sourceSets.test.runtimeClasspath

Expand Down
6 changes: 3 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Sep 04 17:18:36 IDT 2015
#Sat Oct 22 00:20:50 CST 2022
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.3-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ protected FileSystemAdapter(FileSystem fs, FileSystemProvider fsp) {
this.fsp = fsp;
}

// protected FileSystemAdapter(FileSystem fs) {
// this.fs = fs;
// this.fsp = wrapFileSystemProvider(fs.provider());
// }
// protected FileSystemProvider wrapFileSystemProvider(FileSystemProvider fsp) {
// return fsp;
// }
@Override
public String toString() {
return fs.toString();
Expand Down
15 changes: 12 additions & 3 deletions src/main/java/co/paralleluniverse/fuse/Filesystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import jnr.ffi.provider.jffi.ClosureHelper;
import java.nio.BufferOverflowException;
import java.nio.ByteBuffer;
import java.util.logging.Logger;

import jnr.ffi.Pointer;
import jnr.ffi.annotations.In;
import jnr.ffi.annotations.Out;
Expand All @@ -25,6 +27,8 @@ class Filesystem implements
_opendir, _readdir, _releasedir, _fsyncdir,
_init, _destroy, _access, _create, _ftruncate, _utimens, _bmap,
_ioctl, _poll, _write_buf, _read_buf, _flock, _fallocate {
private final Logger logger = Logger.getLogger(getClass().getCanonicalName());

private final FuseFilesystem fs;

public Filesystem(FuseFilesystem fs) {
Expand Down Expand Up @@ -179,9 +183,14 @@ public final int _opendir(String path, Pointer info) {

@Override
public final int _readdir(String path, Pointer buf, Pointer fillFunction, @off_t long offset, @In Pointer info) {
return fs.readdir(path,
new StructFuseFileInfo(info, path),
new DirectoryFillerImpl(buf, ClosureHelper.getInstance().fromNative(fillFunction, DirectoryFillerImpl.fuse_fill_dir_t.class)));
try {
return fs.readdir(path,
new StructFuseFileInfo(info, path),
new DirectoryFillerImpl(buf, ClosureHelper.getInstance().fromNative(fillFunction, DirectoryFillerImpl.fuse_fill_dir_t.class)));
} catch (Error e) {
logger.severe(e.getMessage());
return 1;
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,21 +538,6 @@ protected int fgetattr(String path, StructStat stat, StructFuseFileInfo info) {
protected int lock(String path, StructFuseFileInfo info, int command, StructFlock flock) {
try {
throw new UnsupportedOperationException();
// if (command == StructFlock.CMD_GETLK)
// throw new UnsupportedOperationException();
//
// final Channel channel = toChannel(info);
// if (channel instanceof FileChannel) {
// FileChannel ch = (FileChannel) channel;
// switch (command) {
// case StructFlock.CMD_SETLK:
// FileLock lock = ch.lock(flock.start(), flock.len(), false);
// lock.
// }
// } else if (channel instanceof AsynchronousFileChannel) {
// AsynchronousFileChannel ch = (AsynchronousFileChannel) channel;
// }
// return 0;
} catch (Exception e) {
return -errno(e);
}
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/jnr/ffi/provider/jffi/ClosureHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import jnr.ffi.mapper.FromNativeConverter;
import jnr.ffi.provider.ClosureManager;
import java.util.Collections;
import java.util.Map;

public class ClosureHelper {
public static ClosureHelper getInstance() {
Expand All @@ -51,14 +52,17 @@ private ClosureHelper() {
try {
final ClosureManager closureManager = Runtime.getSystemRuntime().getClosureManager();

final AsmClassLoader cl = (AsmClassLoader) accessible(NativeClosureManager.class.getDeclaredField("classLoader")).get(closureManager);
final CompositeTypeMapper ctm = (CompositeTypeMapper) accessible(NativeClosureManager.class.getDeclaredField("typeMapper")).get(closureManager);
final Map<ClassLoader,AsmClassLoader> asmClassLoaderMap = (Map<ClassLoader,AsmClassLoader>)
accessible(NativeClosureManager.class.getDeclaredField("asmClassLoaders")).get(closureManager);
final CompositeTypeMapper ctm = (CompositeTypeMapper)
accessible(NativeClosureManager.class.getDeclaredField("typeMapper")).get(closureManager);
this.ctx = new SimpleNativeContext(Runtime.getSystemRuntime(), (Collection<Annotation>) Collections.EMPTY_LIST);
this.cache = new ClassValue<FromNativeConverter<?, Pointer>>() {
@Override
protected FromNativeConverter<?, Pointer> computeValue(Class<?> closureClass) {
return ClosureFromNativeConverter.
getInstance(Runtime.getSystemRuntime(), DefaultSignatureType.create(closureClass, (FromNativeContext) ctx), cl, ctm);
getInstance(Runtime.getSystemRuntime(), DefaultSignatureType.create(closureClass,
(FromNativeContext) ctx), asmClassLoaderMap.get(getClass().getClassLoader()), ctm);
}
};
} catch (Exception e) {
Expand Down
1 change: 0 additions & 1 deletion src/test/java/co/paralleluniverse/javafs/JFSTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/
package co.paralleluniverse.javafs;

import co.paralleluniverse.javafs.JavaFS;
import com.google.common.jimfs.Jimfs;
import static com.google.common.truth.Truth.assert_;
import java.io.DataInputStream;
Expand Down