Module: FFI::Libfuse::Adapter::Safe
- Included in:
- Debug
- Defined in:
- lib/ffi/libfuse/adapter/safe.rb
Overview
Safe callbacks convert return values into integer responses, and rescues errors
Class Method Summary collapse
-
.safe_callback(fuse_method, *args, default_errno: Errno::ENOTRECOVERABLE::Errno) ⇒ nil, Integer
Process the result of yielding to the fuse callback to provide a safe return value to libfuse.
Instance Method Summary collapse
-
#default_errno ⇒ Integer
The default errno to return for rescued errors.
Class Method Details
.safe_callback(fuse_method, *args, default_errno: Errno::ENOTRECOVERABLE::Errno) ⇒ nil, Integer
Process the result of yielding to the fuse callback to provide a safe return value to libfuse
For callbacks in FuseOperations::VOID_RETURN
- the return value and any unexpected errors raised are ignored
For callbacks in FuseOperations::MEANINGFUL_RETURN
- should raise appropriate
Errno
error for expected errors (egErrno::ENOENT
) - must return a value convertable to an integer (via :to_i) - either a positive meaningful value or a negative errno value which will be returned directly
- otherwise default_errno is returned
For remaining path callbacks
- should raise appropriate
Errno
error for expected errors (egErrno::ENOENT
) - may return a negative Integer (equivalent to raising the corresponding
SystemCallError
) - any other value returned is considered success and 0 is returned
- unexpected errors raised are rescued and default_errno is returned
63 64 65 66 67 68 69 70 71 |
# File 'lib/ffi/libfuse/adapter/safe.rb', line 63 def safe_callback(fuse_method, *args, default_errno: Errno::ENOTRECOVERABLE::Errno) if FuseOperations::MEANINGFUL_RETURN.include?(fuse_method) safe_meaningful_integer_callback(fuse_method, *args, default_errno: default_errno) elsif FuseOperations::VOID_RETURN.include?(fuse_method) safe_void_callback(fuse_method, *args) else safe_integer_callback(fuse_method, *args, default_errno: default_errno) end end |
Instance Method Details
#default_errno ⇒ Integer
Returns the default errno to return for rescued errors. ENOTRECOVERABLE unless overridden.
30 31 32 |
# File 'lib/ffi/libfuse/adapter/safe.rb', line 30 def default_errno defined?(super) ? super : Errno::ENOTRECOVERABLE::Errno end |