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
-
.by_name(hash) ⇒ {Symbol => Object}
hash, looked up so that an +x32_+-prefixed name falls back to the unprefixed one and an unknown name givesnil. -
.const_missing(cons) ⇒ {Symbol => Integer}
To dynamically fetch constants from files.
-
.load_arg_bits ⇒ {Symbol => Array<Integer>}
Helper for loading syscall argument widths from generated sys_arg.rb.
-
.load_args ⇒ {Symbol => Array<String>}
Helper for loading syscall argument names from generated sys_arg.rb.
-
.load_const(cons) ⇒ {Symbol => Integer}?
Load from file and define const value.
-
.prototypes ⇒ {Symbol => {Symbol => Integer}}
The prototypes in sys_arg.rb, as syscall name to an ordered
{argument name => bits}.
Class Method Details
.by_name(hash) ⇒ {Symbol => Object}
hash, looked up so that an +x32_+-prefixed name falls back to the unprefixed one and an
unknown name gives nil.
210 211 212 213 214 215 216 217 |
# File 'lib/seccomp-tools/const.rb', line 210 def by_name(hash) 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 |
.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_arg_bits ⇒ {Symbol => Array<Integer>}
Helper for loading syscall argument widths from generated sys_arg.rb.
196 197 198 |
# File 'lib/seccomp-tools/const.rb', line 196 def load_arg_bits by_name(prototypes.transform_values(&:values)) end |
.load_args ⇒ {Symbol => Array<String>}
Helper for loading syscall argument names from generated sys_arg.rb.
187 188 189 |
# File 'lib/seccomp-tools/const.rb', line 187 def load_args by_name(prototypes.transform_values { |args| args.keys.map(&:to_s) }) 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 |
.prototypes ⇒ {Symbol => {Symbol => Integer}}
The prototypes in sys_arg.rb, as syscall name to an ordered {argument name => bits}.
202 203 204 |
# File 'lib/seccomp-tools/const.rb', line 202 def prototypes @prototypes ||= instance_eval(File.read(File.join(__dir__, 'consts', 'sys_arg.rb'))) end |