diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c73f431..8dde1ac 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build project +name: Build and Release on: push: @@ -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 }}" \ No newline at end of file + 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 + diff --git a/pom.xml b/pom.xml index 671b092..6e64f44 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,37 @@ com.k3rnl.fuse fuse-native - 1.0.1 + 1.0.2 + jar + + + Fuse Native + A Java library for FUSE filesystem operations in GraalVM Native Image + https://github.com/k3rnL/java-fuse-native + + + + + The Apache License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + + k3rnL + Erwan Daniel + contact@erwandaniel.fr + + + + + + scm:git:https://github.com/k3rnL/java-fuse-native.git + scm:git:ssh://git@github.com/k3rnL/java-fuse-native.git + https://github.com/yourusername/fuse-native + 21 @@ -25,6 +55,32 @@ + + + maven-compiler-plugin + 3.11.0 + + ${maven.compiler.source} + ${maven.compiler.target} + + + + + + maven-source-plugin + 3.2.1 + + + attach-sources + verify + + jar-no-fork + + + + + + org.graalvm.buildtools native-maven-plugin @@ -34,6 +90,69 @@ + + + release + + + performRelease + true + + + + + + + org.apache.maven.plugins + maven-release-plugin + 3.0.1 + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.1.0 + + + sign-artifacts + verify + + sign + + + + + 180911A4092A2DB4 + ${gpg.passphrase} + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.6.0 + true + + central + true + + + + + maven-javadoc-plugin + 3.4.0 + + + attach-javadocs + + jar + + + + + + + build-examples diff --git a/src/main/java/com/k3rnl/fuse/AgentIsolate.java b/src/main/java/com/k3rnl/fuse/AgentIsolate.java index ed45f7f..a578445 100644 --- a/src/main/java/com/k3rnl/fuse/AgentIsolate.java +++ b/src/main/java/com/k3rnl/fuse/AgentIsolate.java @@ -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. + * + *

This class is essential for handling isolated contexts within native FUSE operations, + * especially when working with GraalVM native images and FUSE.

*/ @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. + * + *

This prologue retrieves the {@link Isolate} from the {@link PrivateData} of + * the {@link FuseContext}, then attaches the current thread to this isolate.

+ */ public static final class FuseContextPrologue implements CEntryPointOptions.Prologue { -// private static final CGlobalData 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. + *

This method is uninterruptible to prevent interference with isolate entry.

+ * + *

If an error occurs while entering the isolate, it fails fatally with an + * appropriate error code.

+ */ @Uninterruptible(reason = "prologue") static void enter() { FuseContext ctx = FuseLibrary.fuse_get_context(); @@ -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. + * + *

This ensures that the thread is properly released from the isolate context + * once the function execution completes.

+ */ public static final class DetachEpilogue implements CEntryPointOptions.Epilogue { + + /** + * Detaches the current thread from the isolate context. + *

This method is uninterruptible to prevent interference with isolate detachment.

+ */ @Uninterruptible(reason = "epilogue") static void leave() { CEntryPointActions.leaveDetachThread(); } } + /** + * Private constructor to prevent instantiation of this utility class. + */ private AgentIsolate() { } -} \ No newline at end of file +} diff --git a/src/main/java/com/k3rnl/fuse/NotImplemented.java b/src/main/java/com/k3rnl/fuse/NotImplemented.java index 63ea265..f6d30af 100644 --- a/src/main/java/com/k3rnl/fuse/NotImplemented.java +++ b/src/main/java/com/k3rnl/fuse/NotImplemented.java @@ -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. + * + *

This annotation is retained at runtime, making it accessible via reflection.

+ */ @Retention(RetentionPolicy.RUNTIME) public @interface NotImplemented { } diff --git a/src/main/java/com/k3rnl/fuse/api/FillDir.java b/src/main/java/com/k3rnl/fuse/api/FillDir.java index 8e386c4..476ca3c 100644 --- a/src/main/java/com/k3rnl/fuse/api/FillDir.java +++ b/src/main/java/com/k3rnl/fuse/api/FillDir.java @@ -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. + * + *

This interface is marked as a functional interface, allowing it to be used as the + * assignment target for a lambda expression or method reference.

