lib/ffi/libfuse/fuse_config.rb in ffi-libfuse-0.4.0 vs lib/ffi/libfuse/fuse_config.rb in ffi-libfuse-0.4.1
- old
+ new
@@ -8,11 +8,11 @@
# Configuration of the high-level API
#
# This structure is initialized from the arguments passed to fuse_new(), and then passed to the file system's init()
# handler which should ensure that the configuration is compatible with the file system implementation.
#
- # Some options can only be set via the filesystem init method (use_ino etc..) because the filesystem either
+ # Some options can only be set via the filesystem init method (:use_ino etc..) because the filesystem either
# supports them or it doesn't.
class FuseConfig < FFI::Struct
include FFI::Accessors
spec =
@@ -38,11 +38,11 @@
entry_timeout: :double,
# @!attribute [rw] negative_timeout
# The timeout in seconds for which a negative lookup will be cached.
#
- # This means, that if file did not exist (lookup retuned ENOENT), the lookup will only be redone after the
+ # This means, that if file did not exist (lookup returned ENOENT), the lookup will only be redone after the
# timeout, and the file/directory will be assumed to not exist until then. A value of zero means that
# negative lookups are not cached.
#
# @return [Float]
negative_timeout: :double,
@@ -53,11 +53,11 @@
# (as returned by e.g. the `getattr` handler) are cached.
#
# @return [Float]
attr_timeout: :double,
- # @!attribute [rw] intr
+ # @!attribute [rw] intr?
# Allow requests to be interrupted
# @return [Boolean]
intr: :bool_int,
# @!attribute [rw] intr_signal
@@ -78,11 +78,11 @@
# A number of -1 means that inodes will be remembered for the entire life-time of the file-system process.
#
# @return [Integer]
remember: :int,
- # @!attribute [rw] hard_remove
+ # @!attribute [rw] hard_remove?
# should open files be removed immediately
#
# The default behavior is that if an open file is deleted, the file is renamed to a hidden file
# (.fuse_hiddenXXX), and only removed when the file is finally released. This relieves the filesystem
# implementation of having to deal with this problem. This option disables the hiding behavior, and files are
@@ -93,11 +93,11 @@
# f*xattr(2), ftruncate(2), fstat(2), fchmod(2), fchown(2)
#
# @return [Boolean]
hard_remove: :bool_int,
- # @!attribute [rw] use_ino
+ # @!attribute [rw] use_ino?
# use filesystem provided inode values
#
# Honor the st_ino field in the functions getattr() and fill_dir(). This value is used to fill in the st_ino
# field in the stat(2), lstat(2), fstat(2) functions and the d_ino field in the readdir(2) function. The
# filesystem does not have to guarantee uniqueness, however some applications rely on this value being unique
@@ -107,20 +107,20 @@
# "nodeid").
#
# @return [Boolean]
use_ino: :bool_int,
- # @!attribute [rw] readdir_ino
- # generate inodes for readdir even if {#use_ino} is set
+ # @!attribute [rw] readdir_ino?
+ # generate inodes for readdir even if {#use_ino?} is set
#
# If use_ino option is not given, still try to fill in the d_ino field in readdir(2). If the name was
# previously looked up, and is still in the cache, the inode number found there will be used. Otherwise it
# will be set to -1. If use_ino option is given, this option is ignored.
# @return [Boolean]
readdir_ino: :bool_int,
- # @!attribute [rw] direct_io
+ # @!attribute [rw] direct_io?
# disables the use of kernel page cache (file content cache) in the kernel for this filesystem.
#
# This has several affects:
#
# 1. Each read(2) or write(2) system call will initiate one or more read or write operations, data will not be
@@ -133,25 +133,25 @@
# Internally, enabling this option causes fuse to set {FuseFileInfo#direct_io} overwriting any value that was
# put there by the file system during :open
# @return [Boolean]
direct_io: :bool_int,
- # @!attribute [rw] kernel_cache
+ # @!attribute [rw] kernel_cache?
# disables flushing the cache of the file contents on every open(2).
#
# This should only be enabled on filesystem where the file data is never changed externally (not through the
# mounted FUSE filesystem). Thus it is not suitable for network filesystem and other intermediate filesystem.
#
- # **Note**: if neither this option or {#direct_io} is specified data is still cached after the open(2),
+ # **Note**: if neither this option or {#direct_io?} is specified data is still cached after the open(2),
# so a read(2) system call will not always initiate a read operation.
#
# Internally, enabling this option causes fuse to set {FuseFileInfo#keep_cache} overwriting any value that was
# put there by the file system.
# @return [Boolean]
kernel_cache: :bool_int,
- # @!attribute [rw] auto_cache
+ # @!attribute [rw] auto_cache?
# invalidate cached data on open based on changes in file attributes
#
# This option is an alternative to `kernel_cache`. Instead of unconditionally keeping cached data, the cached
# data is invalidated on open(2) if if the modification time or the size of the file has changed since it was
# last opened.
@@ -163,11 +163,11 @@
# auto_cache should flush the file data on open.
# @return [Float|nil]
ac_attr_timeout_set: :bool_int,
ac_attr_timeout: :double,
- # @!attribute [rw] nullpath_ok
+ # @!attribute [rw] nullpath_ok?
# operations on open files and directories are ok to receive nil paths
#
# If this option is given the file-system handlers for the following operations will not receive path
# information: read, write, flush, release, fsync, readdir, releasedir, fsyncdir, lock, ioctl and poll.
#
@@ -183,23 +183,26 @@
}
layout(spec)
# Find the attrs that have a corresponding setter (prefix set_ or suffix _set
+ # map attr => setter
setters = spec.keys
- .map { |k| [k, k.to_s.sub(/^set_/, '').sub(/_set$/, '').to_sym] }
- .reject { |(s, a)| s == a }.to_h
+ .map { |k| [k.to_s.sub(/^set_/, '').sub(/_set$/, '').to_sym, k] }
+ .reject { |(s, a)| s == a }
+ .to_h
- setters.each do |(setter, attr)|
- ffi_attr_reader(attr) { |val| self[setter] ? val : nil }
+ ffi_attr_reader_method(*setters.keys) do
+ self[setters[__method__]] ? self[__method__] : nil
+ end
- ffi_attr_writer(attr) do |val|
- self[setter] = !val.nil?
- val || 0
- end
+ ffi_attr_writer_method(*setters.keys) do |val|
+ self[setters[__method__]] = !val.nil?
+ self[__method__] = val || 0
end
- remaining = (spec.keys - setters.keys - setters.values).map { |a| spec[a] == :bool_int ? "#{a}?" : a }
- ffi_attr_accessor(*remaining)
+ ffi_attr_reader(:show_help?, :debug?)
+ remaining = (spec.keys - setters.keys - setters.values - %i[show_help modules debug])
+ ffi_attr_accessor(*remaining.map { |a| spec[a] == :bool_int ? "#{a}?" : a })
end
end
end