Class: FFI::Libfuse::Filesystem::MappedDir
- Inherits:
-
Object
- Object
- FFI::Libfuse::Filesystem::MappedDir
- Includes:
- MappedFiles, Utils
- Defined in:
- lib/ffi/libfuse/filesystem/mapped_dir.rb
Overview
A read-only directory of MappedFiles
Constant Summary
Constants included from MappedFiles
FFI::Libfuse::Filesystem::MappedFiles::HAS_XATTR
Instance Attribute Summary collapse
-
#stat ⇒ Object
Returns the value of attribute stat.
Attributes included from MappedFiles
Fuse Callbacks collapse
-
#getattr(path, stat = nil, _ffi = nil) ⇒ Object
For the root path provides this directory's stat information, otherwise passes on to the next filesystem.
- #mkdir(path, mode, *_args) ⇒ Object
-
#readdir(path, *_args, &block) ⇒ Object
For root path enumerates #entries.
Instance Method Summary collapse
-
#entries ⇒ Enumerable
abstract
Set of entries in this directory (excluding '.' and '..').
-
#initialize(accounting: nil) ⇒ MappedDir
constructor
A new instance of MappedDir.
-
#map_path(path) ⇒ Object
subclass only call super for root path.
-
#method_missing(method, path = nil, *args, &block) ⇒ Object
Passes FUSE Callbacks on to the Top Level Namespace filesystem.
- #respond_to_missing?(method, private = false) ⇒ Boolean
Methods included from Utils
#directory?, #empty_dir?, #empty_file?, #exists?, #file?, #mkdir_p
Methods included from MappedFiles
#create, #getxattr, #listxattr, #open, #read, #read_buf, #stat_mask, #statfs, #truncate, #unlink, #utimens, #write, #write_buf
Constructor Details
#initialize(accounting: nil) ⇒ MappedDir
Returns a new instance of MappedDir.
20 21 22 23 |
# File 'lib/ffi/libfuse/filesystem/mapped_dir.rb', line 20 def initialize(accounting: nil) @accounting = accounting @root = VirtualNode.new(accounting: accounting) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, path = nil, *args, &block) ⇒ Object
Passes FUSE Callbacks on to the Top Level Namespace filesystem
53 54 55 56 57 58 59 |
# File 'lib/ffi/libfuse/filesystem/mapped_dir.rb', line 53 def method_missing(method, path = nil, *args, &block) return @root.public_send(method, path, *args, &block) if @root.respond_to?(method) && root?(path) raise Errno::ENOTSUP if FuseOperations.path_callbacks.include?(method) super end |
Instance Attribute Details
#stat ⇒ Object
Returns the value of attribute stat.
14 15 16 |
# File 'lib/ffi/libfuse/filesystem/mapped_dir.rb', line 14 def stat @stat end |
Instance Method Details
#entries ⇒ Enumerable
Returns set of entries in this directory (excluding '.' and '..').
20 21 22 23 |
# File 'lib/ffi/libfuse/filesystem/mapped_dir.rb', line 20 def initialize(accounting: nil) @accounting = accounting @root = VirtualNode.new(accounting: accounting) end |
#getattr(path, stat = nil, _ffi = nil) ⇒ Object
For the root path provides this directory's stat information, otherwise passes on to the next filesystem
28 29 30 31 32 33 34 |
# File 'lib/ffi/libfuse/filesystem/mapped_dir.rb', line 28 def getattr(path, stat = nil, _ffi = nil) return super unless root?(path) stat&.directory(@root.virtual_stat.merge({ nlink: entries.size + 2 })) self end |
#map_path(path) ⇒ Object
subclass only call super for root path
66 67 68 69 70 |
# File 'lib/ffi/libfuse/filesystem/mapped_dir.rb', line 66 def map_path(path) raise ArgumentError, "map_path received non root path #{path}" unless root?(path) [path, @root] end |
#mkdir(path, mode, *_args) ⇒ Object
44 45 46 47 48 |
# File 'lib/ffi/libfuse/filesystem/mapped_dir.rb', line 44 def mkdir(path, mode, *_args) raise Errno::EROFS unless root?(path) @root.init_node(mode) end |
#readdir(path, *_args, &block) ⇒ Object
For root path enumerates #entries
38 39 40 41 42 |
# File 'lib/ffi/libfuse/filesystem/mapped_dir.rb', line 38 def readdir(path, *_args, &block) raise Errno::ENOTDIR unless root?(path) %w[. ..].concat(entries).each(&block) end |
#respond_to_missing?(method, private = false) ⇒ Boolean
61 62 63 |
# File 'lib/ffi/libfuse/filesystem/mapped_dir.rb', line 61 def respond_to_missing?(method, private = false) (FuseOperations.fuse_callbacks.include?(method) && @root.respond_to?(method, false)) || super end |