-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'tbutter-master' (Linux ARM compatibility)
- Loading branch information
Showing
18 changed files
with
115 additions
and
3 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
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env bash | ||
|
||
cd "`dirname "$0"`" | ||
./run.sh net.fusejna.examples.GroovyFS "$@" |
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 |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package net.fusejna.examples | ||
|
||
|
||
import java.util.Map | ||
import java.util.Arrays | ||
import java.util.HashMap | ||
import java.nio.ByteBuffer | ||
import net.fusejna.DirectoryFiller | ||
import net.fusejna.ErrorCodes | ||
import net.fusejna.FuseException | ||
import net.fusejna.StructFuseFileInfo.FileInfoWrapper | ||
import net.fusejna.StructStat.StatWrapper | ||
import net.fusejna.types.TypeMode.NodeType | ||
import net.fusejna.util.FuseFilesystemAdapterFull | ||
import net.fusejna.XattrFiller | ||
import net.fusejna.XattrListFiller | ||
|
||
public class GroovyFS extends FuseFilesystemAdapterFull | ||
{ | ||
public static void main(final String... args) throws FuseException | ||
{ | ||
if (args.length != 1) { | ||
System.err.println("Usage: GroovyFS <mountpoint>"); | ||
System.exit(1); | ||
} | ||
new GroovyFS().log(true).mount(args[0]); | ||
} | ||
|
||
def slurper = new groovy.json.JsonSlurper() | ||
def helloTxtAttrs = slurper.parseText ''' | ||
{ | ||
"user.attr1" : "xattr 1 value", | ||
"user.attr2" : "xattr 2 value", | ||
"user.attr3" : "xattr 3 value" | ||
}''' | ||
final String filename = "/psaux.txt" | ||
String contents = "ps aux".execute().text | ||
|
||
@Override | ||
public int getattr(final String path, final StatWrapper stat) | ||
{ | ||
if (path.equals(File.separator)) { // Root directory | ||
stat.setMode(NodeType.DIRECTORY); | ||
return 0; | ||
} | ||
if (path.equals(filename)) { // psaux.txt | ||
stat.setMode(NodeType.FILE).size(contents.length()); | ||
return 0; | ||
} | ||
return -ErrorCodes.ENOENT(); | ||
} | ||
@Override | ||
public int read(final String path, final ByteBuffer buffer, final long size, final long offset, final FileInfoWrapper info) | ||
{ | ||
// Compute substring that we are being asked to read | ||
final String s = contents.substring((int) offset, | ||
(int) Math.max(offset, Math.min(contents.length() - offset, offset + size))); | ||
buffer.put(s.getBytes()); | ||
return s.getBytes().length; | ||
} | ||
@Override | ||
public int readdir(final String path, final DirectoryFiller filler) | ||
{ | ||
filler.add(filename); | ||
return 0; | ||
} | ||
@Override | ||
public int listxattr(final String path, final XattrListFiller filler) | ||
{ | ||
if (!path.equals(filename)) { | ||
return -ErrorCodes.ENOTSUP(); | ||
} | ||
filler.add(helloTxtAttrs.keySet()); | ||
return 0; | ||
} | ||
@Override | ||
public int getxattr(final String path, final String xattr, final XattrFiller filler, final long size, final long position) | ||
{ | ||
if (!path.equals(filename)) { | ||
return -ErrorCodes.firstNonNull(ErrorCodes.ENOATTR(), ErrorCodes.ENOATTR(), ErrorCodes.ENODATA()); | ||
} | ||
if (!helloTxtAttrs.containsKey(xattr)) { | ||
return -ErrorCodes.firstNonNull(ErrorCodes.ENOATTR(), ErrorCodes.ENOATTR(), ErrorCodes.ENODATA()); | ||
} | ||
filler.set(helloTxtAttrs.get(xattr).getBytes()); | ||
return 0; | ||
}; | ||
} | ||
|
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
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
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
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
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