Skip to content

Commit cc9ce84

Browse files
committed
use libfuse 3.2 api on windows/winfsp
1 parent 9f7ad41 commit cc9ce84

File tree

5 files changed

+79
-12
lines changed

5 files changed

+79
-12
lines changed

jfuse-win-amd64/pom.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
<includeFunction>fuse3_mount</includeFunction>
101101
<includeFunction>fuse3_get_session</includeFunction>
102102
<includeFunction>fuse3_loop</includeFunction>
103-
<includeFunction>fuse3_loop_mt_31</includeFunction>
103+
<includeFunction>fuse3_loop_mt</includeFunction>
104104
<includeFunction>fuse3_exit</includeFunction>
105105
<includeFunction>fuse3_unmount</includeFunction>
106106
<includeFunction>fuse3_destroy</includeFunction>
@@ -115,6 +115,7 @@
115115
<includeStruct>fuse_statvfs</includeStruct>
116116
<includeStruct>fuse_timespec</includeStruct>
117117
<includeStruct>fuse3_conn_info</includeStruct>
118+
<includeStruct>fuse3_loop_config</includeStruct>
118119
</includeStructs>
119120
</configuration>
120121
</execution>

jfuse-win-amd64/src/main/java/org/cryptomator/jfuse/win/amd64/FuseMountImpl.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
package org.cryptomator.jfuse.win.amd64;
22

33
import org.cryptomator.jfuse.api.FuseMount;
4+
import org.cryptomator.jfuse.win.amd64.extr.fuse3_loop_config;
45
import org.cryptomator.jfuse.win.amd64.extr.fuse_h;
56

67
import java.lang.foreign.MemoryAddress;
8+
import java.lang.foreign.MemorySession;
79

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

