- All Known Subinterfaces:
FuseOperationsDecorator
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault intCheck file access permissions.default intChange the permission bits of a filedefault intChange the owner and group of a filedefault intCreate and open a file.default voiddestroy()Clean up filesystemerrno()The error constants used by this file system.default intAllocates space for an open file.default intPerform BSD file locking operation.default intPossibly flush cached data.default intSynchronize file contentsdefault intSynchronize directory contentsdefault intGet file attributes.default intgetxattr(String path, String name, ByteBuffer value) Get extended attributesdefault voidinit(FuseConnInfo conn, @Nullable FuseConfig cfg) Initialize filesystemdefault intioctl(String path, int cmd, ByteBuffer arg, FileInfo fi, int flags, @Nullable ByteBuffer data) Ioctldefault intCreate a hard link to a filedefault intlistxattr(String path, ByteBuffer list) List extended attributesdefault intCreate a directory.default intCreate a file node.default intOpen a file.default intOpen directory.default intread(String path, ByteBuffer buf, long count, long offset, FileInfo fi) Read data from an open file.default intRead directory.default intreadlink(String path, ByteBuffer buf, long len) Read the target of a symbolic link.default intRelease an open file.default intreleasedir(@Nullable String path, FileInfo fi) Release directorydefault intremovexattr(String path, String name) Remove extended attributesdefault intRename a filedefault intRemove a directorydefault intsetxattr(String path, String name, ByteBuffer value, int flags) Set extended attributesdefault intGet file system statistics.The supported file system operations.default intCreate a symbolic linkdefault intChange the size of a file.default intRemove a filedefault intChange the access and modification times of a file with nanosecond resolution.default intwrite(String path, ByteBuffer buf, long count, long offset, FileInfo fi) Write data to an open file.
-
Field Details
-
FUSE_READDIR_PLUS
static final int FUSE_READDIR_PLUS"Plus" mode.The kernel wants to prefill the inode cache during readdir. The filesystem may honour this by filling in the attributes and setting
FUSE_FILL_DIR_PLUSfor the filler function. The filesystem may also just ignore this flag completely.- See Also:
-
-
Method Details
-
errno
Errno errno()The error constants used by this file system.- Returns:
- The error codes from
errno.hfor the current platform. - See Also:
-
supportedOperations
Set<FuseOperations.Operation> supportedOperations()The supported file system operations.- Returns:
- The set of supported operations.
-
getattr
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. In that case it is passed to userspace, but libfuse and the kernel will still assign a different inode for internal use (called the "nodeid").
This method doubles as
fgetattrin libfuse2- Parameters:
path- file pathstat- file informationfi- will always benullif the file is not currently open, but may also benullif the file is open.- Returns:
- 0 on success or negated error code (-errno)
-
readlink
Read the target of a symbolic link.- Parameters:
path- file pathbuf- The buffer should be filled with a null terminated string.len- The buffer size (including the terminating null character). If the linkname is too long to fit in the buffer, it should be truncated.- Returns:
- The return value should be 0
-
mknod
Create a file node.This is called for creation of all non-directory, non-symlink nodes. If the filesystem defines a create() method, then for regular files that will be called instead.
- Parameters:
path- file pathmode- file mode and type of node to create (using bitwise OR)rdev- ignored if mode does not containS_IFCHRorS_IFBLK- Returns:
- 0 on success or negated error code (-errno)
-
mkdir
Create a directory.Note that the mode argument may not have the type specification bits set, i.e. S_ISDIR(mode) can be false. To obtain the correct directory type bits use mode|S_IFDIR
- Parameters:
path- file pathmode- file mode (using bitwise OR)- Returns:
- 0 on success or negated error code (-errno)
-
unlink
Remove a file- Parameters:
path- file path- Returns:
- 0 on success or negated error code (-errno)
-
rmdir
Remove a directory- Parameters:
path- file path- Returns:
- 0 on success or negated error code (-errno)
-
symlink
-
rename
Rename a file- Parameters:
oldpath- old file pathnewpath- new file pathflags- may be `RENAME_EXCHANGE` or `RENAME_NOREPLACE`. If RENAME_NOREPLACE is specified, the filesystem must not overwrite *newname* if it exists and return an error instead. If `RENAME_EXCHANGE` is specified, the filesystem must atomically exchange the two files, i.e. both must exist and neither may be deleted.- Returns:
- 0 on success or negated error code (-errno)
-
link
-
chmod
Change the permission bits of a file- Parameters:
path- file pathmode- file mode (using bitwise OR)fi- will always benullif the file is not currently open, but may also benullif the file is open.- Returns:
- 0 on success or negated error code (-errno)
-
chown
Change the owner and group of a file- Parameters:
path- file pathuid- user idgid- group idfi- will always benullif the file is not currently open, but may also benullif the file is open.- Returns:
- 0 on success or negated error code (-errno)
-
truncate
Change the size of a file.Unless FUSE_CAP_HANDLE_KILLPRIV is disabled, this method is expected to reset the setuid and setgid bits.
This method doubles as
ftruncatein libfuse2- Parameters:
path- file pathsize- new size of the filefi- will always benullif the file is not currently open, but may also benullif the file is open.- Returns:
- 0 on success or negated error code (-errno)
-
open
Open a file.Open flags are available in fi->flags. The following rules apply.
- Creation (O_CREAT, O_EXCL, O_NOCTTY) flags will be filtered out / handled by the kernel.
- Access modes (O_RDONLY, O_WRONLY, O_RDWR, O_EXEC, O_SEARCH) should be used by the filesystem to check if the operation is permitted. If the ``-o default_permissions`` mount option is given, this check is already done by the kernel before calling open() and may thus be omitted by the filesystem.
- When writeback caching is enabled, the kernel may send read requests even for files opened with O_WRONLY. Thefilesystem should be prepared to handle this.
- When writeback caching is disabled, the filesystem is expected to properly handle the O_APPEND flag and ensurethat each write is appending to the end of the file.
- When writeback caching is enabled, the kernel will handle O_APPEND. However, unless all changes to the file come through the kernel this will not work reliably. The filesystem should thus either ignore the O_APPEND flag (and let the kernel handle it), or return an error (indicating that reliably O_APPEND is not available).
fi->fh, and use this in other all other file operations (read, write, flush, release, fsync).Filesystem may also implement stateless file I/O and not store anything in
fi->fh.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 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 `fuse_conn_info.capable`, this is treated as success and future calls to open will also succeed without being send to the filesystem process.
- Parameters:
path- file pathfi- file info, which may be used to store a file handle- Returns:
- 0 on success or negated error code (-errno)
-
read
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.
- Parameters:
path- file pathbuf- the buffer to read intocount- number of bytes to readoffset- position in the file to start readingfi- file info- Returns:
- number of bytes read or negated error code (-errno)
-
write
Write data to an open file.Write should return exactly the number of bytes requested except on error. An exception to this is when the 'direct_io' mount option is specified (see read operation).
Unless FUSE_CAP_HANDLE_KILLPRIV is disabled, this method is expected to reset the setuid and setgid bits.
- Parameters:
path- file pathbuf- the buffer containing the data to be writtencount- number of bytes to writeoffset- position in the file to write tofi- file info- Returns:
- number of bytes written or negated error code (-errno)
-
statfs
Get file system statistics.The 'f_favail', 'f_fsid' and 'f_flag' fields are ignored
- Parameters:
path- file path of any file within the file systemstatvfs- The statistics object to be filled with data- Returns:
- 0 on success or negated error code (-errno)
-
flush
Possibly flush cached data.BIG NOTE: This is not equivalent to fsync(). It's not a request to sync dirty data.
Flush is called on each close() of a file descriptor, as opposed to release which is called on the close of the last file descriptor for a file. Under Linux, errors returned by flush() will be passed to userspace as errors from close(), so flush() is a good place to write back any cached dirty data. However, many applications ignore errors on close(), and on non-Linux systems, close() may succeed even if flush() returns an error. For these reasons, filesystems should not assume that errors returned by flush will ever be noticed or even delivered.
NOTE: The flush() method may be called more than once for each open(). This happens if more than one file descriptor refers to an open file handle, e.g. due to dup(), dup2() or fork() calls. It is not possible to determine if a flush is final, so each flush should be treated equally. Multiple write-flush sequences are relatively rare, so this shouldn't be a problem.
Filesystems shouldn't assume that flush will be called at any particular point. It may be called more times than expected, or not at all.
- Parameters:
path- file pathfi- file info- Returns:
- 0 on success or negated error code (-errno)
-
release
Release an open file.Release is called when there are no more references to an open file: all file descriptors are closed and all memory mappings are unmapped.
For every open() call there will be exactly one release() call with the same flags and file handle. It is possible to have a file opened more than once, in which case only the last release will mean, that no more reads/writes will happen on the file. The return value of release is ignored.
- Parameters:
path- file pathfi- file info- Returns:
- 0 on success or negated error code (-errno)
-
fsync
-
setxattr
Set extended attributes- Parameters:
path- file pathname- attribute namevalue- attribute valueflags- defaults to zero, which creates or replaces the attribute. For fine-grained atomic control,XATTR_CREATEorXATTR_REPLACEmay be used.- Returns:
- 0 on success or negated error code (-errno)
-
getxattr
Get extended attributes- Parameters:
path- file pathname- attribute namevalue- attribute value. If buffer capacity is zero, return the size of the value- Returns:
- the non-negative value size or negated error code (-errno)
-
listxattr
List extended attributes- Parameters:
path- file pathlist- consecutive list of null-terminated attribute names (as many as fit into the buffer). If buffer capacity is zero, return the size of the list- Returns:
- the non-negative number of bytes written to the list buffer or negated error code (-errno)
-
removexattr
-
opendir
Open directory.Unless the 'default_permissions' mount option is given, this method should check if opendir is permitted for this directory. Optionally opendir may also return an arbitrary
filehandle in the fuse_file_info structure, which will be passed to readdir, releasedir and fsyncdir.- Parameters:
path- directory pathfi- file info, which may be used to store a file handle- Returns:
- 0 on success or negated error code (-errno)
-
readdir
Read directory.The filesystem may choose between two modes of operation:
- 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.
- 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'.
- Parameters:
path- directory pathfiller- the fill functionoffset- the offsetfi- file infoflags- WhenFUSE_READDIR_PLUSis not set, only some parameters of the fill function (thefillerparameter) are actually used: The file type (which is part ofStat.getMode()) is used. And if fuse_config::use_ino is set, the inode (stat::st_ino) is also used. The other fields are ignored whenREAD_DIR_PLUSis not set.- Returns:
- 0 on success or negated error code (-errno)
-
releasedir
-
fsyncdir
Synchronize directory contents- Parameters:
path- directory path. If the directory has been removed after the call to opendir, the path parameter will benulldatasync- if non-zero, then only the user data should be flushed, not the meta datafi- file info- Returns:
- 0 on success or negated error code (-errno)
-
init
Initialize filesystem- Parameters:
conn- FUSE connection informationcfg- FUSE configuration object
-
destroy
default void destroy()Clean up filesystemCalled on filesystem exit.
-
access
Check file access permissions.This will be called for the access() system call. If the 'default_permissions' mount option is given, this method is not called.
This method is not called under Linux kernel versions 2.4.x
- Parameters:
path- file pathmask- bitwise OR of file access checks- Returns:
- 0 on success or negated error code (-errno)
-
create
Create and open a file.If the file does not exist, first create it with the specified mode, and then open it.
If this method is not implemented or under Linux kernel versions earlier than 2.6.15, the mknod() and open() methods will be called instead.
- Parameters:
path- file pathmode- mode used to create the file if it does not exist yetfi- file info, which may be used to store a file handle- Returns:
- 0 on success or negated error code (-errno)
-
utimens
Change the access and modification times of a file with nanosecond resolution.This supersedes the old utime() interface. New applications should use this.
See the utimensat(2) man page for details.
- Parameters:
path- file pathatime- last access timemtime- last modified timefi- will always benullif the file is not currently open, but may also benullif the file is open.- Returns:
- 0 on success or negated error code (-errno)
-
ioctl
default int ioctl(String path, int cmd, ByteBuffer arg, FileInfo fi, int flags, @Nullable @Nullable ByteBuffer data) Ioctlflags will have FUSE_IOCTL_COMPAT set for 32bit ioctls in 64bit environment. The size and direction of data is determined by _IOC_*() decoding of cmd. For _IOC_NONE, data will be NULL, for _IOC_WRITE data is out area, for _IOC_READ in area and if both are set in/out area. In all non-NULL cases, the area is of _IOC_SIZE(cmd) bytes.
Note: the unsigned long request submitted by the application is truncated to 32 bits.
- Parameters:
path- file pathcmd- the requestarg- any argumentsfi- file infoflags- if containing FUSE_IOCTL_DIR then thefirefers to a directory file handle.data- data (depends oncmdand may benull)- Returns:
- 0 on success or negated error code (-errno)
-
flock
Perform BSD file locking operation.The op argument will be either LOCK_SH, LOCK_EX or LOCK_UN
Nonblocking requests will be indicated by ORing LOCK_NB to the above operations
For more information see the flock(2) manual page.
Additionally fi->owner will be set to a value unique to this open file. This same value will be supplied to ->release() when the file is released.
Note: if this method is not implemented, the kernel will still allow file locking to work locally. Hence it is only interesting for network filesystems and similar.
- Parameters:
path- file pathfi- file infoop- one ofLOCK_SH,LOCK_EXorLOCK_UN- Returns:
- 0 on success or negated error code (-errno)
-
fallocate
Allocates space for an open file.This function ensures that required space is allocated for specified file. If this function returns success then any subsequent write request to specified range is guaranteed not to fail because of lack of space on the file system media.
- Parameters:
path- file pathmode- the operation to be performedoffset- start of the allocated regionlength- number of bytes to allocate in this filefi- file info- Returns:
- 0 on success or negated error code (-errno)
-