Skip to content

Commit

Permalink
1.0.2
Browse files Browse the repository at this point in the history
- Push to maven Central
- Add Javadoc
  • Loading branch information
edaniel committed Nov 6, 2024
1 parent 998af0c commit 841f277
Show file tree
Hide file tree
Showing 57 changed files with 1,832 additions and 284 deletions.
50 changes: 48 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build project
name: Build and Release

on:
push:
Expand Down Expand Up @@ -76,4 +76,50 @@ jobs:
uses: ncipollo/release-action@v1
with:
artifacts: ./artifacts/jars.zip,./artifacts/examples/*,./artifacts/JARs/*
body: "Release for tag ${{ github.ref_name }}"
body: "Release for tag ${{ github.ref_name }}"

deploy-to-maven-central:
runs-on: ubuntu-latest
needs: build-native
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout code
uses: actions/checkout@v4

- uses: graalvm/setup-graalvm@v1
with:
java-version: '21'
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}

- name: Set up Maven settings
uses: whelk-io/maven-settings-xml-action@v22
with:
servers: >
[
{
"id": "central",
"username": "${{ secrets.OSSRH_USERNAME }}",
"password": "${{ secrets.OSSRH_PASSWORD }}"
}
]
profiles: >
[
{
"id": "ossrh",
"properties": {
"gpg.passphrase": "${{ secrets.GPG_PASSPHRASE }}"
}
}
]
- name: Deploy to Sonatype OSSRH
run: |
mvn clean deploy -P release,ossrh -DskipTests=true
121 changes: 120 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,37 @@

<groupId>com.k3rnl.fuse</groupId>
<artifactId>fuse-native</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
<packaging>jar</packaging>

<!-- Project Metadata -->
<name>Fuse Native</name>
<description>A Java library for FUSE filesystem operations in GraalVM Native Image</description>
<url>https://github.com/k3rnL/java-fuse-native</url>

<!-- Licensing -->
<licenses>
<license>
<name>The Apache License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>

<developers>
<developer>
<id>k3rnL</id>
<name>Erwan Daniel</name>
<email>[email protected]</email>
</developer>
</developers>

<!-- Source Control Management -->
<scm>
<connection>scm:git:https://github.com/k3rnL/java-fuse-native.git</connection>
<developerConnection>scm:git:ssh://[email protected]/k3rnL/java-fuse-native.git</developerConnection>
<url>https://github.com/yourusername/fuse-native</url>
</scm>

<properties>
<maven.compiler.source>21</maven.compiler.source>
Expand All @@ -25,6 +55,32 @@

<build>
<plugins>
<!-- Maven Compiler Plugin -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>

<!-- Maven Source Plugin -->
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>verify</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- GraalVM Native Maven Plugin -->
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
Expand All @@ -34,6 +90,69 @@
</build>

<profiles>
<!-- Release Profile -->
<profile>
<id>release</id>
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<!-- Maven Release Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>3.0.1</version>
</plugin>
<!-- Maven GPG Plugin for signing artifacts -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
<configuration>
<keyname>180911A4092A2DB4</keyname>
<passphrase>${gpg.passphrase}</passphrase>
</configuration>
</plugin>
<!-- Sonatype publishing plugin -->
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.6.0</version>
<extensions>true</extensions>
<configuration>
<publishingServerId>central</publishingServerId>
<autoPublish>true</autoPublish>
</configuration>
</plugin>
<!-- Maven Javadoc Plugin to generate Javadoc JAR -->
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.4.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>build-examples</id>
<build>
Expand Down
46 changes: 38 additions & 8 deletions src/main/java/com/k3rnl/fuse/AgentIsolate.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,32 @@
import org.graalvm.word.WordFactory;

/**
* A utility class for managing isolate.
* The {@code AgentIsolate} class provides utility methods for managing isolates
* in a FUSE-based application. It contains a prologue to enter an isolate
* context and an epilogue to detach the current thread from the isolate.
*
* <p>This class is essential for handling isolated contexts within native FUSE operations,
* especially when working with GraalVM native images and FUSE.</p>
*/
@CContext(LibC.Directives.class)
public final class AgentIsolate {

// public static Isolate isolate;

/**
* The {@code FuseContextPrologue} is a prologue used to enter the isolate
* associated with the current FUSE context before executing a native function.
*
* <p>This prologue retrieves the {@link Isolate} from the {@link PrivateData} of
* the {@link FuseContext}, then attaches the current thread to this isolate.</p>
*/
public static final class FuseContextPrologue implements CEntryPointOptions.Prologue {
// private static final CGlobalData<CCharPointer> errorMessage = CGlobalDataFactory.createCString(
// "Failed to enter (or attach to) the global isolate in the current thread.");

/**
* Enters the isolate context from the FUSE context private data.
* <p>This method is uninterruptible to prevent interference with isolate entry.</p>
*
* <p>If an error occurs while entering the isolate, it fails fatally with an
* appropriate error code.</p>
*/
@Uninterruptible(reason = "prologue")
static void enter() {
FuseContext ctx = FuseLibrary.fuse_get_context();
Expand All @@ -33,19 +48,34 @@ static void enter() {
Isolate isolate = privateData.isolate();
int code = CEntryPointActions.enterAttachThread(isolate, false, true);
if (code != CEntryPointErrors.NO_ERROR) {
// errorMessage.get() doesn't work, compilation fails with violation of @Uninterruptible usage, throwNoClassDefFoundError(String)
// CEntryPointActions.failFatally(code, errorMessage.get());
// Uncomment and customize error handling as needed
// CEntryPointActions.failFatally(code, errorMessage.get());
}
}
}

/**
* The {@code DetachEpilogue} is an epilogue used to detach the current thread
* from the isolate after executing a native function.
*
* <p>This ensures that the thread is properly released from the isolate context
* once the function execution completes.</p>
*/
public static final class DetachEpilogue implements CEntryPointOptions.Epilogue {

/**
* Detaches the current thread from the isolate context.
* <p>This method is uninterruptible to prevent interference with isolate detachment.</p>
*/
@Uninterruptible(reason = "epilogue")
static void leave() {
CEntryPointActions.leaveDetachThread();
}
}

/**
* Private constructor to prevent instantiation of this utility class.
*/
private AgentIsolate() {
}
}
}
7 changes: 7 additions & 0 deletions src/main/java/com/k3rnl/fuse/NotImplemented.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
* The {@code NotImplemented} annotation is used to mark methods or classes that
* are currently not implemented. It serves as a placeholder and can help developers
* identify areas of the codebase that require further work.
*
* <p>This annotation is retained at runtime, making it accessible via reflection.</p>
*/
@Retention(RetentionPolicy.RUNTIME)
public @interface NotImplemented {
}
18 changes: 17 additions & 1 deletion src/main/java/com/k3rnl/fuse/api/FillDir.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,25 @@
import com.k3rnl.fuse.libc.FileStat;
import org.graalvm.nativeimage.c.type.VoidPointer;

