From e36edfde17b15aeac86577df4532e1811e54d3f1 Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Fri, 4 Nov 2022 16:30:47 +0100 Subject: [PATCH 1/4] slight api refinement regarding `fuse.close()` --- .../src/main/java/org/cryptomator/jfuse/api/Fuse.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/jfuse-api/src/main/java/org/cryptomator/jfuse/api/Fuse.java b/jfuse-api/src/main/java/org/cryptomator/jfuse/api/Fuse.java index bf21ec4f..b046eeab 100644 --- a/jfuse-api/src/main/java/org/cryptomator/jfuse/api/Fuse.java +++ b/jfuse-api/src/main/java/org/cryptomator/jfuse/api/Fuse.java @@ -165,19 +165,26 @@ private int fuseLoop(FuseMount mount) { /** * Unmounts (if needed) this fuse file system and frees up system resources. *

+ * This method is idempotent and closing multiple times will be no-op. + *

* Important: Before closing, a graceful unmount via system tools (e.g. {@code fusermount -u}) should be attempted. */ @Override @Blocking @MustBeInvokedByOverriders public void close() throws TimeoutException { + if (fuseScope.ownerThread() != Thread.currentThread()) { + throw new WrongThreadException(); + } else if (!fuseScope.isAlive()) { + return; // already closed + } try { var fuseMount = this.mount.getAndSet(UNMOUNTED); fuseMount.unmount(); executor.shutdown(); boolean exited = executor.awaitTermination(10, TimeUnit.SECONDS); if (!exited) { - throw new TimeoutException("fuse main loop continued runn"); + throw new TimeoutException("fuse main loop continued run"); } fuseMount.destroy(); } catch (InterruptedException e) { From 1077f9453ab99bb2163448b9e64fc6ab254273c5 Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Fri, 4 Nov 2022 16:52:13 +0100 Subject: [PATCH 2/4] allow `fuse.close()` from any thread --- jfuse-api/src/main/java/org/cryptomator/jfuse/api/Fuse.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/jfuse-api/src/main/java/org/cryptomator/jfuse/api/Fuse.java b/jfuse-api/src/main/java/org/cryptomator/jfuse/api/Fuse.java index b046eeab..975af65f 100644 --- a/jfuse-api/src/main/java/org/cryptomator/jfuse/api/Fuse.java +++ b/jfuse-api/src/main/java/org/cryptomator/jfuse/api/Fuse.java @@ -172,10 +172,8 @@ private int fuseLoop(FuseMount mount) { @Override @Blocking @MustBeInvokedByOverriders - public void close() throws TimeoutException { - if (fuseScope.ownerThread() != Thread.currentThread()) { - throw new WrongThreadException(); - } else if (!fuseScope.isAlive()) { + public synchronized void close() throws TimeoutException { + if (!fuseScope.isAlive()) { return; // already closed } try { From ca5d311fbf33349f8a0b83a4b5c400a7acb93c81 Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Sat, 5 Nov 2022 08:55:49 +0100 Subject: [PATCH 3/4] reduce API surface --- jfuse-api/src/main/java/module-info.java | 1 + .../main/java/org/cryptomator/jfuse/api/FuseBuilder.java | 3 +++ .../cryptomator/jfuse/api/{ => platforms}/Architecture.java | 2 +- .../jfuse/api/{ => platforms}/OperatingSystem.java | 2 +- .../jfuse/api/{ => platforms}/SupportedPlatform.java | 4 +++- .../jfuse/api/{ => platforms}/SupportedPlatforms.java | 2 +- .../cryptomator/jfuse/linux/aarch64/LinuxFuseBuilder.java | 6 +++--- .../org/cryptomator/jfuse/linux/amd64/LinuxFuseBuilder.java | 6 +++--- .../main/java/org/cryptomator/jfuse/mac/MacFuseBuilder.java | 6 +++--- .../main/java/org/cryptomator/jfuse/win/WinFuseBuilder.java | 6 +++--- 10 files changed, 22 insertions(+), 16 deletions(-) rename jfuse-api/src/main/java/org/cryptomator/jfuse/api/{ => platforms}/Architecture.java (93%) rename jfuse-api/src/main/java/org/cryptomator/jfuse/api/{ => platforms}/OperatingSystem.java (93%) rename jfuse-api/src/main/java/org/cryptomator/jfuse/api/{ => platforms}/SupportedPlatform.java (90%) rename jfuse-api/src/main/java/org/cryptomator/jfuse/api/{ => platforms}/SupportedPlatforms.java (92%) diff --git a/jfuse-api/src/main/java/module-info.java b/jfuse-api/src/main/java/module-info.java index 92a897db..45a46b4f 100644 --- a/jfuse-api/src/main/java/module-info.java +++ b/jfuse-api/src/main/java/module-info.java @@ -9,6 +9,7 @@ requires static org.jetbrains.annotations; exports org.cryptomator.jfuse.api; + exports org.cryptomator.jfuse.api.platforms to org.cryptomator.jfuse.linux.aarch64, org.cryptomator.jfuse.linux.amd64, org.cryptomator.jfuse.mac, org.cryptomator.jfuse.win; uses FuseBuilder; } \ No newline at end of file diff --git a/jfuse-api/src/main/java/org/cryptomator/jfuse/api/FuseBuilder.java b/jfuse-api/src/main/java/org/cryptomator/jfuse/api/FuseBuilder.java index d7bca7c6..1f6bf48e 100644 --- a/jfuse-api/src/main/java/org/cryptomator/jfuse/api/FuseBuilder.java +++ b/jfuse-api/src/main/java/org/cryptomator/jfuse/api/FuseBuilder.java @@ -1,5 +1,8 @@ package org.cryptomator.jfuse.api; +import org.cryptomator.jfuse.api.platforms.Architecture; +import org.cryptomator.jfuse.api.platforms.OperatingSystem; +import org.cryptomator.jfuse.api.platforms.SupportedPlatform; import org.jetbrains.annotations.Nullable; import java.util.Arrays; diff --git a/jfuse-api/src/main/java/org/cryptomator/jfuse/api/Architecture.java b/jfuse-api/src/main/java/org/cryptomator/jfuse/api/platforms/Architecture.java similarity index 93% rename from jfuse-api/src/main/java/org/cryptomator/jfuse/api/Architecture.java rename to jfuse-api/src/main/java/org/cryptomator/jfuse/api/platforms/Architecture.java index 4760ef6f..40fc5770 100644 --- a/jfuse-api/src/main/java/org/cryptomator/jfuse/api/Architecture.java +++ b/jfuse-api/src/main/java/org/cryptomator/jfuse/api/platforms/Architecture.java @@ -1,4 +1,4 @@ -package org.cryptomator.jfuse.api; +package org.cryptomator.jfuse.api.platforms; /** * CPU architecture diff --git a/jfuse-api/src/main/java/org/cryptomator/jfuse/api/OperatingSystem.java b/jfuse-api/src/main/java/org/cryptomator/jfuse/api/platforms/OperatingSystem.java similarity index 93% rename from jfuse-api/src/main/java/org/cryptomator/jfuse/api/OperatingSystem.java rename to jfuse-api/src/main/java/org/cryptomator/jfuse/api/platforms/OperatingSystem.java index c374d90d..78ca8a2d 100644 --- a/jfuse-api/src/main/java/org/cryptomator/jfuse/api/OperatingSystem.java +++ b/jfuse-api/src/main/java/org/cryptomator/jfuse/api/platforms/OperatingSystem.java @@ -1,4 +1,4 @@ -package org.cryptomator.jfuse.api; +package org.cryptomator.jfuse.api.platforms; /** * Operating System diff --git a/jfuse-api/src/main/java/org/cryptomator/jfuse/api/SupportedPlatform.java b/jfuse-api/src/main/java/org/cryptomator/jfuse/api/platforms/SupportedPlatform.java similarity index 90% rename from jfuse-api/src/main/java/org/cryptomator/jfuse/api/SupportedPlatform.java rename to jfuse-api/src/main/java/org/cryptomator/jfuse/api/platforms/SupportedPlatform.java index d5592cb6..ffe6190f 100644 --- a/jfuse-api/src/main/java/org/cryptomator/jfuse/api/SupportedPlatform.java +++ b/jfuse-api/src/main/java/org/cryptomator/jfuse/api/platforms/SupportedPlatform.java @@ -1,4 +1,6 @@ -package org.cryptomator.jfuse.api; +package org.cryptomator.jfuse.api.platforms; + +import org.cryptomator.jfuse.api.FuseBuilder; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/jfuse-api/src/main/java/org/cryptomator/jfuse/api/SupportedPlatforms.java b/jfuse-api/src/main/java/org/cryptomator/jfuse/api/platforms/SupportedPlatforms.java similarity index 92% rename from jfuse-api/src/main/java/org/cryptomator/jfuse/api/SupportedPlatforms.java rename to jfuse-api/src/main/java/org/cryptomator/jfuse/api/platforms/SupportedPlatforms.java index ecb5c62d..e1025d2d 100644 --- a/jfuse-api/src/main/java/org/cryptomator/jfuse/api/SupportedPlatforms.java +++ b/jfuse-api/src/main/java/org/cryptomator/jfuse/api/platforms/SupportedPlatforms.java @@ -1,4 +1,4 @@ -package org.cryptomator.jfuse.api; +package org.cryptomator.jfuse.api.platforms; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/jfuse-linux-aarch64/src/main/java/org/cryptomator/jfuse/linux/aarch64/LinuxFuseBuilder.java b/jfuse-linux-aarch64/src/main/java/org/cryptomator/jfuse/linux/aarch64/LinuxFuseBuilder.java index 67ce2f5f..11842b17 100644 --- a/jfuse-linux-aarch64/src/main/java/org/cryptomator/jfuse/linux/aarch64/LinuxFuseBuilder.java +++ b/jfuse-linux-aarch64/src/main/java/org/cryptomator/jfuse/linux/aarch64/LinuxFuseBuilder.java @@ -1,12 +1,12 @@ package org.cryptomator.jfuse.linux.aarch64; -import org.cryptomator.jfuse.api.Architecture; import org.cryptomator.jfuse.api.Errno; import org.cryptomator.jfuse.api.Fuse; import org.cryptomator.jfuse.api.FuseBuilder; import org.cryptomator.jfuse.api.FuseOperations; -import org.cryptomator.jfuse.api.OperatingSystem; -import org.cryptomator.jfuse.api.SupportedPlatform; +import org.cryptomator.jfuse.api.platforms.Architecture; +import org.cryptomator.jfuse.api.platforms.OperatingSystem; +import org.cryptomator.jfuse.api.platforms.SupportedPlatform; /** * Builds FUSE file system instances on Linux (aarch64). diff --git a/jfuse-linux-amd64/src/main/java/org/cryptomator/jfuse/linux/amd64/LinuxFuseBuilder.java b/jfuse-linux-amd64/src/main/java/org/cryptomator/jfuse/linux/amd64/LinuxFuseBuilder.java index e122f14c..24ef1284 100644 --- a/jfuse-linux-amd64/src/main/java/org/cryptomator/jfuse/linux/amd64/LinuxFuseBuilder.java +++ b/jfuse-linux-amd64/src/main/java/org/cryptomator/jfuse/linux/amd64/LinuxFuseBuilder.java @@ -1,12 +1,12 @@ package org.cryptomator.jfuse.linux.amd64; -import org.cryptomator.jfuse.api.Architecture; import org.cryptomator.jfuse.api.Errno; import org.cryptomator.jfuse.api.Fuse; import org.cryptomator.jfuse.api.FuseBuilder; import org.cryptomator.jfuse.api.FuseOperations; -import org.cryptomator.jfuse.api.OperatingSystem; -import org.cryptomator.jfuse.api.SupportedPlatform; +import org.cryptomator.jfuse.api.platforms.Architecture; +import org.cryptomator.jfuse.api.platforms.OperatingSystem; +import org.cryptomator.jfuse.api.platforms.SupportedPlatform; /** * Builds FUSE file system instances on Linux (x86_64). diff --git a/jfuse-mac/src/main/java/org/cryptomator/jfuse/mac/MacFuseBuilder.java b/jfuse-mac/src/main/java/org/cryptomator/jfuse/mac/MacFuseBuilder.java index 933c8695..e78c04cb 100644 --- a/jfuse-mac/src/main/java/org/cryptomator/jfuse/mac/MacFuseBuilder.java +++ b/jfuse-mac/src/main/java/org/cryptomator/jfuse/mac/MacFuseBuilder.java @@ -1,12 +1,12 @@ package org.cryptomator.jfuse.mac; -import org.cryptomator.jfuse.api.Architecture; import org.cryptomator.jfuse.api.Errno; import org.cryptomator.jfuse.api.Fuse; import org.cryptomator.jfuse.api.FuseBuilder; import org.cryptomator.jfuse.api.FuseOperations; -import org.cryptomator.jfuse.api.OperatingSystem; -import org.cryptomator.jfuse.api.SupportedPlatform; +import org.cryptomator.jfuse.api.platforms.Architecture; +import org.cryptomator.jfuse.api.platforms.OperatingSystem; +import org.cryptomator.jfuse.api.platforms.SupportedPlatform; import java.nio.file.Files; import java.nio.file.Path; diff --git a/jfuse-win/src/main/java/org/cryptomator/jfuse/win/WinFuseBuilder.java b/jfuse-win/src/main/java/org/cryptomator/jfuse/win/WinFuseBuilder.java index 99c3a3aa..64f0b94b 100644 --- a/jfuse-win/src/main/java/org/cryptomator/jfuse/win/WinFuseBuilder.java +++ b/jfuse-win/src/main/java/org/cryptomator/jfuse/win/WinFuseBuilder.java @@ -1,12 +1,12 @@ package org.cryptomator.jfuse.win; -import org.cryptomator.jfuse.api.Architecture; import org.cryptomator.jfuse.api.Errno; import org.cryptomator.jfuse.api.Fuse; import org.cryptomator.jfuse.api.FuseBuilder; import org.cryptomator.jfuse.api.FuseOperations; -import org.cryptomator.jfuse.api.OperatingSystem; -import org.cryptomator.jfuse.api.SupportedPlatform; +import org.cryptomator.jfuse.api.platforms.Architecture; +import org.cryptomator.jfuse.api.platforms.OperatingSystem; +import org.cryptomator.jfuse.api.platforms.SupportedPlatform; /** * Builds FUSE file system instances on Windows. From bd9e361ea7bc0e42340c45e7dd5995bd7ab26633 Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Sat, 5 Nov 2022 08:57:09 +0100 Subject: [PATCH 4/4] prepare 0.3.3 --- jfuse-api/pom.xml | 2 +- jfuse-examples/pom.xml | 2 +- jfuse-linux-aarch64/pom.xml | 2 +- jfuse-linux-amd64/pom.xml | 2 +- jfuse-mac/pom.xml | 2 +- jfuse-tests/pom.xml | 2 +- jfuse-win/pom.xml | 2 +- jfuse/pom.xml | 2 +- pom.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/jfuse-api/pom.xml b/jfuse-api/pom.xml index 1260c0c9..a123e300 100644 --- a/jfuse-api/pom.xml +++ b/jfuse-api/pom.xml @@ -5,7 +5,7 @@ org.cryptomator jfuse-parent - 0.4.0-SNAPSHOT + 0.3.3 4.0.0 jfuse-api diff --git a/jfuse-examples/pom.xml b/jfuse-examples/pom.xml index e67a726a..f107c22f 100644 --- a/jfuse-examples/pom.xml +++ b/jfuse-examples/pom.xml @@ -5,7 +5,7 @@ org.cryptomator jfuse-parent - 0.4.0-SNAPSHOT + 0.3.3 4.0.0 jfuse-examples diff --git a/jfuse-linux-aarch64/pom.xml b/jfuse-linux-aarch64/pom.xml index 6bdddda8..acf929c1 100644 --- a/jfuse-linux-aarch64/pom.xml +++ b/jfuse-linux-aarch64/pom.xml @@ -5,7 +5,7 @@ jfuse-parent org.cryptomator - 0.4.0-SNAPSHOT + 0.3.3 4.0.0 jfuse-linux-aarch64 diff --git a/jfuse-linux-amd64/pom.xml b/jfuse-linux-amd64/pom.xml index 78cc67b0..456ff258 100644 --- a/jfuse-linux-amd64/pom.xml +++ b/jfuse-linux-amd64/pom.xml @@ -5,7 +5,7 @@ org.cryptomator jfuse-parent - 0.4.0-SNAPSHOT + 0.3.3 4.0.0 jfuse-linux-amd64 diff --git a/jfuse-mac/pom.xml b/jfuse-mac/pom.xml index dd6a68d4..c9671817 100644 --- a/jfuse-mac/pom.xml +++ b/jfuse-mac/pom.xml @@ -5,7 +5,7 @@ org.cryptomator jfuse-parent - 0.4.0-SNAPSHOT + 0.3.3 4.0.0 jfuse-mac diff --git a/jfuse-tests/pom.xml b/jfuse-tests/pom.xml index 63eac0e9..f09be207 100644 --- a/jfuse-tests/pom.xml +++ b/jfuse-tests/pom.xml @@ -5,7 +5,7 @@ org.cryptomator jfuse-parent - 0.4.0-SNAPSHOT + 0.3.3 4.0.0 jfuse-tests diff --git a/jfuse-win/pom.xml b/jfuse-win/pom.xml index 8e9e3e04..f475c73d 100644 --- a/jfuse-win/pom.xml +++ b/jfuse-win/pom.xml @@ -5,7 +5,7 @@ org.cryptomator jfuse-parent - 0.4.0-SNAPSHOT + 0.3.3 4.0.0 jfuse-win diff --git a/jfuse/pom.xml b/jfuse/pom.xml index f43be855..20dfa0d7 100644 --- a/jfuse/pom.xml +++ b/jfuse/pom.xml @@ -5,7 +5,7 @@ org.cryptomator jfuse-parent - 0.4.0-SNAPSHOT + 0.3.3 4.0.0 jfuse diff --git a/pom.xml b/pom.xml index 52c95717..2608adca 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.cryptomator jfuse-parent pom - 0.4.0-SNAPSHOT + 0.3.3 jFUSE Java bindings for FUSE using foreign functions & memory API https://github.com/cryptomator/jfuse