-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
137 changed files
with
7,258 additions
and
3,649 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
.idea/runConfigurations/HelloWorldFileSystem__Windows_.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
.../runConfigurations/HelloJnrFileSystem.xml → ...runConfigurations/RandomJnrFileSystem.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 33 additions & 44 deletions
77
jfuse-api/src/main/java/org/cryptomator/jfuse/api/DirFiller.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,58 @@ | ||
package org.cryptomator.jfuse.api; | ||
|
||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.io.IOException; | ||
import java.util.stream.Stream; | ||
import java.util.function.Consumer; | ||
|
||
public interface DirFiller { | ||
|
||
/** | ||
* Inserts a single item into the directory entry buffer. | ||
* | ||
* @param name The file name | ||
* @param stat Currently ignored, future use | ||
* @param offset The offset of the readdir-call plus the number of already filled entries | ||
* @return 0 if readdir should continue to fill in further items, non-zero otherwise (including errors) | ||
* @see <a href="https://libfuse.github.io/doxygen/structfuse__operations.html#adc01d3622754fc7de8e643249e73268d">official readdir docs</a> | ||
* @see <a href="https://www.cs.hmc.edu/~geoff/classes/hmc.cs135.201001/homework/fuse/fuse_doc.html#readdir-details">readdir explanation from Geoff Kuenning</a> | ||
* "Plus" mode: all file attributes are valid. | ||
* <p> | ||
* The attributes are used by the kernel to prefill the inode cache during a readdir. | ||
* <p> | ||
* It is okay to set FUSE_FILL_DIR_PLUS if {@link FuseOperations#FUSE_READDIR_PLUS FUSE_READDIR_PLUS} is not set | ||
* and vice versa. | ||
*/ | ||
int fill(String name, @Nullable Stat stat, long offset); | ||
int FUSE_FILL_DIR_PLUS = 1 << 1; | ||
|
||
/** | ||
* Convenience wrapper for {@link #fill(String, Stat, long)}, ignoring the offset parameter. | ||
* Function to add an entry in a readdir() operation | ||
* <p> | ||
* The off parameter can be any non-zero value that enables the filesystem to identify the current point in the | ||
* directory stream. It does not need to be the actual physical position. A value of zero is reserved to indicate | ||
* that seeking in directories is not supported. | ||
* | ||
* @param name The file name | ||
* @param stat Currently ignored, future use. | ||
* @throws IOException If {@link #fill(String, Stat, long) fuse_fill_dir_t} returns 1, which indicates an error. | ||
* @param name the file name of the directory entry | ||
* @param stat file attributes, can be NULL | ||
* @param offset offset of the next entry or zero when ignoring the offset parameter | ||
* @param flags fill flags, set to {@link #FUSE_FILL_DIR_PLUS} to cache stats | ||
* @return 1 if buffer is full or an error occured, zero otherwise | ||
* @see <a href="https://libfuse.github.io/doxygen/structfuse__operations.html#adc01d3622754fc7de8e643249e73268d">official readdir docs</a> | ||
* @see <a href="https://www.cs.hmc.edu/~geoff/classes/hmc.cs135.201001/homework/fuse/fuse_doc.html#readdir-details">readdir explanation from Geoff Kuenning</a> | ||
*/ | ||
default void fill(String name, @Nullable Stat stat) throws IOException { | ||
if (fill(name, stat, 0) != 0) { | ||
throw new IOException("fuse_fill_dir_t unexpectedly returned 1"); | ||
} | ||
} | ||
int fill(String name, Consumer<Stat> stat, long offset, int flags); | ||
|
||
/** | ||
* Convenience wrapper for {@link #fill(String, Stat, long)}, using the offset parameter. | ||
* <p> | ||
* <strong>Important:</strong> Note that the complete set of directors entries must contain <code>.</code> and <code>..</code>. | ||
* Convenience wrapper for {@link #fill(String, Consumer, long, int)}, ignoring the offset parameter. | ||
* | ||
* @param children A stream of directory entries offset by the given <code>offset</code> | ||
* @param offset The offset of the stream (as requested by <code>readdir</code>) | ||
* @param name The file name | ||
* @param stat A method to pre-fill the stats of this node | ||
* @throws IOException If {@link #fill(String, Consumer, long, int) fuse_fill_dir_t} returns 1, which indicates an error. | ||
*/ | ||
default void fillChildrenFromOffset(Stream<Child> children, long offset) { | ||
var iterator = children.iterator(); | ||
for (long i = offset; iterator.hasNext(); i++) { | ||
var child = iterator.next(); | ||
if (fill(child.name, child.stat, i + 1) != 0) { | ||
return; | ||
} | ||
default void fill(String name, Consumer<Stat> stat) throws IOException { | ||
if (fill(name, stat, 0, 0) != 0) { | ||
throw new IOException("fuse_fill_dir_t unexpectedly returned 1"); | ||
} | ||
} | ||
|
||
/** | ||
* Convenience wrapper for {@link #fill(String, Stat, long)}, using the offset parameter. | ||
* <p> | ||
* <strong>Important:</strong> Note that the complete set of directors entries must contain <code>.</code> and <code>..</code>. | ||
* Convenienve wrapper for {@link #fill(String, Consumer, long, int)}, just filling in the name, ignoring stats. | ||
* | ||
* @param childNames A stream of the names of directory entries offset by the given <code>offset</code> | ||
* @param offset The offset of the stream (as requested by <code>readdir</code>) | ||
* @param name The file name | ||
* @throws IOException If {@link #fill(String, Consumer, long, int) fuse_fill_dir_t} returns 1, which indicates an error. | ||
*/ | ||
default void fillNamesFromOffset(Stream<String> childNames, long offset) { | ||
var children = childNames.map(name -> new Child(name, null)); | ||
fillChildrenFromOffset(children, offset); | ||
} | ||
|
||
record Child(String name, @Nullable Stat stat) { | ||
default void fill(String name) throws IOException { | ||
fill(name, stat -> {}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.