org.catacombae.jfuse.examples
Class HelloFS

java.lang.Object
  extended by org.catacombae.jfuse.FUSE26FileSystemAdapter
      extended by org.catacombae.jfuse.FUSEFileSystemAdapter
          extended by org.catacombae.jfuse.examples.HelloFS
All Implemented Interfaces:
FUSE26FileSystem, FUSE26Operations, FUSEErrorValues, FUSEFileSystem, FileModeFlags, FileStatusFlags, SystemConstants

public class HelloFS
extends FUSEFileSystemAdapter

Example "Hello world" filesystem.

Author:
Erik Larsson

Field Summary
 
Fields inherited from interface org.catacombae.jfuse.types.system.FileStatusFlags
O_ACCMODE, O_APPEND, O_ASYNC, O_CREAT, O_DIRECTORY, O_EVTONLY, O_EXCL, O_EXLOCK, O_NOCTTY, O_NOFOLLOW, O_NONBLOCK, O_RDONLY, O_RDWR, O_SHLOCK, O_SYMLINK, O_SYNC, O_TRUNC, O_WRONLY
 
Fields inherited from interface org.catacombae.jfuse.types.system.FileModeFlags
S_IFBLK, S_IFCHR, S_IFDIR, S_IFIFO, S_IFLNK, S_IFMT, S_IFREG, S_IFSOCK, S_IRGRP, S_IROTH, S_IRUSR, S_IRWXG, S_IRWXO, S_IRWXU, S_ISGID, S_ISUID, S_ISVTX, S_IWGRP, S_IWOTH, S_IWUSR, S_IXGRP, S_IXOTH, S_IXUSR
 
Fields inherited from interface org.catacombae.jfuse.FUSEErrorValues
E2BIG, EACCES, EADDRINUSE, EADDRNOTAVAIL, EAFNOSUPPORT, EAGAIN, EALREADY, EBADF, EBADMSG, EBUSY, ECANCELED, ECHILD, ECONNABORTED, ECONNREFUSED, ECONNRESET, EDEADLK, EDESTADDRREQ, EDOM, EDQUOT, EEXIST, EFAULT, EFBIG, EHOSTDOWN, EHOSTUNREACH, EIDRM, EILSEQ, EINPROGRESS, EINTR, EINVAL, EIO, EISCONN, EISDIR, ELOOP, EMFILE, EMLINK, EMSGSIZE, EMULTIHOP, ENAMETOOLONG, ENETDOWN, ENETRESET, ENETUNREACH, ENFILE, ENOBUFS, ENODEV, ENOENT, ENOEXEC, ENOLCK, ENOLINK, ENOMEM, ENOMSG, ENOPROTOOPT, ENOSPC, ENOSYS, ENOTBLK, ENOTCONN, ENOTDIR, ENOTEMPTY, ENOTSOCK, ENOTSUP, ENOTTY, ENXIO, EOPNOTSUPP, EOVERFLOW, EPERM, EPFNOSUPPORT, EPIPE, EPROTO, EPROTONOSUPPORT, EPROTOTYPE, ERANGE, EREMOTE, EROFS, ESHUTDOWN, ESOCKTNOSUPPORT, ESPIPE, ESRCH, ESTALE, ETIMEDOUT, ETOOMANYREFS, ETXTBSY, EUSERS, EWOULDBLOCK, EXDEV
 
Constructor Summary
HelloFS()
           
 
Method Summary
 int getattr(ByteBuffer path, Stat stbuf)
           Get file attributes.
static void main(String[] args)
           
 int open(ByteBuffer path, FUSEFileInfo fi)
           File open operation.
 int read(ByteBuffer path, ByteBuffer buf, long offset, FUSEFileInfo fi)
           Read data from an open file.
 int readdir(ByteBuffer path, FUSEFillDir filler, long offset, FUSEFileInfo fi)
           Read directory.
 
