Skip to content

Commit

Permalink
Merge branch 'release/0.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
overheadhunter committed Oct 7, 2022
2 parents 1f54357 + 184d161 commit b1b04df
Show file tree
Hide file tree
Showing 53 changed files with 840 additions and 891 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
java-version: 19-ea
java-version: 19
distribution: 'zulu'
cache: 'maven'
- name: Setup fuse
Expand All @@ -35,7 +35,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
java-version: 19-ea
java-version: 19
distribution: 'zulu'
cache: 'maven'
- name: Setup fuse
Expand All @@ -56,7 +56,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
java-version: 19-ea
java-version: 19
distribution: 'zulu'
cache: 'maven'
- name: Setup fuse
Expand All @@ -79,7 +79,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-java@v2
with:
java-version: 19-ea
java-version: 19
distribution: 'zulu'
cache: 'maven'
- name: Cache SonarCloud packages
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-central.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
ref: "refs/tags/${{ github.event.inputs.tag }}"
- uses: actions/setup-java@v2
with:
java-version: 19-ea
java-version: 19
distribution: 'zulu'
cache: 'maven'
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
java-version: 19-ea
java-version: 19
distribution: 'zulu'
cache: 'maven'
gpg-private-key: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
Expand Down
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion jfuse-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.cryptomator</groupId>
<artifactId>jfuse</artifactId>
<version>0.2.0</version>
<version>0.2.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jfuse-api</artifactId>
Expand Down
10 changes: 5 additions & 5 deletions jfuse-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.cryptomator</groupId>
<artifactId>jfuse</artifactId>
<version>0.2.0</version>
<version>0.2.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jfuse-examples</artifactId>
Expand All @@ -24,7 +24,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.0-alpha6</version>
<version>2.0.3</version>
</dependency>
</dependencies>

