Class: FFI::Libfuse::FuseContext

Inherits:
Struct
  • Object
show all
Includes:
Accessors
Defined in:
lib/ffi/libfuse/fuse_context.rb

Overview

Context for each callback operation

See Also:

Constant Summary collapse

DEFAULT_CONTEXT =
{ uid: Process.uid, gid: Process.gid, umask: File.umask }.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Accessors

#ffi_attr_fill, #ffi_attr_reader_member, #ffi_attr_writer_member, #fill, #inspect, #to_h

Methods included from Accessors::ClassMethods

#attr_accessor, #attr_reader, #attr_writer, #ffi_attr_accessor, #ffi_attr_reader, #ffi_attr_reader_method, #ffi_attr_readers, #ffi_attr_writer, #ffi_attr_writer_method, #ffi_attr_writers, #ffi_bitflag_accessor, #ffi_bitflag_reader, #ffi_bitflag_writer, #ffi_public_attr_readers, #ffi_public_attr_writers

Instance Attribute Details

#gidInteger (readonly)

Returns group id of the calling process.

Returns:

  • (Integer)

    group id of the calling process



# File 'lib/ffi/libfuse/fuse_context.rb', line 37

#pidInteger (readonly)

Returns process id of the calling thread.

Returns:

  • (Integer)

    process id of the calling thread



# File 'lib/ffi/libfuse/fuse_context.rb', line 40

#private_dataObject (readonly)

Returns private filesystem data.

Returns:

  • (Object)

    private filesystem data

See Also:



# File 'lib/ffi/libfuse/fuse_context.rb', line 43

#uidInteger (readonly)

Returns user id of the calling process.

Returns:

  • (Integer)

    user id of the calling process



# File 'lib/ffi/libfuse/fuse_context.rb', line 34

#umaskInteger

Writable only for Fuse version < 28

Returns:

  • (Integer)

    umask of the calling process



47
48
49
# File 'lib/ffi/libfuse/fuse_context.rb', line 47

def umask
  @umask ||= File.umask
end

Class Method Details

.fuse_get_contextFuseContext Also known as: get

Note:

if called outside a fuse callback the native FFI::Libfuse::FuseContext will have invalid values. See overrides

Returns the context for the current filesystem operation.

Returns:

  • (FuseContext)

    the context for the current filesystem operation



96
97
98
# File 'lib/ffi/libfuse/fuse_context.rb', line 96

def fuse_get_context
  Libfuse.fuse_get_context
end

.overrides(hash) { ... } ⇒ Object .overridesHash

Overloads:

  • .overrides(hash) { ... } ⇒ Object

    @param[Hash<Symbol,Object|nil] hash a list of override values that will apply to this context

    If not set uid, gid, umask will be overridden from the current process, which is useful if FFI::Libfuse::FuseContext is referenced from outside of a fuse callback

    Yields:

    • [] executes block with the given hash overriding FuseContext values

    Returns:

    • (Object)

      the result of the block

  • .overridesHash

    Returns current thread local overrides for FuseContext.

    Returns:

    • (Hash)

      current thread local overrides for FuseContext



83
84
85
86
87
88
89
90
91
92
# File 'lib/ffi/libfuse/fuse_context.rb', line 83

def overrides(hash = nil)
  return Thread.current[:fuse_context_overrides] ||= {} unless block_given?

  begin
    Thread.current[:fuse_context_overrides] = hash || DEFAULT_CONTEXT
    yield
  ensure
    Thread.current[:fuse_context_overrides] = nil
  end
end

Instance Method Details

#interrupted?Boolean

Returns:

  • (Boolean)

See Also:



54
55
56
# File 'lib/ffi/libfuse/fuse_context.rb', line 54

def interrupted?
  Libfuse.fuse_interrupted?
end

#mask(perms) ⇒ Object

Returns perms adjusted by #umask.

Parameters:

  • perms (Integer)

Returns:



67
68
69
# File 'lib/ffi/libfuse/fuse_context.rb', line 67

def mask(perms)
  perms & ~umask
end

#raise_interruptvoid

This method returns an undefined value.

Raises:

  • (Errno::EINTR)

See Also:



61
62
63
# File 'lib/ffi/libfuse/fuse_context.rb', line 61

def raise_interrupt
  Libfuse.raise_interrupt
end