/**
* The {@code FillDir} functional interface represents a callback used by the FUSE
* {@code readdir} operation to fill directory entries in the directory listing buffer.
*
* <p>This interface is marked as a functional interface, allowing it to be used as the
* assignment target for a lambda expression or method reference.</p>
*/
@FunctionalInterface
public interface FillDir {

/**
* Adds a directory entry to the buffer.
*
* @param buf the buffer where directory entries are stored.
* @param name the name of the directory entry.
* @param stat the {@link FileStat} structure containing file attributes for the entry.
* @param offset the offset for the next directory entry.
* @param flags additional flags affecting the behavior of the directory filling, represented by {@link FuseFillDirFlags}.
* @return an integer status code (0 for success, non-zero for failure).
*/
int apply(VoidPointer buf, String name, FileStat stat, long offset, FuseFillDirFlags flags);

}
2 changes: 1 addition & 1 deletion src/main/java/com/k3rnl/fuse/api/JavaFuseOperations.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public int truncate(String path, long size, FuseFileInfo fi) {
* <p>
* There are also some flags (direct_io, keep_cache) which the
* filesystem may set in fi, to change the way the file is opened.
* See fuse_file_info structure in <fuse_common.h> for more details.
* See fuse_file_info structure in fuse_common.h for more details.
* <p>
* If this request is answered with an error code of ENOSYS
* and FUSE_CAP_NO_OPEN_SUPPORT is set in
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/k3rnl/fuse/callbacks/AccessFunction.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer;
import org.graalvm.nativeimage.c.type.CCharPointer;

/**
* Callback for access
*/
public interface AccessFunction extends CFunctionPointer {
@InvokeCFunctionPointer
int invoke(CCharPointer path, int mask);
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/k3rnl/fuse/callbacks/BmapFunction.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import org.graalvm.nativeimage.c.type.CCharPointer;
import org.graalvm.nativeimage.c.type.VoidPointer;

/**
* Callback for bmap
*/
public interface BmapFunction extends CFunctionPointer {
@InvokeCFunctionPointer
int invoke(CCharPointer path, long blockSize, VoidPointer idx);
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/k3rnl/fuse/callbacks/ChmodFunction.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer;
import org.graalvm.nativeimage.c.type.CCharPointer;

/**
* Callback for chmod
*/
public interface ChmodFunction extends CFunctionPointer {
@InvokeCFunctionPointer
int invoke(CCharPointer path, long mode, FuseFileInfo fi);
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/k3rnl/fuse/callbacks/ChownFunction.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer;
import org.graalvm.nativeimage.c.type.CCharPointer;

/**
* Callback for chown
*/
public interface ChownFunction extends CFunctionPointer {
@InvokeCFunctionPointer
int invoke(CCharPointer path, int uid, int gid, FuseFileInfo fi);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer;
import org.graalvm.nativeimage.c.type.CCharPointer;

/**
* Callback for copy_file_range
*/
public interface CopyFileRangeFunction extends CFunctionPointer {
@InvokeCFunctionPointer
long invoke(CCharPointer pathIn, FuseFileInfo fiIn, long offIn,
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/k3rnl/fuse/callbacks/CreateFunction.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer;
import org.graalvm.nativeimage.c.type.CCharPointer;

/**
* Callback for create
*/
public interface CreateFunction extends CFunctionPointer {
@InvokeCFunctionPointer
int invoke(CCharPointer path, int mode, FuseFileInfo fi);
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/k3rnl/fuse/callbacks/DestroyFunction.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer;
import org.graalvm.nativeimage.c.type.VoidPointer;

/**
* Callback for destroy
*/
public interface DestroyFunction extends CFunctionPointer {
@InvokeCFunctionPointer
int invoke(VoidPointer privateData);
Expand Down
Loading

0 comments on commit 841f277

Please sign in to comment.