Module: FFI::Libfuse::Filesystem::Ruby::VirtualLink
Overview
Filesystem methods representing a symbolic link
Satisfies the contract of Adapter::Ruby
Instance Attribute Summary collapse
Attributes included from VirtualNode
#accounting, #virtual_stat, #virtual_xattr
Instance Method Summary
collapse
#chmod, #chown, #getxattr, #init_node, #listxattr, #statfs, #utimens
Instance Attribute Details
#target ⇒ Object
Returns the value of attribute target.
10
11
12
|
# File 'lib/ffi/libfuse/filesystem/virtual_link.rb', line 10
def target
@target
end
|
Instance Method Details
#getattr(path, stat = nil, _ffi = nil) ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/ffi/libfuse/filesystem/virtual_link.rb', line 42
def getattr(path, stat = nil, _ffi = nil)
raise Errno::ENOENT unless root?(path) && virtual_stat
stat&.symlink(size: @target.length + 1, **virtual_stat)
self
end
|
#initialize(accounting: nil) ⇒ Object
13
14
15
16
|
# File 'lib/ffi/libfuse/filesystem/virtual_link.rb', line 13
def initialize(accounting: nil)
@target = target
super
end
|
#link(_from_path, path) ⇒ Object
29
30
31
32
33
34
|
# File 'lib/ffi/libfuse/filesystem/virtual_link.rb', line 29
def link(_from_path, path)
raise Errno::ENOENT unless root?(path)
raise Errno::EPERM
end
|
#readlink(_path, size) ⇒ Object
18
19
20
|
# File 'lib/ffi/libfuse/filesystem/virtual_link.rb', line 18
def readlink(_path, size)
@target[0, size - 1] end
|
#symlink(from_path, path) ⇒ Object
22
23
24
25
26
27
|
# File 'lib/ffi/libfuse/filesystem/virtual_link.rb', line 22
def symlink(from_path, path)
raise Errno::ENOENT unless root?(path)
@target = from_path
init_node(0o777)
end
|
#unlink(path) ⇒ Object
36
37
38
39
40
|
# File 'lib/ffi/libfuse/filesystem/virtual_link.rb', line 36
def unlink(path)
raise Errno::ENOENT unless root?(path)
accounting&.adjust(0, -1)
end
|