+ */ @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); - } diff --git a/src/main/java/com/k3rnl/fuse/api/JavaFuseOperations.java b/src/main/java/com/k3rnl/fuse/api/JavaFuseOperations.java index 843bb93..df5a52a 100644 --- a/src/main/java/com/k3rnl/fuse/api/JavaFuseOperations.java +++ b/src/main/java/com/k3rnl/fuse/api/JavaFuseOperations.java @@ -216,7 +216,7 @@ public int truncate(String path, long size, FuseFileInfo fi) { *

* 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 for more details. + * See fuse_file_info structure in fuse_common.h for more details. *

* If this request is answered with an error code of ENOSYS * and FUSE_CAP_NO_OPEN_SUPPORT is set in diff --git a/src/main/java/com/k3rnl/fuse/callbacks/AccessFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/AccessFunction.java index 8349f28..e94a89b 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/AccessFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/AccessFunction.java @@ -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); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/BmapFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/BmapFunction.java index 1eadc28..277969a 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/BmapFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/BmapFunction.java @@ -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); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/ChmodFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/ChmodFunction.java index 1951504..17bb8b3 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/ChmodFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/ChmodFunction.java @@ -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); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/ChownFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/ChownFunction.java index 4827f6c..96f1e06 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/ChownFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/ChownFunction.java @@ -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); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/CopyFileRangeFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/CopyFileRangeFunction.java index 0542227..9497cf7 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/CopyFileRangeFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/CopyFileRangeFunction.java @@ -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, diff --git a/src/main/java/com/k3rnl/fuse/callbacks/CreateFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/CreateFunction.java index c70f868..69ee7ea 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/CreateFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/CreateFunction.java @@ -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); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/DestroyFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/DestroyFunction.java index a77eb99..e8b79cb 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/DestroyFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/DestroyFunction.java @@ -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); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/FallocateFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/FallocateFunction.java index 1477e81..15021f2 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/FallocateFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/FallocateFunction.java @@ -5,6 +5,9 @@ import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; import org.graalvm.nativeimage.c.type.CCharPointer; +/** + * Callback for fallocate + */ public interface FallocateFunction extends CFunctionPointer { @InvokeCFunctionPointer int invoke(CCharPointer path, int mode, long offset, long length, FuseFileInfo fi); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/FillDirFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/FillDirFunction.java index 28f3220..cc31996 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/FillDirFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/FillDirFunction.java @@ -7,6 +7,9 @@ import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.VoidPointer; +/** + * Callback for fillDir + */ public interface FillDirFunction extends CFunctionPointer { @InvokeCFunctionPointer int invoke(VoidPointer buf, CCharPointer name, FileStat stat, long off, int fillDirPlus); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/FlockFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/FlockFunction.java index fbac4d1..8b5bb17 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/FlockFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/FlockFunction.java @@ -5,6 +5,9 @@ import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; import org.graalvm.nativeimage.c.type.CCharPointer; +/** + * Callback for flock + */ public interface FlockFunction extends CFunctionPointer { @InvokeCFunctionPointer int invoke(CCharPointer path, FuseFileInfo fi, int op); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/FlushFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/FlushFunction.java index 3619494..71ef665 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/FlushFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/FlushFunction.java @@ -5,6 +5,9 @@ import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; import org.graalvm.nativeimage.c.type.CCharPointer; +/** + * Callback for flush + */ public interface FlushFunction extends CFunctionPointer { @InvokeCFunctionPointer int invoke(CCharPointer path, FuseFileInfo fi); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/GetAttrFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/GetAttrFunction.java index 3973d13..e2bbcd9 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/GetAttrFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/GetAttrFunction.java @@ -5,6 +5,9 @@ import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; import org.graalvm.nativeimage.c.type.CCharPointer; +/** + * Callback for getAttr + */ public interface GetAttrFunction extends CFunctionPointer { @InvokeCFunctionPointer int invoke(CCharPointer path, FileStat stat); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/InitFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/InitFunction.java index e13f175..ad5ffa3 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/InitFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/InitFunction.java @@ -5,6 +5,9 @@ import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; import org.graalvm.nativeimage.c.type.VoidPointer; +/** + * Callback for init + */ public interface InitFunction extends CFunctionPointer { @InvokeCFunctionPointer VoidPointer invoke(VoidPointer conn, FuseConfig config); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/IoctlFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/IoctlFunction.java index 4c67e8e..1bd25b5 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/IoctlFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/IoctlFunction.java @@ -7,6 +7,9 @@ import org.graalvm.nativeimage.c.type.VoidPointer; import org.graalvm.word.UnsignedWord; +/** + * Callback for ioctl + */ public interface IoctlFunction extends CFunctionPointer { @InvokeCFunctionPointer int invoke(CCharPointer path, int cmd, VoidPointer arg, FuseFileInfo fi, int flags, VoidPointer data); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/LinkFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/LinkFunction.java index 3846e74..392421e 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/LinkFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/LinkFunction.java @@ -4,6 +4,9 @@ import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; import org.graalvm.nativeimage.c.type.CCharPointer; +/** + * Callback for link + */ public interface LinkFunction extends CFunctionPointer { @InvokeCFunctionPointer int invoke(CCharPointer path, CCharPointer dest); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/LockFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/LockFunction.java index 2df7490..7599ab8 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/LockFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/LockFunction.java @@ -6,6 +6,9 @@ import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; import org.graalvm.nativeimage.c.type.CCharPointer; +/** + * Callback for lock + */ public interface LockFunction extends CFunctionPointer { @InvokeCFunctionPointer int invoke(CCharPointer path, FuseFileInfo fi, int cmd, Flock flock); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/LseekFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/LseekFunction.java index 5d70383..ee77bc1 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/LseekFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/LseekFunction.java @@ -5,6 +5,9 @@ import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; import org.graalvm.nativeimage.c.type.CCharPointer; +/** + * Callback for lseek + */ public interface LseekFunction extends CFunctionPointer { @InvokeCFunctionPointer long invoke(CCharPointer path, long offset, int whence, FuseFileInfo fi); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/MkDirFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/MkDirFunction.java index 2ea6531..ceeee7b 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/MkDirFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/MkDirFunction.java @@ -4,6 +4,9 @@ import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; import org.graalvm.nativeimage.c.type.CCharPointer; +/** + * Callback for mkdir + */ public interface MkDirFunction extends CFunctionPointer { @InvokeCFunctionPointer int invoke(CCharPointer path, int mode); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/MkNodFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/MkNodFunction.java index 0548781..53cebb8 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/MkNodFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/MkNodFunction.java @@ -4,6 +4,9 @@ import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; import org.graalvm.nativeimage.c.type.CCharPointer; +/** + * Callback for mkNod + */ public interface MkNodFunction extends CFunctionPointer { @InvokeCFunctionPointer int invoke(CCharPointer path, int mode, int flags); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/OpenDirFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/OpenDirFunction.java index 1c5cd2c..3a79a78 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/OpenDirFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/OpenDirFunction.java @@ -5,6 +5,9 @@ import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; import org.graalvm.nativeimage.c.type.CCharPointer; +/** + * Callback for opendir + */ public interface OpenDirFunction extends CFunctionPointer { @InvokeCFunctionPointer int invoke(CCharPointer path, FuseFileInfo fi); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/OpenFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/OpenFunction.java index 30355d7..d544dd1 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/OpenFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/OpenFunction.java @@ -5,6 +5,9 @@ import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; import org.graalvm.nativeimage.c.type.CCharPointer; +/** + * + */ public interface OpenFunction extends CFunctionPointer { @InvokeCFunctionPointer int invoke(CCharPointer path, FuseFileInfo fi); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/PollFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/PollFunction.java index 5bd25b5..2af3106 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/PollFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/PollFunction.java @@ -6,6 +6,9 @@ import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.VoidPointer; +/** + * Callback for poll + */ public interface PollFunction extends CFunctionPointer { @InvokeCFunctionPointer int invoke(CCharPointer path, FuseFileInfo fi, VoidPointer ph, VoidPointer reventsp); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/ReadBufFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/ReadBufFunction.java index 1bf50bf..581878b 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/ReadBufFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/ReadBufFunction.java @@ -6,6 +6,9 @@ import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; import org.graalvm.nativeimage.c.type.CCharPointer; +/** + * Callback for read_buf + */ public interface ReadBufFunction extends CFunctionPointer { @InvokeCFunctionPointer int invoke(CCharPointer path, FuseBufVec.FuseBufVecPointer buf, long size, long offset, FuseFileInfo fi); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/ReadDirFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/ReadDirFunction.java index fc7e129..4c2e381 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/ReadDirFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/ReadDirFunction.java @@ -6,6 +6,9 @@ import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.VoidPointer; +/** + * Callback for readdir + */ public interface ReadDirFunction extends CFunctionPointer { @InvokeCFunctionPointer int invoke(CCharPointer path, VoidPointer buf, FillDirFunction filler, long offset, FuseFileInfo fi); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/ReadFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/ReadFunction.java index a17e05c..d248306 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/ReadFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/ReadFunction.java @@ -5,6 +5,9 @@ import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; import org.graalvm.nativeimage.c.type.CCharPointer; +/** + * Callback for read + */ public interface ReadFunction extends CFunctionPointer { @InvokeCFunctionPointer int invoke(CCharPointer path, CCharPointer buf, long size, long offset, FuseFileInfo fi); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/ReadLinkFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/ReadLinkFunction.java index b9b7ee9..c14e5cc 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/ReadLinkFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/ReadLinkFunction.java @@ -4,6 +4,9 @@ import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; import org.graalvm.nativeimage.c.type.CCharPointer; +/** + * Callback for readlink + */ public interface ReadLinkFunction extends CFunctionPointer { @InvokeCFunctionPointer int invoke(CCharPointer path, CCharPointer buf, long size); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/ReleaseDirFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/ReleaseDirFunction.java index 3876f24..801cd8b 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/ReleaseDirFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/ReleaseDirFunction.java @@ -5,6 +5,9 @@ import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; import org.graalvm.nativeimage.c.type.CCharPointer; +/** + * Callback for releasedir + */ public interface ReleaseDirFunction extends CFunctionPointer { @InvokeCFunctionPointer int invoke(CCharPointer path, FuseFileInfo fi); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/ReleaseFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/ReleaseFunction.java index 43dedd5..ba9f8b5 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/ReleaseFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/ReleaseFunction.java @@ -5,6 +5,9 @@ import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; import org.graalvm.nativeimage.c.type.CCharPointer; +/** + * Callback for release + */ public interface ReleaseFunction extends CFunctionPointer { @InvokeCFunctionPointer int invoke(CCharPointer path, FuseFileInfo fi); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/RenameFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/RenameFunction.java index 7c005ab..f7cb898 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/RenameFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/RenameFunction.java @@ -4,6 +4,9 @@ import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; import org.graalvm.nativeimage.c.type.CCharPointer; +/** + * Callback for rename + */ public interface RenameFunction extends CFunctionPointer { @InvokeCFunctionPointer int invoke(CCharPointer path, CCharPointer newPath, int flags); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/RmdirFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/RmdirFunction.java index ba5c06e..5a165b3 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/RmdirFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/RmdirFunction.java @@ -4,6 +4,9 @@ import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; import org.graalvm.nativeimage.c.type.CCharPointer; +/** + * Callback for rmdir + */ public interface RmdirFunction extends CFunctionPointer { @InvokeCFunctionPointer int invoke(CCharPointer path); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/StatVfsFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/StatVfsFunction.java index 669073f..f878aba 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/StatVfsFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/StatVfsFunction.java @@ -5,6 +5,9 @@ import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; import org.graalvm.nativeimage.c.type.CCharPointer; +/** + * Callback for statvfs + */ public interface StatVfsFunction extends CFunctionPointer { @InvokeCFunctionPointer int invoke(CCharPointer path, StatVFS statVFS); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/SymlinkFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/SymlinkFunction.java index 61d4363..a1627da 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/SymlinkFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/SymlinkFunction.java @@ -4,6 +4,9 @@ import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; import org.graalvm.nativeimage.c.type.CCharPointer; +/** + * Callback for symlink + */ public interface SymlinkFunction extends CFunctionPointer { @InvokeCFunctionPointer int invoke(CCharPointer path, CCharPointer dest); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/TruncateFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/TruncateFunction.java index 96bc258..381bb14 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/TruncateFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/TruncateFunction.java @@ -5,6 +5,9 @@ import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; import org.graalvm.nativeimage.c.type.CCharPointer; +/** + * Callback for truncate + */ public interface TruncateFunction extends CFunctionPointer { @InvokeCFunctionPointer int invoke(CCharPointer path, long offset, FuseFileInfo fi); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/UnlinkFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/UnlinkFunction.java index eaa7c36..6ccc681 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/UnlinkFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/UnlinkFunction.java @@ -4,6 +4,9 @@ import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; import org.graalvm.nativeimage.c.type.CCharPointer; +/** + * Callback for unlink + */ public interface UnlinkFunction extends CFunctionPointer { @InvokeCFunctionPointer int invoke(CCharPointer path); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/UtimensFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/UtimensFunction.java index bc882ab..0c3f287 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/UtimensFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/UtimensFunction.java @@ -6,6 +6,9 @@ import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; import org.graalvm.nativeimage.c.type.CCharPointer; +/** + * Callback for utimens + */ public interface UtimensFunction extends CFunctionPointer { @InvokeCFunctionPointer int invoke(CCharPointer path, TimeSpec[] timespec, FuseFileInfo fi); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/WriteBufFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/WriteBufFunction.java index f44b9e1..1d585ea 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/WriteBufFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/WriteBufFunction.java @@ -6,6 +6,9 @@ import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; import org.graalvm.nativeimage.c.type.CCharPointer; +/** + * Callback for write_buf + */ public interface WriteBufFunction extends CFunctionPointer { @InvokeCFunctionPointer int invoke(CCharPointer path, FuseBufVec buf, long offset, FuseFileInfo fi); diff --git a/src/main/java/com/k3rnl/fuse/callbacks/WriteFunction.java b/src/main/java/com/k3rnl/fuse/callbacks/WriteFunction.java index 4ee78d2..9131e1d 100644 --- a/src/main/java/com/k3rnl/fuse/callbacks/WriteFunction.java +++ b/src/main/java/com/k3rnl/fuse/callbacks/WriteFunction.java @@ -5,6 +5,9 @@ import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; import org.graalvm.nativeimage.c.type.CCharPointer; +/** + * Callback for write + */ public interface WriteFunction extends CFunctionPointer { @InvokeCFunctionPointer int invoke(CCharPointer path, CCharPointer buf, long size, long offset, FuseFileInfo fi); diff --git a/src/main/java/com/k3rnl/fuse/fuse/FuseBuf.java b/src/main/java/com/k3rnl/fuse/fuse/FuseBuf.java index e273522..64d6308 100644 --- a/src/main/java/com/k3rnl/fuse/fuse/FuseBuf.java +++ b/src/main/java/com/k3rnl/fuse/fuse/FuseBuf.java @@ -6,23 +6,41 @@ import org.graalvm.nativeimage.c.type.VoidPointer; import org.graalvm.word.PointerBase; +/** + * The {@code FuseBuf} interface represents the native "fuse_buf" structure, + * which is used to handle data buffers in the FUSE (Filesystem in Userspace) library. + */ @CContext(FuseLibrary.Directives.class) @CStruct(value = "fuse_buf", addStructKeyword = true) public interface FuseBuf extends PointerBase { + /** + * @return the size of the buffer in bytes. + */ @CField("size") long size(); + /** + * @return the flags associated with the buffer. + */ @CField("flags") int flags(); + /** + * @return a {@link VoidPointer} pointing to the memory address of the buffer. + */ @CField("mem") VoidPointer mem(); + /** + * @return the file descriptor associated with this buffer. + */ @CField("fd") int fd(); + /** + * @return the position within the file for this buffer, typically used with file operations. + */ @CField("pos") long pos(); - } diff --git a/src/main/java/com/k3rnl/fuse/fuse/FuseBufVec.java b/src/main/java/com/k3rnl/fuse/fuse/FuseBufVec.java index 3378c1e..70a12ed 100644 --- a/src/main/java/com/k3rnl/fuse/fuse/FuseBufVec.java +++ b/src/main/java/com/k3rnl/fuse/fuse/FuseBufVec.java @@ -7,26 +7,58 @@ import org.graalvm.nativeimage.c.struct.CStruct; import org.graalvm.word.PointerBase; +/** + * The {@code FuseBufVec} interface represents the native "fuse_bufvec" structure, + * which is used to handle vectors of data buffers in the FUSE (Filesystem in Userspace) library. + */ @CContext(FuseLibrary.Directives.class) @CStruct(value = "fuse_bufvec", addStructKeyword = true) public interface FuseBufVec extends PointerBase { + /** + * Pointer interface for {@code FuseBufVec}, allowing array-like access to multiple {@code FuseBufVec} instances. + */ @CPointerTo(FuseBufVec.class) public interface FuseBufVecPointer extends PointerBase { + + /** + * Reads the {@code FuseBufVec} at the specified index. + * + * @param index the index of the {@code FuseBufVec} to read. + * @return the {@code FuseBufVec} instance at the specified index. + */ FuseBufVec read(int index); + + /** + * Writes a {@code FuseBufVec} value at the specified index. + * + * @param index the index to write the {@code FuseBufVec} to. + * @param value the {@code FuseBufVec} instance to write. + */ void write(int index, FuseBufVec value); } + /** + * @return the number of buffers in the vector. + */ @CField("count") long count(); + /** + * @return the index of the current buffer in the vector. + */ @CField("idx") long idx(); + /** + * @return the offset within the current buffer. + */ @CField("off") long off(); + /** + * @return a reference to the first {@code FuseBuf} in the vector. + */ @CFieldAddress("buf") FuseBuf buf(); - } diff --git a/src/main/java/com/k3rnl/fuse/fuse/FuseConfig.java b/src/main/java/com/k3rnl/fuse/fuse/FuseConfig.java index 7e873de..befb3e5 100644 --- a/src/main/java/com/k3rnl/fuse/fuse/FuseConfig.java +++ b/src/main/java/com/k3rnl/fuse/fuse/FuseConfig.java @@ -5,250 +5,284 @@ import org.graalvm.nativeimage.c.struct.CStruct; import org.graalvm.word.PointerBase; +/** + * The {@code FuseConfig} interface represents the native "fuse_config" structure, + * which is used to configure various options in the FUSE (Filesystem in Userspace) library. + */ @CContext(FuseLibrary.Directives.class) @CStruct(value = "fuse_config", addStructKeyword = true) public interface FuseConfig extends PointerBase { /** - * If `set_gid` is non-zero, the st_gid attribute of each file - * is overwritten with the value of `gid`. + * @return whether the group ID (gid) of each file is overwritten with the value of `gid`. */ @CField("set_gid") - int set_gid(); // Set the gid + int set_gid(); + + /** + * Sets the value of `set_gid`. + * @param value non-zero to enable gid overwrite; zero to disable. + */ @CField("set_gid") void set_gid(int value); + /** + * @return the group ID to set if `set_gid` is enabled. + */ @CField("gid") - int gid(); // Group ID + int gid(); + + /** + * Sets the group ID. + * @param value the group ID to set. + */ @CField("gid") void gid(int value); /** - * If `set_uid` is non-zero, the st_uid attribute of each file - * is overwritten with the value of `uid`. + * @return whether the user ID (uid) of each file is overwritten with the value of `uid`. */ @CField("set_uid") - int set_uid(); // Set the uid + int set_uid(); + + /** + * Sets the value of `set_uid`. + * @param value non-zero to enable uid overwrite; zero to disable. + */ @CField("set_uid") void set_uid(int value); + /** + * @return the user ID to set if `set_uid` is enabled. + */ @CField("uid") - int uid(); // User ID + int uid(); + + /** + * Sets the user ID. + * @param value the user ID to set. + */ @CField("uid") void uid(int value); /** - * If `set_mode` is non-zero, the any permissions bits set in - * `umask` are unset in the st_mode attribute of each file. + * @return whether to unset any permissions bits set in `umask` in each file's permissions. */ @CField("set_mode") - int set_mode(); // Set the mode + int set_mode(); + + /** + * Sets the value of `set_mode`. + * @param value non-zero to enable umask; zero to disable. + */ @CField("set_mode") void set_mode(int value); + /** + * @return the umask applied if `set_mode` is enabled. + */ @CField("umask") - int umask(); // Umask + int umask(); + + /** + * Sets the umask. + * @param value the umask to set. + */ @CField("umask") void umask(int value); /** - * The timeout in seconds for which name lookups will be - * cached. + * @return the timeout in seconds for name lookups to be cached. */ @CField("entry_timeout") - long entry_timeout(); // Entry timeout + long entry_timeout(); + + /** + * Sets the entry timeout. + * @param value the timeout in seconds. + */ @CField("entry_timeout") void entry_timeout(long value); /** - * The timeout in seconds for which a negative lookup will be - * cached. This means, that if file did not exist (lookup - * returned ENOENT), the lookup will only be redone after the - * timeout, and the file/directory will be assumed to not - * exist until then. A value of zero means that negative - * lookups are not cached. + * @return the timeout in seconds for negative lookups (when a file does not exist) to be cached. */ @CField("negative_timeout") - long negative_timeout(); // Negative timeout + long negative_timeout(); + + /** + * Sets the negative lookup timeout. + * @param value the timeout in seconds. + */ @CField("negative_timeout") void negative_timeout(long value); /** - * The timeout in seconds for which file/directory attributes - * (as returned by e.g. the `getattr` handler) are cached. + * @return the timeout in seconds for caching file/directory attributes. */ @CField("attr_timeout") - long attr_timeout(); // Attribute timeout + long attr_timeout(); + + /** + * Sets the attribute timeout. + * @param value the timeout in seconds. + */ @CField("attr_timeout") void attr_timeout(long value); /** - * Allow requests to be interrupted + * @return whether requests are allowed to be interrupted. */ @CField("intr") - int intr(); // Interrupt + int intr(); + + /** + * Sets whether requests can be interrupted. + * @param value non-zero to allow interruption; zero to disallow. + */ @CField("intr") void intr(int value); /** - * Specify which signal number to send to the filesystem when - * a request is interrupted. The default is hardcoded to - * USR1. + * @return the signal number to send to the filesystem when a request is interrupted. */ @CField("intr_signal") - int intr_signal(); // Interrupt signal + int intr_signal(); + + /** + * Sets the signal for interrupted requests. + * @param value the signal number. + */ @CField("intr_signal") void intr_signal(int value); /** - * Normally, FUSE assigns inodes to paths only for as long as - * the kernel is aware of them. With this option inodes are - * instead remembered for at least this many seconds. This - * will require more memory, but may be necessary when using - * applications that make use of inode numbers. - * - * A number of -1 means that inodes will be remembered for the - * entire life-time of the file-system process. + * @return the number of seconds to remember inodes, requiring additional memory but supporting applications that use inode numbers. */ @CField("remember") - int remember(); // Remember + int remember(); + + /** + * Sets the inode retention time. + * @param value seconds to remember inodes, or -1 for the lifetime of the filesystem process. + */ @CField("remember") void remember(int value); /** - * The default behavior is that if an open file is deleted, - * the file is renamed to a hidden file (.fuse_hiddenXXX), and - * only removed when the file is finally released. This - * relieves the filesystem implementation of having to deal - * with this problem. This option disables the hiding - * behavior, and files are removed immediately in an unlink - * operation (or in a rename operation which overwrites an - * existing file). - * - * It is recommended that you not use the hard_remove - * option. When hard_remove is set, the following libc - * functions fail on unlinked files (returning errno of - * ENOENT): read(2), write(2), fsync(2), close(2), f*xattr(2), - * ftruncate(2), fstat(2), fchmod(2), fchown(2) + * @return whether files should be removed immediately instead of renamed and hidden. */ @CField("hard_remove") - int hard_remove(); // Hard remove + int hard_remove(); + + /** + * Sets the hard remove option. + * @param value non-zero to remove files immediately; zero to rename and hide. + */ @CField("hard_remove") void hard_remove(int value); /** - * Honor the st_ino field in the functions getattr() and - * fill_dir(). This value is used to fill in the st_ino field - * in the stat(2), lstat(2), fstat(2) functions and the d_ino - * field in the readdir(2) function. The filesystem does not - * have to guarantee uniqueness, however some applications - * rely on this value being unique for the whole filesystem. - * - * Note that this does *not* affect the inode that libfuse - * and the kernel use internally (also called the "nodeid"). + * @return whether to use the inode numbers provided by `getattr()` and `fill_dir()`. */ @CField("use_ino") - int use_ino(); // Use inode + int use_ino(); + + /** + * Sets whether to use provided inode numbers. + * @param value non-zero to use provided inodes; zero to ignore. + */ @CField("use_ino") void use_ino(int value); /** - * If use_ino option is not given, still try to fill in the - * d_ino field in readdir(2). If the name was previously - * looked up, and is still in the cache, the inode number - * found there will be used. Otherwise it will be set to -1. - * If use_ino option is given, this option is ignored. + * @return whether to attempt to fill `d_ino` field in `readdir()` for cache lookups. */ @CField("readdir_ino") - int readdir_ino(); // Readdir inode + int readdir_ino(); + + /** + * Sets the readdir inode behavior. + * @param value non-zero to attempt `d_ino` fill; zero otherwise. + */ @CField("readdir_ino") void readdir_ino(int value); /** - * This option disables the use of page cache (file content cache) - * in the kernel for this filesystem. This has several affects: - * - * 1. Each read(2) or write(2) system call will initiate one - * or more read or write operations, data will not be - * cached in the kernel. - * - * 2. The return value of the read() and write() system calls - * will correspond to the return values of the read and - * write operations. This is useful for example if the - * file size is not known in advance (before reading it). - * - * Internally, enabling this option causes fuse to set the - * `direct_io` field of `struct fuse_file_info` - overwriting - * any value that was put there by the file system. + * @return whether to disable the use of kernel page cache for file content. */ @CField("direct_io") - int direct_io(); // Direct I/O + int direct_io(); + + /** + * Sets the direct I/O option. + * @param value non-zero to disable page cache; zero to use cache. + */ @CField("direct_io") void direct_io(int value); /** - * This option disables flushing the cache of the file - * contents on every open(2). This should only be enabled on - * filesystems where the file data is never changed - * externally (not through the mounted FUSE filesystem). Thus - * it is not suitable for network filesystems and other - * intermediate filesystems. - * - * NOTE: if this option is not specified (and neither - * direct_io) data is still cached after the open(2), so a - * read(2) system call will not always initiate a read - * operation. - * - * Internally, enabling this option causes fuse to set the - * `keep_cache` field of `struct fuse_file_info` - overwriting - * any value that was put there by the file system. - **/ + * @return whether to disable cache flush on every open. + */ @CField("kernel_cache") - int kernel_cache(); // Kernel cache + int kernel_cache(); + + /** + * Sets the kernel cache option. + * @param value non-zero to disable cache flush; zero otherwise. + */ @CField("kernel_cache") void kernel_cache(int value); /** - * This option is an alternative to `kernel_cache`. Instead of - * unconditionally keeping cached data, the cached data is - * invalidated on open(2) if if the modification time or the - * size of the file has changed since it was last opened. + * @return whether to invalidate cached data on open if file metadata has changed. */ @CField("auto_cache") - int auto_cache(); // Auto cache + int auto_cache(); + + /** + * Sets the auto cache option. + * @param value non-zero to enable; zero to disable. + */ @CField("auto_cache") void auto_cache(int value); /** - * The timeout in seconds for which file attributes are cached - * for the purpose of checking if auto_cache should flush the - * file data on open. + * @return whether the attribute cache timeout is set. */ @CField("ac_attr_timeout_set") - int ac_attr_timeout_set(); // Attribute cache timeout set + int ac_attr_timeout_set(); + + /** + * Sets the attribute cache timeout flag. + * @param value non-zero to enable timeout; zero to disable. + */ @CField("ac_attr_timeout_set") void ac_attr_timeout_set(int value); + /** + * @return the attribute cache timeout duration. + */ @CField("ac_attr_timeout") - long ac_attr_timeout(); // Attribute cache timeout + long ac_attr_timeout(); + + /** + * Sets the attribute cache timeout. + * @param value the timeout duration. + */ @CField("ac_attr_timeout") void ac_attr_timeout(long value); /** - * If this option is given the file-system handlers for the - * following operations will not receive path information: - * read, write, flush, release, fallocate, fsync, readdir, - * releasedir, fsyncdir, lock, ioctl and poll. - * - * For the truncate, getattr, chmod, chown and utimens - * operations the path will be provided only if the struct - * fuse_file_info argument is NULL. + * @return whether certain file operations can proceed without path information. */ @CField("nullpath_ok") - int nullpath_ok(); // Null path OK + int nullpath_ok(); + + /** + * Sets the null path option. + * @param value non-zero to allow certain operations without paths. + */ @CField("nullpath_ok") void nullpath_ok(int value); - - - } diff --git a/src/main/java/com/k3rnl/fuse/fuse/FuseContext.java b/src/main/java/com/k3rnl/fuse/fuse/FuseContext.java index d8fff0c..8aea069 100644 --- a/src/main/java/com/k3rnl/fuse/fuse/FuseContext.java +++ b/src/main/java/com/k3rnl/fuse/fuse/FuseContext.java @@ -6,22 +6,42 @@ import org.graalvm.nativeimage.c.type.VoidPointer; import org.graalvm.word.PointerBase; +/** + * The {@code FuseContext} interface represents the native "fuse_context" structure, + * which provides context information for the FUSE (Filesystem in Userspace) library, + * related to the current operation. + */ @CContext(FuseLibrary.Directives.class) @CStruct(value = "fuse_context", addStructKeyword = true) public interface FuseContext extends PointerBase { + /** + * @return a pointer to the private data associated with the filesystem, often used to store custom data. + */ @CField VoidPointer private_data(); + /** + * @return the umask of the calling process, which is used to set file creation permissions. + */ @CField - int umask(); // Umask of the calling process + int umask(); + /** + * @return the process ID (PID) of the calling thread, which identifies the specific process making the request. + */ @CField - int pid(); // PID of the calling thread + int pid(); + /** + * @return the user ID (UID) of the calling process. + */ @CField - int uid(); // UID of the calling process + int uid(); + /** + * @return the group ID (GID) of the calling process. + */ @CField - int gid(); // GID of the calling process + int gid(); } diff --git a/src/main/java/com/k3rnl/fuse/fuse/FuseFileInfo.java b/src/main/java/com/k3rnl/fuse/fuse/FuseFileInfo.java index cc64737..61b264b 100644 --- a/src/main/java/com/k3rnl/fuse/fuse/FuseFileInfo.java +++ b/src/main/java/com/k3rnl/fuse/fuse/FuseFileInfo.java @@ -6,68 +6,136 @@ import org.graalvm.nativeimage.c.struct.CStruct; import org.graalvm.word.PointerBase; +/** + * The {@code FuseFileInfo} interface represents the native "fuse_file_info" structure, + * which provides information about an open file in the FUSE (Filesystem in Userspace) library. + */ @CContext(FuseLibrary.Directives.class) @CStruct(value = "fuse_file_info", addStructKeyword = true) public interface FuseFileInfo extends PointerBase { + /** + * @return the open flags associated with the file (e.g., read, write). + */ @CField("flags") - int flags(); // Open flags + int flags(); + /** + * Sets the open flags for the file. + * @param value the open flags to set. + */ @CField("flags") void flags(int value); + /** + * @return the file handle, a unique identifier for the open file. + */ @CField("fh") - long fh(); // File handle + long fh(); + /** + * Sets the file handle. + * @param value the file handle to set. + */ @CField("fh") void fh(long value); + /** + * @return an indicator for the writepage operation. + */ @CBitfield("writepage") - int writepage(); // Writepage operation indicator + int writepage(); + /** + * Sets the writepage operation indicator. + * @param value the indicator value. + */ @CBitfield("writepage") void writepage(int value); - // Bitfields are treated as booleans in Java, since each bitfield in C is typically used as a boolean flag + /** + * @return whether direct I/O is enabled, bypassing the kernel page cache. + */ @CBitfield("direct_io") - boolean direct_io(); // Direct I/O + boolean direct_io(); + /** + * Sets the direct I/O option. + * @param value {@code true} to enable direct I/O; {@code false} otherwise. + */ @CBitfield("direct_io") void direct_io(boolean value); + /** + * @return whether to keep the file data in the cache. + */ @CBitfield("keep_cache") - boolean keep_cache(); // Keep cache + boolean keep_cache(); + /** + * Sets the keep cache option. + * @param value {@code true} to keep cache; {@code false} otherwise. + */ @CBitfield("keep_cache") void keep_cache(boolean value); + /** + * @return the flush flag, indicating if data should be flushed to storage. + */ @CBitfield("flush") - boolean flush(); // Flush flag + boolean flush(); + /** + * Sets the flush flag. + * @param value {@code true} to enable flush; {@code false} otherwise. + */ @CBitfield("flush") void flush(boolean value); + /** + * @return whether the file is non-seekable. + */ @CBitfield("nonseekable") - boolean nonseekable(); // Non-seekable file + boolean nonseekable(); + /** + * Sets the non-seekable flag. + * @param value {@code true} if the file is non-seekable; {@code false} otherwise. + */ @CBitfield("nonseekable") void nonseekable(boolean value); + /** + * @return whether the file should be released from the flock (file lock). + */ @CBitfield("flock_release") - boolean flock_release(); // Flock release + boolean flock_release(); + /** + * Sets the flock release flag. + * @param value {@code true} to release the file lock; {@code false} otherwise. + */ @CBitfield("flock_release") void flock_release(boolean value); -// @CField("cache_readdir") -// boolean cache_readdir(); // Cache readdir entries -// -// @CField("cache_readdir") -// void cache_readdir(boolean value); + /* + @CField("cache_readdir") + boolean cache_readdir(); // Cache readdir entries + @CField("cache_readdir") + void cache_readdir(boolean value); + */ + + /** + * @return the lock owner ID, used for managing file locks. + */ @CField("lock_owner") - long lock_owner(); // Lock owner + long lock_owner(); + /** + * Sets the lock owner ID. + * @param value the lock owner ID. + */ @CField("lock_owner") void lock_owner(long value); } diff --git a/src/main/java/com/k3rnl/fuse/fuse/FuseLibrary.java b/src/main/java/com/k3rnl/fuse/fuse/FuseLibrary.java index f583b25..14aca28 100644 --- a/src/main/java/com/k3rnl/fuse/fuse/FuseLibrary.java +++ b/src/main/java/com/k3rnl/fuse/fuse/FuseLibrary.java @@ -10,36 +10,77 @@ import java.util.List; +/** + * The {@code FuseLibrary} class provides access to key FUSE (Filesystem in Userspace) functions + * and configurations, enabling integration between FUSE and Java using GraalVM. + */ @CContext(FuseLibrary.Directives.class) public class FuseLibrary { + /** + * Calls the native `fuse_main_real` function, which initializes and mounts the filesystem. + * + * @param argc the argument count, representing the number of command-line arguments. + * @param argv the arguments for the FUSE filesystem. + * @param op the FUSE operations interface that defines filesystem behavior. + * @param op_size the size of the {@code FuseOperations} structure. + * @param user_data user-defined data passed to each operation. + * @return an integer status code (0 on success, non-zero on failure). + */ @CFunction(value = "fuse_main_real") public static native int fuse_main_real(int argc, CCharPointerPointer argv, FuseOperations op, int op_size, VoidPointer user_data); + /** + * A higher-level method for initializing and mounting the FUSE filesystem. + * Converts a list of Java strings to native strings for the `fuse_main_real` function. + * + * @param args the command-line arguments for FUSE. + * @param op the FUSE operations interface that defines filesystem behavior. + * @param user_data user-defined data passed to each operation. + * @return an integer status code (0 on success, non-zero on failure). + */ public static int fuseMain(List args, FuseOperations op, VoidPointer user_data) { try (var cargs = CTypeConversion.toCStrings(args.toArray(new String[0]))) { - return fuse_main_real(args.size(), cargs.get(), op, SizeOf.get(FuseOperations.class), user_data); + return fuse_main_real(args.size(), cargs.get(), op, SizeOf.get(FuseOperations.class), user_data); } } + /** + * Retrieves the current FUSE context, containing information about the calling process and other details. + * + * @return the {@code FuseContext} associated with the current FUSE request. + */ @CFunction(value = "fuse_get_context", transition = CFunction.Transition.NO_TRANSITION) public static native FuseContext fuse_get_context(); + /** + * The {@code Directives} class provides the necessary directives for GraalVM to locate and configure + * the FUSE C library headers, libraries, and compilation options. + */ public static class Directives implements CContext.Directives { + + /** + * @return the list of required C header files for FUSE. + */ @Override public List getHeaderFiles() { return List.of(""); } + /** + * @return the list of libraries to link with, in this case, the FUSE library. + */ @Override public List getLibraries() { return List.of("fuse3"); } + /** + * @return the compilation options required for compatibility with FUSE. + */ @Override public List getOptions() { return List.of("-D_FILE_OFFSET_BITS=64", "-DFUSE_USE_VERSION=30"); } } - -} \ No newline at end of file +} diff --git a/src/main/java/com/k3rnl/fuse/fuse/FuseOperations.java b/src/main/java/com/k3rnl/fuse/fuse/FuseOperations.java index bece3e8..ea7d439 100644 --- a/src/main/java/com/k3rnl/fuse/fuse/FuseOperations.java +++ b/src/main/java/com/k3rnl/fuse/fuse/FuseOperations.java @@ -6,189 +6,628 @@ import org.graalvm.nativeimage.c.struct.CStruct; import org.graalvm.word.PointerBase; +/** + * The {@code FuseOperations} interface represents the native "fuse_operations" structure, + * which defines the set of callback functions that implement the behavior of the + * FUSE (Filesystem in Userspace) filesystem. Each method corresponds to a specific + * filesystem operation, allowing the filesystem to handle various requests from the + * operating system. + */ @CContext(FuseLibrary.Directives.class) @CStruct(value = "fuse_operations", addStructKeyword = true) public interface FuseOperations extends PointerBase { - // Existing fields + /** + * Retrieves the callback function for the {@code getattr} operation, + * which is used to get file attributes. + * + * @return the {@link GetAttrFunction} callback. + */ @CField("getattr") GetAttrFunction getattr(); + + /** + * Sets the callback function for the {@code getattr} operation. + * + * @param func the {@link GetAttrFunction} to handle {@code getattr} requests. + */ @CField("getattr") void getattr(GetAttrFunction func); + /** + * Retrieves the callback function for the {@code readdir} operation, + * which is used to read directory entries. + * + * @return the {@link ReadDirFunction} callback. + */ @CField("readdir") ReadDirFunction readdir(); + + /** + * Sets the callback function for the {@code readdir} operation. + * + * @param func the {@link ReadDirFunction} to handle {@code readdir} requests. + */ @CField("readdir") void readdir(ReadDirFunction func); + /** + * Retrieves the callback function for the {@code opendir} operation, + * which is used to open a directory. + * + * @return the {@link OpenDirFunction} callback. + */ @CField("opendir") OpenDirFunction opendir(); + + /** + * Sets the callback function for the {@code opendir} operation. + * + * @param func the {@link OpenDirFunction} to handle {@code opendir} requests. + */ @CField("opendir") void opendir(OpenDirFunction func); + /** + * Retrieves the callback function for the {@code releasedir} operation, + * which is used to release (close) a directory. + * + * @return the {@link ReleaseDirFunction} callback. + */ @CField("releasedir") ReleaseDirFunction releasedir(); + + /** + * Sets the callback function for the {@code releasedir} operation. + * + * @param func the {@link ReleaseDirFunction} to handle {@code releasedir} requests. + */ @CField("releasedir") void releasedir(ReleaseDirFunction func); + /** + * Retrieves the callback function for the {@code open} operation, + * which is used to open a file. + * + * @return the {@link OpenFunction} callback. + */ @CField("open") OpenFunction open(); + + /** + * Sets the callback function for the {@code open} operation. + * + * @param func the {@link OpenFunction} to handle {@code open} requests. + */ @CField("open") void open(OpenFunction func); + /** + * Retrieves the callback function for the {@code read} operation, + * which is used to read data from a file. + * + * @return the {@link ReadFunction} callback. + */ @CField("read") ReadFunction read(); + + /** + * Sets the callback function for the {@code read} operation. + * + * @param func the {@link ReadFunction} to handle {@code read} requests. + */ @CField("read") void read(ReadFunction func); + /** + * Retrieves the callback function for the {@code write} operation, + * which is used to write data to a file. + * + * @return the {@link WriteFunction} callback. + */ @CField("write") WriteFunction write(); + + /** + * Sets the callback function for the {@code write} operation. + * + * @param func the {@link WriteFunction} to handle {@code write} requests. + */ @CField("write") void write(WriteFunction func); + /** + * Retrieves the callback function for the {@code create} operation, + * which is used to create a new file. + * + * @return the {@link CreateFunction} callback. + */ @CField("create") CreateFunction create(); + + /** + * Sets the callback function for the {@code create} operation. + * + * @param func the {@link CreateFunction} to handle {@code create} requests. + */ @CField("create") void create(CreateFunction func); + /** + * Retrieves the callback function for the {@code release} operation, + * which is used to release (close) a file. + * + * @return the {@link ReleaseFunction} callback. + */ @CField("release") ReleaseFunction release(); + + /** + * Sets the callback function for the {@code release} operation. + * + * @param func the {@link ReleaseFunction} to handle {@code release} requests. + */ @CField("release") void release(ReleaseFunction func); + /** + * Retrieves the callback function for the {@code rmdir} operation, + * which is used to remove a directory. + * + * @return the {@link RmdirFunction} callback. + */ @CField("rmdir") RmdirFunction rmdir(); + + /** + * Sets the callback function for the {@code rmdir} operation. + * + * @param func the {@link RmdirFunction} to handle {@code rmdir} requests. + */ @CField("rmdir") void rmdir(RmdirFunction func); + /** + * Retrieves the callback function for the {@code unlink} operation, + * which is used to remove a file. + * + * @return the {@link UnlinkFunction} callback. + */ @CField("unlink") UnlinkFunction unlink(); + + /** + * Sets the callback function for the {@code unlink} operation. + * + * @param func the {@link UnlinkFunction} to handle {@code unlink} requests. + */ @CField("unlink") void unlink(UnlinkFunction func); + /** + * Retrieves the callback function for the {@code init} operation, + * which is used to initialize the filesystem. + * + * @return the {@link InitFunction} callback. + */ @CField("init") InitFunction init(); + + /** + * Sets the callback function for the {@code init} operation. + * + * @param func the {@link InitFunction} to handle {@code init} requests. + */ @CField("init") void init(InitFunction func); // New fields based on additional CEntryPointLiterals + + /** + * Retrieves the callback function for the {@code access} operation, + * which is used to check file access permissions. + * + * @return the {@link AccessFunction} callback. + */ @CField("access") AccessFunction access(); + + /** + * Sets the callback function for the {@code access} operation. + * + * @param func the {@link AccessFunction} to handle {@code access} requests. + */ @CField("access") void access(AccessFunction func); + /** + * Retrieves the callback function for the {@code bmap} operation, + * which is used to map block numbers. + * + * @return the {@link BmapFunction} callback. + */ @CField("bmap") BmapFunction bmap(); + + /** + * Sets the callback function for the {@code bmap} operation. + * + * @param func the {@link BmapFunction} to handle {@code bmap} requests. + */ @CField("bmap") void bmap(BmapFunction func); + /** + * Retrieves the callback function for the {@code chmod} operation, + * which is used to change file permissions. + * + * @return the {@link ChmodFunction} callback. + */ @CField("chmod") ChmodFunction chmod(); + + /** + * Sets the callback function for the {@code chmod} operation. + * + * @param func the {@link ChmodFunction} to handle {@code chmod} requests. + */ @CField("chmod") void chmod(ChmodFunction func); + /** + * Retrieves the callback function for the {@code chown} operation, + * which is used to change file ownership. + * + * @return the {@link ChownFunction} callback. + */ @CField("chown") ChownFunction chown(); + + /** + * Sets the callback function for the {@code chown} operation. + * + * @param func the {@link ChownFunction} to handle {@code chown} requests. + */ @CField("chown") void chown(ChownFunction func); + /** + * Retrieves the callback function for the {@code copy_file_range} operation, + * which is used to copy a range of data from one file to another. + * + * @return the {@link CopyFileRangeFunction} callback. + */ @CField("copy_file_range") CopyFileRangeFunction copyFileRange(); + + /** + * Sets the callback function for the {@code copy_file_range} operation. + * + * @param func the {@link CopyFileRangeFunction} to handle {@code copy_file_range} requests. + */ @CField("copy_file_range") void copyFileRange(CopyFileRangeFunction func); + /** + * Retrieves the callback function for the {@code destroy} operation, + * which is used to clean up and unmount the filesystem. + * + * @return the {@link DestroyFunction} callback. + */ @CField("destroy") DestroyFunction destroy(); + + /** + * Sets the callback function for the {@code destroy} operation. + * + * @param func the {@link DestroyFunction} to handle {@code destroy} requests. + */ @CField("destroy") void destroy(DestroyFunction func); + /** + * Retrieves the callback function for the {@code fallocate} operation, + * which is used to allocate space for a file. + * + * @return the {@link FallocateFunction} callback. + */ @CField("fallocate") FallocateFunction fallocate(); + + /** + * Sets the callback function for the {@code fallocate} operation. + * + * @param func the {@link FallocateFunction} to handle {@code fallocate} requests. + */ @CField("fallocate") void fallocate(FallocateFunction func); + /** + * Retrieves the callback function for the {@code flock} operation, + * which is used to apply or remove an advisory lock on an open file. + * + * @return the {@link FlockFunction} callback. + */ @CField("flock") FlockFunction flock(); + + /** + * Sets the callback function for the {@code flock} operation. + * + * @param func the {@link FlockFunction} to handle {@code flock} requests. + */ @CField("flock") void flock(FlockFunction func); + /** + * Retrieves the callback function for the {@code flush} operation, + * which is used to flush any cached data for an open file to disk. + * + * @return the {@link FlushFunction} callback. + */ @CField("flush") FlushFunction flush(); + + /** + * Sets the callback function for the {@code flush} operation. + * + * @param func the {@link FlushFunction} to handle {@code flush} requests. + */ @CField("flush") void flush(FlushFunction func); + /** + * Retrieves the callback function for the {@code ioctl} operation, + * which is used to perform device-specific input/output operations. + * + * @return the {@link IoctlFunction} callback. + */ @CField("ioctl") IoctlFunction ioctl(); + + /** + * Sets the callback function for the {@code ioctl} operation. + * + * @param func the {@link IoctlFunction} to handle {@code ioctl} requests. + */ @CField("ioctl") void ioctl(IoctlFunction func); + /** + * Retrieves the callback function for the {@code link} operation, + * which is used to create a hard link to a file. + * + * @return the {@link LinkFunction} callback. + */ @CField("link") LinkFunction link(); + + /** + * Sets the callback function for the {@code link} operation. + * + * @param func the {@link LinkFunction} to handle {@code link} requests. + */ @CField("link") void link(LinkFunction func); + /** + * Retrieves the callback function for the {@code lock} operation, + * which is used to apply or remove a file lock. + * + * @return the {@link LockFunction} callback. + */ @CField("lock") LockFunction lock(); + + /** + * Sets the callback function for the {@code lock} operation. + * + * @param func the {@link LockFunction} to handle {@code lock} requests. + */ @CField("lock") void lock(LockFunction func); + /** + * Retrieves the callback function for the {@code lseek} operation, + * which is used to reposition the file offset of an open file. + * + * @return the {@link LseekFunction} callback. + */ @CField("lseek") LseekFunction lseek(); + + /** + * Sets the callback function for the {@code lseek} operation. + * + * @param func the {@link LseekFunction} to handle {@code lseek} requests. + */ @CField("lseek") void lseek(LseekFunction func); + /** + * Retrieves the callback function for the {@code mkdir} operation, + * which is used to create a new directory. + * + * @return the {@link MkDirFunction} callback. + */ @CField("mkdir") MkDirFunction mkdir(); + + /** + * Sets the callback function for the {@code mkdir} operation. + * + * @param func the {@link MkDirFunction} to handle {@code mkdir} requests. + */ @CField("mkdir") void mkdir(MkDirFunction func); + /** + * Retrieves the callback function for the {@code mknod} operation, + * which is used to create a filesystem node (file, device special file, etc.). + * + * @return the {@link MkNodFunction} callback. + */ @CField("mknod") MkNodFunction mknod(); + + /** + * Sets the callback function for the {@code mknod} operation. + * + * @param func the {@link MkNodFunction} to handle {@code mknod} requests. + */ @CField("mknod") void mknod(MkNodFunction func); + /** + * Retrieves the callback function for the {@code poll} operation, + * which is used to perform polling on a file descriptor. + * + * @return the {@link PollFunction} callback. + */ @CField("poll") PollFunction poll(); + + /** + * Sets the callback function for the {@code poll} operation. + * + * @param func the {@link PollFunction} to handle {@code poll} requests. + */ @CField("poll") void poll(PollFunction func); + /** + * Retrieves the callback function for the {@code read_buf} operation, + * which is used to read data into a buffer. + * + * @return the {@link ReadBufFunction} callback. + */ @CField("read_buf") ReadBufFunction readBuf(); + + /** + * Sets the callback function for the {@code read_buf} operation. + * + * @param func the {@link ReadBufFunction} to handle {@code read_buf} requests. + */ @CField("read_buf") void readBuf(ReadBufFunction func); + /** + * Retrieves the callback function for the {@code readlink} operation, + * which is used to read the target of a symbolic link. + * + * @return the {@link ReadLinkFunction} callback. + */ @CField("readlink") ReadLinkFunction readlink(); + + /** + * Sets the callback function for the {@code readlink} operation. + * + * @param func the {@link ReadLinkFunction} to handle {@code readlink} requests. + */ @CField("readlink") void readlink(ReadLinkFunction func); + /** + * Retrieves the callback function for the {@code rename} operation, + * which is used to rename a file or directory. + * + * @return the {@link RenameFunction} callback. + */ @CField("rename") RenameFunction rename(); + + /** + * Sets the callback function for the {@code rename} operation. + * + * @param func the {@link RenameFunction} to handle {@code rename} requests. + */ @CField("rename") void rename(RenameFunction func); + /** + * Retrieves the callback function for the {@code statfs} operation, + * which is used to get filesystem statistics. + * + * @return the {@link StatVfsFunction} callback. + */ @CField("statfs") StatVfsFunction statfs(); + + /** + * Sets the callback function for the {@code statfs} operation. + * + * @param func the {@link StatVfsFunction} to handle {@code statfs} requests. + */ @CField("statfs") void statfs(StatVfsFunction func); + /** + * Retrieves the callback function for the {@code symlink} operation, + * which is used to create a symbolic link. + * + * @return the {@link SymlinkFunction} callback. + */ @CField("symlink") SymlinkFunction symlink(); + + /** + * Sets the callback function for the {@code symlink} operation. + * + * @param func the {@link SymlinkFunction} to handle {@code symlink} requests. + */ @CField("symlink") void symlink(SymlinkFunction func); + /** + * Retrieves the callback function for the {@code truncate} operation, + * which is used to truncate a file to a specified length. + * + * @return the {@link TruncateFunction} callback. + */ @CField("truncate") TruncateFunction truncate(); + + /** + * Sets the callback function for the {@code truncate} operation. + * + * @param func the {@link TruncateFunction} to handle {@code truncate} requests. + */ @CField("truncate") void truncate(TruncateFunction func); + /** + * Retrieves the callback function for the {@code utimens} operation, + * which is used to update file access and modification times. + * + * @return the {@link UtimensFunction} callback. + */ @CField("utimens") UtimensFunction utimens(); + + /** + * Sets the callback function for the {@code utimens} operation. + * + * @param func the {@link UtimensFunction} to handle {@code utimens} requests. + */ @CField("utimens") void utimens(UtimensFunction func); + /** + * Retrieves the callback function for the {@code write_buf} operation, + * which is used to write data from a buffer to a file. + * + * @return the {@link WriteBufFunction} callback. + */ @CField("write_buf") WriteBufFunction writeBuf(); + + /** + * Sets the callback function for the {@code write_buf} operation. + * + * @param func the {@link WriteBufFunction} to handle {@code write_buf} requests. + */ @CField("write_buf") void writeBuf(WriteBufFunction func); } diff --git a/src/main/java/com/k3rnl/fuse/fuse/PrivateData.java b/src/main/java/com/k3rnl/fuse/fuse/PrivateData.java index 7e816fd..4de6d8e 100644 --- a/src/main/java/com/k3rnl/fuse/fuse/PrivateData.java +++ b/src/main/java/com/k3rnl/fuse/fuse/PrivateData.java @@ -7,17 +7,42 @@ import org.graalvm.nativeimage.c.struct.RawStructure; import org.graalvm.word.PointerBase; -@RawStructure() +/** + * The {@code PrivateData} interface represents a raw structure that holds private data in a FUSE-based + * filesystem, specifically using GraalVM's native image features. This structure allows for the storage + * and retrieval of data associated with the FUSE isolate and Java objects. + */ +@RawStructure public interface PrivateData extends PointerBase { + /** + * @return the {@link Isolate} associated with the current GraalVM native image, allowing + * for isolation of the Java runtime within the FUSE context. + */ @RawField Isolate isolate(); + + /** + * Sets the {@link Isolate} for the FUSE context. + * + * @param value the isolate to associate with this structure. + */ @RawField void isolate(Isolate value); + /** + * @return the {@link ObjectHandle} representing a reference to a Java object + * stored in the native structure. This handle can be used to access or modify + * Java data associated with the filesystem. + */ @RawField ObjectHandle javaData(); + + /** + * Sets the {@link ObjectHandle} representing a Java object in the native structure. + * + * @param value the Java object handle to set in the structure. + */ @RawField void javaData(ObjectHandle value); - } diff --git a/src/main/java/com/k3rnl/fuse/libc/Errno.java b/src/main/java/com/k3rnl/fuse/libc/Errno.java index ec36634..bfe5883 100644 --- a/src/main/java/com/k3rnl/fuse/libc/Errno.java +++ b/src/main/java/com/k3rnl/fuse/libc/Errno.java @@ -5,9 +5,16 @@ import java.util.List; +/** + * The {@code Errno} class provides native error codes commonly used in POSIX-compliant operating systems. + * These error codes are used to identify specific system errors. + */ @CContext(Errno.Directives.class) public class Errno { + /** + * Defines the directives for including necessary C headers. + */ static class Directives implements CContext.Directives { @Override public List getHeaderFiles() { @@ -15,145 +22,424 @@ public List getHeaderFiles() { } } + /** + * @return the error code for "Operation not permitted" + */ @CConstant - public static native int EPERM(); // Operation not permitted + public static native int EPERM(); + + /** + * @return the error code for "No such file or directory" + */ @CConstant - public static native int ENOENT(); // No such file or directory + public static native int ENOENT(); + + /** + * @return the error code for "No such process" + */ @CConstant - public static native int ESRCH(); // No such process + public static native int ESRCH(); + + /** + * @return the error code for "Interrupted system call" + */ @CConstant - public static native int EINTR(); // Interrupted system call + public static native int EINTR(); + + /** + * @return the error code for "Input/output error" + */ @CConstant - public static native int EIO(); // Input/output error + public static native int EIO(); + + /** + * @return the error code for "No such device or address" + */ @CConstant - public static native int ENXIO(); // No such device or address + public static native int ENXIO(); + + /** + * @return the error code for "Argument list too long" + */ @CConstant - public static native int E2BIG(); // Argument list too long + public static native int E2BIG(); + + /** + * @return the error code for "Exec format error" + */ @CConstant - public static native int ENOEXEC(); // Exec format error + public static native int ENOEXEC(); + + /** + * @return the error code for "Bad file descriptor" + */ @CConstant - public static native int EBADF(); // Bad file descriptor + public static native int EBADF(); + + /** + * @return the error code for "No child processes" + */ @CConstant - public static native int ECHILD(); // No child processes + public static native int ECHILD(); + + /** + * @return the error code for "Resource deadlock avoided" + */ @CConstant - public static native int EDEADLK(); // Resource deadlock avoided + public static native int EDEADLK(); + + /** + * @return the error code for "Cannot allocate memory" + */ @CConstant - public static native int ENOMEM(); // Cannot allocate memory + public static native int ENOMEM(); + + /** + * @return the error code for "Permission denied" + */ @CConstant - public static native int EACCES(); // Permission denied + public static native int EACCES(); + + /** + * @return the error code for "Bad address" + */ @CConstant - public static native int EFAULT(); // Bad address + public static native int EFAULT(); + + /** + * @return the error code for "Block device required" + */ @CConstant - public static native int ENOTBLK(); // Block device required + public static native int ENOTBLK(); + + /** + * @return the error code for "Device or resource busy" + */ @CConstant - public static native int EBUSY(); // Device or resource busy + public static native int EBUSY(); + + /** + * @return the error code for "File exists" + */ @CConstant - public static native int EEXIST(); // File exists + public static native int EEXIST(); + + /** + * @return the error code for "Cross-device link" + */ @CConstant - public static native int EXDEV(); // Cross-device link + public static native int EXDEV(); + + /** + * @return the error code for "No such device" + */ @CConstant - public static native int ENODEV(); // No such device + public static native int ENODEV(); + + /** + * @return the error code for "Not a directory" + */ @CConstant - public static native int ENOTDIR(); // Not a directory + public static native int ENOTDIR(); + + /** + * @return the error code for "Is a directory" + */ @CConstant - public static native int EISDIR(); // Is a directory + public static native int EISDIR(); + + /** + * @return the error code for "Invalid argument" + */ @CConstant - public static native int EINVAL(); // Invalid argument + public static native int EINVAL(); + + /** + * @return the error code for "File table overflow" + */ @CConstant - public static native int ENFILE(); // File table overflow + public static native int ENFILE(); + + /** + * @return the error code for "Too many open files" + */ @CConstant - public static native int EMFILE(); // Too many open files + public static native int EMFILE(); + + /** + * @return the error code for "Not a typewriter" + */ @CConstant - public static native int ENOTTY(); // Not a typewriter + public static native int ENOTTY(); + + /** + * @return the error code for "Text file busy" + */ @CConstant - public static native int ETXTBSY(); // Text file busy + public static native int ETXTBSY(); + + /** + * @return the error code for "File too large" + */ @CConstant - public static native int EFBIG(); // File too large + public static native int EFBIG(); + + /** + * @return the error code for "No space left on device" + */ @CConstant - public static native int ENOSPC(); // No space left on device + public static native int ENOSPC(); + + /** + * @return the error code for "Illegal seek" + */ @CConstant - public static native int ESPIPE(); // Illegal seek + public static native int ESPIPE(); + + /** + * @return the error code for "Read-only file system" + */ @CConstant - public static native int EROFS(); // Read-only file system + public static native int EROFS(); + + /** + * @return the error code for "Too many links" + */ @CConstant - public static native int EMLINK(); // Too many links + public static native int EMLINK(); + + /** + * @return the error code for "Broken pipe" + */ @CConstant - public static native int EPIPE(); // Broken pipe + public static native int EPIPE(); + + /** + * @return the error code for "Math argument out of domain of func" + */ @CConstant - public static native int EDOM(); // Math argument out of domain of func + public static native int EDOM(); + + /** + * @return the error code for "Math result not representable" + */ @CConstant - public static native int ERANGE(); // Math result not representable + public static native int ERANGE(); + + /** + * @return the error code for "Resource temporarily unavailable" + */ @CConstant - public static native int EAGAIN(); // Resource temporarily unavailable + public static native int EAGAIN(); + + /** + * @return the error code for "Operation would block" + */ @CConstant - public static native int EWOULDBLOCK(); // Operation would block + public static native int EWOULDBLOCK(); + + /** + * @return the error code for "Operation now in progress" + */ @CConstant - public static native int EINPROGRESS(); // Operation now in progress + public static native int EINPROGRESS(); + + /** + * @return the error code for "Operation already in progress" + */ @CConstant - public static native int EALREADY(); // Operation already in progress + public static native int EALREADY(); + + /** + * @return the error code for "Socket operation on non-socket" + */ @CConstant - public static native int ENOTSOCK(); // Socket operation on non-socket + public static native int ENOTSOCK(); + + /** + * @return the error code for "Destination address required" + */ @CConstant - public static native int EDESTADDRREQ(); // Destination address required + public static native int EDESTADDRREQ(); + + /** + * @return the error code for "Message too long" + */ @CConstant - public static native int EMSGSIZE(); // Message too long + public static native int EMSGSIZE(); + + /** + * @return the error code for "Protocol wrong type for socket" + */ @CConstant - public static native int EPROTOTYPE(); // Protocol wrong type for socket + public static native int EPROTOTYPE(); + + /** + * @return the error code for "Protocol not available" + */ @CConstant - public static native int ENOPROTOOPT();// Protocol not available + public static native int ENOPROTOOPT(); + + /** + * @return the error code for "Protocol not supported" + */ @CConstant - public static native int EPROTONOSUPPORT(); // Protocol not supported + public static native int EPROTONOSUPPORT(); + + /** + * @return the error code for "Socket type not supported" + */ @CConstant - public static native int ESOCKTNOSUPPORT(); // Socket type not supported + public static native int ESOCKTNOSUPPORT(); + + /** + * @return the error code for "Operation not supported on socket" + */ @CConstant - public static native int EOPNOTSUPP(); // Operation not supported on socket + public static native int EOPNOTSUPP(); + + /** + * @return the error code for "Protocol family not supported" + */ @CConstant - public static native int EPFNOSUPPORT(); // Protocol family not supported + public static native int EPFNOSUPPORT(); + + /** + * @return the error code for "Address family not supported by protocol" + */ @CConstant - public static native int EAFNOSUPPORT(); // Address family not supported by protocol + public static native int EAFNOSUPPORT(); + + /** + * @return the error code for "Address already in use" + */ @CConstant - public static native int EADDRINUSE(); // Address already in use + public static native int EADDRINUSE(); + + /** + * @return the error code for "Cannot assign requested address" + */ @CConstant - public static native int EADDRNOTAVAIL(); // Cannot assign requested address + public static native int EADDRNOTAVAIL(); + + /** + * @return the error code for "Network is down" + */ @CConstant - public static native int ENETDOWN(); // Network is down + public static native int ENETDOWN(); + + /** + * @return the error code for "Network is unreachable" + */ @CConstant - public static native int ENETUNREACH(); // Network is unreachable + public static native int ENETUNREACH(); + + /** + * @return the error code for "Network dropped connection on reset" + */ @CConstant - public static native int ENETRESET(); // Network dropped connection on reset + public static native int ENETRESET(); + + /** + * @return the error code for "Software caused connection abort" + */ @CConstant - public static native int ECONNABORTED(); // Software caused connection abort + public static native int ECONNABORTED(); + + /** + * @return the error code for "Connection reset by peer" + */ @CConstant - public static native int ECONNRESET(); // Connection reset by peer + public static native int ECONNRESET(); + + /** + * @return the error code for "No buffer space available" + */ @CConstant - public static native int ENOBUFS(); // No buffer space available + public static native int ENOBUFS(); + + /** + * @return the error code for "Transport endpoint is already connected" + */ @CConstant - public static native int EISCONN(); // Transport endpoint is already connected + public static native int EISCONN(); + + /** + * @return the error code for "Transport endpoint is not connected" + */ @CConstant - public static native int ENOTCONN(); // Transport endpoint is not connected + public static native int ENOTCONN(); + + /** + * @return the error code for "Cannot send after transport endpoint shutdown" + */ @CConstant - public static native int ESHUTDOWN(); // Cannot send after transport endpoint shutdown + public static native int ESHUTDOWN(); + + /** + * @return the error code for "Connection timed out" + */ @CConstant - public static native int ETIMEDOUT(); // Connection timed out + public static native int ETIMEDOUT(); + + /** + * @return the error code for "Connection refused" + */ @CConstant - public static native int ECONNREFUSED(); // Connection refused + public static native int ECONNREFUSED(); + + /** + * @return the error code for "Too many symbolic links encountered" + */ @CConstant - public static native int ELOOP(); // Too many symbolic links encountered + public static native int ELOOP(); + + /** + * @return the error code for "File name too long" + */ @CConstant - public static native int ENAMETOOLONG(); // File name too long + public static native int ENAMETOOLONG(); + + /** + * @return the error code for "Host is down" + */ @CConstant - public static native int EHOSTDOWN(); // Host is down + public static native int EHOSTDOWN(); + + /** + * @return the error code for "No route to host" + */ @CConstant - public static native int EHOSTUNREACH(); // No route to host + public static native int EHOSTUNREACH(); + + /** + * @return the error code for "Directory not empty" + */ @CConstant - public static native int ENOTEMPTY(); // Directory not empty + public static native int ENOTEMPTY(); + + /** + * @return the error code for "Too many users" + */ @CConstant - public static native int EUSERS(); // Too many users + public static native int EUSERS(); + + /** + * @return the error code for "Disk quota exceeded" + */ @CConstant - public static native int EDQUOT(); // Disk quota exceeded + public static native int EDQUOT(); + + /** + * @return the error code for "Stale NFS file handle" + */ @CConstant - public static native int ESTALE(); // Stale NFS file handle + public static native int ESTALE(); + + /** + * @return the error code for "Object is remote" + */ @CConstant - public static native int EREMOTE(); // Object is remote - // Add more error codes as needed -} \ No newline at end of file + public static native int EREMOTE(); + +} diff --git a/src/main/java/com/k3rnl/fuse/libc/FileStat.java b/src/main/java/com/k3rnl/fuse/libc/FileStat.java index 3e6299c..9ba955a 100644 --- a/src/main/java/com/k3rnl/fuse/libc/FileStat.java +++ b/src/main/java/com/k3rnl/fuse/libc/FileStat.java @@ -6,86 +6,159 @@ import org.graalvm.nativeimage.c.struct.CStruct; import org.graalvm.word.PointerBase; - +/** + * The {@code FileStat} interface represents the structure of the native "stat" structure, + * providing fields to access file status information. + */ @CContext(LibC.Directives.class) @CStruct(value = "stat", addStructKeyword = true) public interface FileStat extends PointerBase { + /** + * @return the device ID of the file. + */ @CField("st_dev") - long st_dev(); // Device ID + long st_dev(); + /** + * Sets the device ID of the file. + * @param value the device ID to set. + */ @CField("st_dev") void st_dev(long value); + /** + * @return the inode number of the file. + */ @CField("st_ino") - long st_ino(); // Inode number + long st_ino(); + /** + * Sets the inode number of the file. + * @param value the inode number to set. + */ @CField("st_ino") void st_ino(long value); + /** + * @return the file mode (permissions). + */ @CField("st_mode") - int st_mode(); // File mode (permissions) + int st_mode(); + /** + * Sets the file mode (permissions). + * @param value the file mode to set. + */ @CField("st_mode") void st_mode(int value); + /** + * @return the number of hard links to the file. + */ @CField("st_nlink") - long st_nlink(); // Number of hard links + long st_nlink(); + /** + * Sets the number of hard links to the file. + * @param value the number of hard links to set. + */ @CField("st_nlink") void st_nlink(long value); + /** + * @return the user ID of the file owner. + */ @CField("st_uid") - int st_uid(); // User ID of the owner + int st_uid(); + /** + * Sets the user ID of the file owner. + * @param value the user ID to set. + */ @CField("st_uid") void st_uid(int value); + /** + * @return the group ID of the file owner. + */ @CField("st_gid") - int st_gid(); // Group ID of the owner + int st_gid(); + /** + * Sets the group ID of the file owner. + * @param value the group ID to set. + */ @CField("st_gid") void st_gid(int value); + /** + * @return the device ID (if the file is a special file). + */ @CField("st_rdev") - long st_rdev(); // Device ID (if special file) + long st_rdev(); + /** + * Sets the device ID (if the file is a special file). + * @param value the device ID to set. + */ @CField("st_rdev") void st_rdev(long value); + /** + * @return the total size of the file, in bytes. + */ @CField("st_size") - long st_size(); // Total size, in bytes + long st_size(); + /** + * Sets the total size of the file, in bytes. + * @param value the size in bytes to set. + */ @CField("st_size") void st_size(long value); + /** + * @return the block size for filesystem I/O. + */ @CField("st_blksize") - long st_blksize(); // Block size for filesystem I/O + long st_blksize(); + /** + * Sets the block size for filesystem I/O. + * @param value the block size to set. + */ @CField("st_blksize") void st_blksize(long value); + /** + * @return the number of 512B blocks allocated for the file. + */ @CField("st_blocks") - long st_blocks(); // Number of 512B blocks allocated + long st_blocks(); + /** + * Sets the number of 512B blocks allocated for the file. + * @param value the number of blocks to set. + */ @CField("st_blocks") void st_blocks(long value); + /** + * @return a {@code TimeSpec} representing the time of the last access. + */ @CFieldAddress("st_atime") - TimeSpec st_atime(); // Time of last access - -// @CField("st_atime") -// void st_atime(long value); + TimeSpec st_atime(); + /** + * @return a {@code TimeSpec} representing the time of the last modification. + */ @CFieldAddress("st_mtime") - TimeSpec st_mtime(); // Time of last modification - -// @CField("st_mtime") -// void st_mtime(long value); + TimeSpec st_mtime(); + /** + * @return a {@code TimeSpec} representing the time of the last status change. + */ @CFieldAddress("st_ctime") - TimeSpec st_ctime(); // Time of last status change - -// @CField("st_ctime") -// void st_ctime(long value); -} \ No newline at end of file + TimeSpec st_ctime(); +} diff --git a/src/main/java/com/k3rnl/fuse/libc/Flock.java b/src/main/java/com/k3rnl/fuse/libc/Flock.java index 0ae5d3f..094a0c3 100644 --- a/src/main/java/com/k3rnl/fuse/libc/Flock.java +++ b/src/main/java/com/k3rnl/fuse/libc/Flock.java @@ -5,34 +5,78 @@ import org.graalvm.nativeimage.c.struct.CStruct; import org.graalvm.word.PointerBase; +/** + * The {@code Flock} interface represents the native "flock" structure, + * used to specify details for file locking in POSIX-compliant systems. + */ @CContext(LibC.Directives.class) @CStruct(value = "flock", addStructKeyword = true) public interface Flock extends PointerBase { + /** + * @return the type of the lock, which can be one of {@code F_RDLCK} (read lock), {@code F_WRLCK} (write lock), or {@code F_UNLCK} (unlock). + */ @CField("l_type") - short l_type(); // Specifies the type of the lock; one of F_RDLCK, F_WRLCK, or F_UNLCK. + short l_type(); + + /** + * Sets the type of the lock. + * @param value the type of the lock to set, which can be one of {@code F_RDLCK}, {@code F_WRLCK}, or {@code F_UNLCK}. + */ @CField("l_type") void l_type(short value); + /** + * @return the starting point for the lock's offset, which corresponds to the {@code whence} argument in {@code fseek} or {@code lseek}. + * It specifies what the offset is relative to, with possible values being {@code SEEK_SET}, {@code SEEK_CUR}, or {@code SEEK_END}. + */ @CField("l_whence") - short l_whence(); // This corresponds to the whence argument to fseek or lseek, and specifies what the offset is relative to. Its value can be one of SEEK_SET, SEEK_CUR, or SEEK_END. + short l_whence(); + + /** + * Sets the starting point for the lock's offset. + * @param value the whence value, which can be {@code SEEK_SET}, {@code SEEK_CUR}, or {@code SEEK_END}. + */ @CField("l_whence") void l_whence(short value); + /** + * @return the offset of the start of the region to which the lock applies, in bytes relative to the position specified by {@code l_whence}. + */ @CField("l_start") - long l_start(); // This specifies the offset of the start of the region to which the lock applies, and is given in bytes relative to the point specified by the l_whence member. + long l_start(); + + /** + * Sets the offset of the start of the region to which the lock applies. + * @param value the offset in bytes, relative to {@code l_whence}. + */ @CField("l_start") void l_start(long value); + /** + * @return the length of the region to be locked. A value of 0 means the lock extends to the end of the file. + */ @CField("l_len") - long l_len(); // This specifies the length of the region to be locked. A value of 0 is treated specially; it means the region extends to the end of the file. + long l_len(); + + /** + * Sets the length of the region to be locked. + * @param value the length of the region in bytes, with 0 indicating the region extends to the end of the file. + */ @CField("l_len") void l_len(long value); + /** + * @return the process ID of the process holding the lock. This is filled in by a call to {@code fcntl} with the {@code F_GETLK} command. + * If the conflicting lock is an open file description lock, this field will be set to -1. + */ @CField("l_pid") - int l_pid(); // This field is the process ID (see Process Creation Concepts) of the process holding the lock. It is filled in by calling fcntl with the F_GETLK command, but is ignored when making a lock. - // If the conflicting lock is an open file description lock (see Open File Description Locks), then this field will be set to -1. + int l_pid(); + + /** + * Sets the process ID for the lock holder. + * @param value the process ID of the lock holder; ignored when setting a lock. + */ @CField("l_pid") void l_pid(int value); - } diff --git a/src/main/java/com/k3rnl/fuse/libc/LibC.java b/src/main/java/com/k3rnl/fuse/libc/LibC.java index 73ca8ff..0477044 100644 --- a/src/main/java/com/k3rnl/fuse/libc/LibC.java +++ b/src/main/java/com/k3rnl/fuse/libc/LibC.java @@ -8,9 +8,16 @@ import java.util.List; +/** + * The {@code LibC} class provides access to native C library functions and utilities, + * including memory operations and file manipulation functions. + */ @CContext(LibC.Directives.class) public class LibC { + /** + * Defines the directives for including necessary C headers. + */ public static class Directives implements CContext.Directives { @Override public List getHeaderFiles() { @@ -20,11 +27,25 @@ public List getHeaderFiles() { } } + /** + * Sets a block of memory to a specified value. + * + * @param dest the destination pointer where memory will be set. + * @param value the value to set, typically interpreted as an unsigned char. + * @param count the number of bytes to set to {@code value}. + * @return an integer result from the native {@code memset} function (typically 0 on success). + */ @CFunction public static native int memset(VoidPointer dest, int value, long count); + /** + * Casts a {@link PointerBase} to a different pointer type. + * + * @param ptr the pointer to cast. + * @param the desired pointer type. + * @return the casted pointer as the specified type. + */ public static R autoCast(PointerBase ptr) { return WordFactory.pointer(ptr.rawValue()); } - } diff --git a/src/main/java/com/k3rnl/fuse/libc/StatVFS.java b/src/main/java/com/k3rnl/fuse/libc/StatVFS.java index 7da767e..1cbc086 100644 --- a/src/main/java/com/k3rnl/fuse/libc/StatVFS.java +++ b/src/main/java/com/k3rnl/fuse/libc/StatVFS.java @@ -5,63 +5,154 @@ import org.graalvm.nativeimage.c.struct.CStruct; import org.graalvm.word.PointerBase; - +/** + * The {@code StatVFS} interface represents the native "statvfs" structure, + * providing information about a filesystem. + */ @CContext(LibC.Directives.class) @CStruct(value = "statvfs", addStructKeyword = true) public interface StatVFS extends PointerBase { + /** + * @return the file system block size. + */ @CField("f_bsize") - long f_bsize(); // File system block size. + long f_bsize(); + + /** + * Sets the file system block size. + * @param value the block size to set. + */ @CField("f_bsize") void f_bsize(long value); + /** + * @return the fundamental file system block size. + */ @CField("f_frsize") - long f_frsize(); // Fundamental file system block size. + long f_frsize(); + + /** + * Sets the fundamental file system block size. + * @param value the fundamental block size to set. + */ @CField("f_frsize") void f_frsize(long value); + /** + * @return the total number of blocks on the file system, in units of {@code f_frsize}. + */ @CField("f_blocks") - long f_blocks(); // Total number of blocks on file system in units of f_frsize. + long f_blocks(); + + /** + * Sets the total number of blocks on the file system. + * @param value the number of blocks to set, in units of {@code f_frsize}. + */ @CField("f_blocks") void f_blocks(long value); + /** + * @return the number of free blocks. + */ @CField("f_bfree") - long f_bfree(); // Number of free blocks + long f_bfree(); + + /** + * Sets the number of free blocks. + * @param value the number of free blocks to set. + */ @CField("f_bfree") void f_bfree(long value); + /** + * @return the number of free blocks available to unprivileged users. + */ @CField("f_bavail") - long f_bavail(); // Number of free blocks for unprivileged users + long f_bavail(); + + /** + * Sets the number of free blocks for unprivileged users. + * @param value the number of available blocks to set. + */ @CField("f_bavail") void f_bavail(long value); + /** + * @return the total number of inodes. + */ @CField("f_files") - long f_files(); // Number of inodes + long f_files(); + + /** + * Sets the total number of inodes. + * @param value the number of inodes to set. + */ @CField("f_files") void f_files(long value); + /** + * @return the number of free inodes. + */ @CField("f_ffree") - long f_ffree(); // Number of free inodes + long f_ffree(); + + /** + * Sets the number of free inodes. + * @param value the number of free inodes to set. + */ @CField("f_ffree") void f_ffree(long value); + /** + * @return the number of free inodes available to unprivileged users. + */ @CField("f_favail") - long f_favail(); // Number of free inodes for unprivileged users + long f_favail(); + + /** + * Sets the number of free inodes for unprivileged users. + * @param value the number of available inodes to set. + */ @CField("f_favail") void f_favail(long value); + /** + * @return the filesystem ID. + */ @CField("f_fsid") - long f_fsid(); // Filesystem ID + long f_fsid(); + + /** + * Sets the filesystem ID. + * @param value the filesystem ID to set. + */ @CField("f_fsid") void f_fsid(long value); + /** + * @return the mount flags. + */ @CField("f_flag") - long f_flag(); // Mount flags + long f_flag(); + + /** + * Sets the mount flags. + * @param value the mount flags to set. + */ @CField("f_flag") void f_flag(long value); + /** + * @return the maximum length of filenames. + */ @CField("f_namemax") - long f_namemax(); // Maximum filename length + long f_namemax(); + + /** + * Sets the maximum filename length. + * @param value the maximum filename length to set. + */ @CField("f_namemax") void f_namemax(long value); -} \ No newline at end of file +} diff --git a/src/main/java/com/k3rnl/fuse/libc/TimeSpec.java b/src/main/java/com/k3rnl/fuse/libc/TimeSpec.java index c91388e..3e6978f 100644 --- a/src/main/java/com/k3rnl/fuse/libc/TimeSpec.java +++ b/src/main/java/com/k3rnl/fuse/libc/TimeSpec.java @@ -5,20 +5,47 @@ import org.graalvm.nativeimage.c.struct.CStruct; import org.graalvm.word.PointerBase; +/** + * The {@code TimeSpec} interface represents the native "timespec" structure, + * which provides a way to specify time with nanosecond precision. + */ @CContext(LibC.Directives.class) @CStruct(value = "timespec", addStructKeyword = true) public interface TimeSpec extends PointerBase { + /** + * Returns the address of a specific {@code TimeSpec} instance in an array. + * + * @param index the index of the {@code TimeSpec} instance in the array. + * @return the address of the {@code TimeSpec} instance at the specified index. + */ TimeSpec addressOf(int index); + /** + * @return the number of seconds since the epoch (UNIX time). + */ @CField("tv_sec") long tv_sec(); + + /** + * Sets the number of seconds since the epoch (UNIX time). + * + * @param tv_sec the seconds to set. + */ @CField("tv_sec") void tv_sec(long tv_sec); + /** + * @return the number of nanoseconds, providing additional precision. + */ @CField("tv_nsec") long tv_nsec(); + + /** + * Sets the number of nanoseconds. + * + * @param tv_nsec the nanoseconds to set. + */ @CField("tv_nsec") void tv_nsec(long tv_nsec); - }