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 CGlobalDataThis 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
* 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