Class: HaveAPI::Fs::Components::RemoteControlFile
- Inherits:
-
File
show all
- Defined in:
- lib/haveapi/fs/components/remote_control_file.rb
Overview
This file serves as an IPC between the file system and outer processes,
mainly executables from the file system itself.
It does not behave like a regular file, it's more like a local socket.
The process opens the file, writes a message with a command and then reads
a message with a response.
Messages are formatted in YAML and separated by MSG_DELIMITER.
Defined Under Namespace
Classes: FileHandle
Constant Summary
collapse
- MSG_DELIMITER =
"\nMSG_OVER\n"
Instance Attribute Summary
#atime, #context, #ctime, #mtime
Instance Method Summary
collapse
-
#raw_close(path, handle = nil) ⇒ Object
-
#raw_open(path, mode, rfusefs = nil) ⇒ Object
-
#raw_read(path, offset, size, handle = nil) ⇒ Object
-
#raw_sync(path, datasync, handle = nil) ⇒ Object
-
#raw_truncate(path, offset, handle = nil) ⇒ Object
-
#raw_write(path, offset, size, buf, handle = nil) ⇒ Object
-
#size ⇒ Object
-
#writable? ⇒ Boolean
Methods inherited from File
#file?, #read, #write
#abspath, #bound=, #bound?, children_reader, component, #contents, #directory?, #executable?, #file?, #find, inherited, #initialize, #invalid?, #invalidate, #parent, #path, #readable?, #reset, #setup, #times, #title, #unsaved?, #use
Instance Method Details
#raw_close(path, handle = nil) ⇒ Object
88
89
90
|
# File 'lib/haveapi/fs/components/remote_control_file.rb', line 88
def raw_close(path, handle = nil)
nil
end
|
#raw_open(path, mode, rfusefs = nil) ⇒ Object
52
53
54
|
# File 'lib/haveapi/fs/components/remote_control_file.rb', line 52
def raw_open(path, mode, rfusefs = nil)
FileHandle.new
end
|
#raw_read(path, offset, size, handle = nil) ⇒ Object
56
57
58
|
# File 'lib/haveapi/fs/components/remote_control_file.rb', line 56
def raw_read(path, offset, size, handle = nil)
handle.read(offset, size)
end
|
#raw_sync(path, datasync, handle = nil) ⇒ Object
80
81
82
|
# File 'lib/haveapi/fs/components/remote_control_file.rb', line 80
def raw_sync(path, datasync, handle = nil)
nil
end
|
#raw_truncate(path, offset, handle = nil) ⇒ Object
84
85
86
|
# File 'lib/haveapi/fs/components/remote_control_file.rb', line 84
def raw_truncate(path, offset, handle = nil)
true
end
|
#raw_write(path, offset, size, buf, handle = nil) ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/haveapi/fs/components/remote_control_file.rb', line 60
def raw_write(path, offset, size, buf, handle = nil)
handle.write(offset, size, buf)
if handle.complete?
cmd = handle.parse
case cmd[:action]
when :execute
ret = HaveAPI::Fs::RemoteControl.execute(context, cmd[:path])
else
raise Errno::EIO, "unsupported action '#{cmd[:action]}'"
end
handle.read_buf = YAML.dump(ret)
end
size
end
|
#size ⇒ Object
47
48
49
50
|
# File 'lib/haveapi/fs/components/remote_control_file.rb', line 47
def size
4096
end
|
#writable? ⇒ Boolean
43
44
45
|
# File 'lib/haveapi/fs/components/remote_control_file.rb', line 43
def writable?
true
end
|