1012
@Override
1113
public int loop() {
1214
if (fuseArgs.multiThreaded()) {
13-
return fuse_h.fuse3_loop_mt_31(fuse, 0);
15+
try (var scope = MemorySession.openConfined()) {
16+
var loopCfg = fuse3_loop_config.allocate(scope);
17+
fuse3_loop_config.clone_fd$set(loopCfg, 0);
18+
fuse3_loop_config.max_idle_threads$set(loopCfg, 10);
19+
return fuse_h.fuse3_loop_mt(fuse, loopCfg);
20+
}
1421
} else {
1522
return fuse_h.fuse3_loop(fuse);
1623
}

jfuse-win-amd64/src/main/java/org/cryptomator/jfuse/win/amd64/extr/constants$1.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ class constants$1 {
2323
"fuse3_loop",
2424
constants$1.fuse3_loop$FUNC
2525
);
26-
static final FunctionDescriptor fuse3_loop_mt_31$FUNC = FunctionDescriptor.of(Constants$root.C_LONG$LAYOUT,
26+
static final FunctionDescriptor fuse3_loop_mt$FUNC = FunctionDescriptor.of(Constants$root.C_LONG$LAYOUT,
2727
Constants$root.C_POINTER$LAYOUT,
28-
Constants$root.C_LONG$LAYOUT
28+
Constants$root.C_POINTER$LAYOUT
2929
);
30-
static final MethodHandle fuse3_loop_mt_31$MH = RuntimeHelper.downcallHandle(
31-
"fuse3_loop_mt_31",
32-
constants$1.fuse3_loop_mt_31$FUNC
30+
static final MethodHandle fuse3_loop_mt$MH = RuntimeHelper.downcallHandle(
31+
"fuse3_loop_mt",
32+
constants$1.fuse3_loop_mt$FUNC
3333
);
3434
static final FunctionDescriptor fuse3_exit$FUNC = FunctionDescriptor.ofVoid(
3535
Constants$root.C_POINTER$LAYOUT
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Generated by jextract
2+
3+
package org.cryptomator.jfuse.win.amd64.extr;
4+
5+
import java.lang.invoke.MethodHandle;
6+
import java.lang.invoke.VarHandle;
7+
import java.nio.ByteOrder;
8+
import java.lang.foreign.*;
9+
import static java.lang.foreign.ValueLayout.*;
10+
public class fuse3_loop_config {
11+
12+
static final GroupLayout $struct$LAYOUT = MemoryLayout.structLayout(
13+
Constants$root.C_LONG$LAYOUT.withName("clone_fd"),
14+
Constants$root.C_LONG$LAYOUT.withName("max_idle_threads")
15+
).withName("fuse3_loop_config");
16+
public static MemoryLayout $LAYOUT() {
17+
return fuse3_loop_config.$struct$LAYOUT;
18+
}
19+
static final VarHandle clone_fd$VH = $struct$LAYOUT.varHandle(MemoryLayout.PathElement.groupElement("clone_fd"));
20+
public static VarHandle clone_fd$VH() {
21+
return fuse3_loop_config.clone_fd$VH;
22+
}
23+
public static int clone_fd$get(MemorySegment seg) {
24+
return (int)fuse3_loop_config.clone_fd$VH.get(seg);
25+
}
26+
public static void clone_fd$set( MemorySegment seg, int x) {
27+
fuse3_loop_config.clone_fd$VH.set(seg, x);
28+
}
29+
public static int clone_fd$get(MemorySegment seg, long index) {
30+
return (int)fuse3_loop_config.clone_fd$VH.get(seg.asSlice(index*sizeof()));
31+
}
32+
public static void clone_fd$set(MemorySegment seg, long index, int x) {
33+
fuse3_loop_config.clone_fd$VH.set(seg.asSlice(index*sizeof()), x);
34+
}
35+
static final VarHandle max_idle_threads$VH = $struct$LAYOUT.varHandle(MemoryLayout.PathElement.groupElement("max_idle_threads"));
36+
public static VarHandle max_idle_threads$VH() {
37+
return fuse3_loop_config.max_idle_threads$VH;
38+
}
39+
public static int max_idle_threads$get(MemorySegment seg) {
40+
return (int)fuse3_loop_config.max_idle_threads$VH.get(seg);
41+
}
42+
public static void max_idle_threads$set( MemorySegment seg, int x) {
43+
fuse3_loop_config.max_idle_threads$VH.set(seg, x);
44+
}
45+
public static int max_idle_threads$get(MemorySegment seg, long index) {
46+
return (int)fuse3_loop_config.max_idle_threads$VH.get(seg.asSlice(index*sizeof()));
47+
}
48+
public static void max_idle_threads$set(MemorySegment seg, long index, int x) {
49+
fuse3_loop_config.max_idle_threads$VH.set(seg.asSlice(index*sizeof()), x);
50+
}
51+
public static long sizeof() { return $LAYOUT().byteSize(); }
52+
public static MemorySegment allocate(SegmentAllocator allocator) { return allocator.allocate($LAYOUT()); }
53+
public static MemorySegment allocateArray(int len, SegmentAllocator allocator) {
54+
return allocator.allocate(MemoryLayout.sequenceLayout(len, $LAYOUT()));
55+
}
56+
public static MemorySegment ofAddress(MemoryAddress addr, MemorySession session) { return RuntimeHelper.asArray(addr, $LAYOUT(), 1, session); }
57+
}
58+
59+

jfuse-win-amd64/src/main/java/org/cryptomator/jfuse/win/amd64/extr/fuse_h.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ public static int fuse3_loop ( Addressable f) {
8484
throw new AssertionError("should not reach here", ex$);
8585
}
8686
}
87-
public static MethodHandle fuse3_loop_mt_31$MH() {
88-
return RuntimeHelper.requireNonNull(constants$1.fuse3_loop_mt_31$MH,"fuse3_loop_mt_31");
87+
public static MethodHandle fuse3_loop_mt$MH() {
88+
return RuntimeHelper.requireNonNull(constants$1.fuse3_loop_mt$MH,"fuse3_loop_mt");
8989
}
90-
public static int fuse3_loop_mt_31 ( Addressable f, int clone_fd) {
91-
var mh$ = fuse3_loop_mt_31$MH();
90+
public static int fuse3_loop_mt ( Addressable f, Addressable config) {
91+
var mh$ = fuse3_loop_mt$MH();
9292
try {
93-
return (int)mh$.invokeExact(f, clone_fd);
93+
return (int)mh$.invokeExact(f, config);
9494
} catch (Throwable ex$) {
9595
throw new AssertionError("should not reach here", ex$);
9696
}

0 commit comments

Comments
 (0)