Methods inherited from class org.catacombae.jfuse.FUSE26FileSystemAdapter
access, bmap, chmod, chown, create, destroy, fgetattr, flush, fsync, fsyncdir, ftruncate, getdir, getFUSECapabilities, getxattr_BSD, getxattr, init, link, listxattr, lock, mkdir, mknod, opendir, readlink, release, releasedir, removexattr, rename, rmdir, setxattr_BSD, setxattr, statfs, symlink, truncate, unlink, utime, utimens, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HelloFS

public HelloFS()
Method Detail

getattr

public int getattr(ByteBuffer path,
                   Stat stbuf)
Description copied from interface: FUSE26Operations
 Get file attributes.

 Similar to stat().  The 'st_dev' and 'st_blksize' fields are
 ignored.  The 'st_ino' field is ignored except if the 'use_ino'
 mount option is given.
 

Specified by:
getattr in interface FUSE26Operations
Overrides:
getattr in class FUSE26FileSystemAdapter
Parameters:
path - (const char*)
stbuf - (struct stat*)
Returns:
0 if successful or an inverted error value from FUSEErrorValues otherwise.

readdir

public int readdir(ByteBuffer path,
                   FUSEFillDir filler,
                   long offset,
                   FUSEFileInfo fi)
Description copied from interface: FUSE26Operations
 Read directory.

 This supersedes the old getdir() interface.  New applications
 should use this.

 The filesystem may choose between two modes of operation:

 1) The readdir implementation ignores the offset parameter, and
 passes zero to the filler function's offset.  The filler
 function will not return '1' (unless an error happens), so the
 whole directory is read in a single readdir operation.  This
 works just like the old getdir() method.

 2) The readdir implementation keeps track of the offsets of the
 directory entries.  It uses the offset parameter and always
 passes non-zero offset to the filler function.  When the buffer
 is full (or an error happens) the filler function will return
 '1'.

 Introduced in version 2.3
 

Specified by:
readdir in interface FUSE26Operations
Overrides:
readdir in class FUSE26FileSystemAdapter
Parameters:
path - (const char*)
filler - (fuse_fill_dir_t)
offset - (off_t)
fi - (struct fuse_file_info*)
Returns:
0 if successful or an inverted error value from FUSEErrorValues otherwise.

open

public int open(ByteBuffer path,
                FUSEFileInfo fi)
Description copied from interface: FUSE26Operations
 File open operation.

 No creation, or truncation flags (O_CREAT, O_EXCL, O_TRUNC)
 will be passed to open().  Open should check if the operation
 is permitted for the given flags.  Optionally open may also
 return an arbitrary filehandle in the fuse_file_info structure,
 which will be passed to all file operations.

 Changed in version 2.2
 

Specified by:
open in interface FUSE26Operations
Overrides:
open in class FUSE26FileSystemAdapter
Parameters:
path - (const char*) the path to the file system node on which the operation is to be applied.
fi - (struct fuse_file_info*)
Returns:
0 if successful or an inverted error value from FUSEErrorValues otherwise.

read

public int read(ByteBuffer path,
                ByteBuffer buf,
                long offset,
                FUSEFileInfo fi)
Description copied from interface: FUSE26Operations
 Read data from an open file.

 Read should return exactly the number of bytes requested except
 on EOF or error, otherwise the rest of the data will be
 substituted with zeroes.  An exception to this is when the
 'direct_io' mount option is specified, in which case the return
 value of the read system call will reflect the return value of
 this operation.

 Changed in version 2.2
 

Specified by:
read in interface FUSE26Operations
Overrides:
read in class FUSE26FileSystemAdapter
Parameters:
path - (const char*) a path to the file to read from.
buf - (char*) the destination buffer.
offset - (off_t) offset in file to start reading.
fi - (struct fuse_file_info*) file info.
Returns:
the number of bytes read (a positive number) if the operation completed successfully, or a negated value from FUSEErrorValues if an error occurred.
Typical error return values for read:

main

public static void main(String[] args)