Expand All @@ -51,8 +51,8 @@
<activation>
<os>
<family>unix</family>
<name>Linux</name>
<arch>x86_64</arch>
<name>linux</name>
<arch>amd64</arch>
</os>
</activation>
<dependencies>
Expand All @@ -69,7 +69,7 @@
<activation>
<os>
<family>unix</family>
<name>Linux</name>
<name>linux</name>
<arch>aarch64</arch>
</os>
</activation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ protected Path resolvePath(String absolutePath) {
public Set<FuseOperations.Operation> supportedOperations() {
return EnumSet.of(
FuseOperations.Operation.ACCESS,
FuseOperations.Operation.CHMOD,
FuseOperations.Operation.CREATE,
FuseOperations.Operation.DESTROY,
FuseOperations.Operation.GET_ATTR,
Expand Down Expand Up @@ -216,18 +215,6 @@ private long countSubDirs(Path dir) throws IOException {
}
}

@Override
public int chmod(String path, int mode, FileInfo fi) {
LOG.trace("chmod {}", path);
Path node = resolvePath(path);
try {
Files.setPosixFilePermissions(node, FileModes.toPermissions(mode));
return 0;
} catch (IOException e) {
return -errno.eio();
}
}

@Override
public int utimens(String path, TimeSpec atime, TimeSpec mtime, FileInfo fi) {
LOG.trace("utimens {}", path);
Expand Down
18 changes: 10 additions & 8 deletions jfuse-linux-aarch64/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>jfuse</artifactId>
<groupId>org.cryptomator</groupId>
<version>0.2.0</version>
<version>0.2.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jfuse-linux-aarch64</artifactId>
Expand Down Expand Up @@ -91,14 +91,19 @@
<headerClassName>fuse_h</headerClassName>
<cPreprocessorMacros>
<cPreprocessorMacro>_FILE_OFFSET_BITS=64</cPreprocessorMacro>
<cPreprocessorMacro>FUSE_USE_VERSION=35</cPreprocessorMacro>
<cPreprocessorMacro>FUSE_USE_VERSION=312</cPreprocessorMacro>
</cPreprocessorMacros>
<includeFunctions>
<includeFunction>fuse_version</includeFunction>
<includeFunction>fuse_lib_help</includeFunction>
<includeFunction>fuse_new</includeFunction>
<includeFunction>fuse_mount</includeFunction>
<includeFunction>fuse_get_session</includeFunction>
<includeFunction>fuse_loop</includeFunction>
<includeFunction>fuse_loop_cfg_create</includeFunction>
<includeFunction>fuse_loop_cfg_set_clone_fd</includeFunction>
<includeFunction>fuse_loop_cfg_set_max_threads</includeFunction>
<includeFunction>fuse_loop_cfg_destroy</includeFunction>
<includeFunction>fuse_loop_mt</includeFunction>
<includeFunction>fuse_exit</includeFunction>
<includeFunction>fuse_unmount</includeFunction>
Expand All @@ -115,7 +120,7 @@
<includeStruct>timespec</includeStruct>
<includeStruct>fuse_conn_info</includeStruct>
<includeStruct>fuse_args</includeStruct>
<includeStruct>fuse_loop_config</includeStruct>
<includeStruct>fuse_loop_config_v1</includeStruct>
</includeStructs>
</configuration>
</execution>
Expand All @@ -126,15 +131,12 @@
</goals>
<configuration>
<headerFile>${project.parent.basedir}/libfuse3/include/fuse_lowlevel.h</headerFile>
<targetPackage>org.cryptomator.jfuse.linux.aarch64.extr.ll</targetPackage>
<targetPackage>org.cryptomator.jfuse.linux.aarch64.extr</targetPackage>
<headerClassName>fuse_lowlevel_h</headerClassName>
<cPreprocessorMacros>
<cPreprocessorMacro>_FILE_OFFSET_BITS=64</cPreprocessorMacro>
<cPreprocessorMacro>FUSE_USE_VERSION=35</cPreprocessorMacro>
<cPreprocessorMacro>FUSE_USE_VERSION=312</cPreprocessorMacro>
</cPreprocessorMacros>
<includeFunctions>
<includeFunction>fuse_parse_cmdline</includeFunction>
</includeFunctions>
<includeStructs>
<includeStruct>fuse_cmdline_opts</includeStruct>
</includeStructs>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.cryptomator.jfuse.linux.aarch64;

import org.cryptomator.jfuse.linux.aarch64.extr.fuse_args;
import org.cryptomator.jfuse.linux.aarch64.extr.ll.fuse_cmdline_opts;
import org.cryptomator.jfuse.linux.aarch64.extr.fuse_cmdline_opts;

import java.lang.foreign.MemoryAddress;
import java.lang.foreign.MemorySegment;
Expand Down Expand Up @@ -31,4 +31,16 @@ public MemoryAddress mountPoint() {
public boolean multithreaded() {
return fuse_cmdline_opts.singlethread$get(cmdLineOpts) == 0;
}

public int cloneFd() {
return fuse_cmdline_opts.clone_fd$get(cmdLineOpts);
}

public int maxIdleThreads() {
return fuse_cmdline_opts.max_idle_threads$get(cmdLineOpts);
}

public int maxThreads() {
return fuse_cmdline_opts.max_threads$get(cmdLineOpts);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.cryptomator.jfuse.linux.aarch64;

import java.lang.foreign.Addressable;
import java.lang.foreign.FunctionDescriptor;
import java.lang.foreign.Linker;
import java.lang.foreign.SymbolLookup;
import java.lang.invoke.MethodHandle;

import static java.lang.foreign.ValueLayout.ADDRESS;
import static java.lang.foreign.ValueLayout.JAVA_INT;

/**
* These method references can not be jextract'ed, partly due to jextract not being able to understand {@code #define},
* partly due to slight differences in the FUSE API, which applies a versioning scheme via dlvsym, that Panama's default
* {@link java.lang.foreign.SymbolLookup} doesn't support.
*/
class FuseFunctions {

// see https://github.com/libfuse/libfuse/blob/fuse-3.12.0/include/fuse_lowlevel.h#L1892-L1923
private static final FunctionDescriptor FUSE_PARSE_CMDLINE = FunctionDescriptor.of(JAVA_INT, ADDRESS, ADDRESS);

private final MethodHandle fuse_parse_cmdline;

private FuseFunctions() {
var lookup = SymbolLookup.loaderLookup();
var linker = Linker.nativeLinker();
this.fuse_parse_cmdline = lookup.lookup("fuse_parse_cmdline")
.map(symbol -> linker.downcallHandle(symbol, FUSE_PARSE_CMDLINE))
.orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol fuse_parse_cmdline"));
}

private static class Holder {
private static final FuseFunctions INSTANCE = new FuseFunctions();
}

public static int fuse_parse_cmdline(Addressable args, Addressable opts) {
try {
return (int) Holder.INSTANCE.fuse_parse_cmdline.invokeExact(args, opts);
} catch (Throwable e) {
throw new AssertionError("should not reach here", e);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
import org.cryptomator.jfuse.linux.aarch64.extr.fuse_args;
import org.cryptomator.jfuse.linux.aarch64.extr.fuse_h;
import org.cryptomator.jfuse.linux.aarch64.extr.fuse_operations;
import org.cryptomator.jfuse.linux.aarch64.extr.ll.fuse_cmdline_opts;
import org.cryptomator.jfuse.linux.aarch64.extr.ll.fuse_lowlevel_h;
import org.cryptomator.jfuse.linux.aarch64.extr.fuse_cmdline_opts;
import org.cryptomator.jfuse.linux.aarch64.extr.stat_h;
import org.cryptomator.jfuse.linux.aarch64.extr.timespec;
import org.jetbrains.annotations.VisibleForTesting;
Expand Down Expand Up @@ -61,7 +60,7 @@ FuseArgs parseArgs(List<String> cmdLineArgs) throws IllegalArgumentException {
fuse_args.allocated$set(args, 0);

var opts = fuse_cmdline_opts.allocate(fuseScope);
int parseResult = fuse_lowlevel_h.fuse_parse_cmdline(args, opts);
int parseResult = FuseFunctions.fuse_parse_cmdline(args, opts);
if (parseResult != 0) {
throw new IllegalArgumentException("fuse_parse_cmdline failed to parse " + String.join(" ", cmdLineArgs));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,40 @@

import org.cryptomator.jfuse.api.FuseMount;
import org.cryptomator.jfuse.linux.aarch64.extr.fuse_h;
import org.cryptomator.jfuse.linux.aarch64.extr.fuse_loop_config;
import org.cryptomator.jfuse.linux.aarch64.extr.fuse_loop_config_v1;

import java.lang.foreign.MemoryAddress;
import java.lang.foreign.MemorySession;

record FuseMountImpl(MemoryAddress fuse, FuseArgs fuseArgs) implements FuseMount {

private static final int FUSE_3_2 = 32;
private static final int FUSE_3_12 = 312;

@Override
public int loop() {
if (fuseArgs.multithreaded()) {
// depends on fuse version: https://github.com/libfuse/libfuse/blob/fuse-3.12.0/include/fuse.h#L1011-L1050
if (!fuseArgs.multithreaded() || fuse_h.fuse_version() < FUSE_3_2) {
// FUSE 3.1: to keep things simple, we just don't support fuse_loop_mt
return fuse_h.fuse_loop(fuse);
} else if (fuse_h.fuse_version() < FUSE_3_12) {
// FUSE 3.2
try (var scope = MemorySession.openConfined()) {
var loopCfg = fuse_loop_config.allocate(scope);
fuse_loop_config.clone_fd$set(loopCfg, 0);
fuse_loop_config.max_idle_threads$set(loopCfg, 10);
var loopCfg = fuse_loop_config_v1.allocate(scope);
fuse_loop_config_v1.clone_fd$set(loopCfg, fuseArgs.cloneFd());
fuse_loop_config_v1.max_idle_threads$set(loopCfg, fuseArgs.maxIdleThreads());
return fuse_h.fuse_loop_mt(fuse, loopCfg);
}
} else {
return fuse_h.fuse_loop(fuse);
// FUSE 3.12
var loopCfg = fuse_h.fuse_loop_cfg_create();
try {
fuse_h.fuse_loop_cfg_set_clone_fd(loopCfg, fuseArgs.cloneFd());
fuse_h.fuse_loop_cfg_set_max_threads(loopCfg, fuseArgs.maxThreads());
return fuse_h.fuse_loop_mt(fuse, loopCfg);
} finally {
fuse_h.fuse_loop_cfg_destroy(loopCfg);
}
}
}

Expand Down
Loading

0 comments on commit b1b04df

Please sign in to comment.