Module: SeccompTools::Const::Syscall
- Defined in:
- lib/seccomp-tools/const.rb
Overview
Define syscall numbers for all architectures. Since the list is too long, split it to files in consts/*.rb and load them in this module.
Class Method Summary collapse
-
.const_missing(cons) ⇒ {Symbol => Integer}
To dynamically fetch constants from files.
-
.load_args ⇒ {Symbol => Array<String>}
Helper for loading syscall prototypes from generated sys_arg.rb.
-
.load_const(cons) ⇒ {Symbol => Integer}?
Load from file and define const value.
Class Method Details
.const_missing(cons) ⇒ {Symbol => Integer}
To dynamically fetch constants from files.
164 165 166 |
# File 'lib/seccomp-tools/const.rb', line 164 def const_missing(cons) load_const(cons) || super end |
.load_args ⇒ {Symbol => Array<String>}
Helper for loading syscall prototypes from generated sys_arg.rb.
187 188 189 190 191 192 193 194 195 |
# File 'lib/seccomp-tools/const.rb', line 187 def load_args hash = instance_eval(File.read(File.join(__dir__, 'consts', 'sys_arg.rb'))) Hash.new do |_h, k| next hash[k] if hash[k] next hash[k.to_s[4..].to_sym] if k.to_s.start_with?('x32_') nil end end |
.load_const(cons) ⇒ {Symbol => Integer}?
Load from file and define const value.
174 175 176 177 178 179 180 |
# File 'lib/seccomp-tools/const.rb', line 174 def load_const(cons) arch = cons.to_s.downcase filename = File.join(__dir__, 'consts', 'sys_nr', "#{arch}.rb") return unless File.exist?(filename) const_set(cons, instance_eval(File.read(filename))) end |