Class: FFI::Libfuse::FuseOperations
- Inherits:
-
Struct
- Object
- Struct
- FFI::Libfuse::FuseOperations
- Includes:
- FuseCallbacks
- Defined in:
- lib/ffi/libfuse/fuse_operations.rb
Overview
Constant Summary collapse
- VOID_RETURN =
Callbacks that have no return value
%i[init destroy].freeze
- MEANINGFUL_RETURN =
Callbacks that are expected to return meaningful positive integers
%i[read write write_buf lseek copy_file_range getxattr listxattr].freeze
FUSE Callbacks collapse
-
#access(path, mode) ⇒ Integer
abstract
Check file access permissions.
-
#bmap(path, blocksize, index) ⇒ Integer
abstract
Map block index within file to block index within device.
-
#chmod(path, mode, fuse_file_info = nil) ⇒ Integer
abstract
Change the permission bits of a file.
-
#chown(path, uid, gid, fuse_file_info = nil) ⇒ Integer
abstract
Change the owner and group of a file.
-
#copy_file_range(path_in, fi_in, offset_in, path_out, fi_out, offset_out, size, flags) ⇒ Integer
abstract
Copy a range of data from one file to another.
-
#create(path, mode, fuse_file_info) ⇒ Integer
abstract
Create and open a file.
-
#destroy(obj) ⇒ Object
abstract
Clean up filesystem.
-
#fallocate(path, mode, offset, len, fuse_file_info) ⇒ Object
abstract
Allocates space for an open file.
-
#fgetattr(path, stat, fuse_file_info) ⇒ Integer
deprecated
Deprecated.
in Fuse3 implement #getattr instead
-
#flock(path, fuse_file_info, op) ⇒ Object
abstract
Perform BSD file locking operation.
-
#flush(path, fuse_file_info) ⇒ Integer
Possibly flush cached data.
-
#fsync(path, datasync, fuse_file_info) ⇒ Integer
Synchronize file contents.
-
#fsyncdir(path, datasync, fuse_file_info) ⇒ Integer
Synchronize directory contents.
-
#ftruncate(path, offset, fuse_file_info) ⇒ Integer
abstract
deprecated
Deprecated.
in Fuse3 implement #truncate instead
-
#fuse_flags ⇒ Array<Symbol>
abstract
deprecated
Deprecated.
in Fuse3 use fuse_config object in #init
-
#getattr(path, stat, fuse_file_info = nil) ⇒ Integer
abstract
Get file attributes.
-
#getdir ⇒ Object
deprecated
Deprecated.
use #readdir instead
-
#getxattr(path, name, buf, size) ⇒ Integer
abstract
Get extended attributes.
-
#init(fuse_conn_info, fuse_config = nil) ⇒ Object
abstract
Initialize filesystem.
-
#initialize(fuse_wrappers: [], fuse_flags: [], delegate: self) ⇒ FuseOperations
constructor
Build a FuseOperations struct and register callback methods.
-
#ioctl(path, cmd, arg, fuse_file_info, flags, data) ⇒ Object
abstract
Ioctl The size and direction of data is determined by IOC*() decoding of cmd.
-
#link(target, path) ⇒ Integer
abstract
Create a hard link to a file.
-
#listxattr(path, buf, size) ⇒ Integer
abstract
List extended attributes.
-
#lock(path, fuse_file_info, cmd, flock) ⇒ Integer
abstract
Perform POSIX file locking operation For :f_getlk operation, the library will first check currently held locks, and if a conflicting lock is found it will return information without calling this method.
-
#lseek(path, offset, whence, fuse_file_info) ⇒ Integer
abstract
Find next data or hole after the specified offset.
-
#mkdir(path, mode) ⇒ Integer
abstract
Create a directory.
-
#mknod(path, mode, dev) ⇒ Integer
Create a file node.
-
#open(path, fuse_file_info) ⇒ Integer
abstract
File open operation.
-
#opendir(path, fuse_file_info) ⇒ Object
abstract
Open directory.
-
#poll(path, fuse_file_info, ph, reventsp) ⇒ Integer
abstract
Poll for IO readiness events.
-
#read(path, buf, size, offset, fuse_file_info) ⇒ Integer
abstract
Read data from an open file.
-
#read_buf(path, bufp, size, offset, fuse_file_info) ⇒ Object
abstract
Similar to the #read method, but data is stored and returned in a generic buffer.
-
#readdir(path, buffer, filler, offset, fuse_file_info, fuse_readdir_flag = 0) ⇒ Integer
abstract
Read directory.
-
#readlink(path, target_buffer, buffer_size) ⇒ Integer
abstract
Resolve the target of a symbolic link.
-
#release(path, fuse_file_info) ⇒ Integer
Release an open file.
-
#releasedir(path, fuse_file_info) ⇒ Integer
Release directory.
-
#removexattr(path, name) ⇒ Integer
abstract
Remove extended attributes.
-
#rename(from_path, to_path) ⇒ Integer
abstract
Rename a file.
-
#rmdir(path) ⇒ Integer
abstract
Remove a directory.
-
#setxattr(path, name, data, size, flags) ⇒ Integer
abstract
Set extended attributes.
-
#statfs(path, statvfs) ⇒ Integer
abstract
Get file system statistics.
-
#symlink(target, path) ⇒ Integer
abstract
Create a symbolic link.
-
#truncate(path, offset, fuse_file_info = nil) ⇒ Integer
abstract
Change the size of a file.
-
#unlink(path) ⇒ Integer
abstract
Remove a file.
-
#utimens(path, time_specs, fuse_file_info = nil) ⇒ Integer
abstract
Change the access and modification times of a file with nanosecond resolution.
-
#write(path, data, size, offset, fuse_file_info) ⇒ Integer
abstract
Write data to an open file.
-
#write_buf(path, buf, offset, fuse_file_info) ⇒ Integer
abstract
Write contents of buffer to an open file.
Class Method Summary collapse
-
.fuse_callbacks ⇒ Set<Symbol>
List of callback methods.
-
.meaningful_return?(fuse_callback) ⇒ Boolean
True if fuse_callback expects a meaningful integer return.
-
.path_arg_methods(fuse_callback) ⇒ Symbol
Helper to determine how to handle the path argument for a path callback.
-
.path_callbacks ⇒ Set<Symbol>
List of path callback methods.
-
.void_return?(fuse_callback) ⇒ Boolean
True if fuse_callback expects a void return.
Methods included from FuseCallbacks
#fuse_respond_to?, #fuse_wrappers
Methods included from Callbacks
Constructor Details
#initialize(fuse_wrappers: [], fuse_flags: [], delegate: self) ⇒ FuseOperations
Returns a new instance of FuseOperations.
938 939 940 941 942 943 944 945 946 947 948 |
# File 'lib/ffi/libfuse/fuse_operations.rb', line 938 def initialize(*args, fuse_wrappers: [], fuse_flags: [], delegate: self) super(*args) # FFI::Struct constructor return if args.any? # only configure if this is a new allocation initialize_callbacks(wrappers: fuse_wrappers, delegate: delegate) return unless FUSE_MAJOR_VERSION < 3 fuse_flags.concat(delegate.fuse_flags) if delegate.respond_to?(:fuse_flags) send(:[]=, :flags, fuse_flags.uniq) end |
Class Method Details
.fuse_callbacks ⇒ Set<Symbol>
Returns list of callback methods.
107 108 109 |
# File 'lib/ffi/libfuse/fuse_operations.rb', line 107 def fuse_callbacks @fuse_callbacks ||= Set.new(members - [:flags]) end |
.meaningful_return?(fuse_callback) ⇒ Boolean
Returns true if fuse_callback expects a meaningful integer return.
77 78 79 |
# File 'lib/ffi/libfuse/fuse_operations.rb', line 77 def meaningful_return?(fuse_callback) MEANINGFUL_RETURN.include?(fuse_callback) end |
.path_arg_methods(fuse_callback) ⇒ Symbol
Helper to determine how to handle the path argument for a path callback
102 103 104 |
# File 'lib/ffi/libfuse/fuse_operations.rb', line 102 def path_arg_methods(fuse_callback) CALLBACK_PATH_ARG_METHODS[fuse_callback] end |
.path_callbacks ⇒ Set<Symbol>
Returns list of path callback methods.
112 113 114 |
# File 'lib/ffi/libfuse/fuse_operations.rb', line 112 def path_callbacks @path_callbacks ||= fuse_callbacks - VOID_RETURN end |
.void_return?(fuse_callback) ⇒ Boolean
Returns true if fuse_callback expects a void return.
82 83 84 |
# File 'lib/ffi/libfuse/fuse_operations.rb', line 82 def void_return?(fuse_callback) VOID_RETURN.include?(fuse_callback) end |
Instance Method Details
#access(path, mode) ⇒ Integer
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
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 565
|
#bmap(path, blocksize, index) ⇒ Integer
This makes sense only for block device backed filesystem mounted with the 'blkdev' option
Map block index within file to block index within device
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 683
|
#chmod(path, mode, fuse_file_info = nil) ⇒ Integer
Change the permission bits of a file
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 247
|
#chown(path, uid, gid, fuse_file_info = nil) ⇒ Integer
Change the owner and group of a file
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 260
|
#copy_file_range(path_in, fi_in, offset_in, path_out, fi_out, offset_out, size, flags) ⇒ Integer
Copy a range of data from one file to another
Performs an optimized copy between two file descriptors without the additional cost of transferring data through the FUSE kernel module to user space (glibc) and then back into the FUSE filesystem again.
In case this method is not implemented, glibc falls back to reading data from the source and writing to the destination. Effectively doing an inefficient copy of the data.
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 862
|
#create(path, mode, fuse_file_info) ⇒ Integer
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.
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 582
|
#destroy(obj) ⇒ Object
Clean up filesystem. Called on filesystem exit.
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 554
|
#fallocate(path, mode, offset, len, fuse_file_info) ⇒ Object
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.
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 835
|
#fgetattr(path, stat, fuse_file_info) ⇒ Integer
in Fuse3 implement #getattr instead
Get attributes from an open file
This method is called instead of the getattr() method if the file information is available.
Currently this is only called after the create() method if that is implemented (see above). Later it may be called for invocations of fstat() too.
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 618
|
#flock(path, fuse_file_info, op) ⇒ Object
Perform BSD file locking operation
@note: if this method is not implemented, the kernel will still allow file locking to work locally. Hence it is only interesting for network filesystem and similar.
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 815
|
#flush(path, fuse_file_info) ⇒ Integer
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. So if a filesystem wants to return write errors in close() and the file has cached dirty data, this is a good place to write back data and return any errors. Since many applications ignore close() errors this is not always useful.
NOTE: The flush() method may be called more than once for each open(). This happens if more than one file descriptor refers to an opened file 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 always be called after some writes, or that if will be called at all.
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 361
|
#fsync(path, datasync, fuse_file_info) ⇒ Integer
Synchronize file contents
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 404
|
#fsyncdir(path, datasync, fuse_file_info) ⇒ Integer
Synchronize directory contents
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 522
|
#ftruncate(path, offset, fuse_file_info) ⇒ Integer
in Fuse3 implement #truncate instead
Change the size of an open file
This method is called instead of the truncate() method if the truncation was invoked from an ftruncate() system call.
If this method is not implemented or under Linux kernel versions earlier than 2.6.15, the truncate() method will be called instead.
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 599
|
#fuse_flags ⇒ Array<Symbol>
in Fuse3 use fuse_config object in #init
Not available in Fuse3
Configuration method to set fuse flags
- :nullpath_ok
Flag indicating that the filesystem can accept a NULL path as the first argument for the following operations: read, write, flush, release, fsync, readdir, releasedir, fsyncdir, ftruncate, fgetattr, lock, ioctl and poll
If this flag is set these operations continue to work on unlinked files even if "-ohard_remove" option was specified.
- :nopath
Flag indicating that the path need not be calculated for the following operations: read, write, flush, release, fsync, readdir, releasedir, fsyncdir, ftruncate, fgetattr, lock, ioctl and poll
Closely related to flag_nullpath_ok, but if this flag is set then the path will not be calculaged even if the file wasn't unlinked. However the path can still be non-NULL if it needs to be calculated for some other reason.
- :utime_omit_ok
Flag indicating that the filesystem accepts special UTIME_NOW and UTIME_OMIT values in its utimens operation.
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 698
|
#getattr(path, stat, fuse_file_info = nil) ⇒ Integer
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.
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 127
|
#getdir ⇒ Object
use #readdir instead
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 161
|
#getxattr(path, name, buf, size) ⇒ Integer
Get extended attributes
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 430
|
#init(fuse_conn_info, fuse_config = nil) ⇒ Object
Initialize filesystem
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 533
|
#ioctl(path, cmd, arg, fuse_file_info, flags, data) ⇒ Object
Ioctl 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.
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 734
|
#link(target, path) ⇒ Integer
Create a hard link to a file
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 236
|
#listxattr(path, buf, size) ⇒ Integer
List extended attributes
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 443
|
#lock(path, fuse_file_info, cmd, flock) ⇒ Integer
if this method is not implemented, the kernel will still allow file locking to work locally. Hence it
Perform POSIX file locking operation For :f_getlk operation, the library will first check currently held locks, and if a conflicting lock is found it will return information without calling this method. This ensures, that for local locks the pid field is correctly filled in. The results may not be accurate in case of race conditions and in the presence of hard links, but its unlikely that an application would rely on accurate GETLK results in these cases. If a conflicting lock is not found, this method will be called, and the filesystem may fill out l_pid by a meaningful value, or it may leave this field zero.
For :f_setlk and :f_setlkw the pid field will be set to the pid of the process performing the locking operation.
is only interesting for network filesystem and similar.
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 635
|
#lseek(path, offset, whence, fuse_file_info) ⇒ Integer
Find next data or hole after the specified offset
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 893
|
#mkdir(path, mode) ⇒ Integer
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 | Stat::S_IFDIR
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 181
|
#mknod(path, mode, dev) ⇒ Integer
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.
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 167
|
#open(path, fuse_file_info) ⇒ Integer
File open operation
No creation (O_CREAT, O_EXCL) and by default also no truncation (O_TRUNC) flags will be passed to open(). If an application specifies O_TRUNC, fuse first calls truncate() and then open(). Only if 'atomic_o_trunc' has been specified and kernel version is 2.6.24 or later, O_TRUNC is passed on to open.
Unless the 'default_permissions' mount option is given, 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.
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 291
|
#opendir(path, fuse_file_info) ⇒ Object
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.
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 468
|
#poll(path, fuse_file_info, ph, reventsp) ⇒ Integer
Poll for IO readiness events
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 757
|
#read(path, buf, size, offset, fuse_file_info) ⇒ Integer
Read data from an open file
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 313
|
#read_buf(path, bufp, size, offset, fuse_file_info) ⇒ Object
Similar to the #read method, but data is stored and returned in a generic buffer.
No actual copying of data has to take place, the source file descriptor may simply be stored in the buffer for later data transfer.
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 795
|
#readdir(path, buffer, filler, offset, fuse_file_info, fuse_readdir_flag = 0) ⇒ Integer
Read directory
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.
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'.
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 483
|
#readlink(path, target_buffer, buffer_size) ⇒ Integer
Resolve the target of a symbolic link
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 144
|
#release(path, fuse_file_info) ⇒ Integer
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 descriptor. 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.
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 386
|
#releasedir(path, fuse_file_info) ⇒ Integer
Release directory
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 513
|
#removexattr(path, name) ⇒ Integer
Remove extended attributes
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 455
|
#rename(from_path, to_path) ⇒ Integer
Rename a file
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 225
|
#rmdir(path) ⇒ Integer
Remove a directory
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 205
|
#setxattr(path, name, data, size, flags) ⇒ Integer
Set extended attributes
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 416
|
#statfs(path, statvfs) ⇒ Integer
Get file system statistics
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 348
|
#symlink(target, path) ⇒ Integer
Create a symbolic link
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 215
|
#truncate(path, offset, fuse_file_info = nil) ⇒ Integer
Change the size of a file
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 274
|
#unlink(path) ⇒ Integer
Remove a file
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 195
|
#utimens(path, time_specs, fuse_file_info = nil) ⇒ Integer
Change the access and modification times of a file with nanosecond resolution
This supersedes the old utime() interface. New applications should use this.
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 665
|
#write(path, data, size, offset, fuse_file_info) ⇒ Integer
Write data to an open file
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 331
|
#write_buf(path, buf, offset, fuse_file_info) ⇒ Integer
Write contents of buffer to an open file
Similar to the #write method, but data is supplied in a generic buffer. Use FFI::Libfuse::FuseBufVec#copy_to_fd to copy data to an open file descriptor, or FFI::Libfuse::FuseBufVec#copy_to_str to extract string data from the buffer
|
# File 'lib/ffi/libfuse/fuse_operations.rb', line 777
|