Module: HrrRbLxns
- Includes:
- Constants
- Defined in:
- lib/hrr_rb_lxns.rb,
lib/hrr_rb_lxns/files.rb,
lib/hrr_rb_lxns/version.rb,
lib/hrr_rb_lxns/files/file.rb,
ext/hrr_rb_lxns/hrr_rb_lxns.c
Overview
Utilities working with Linux namespaces for CRuby.
Defined Under Namespace
Modules: Constants Classes: Files
Constant Summary collapse
- VERSION =
"0.3.1"- @@namespaces =
Hash.new
Constants included from Constants
Constants::BOOTTIME, Constants::MONOTONIC, Constants::NEWCGROUP, Constants::NEWIPC, Constants::NEWNET, Constants::NEWNS, Constants::NEWPID, Constants::NEWTIME, Constants::NEWUSER, Constants::NEWUTS
Class Method Summary collapse
-
.__setns__(fd, nstype) ⇒ Integer
A primitive wrapper around setns(2) system call.
-
.__unshare__(flags) ⇒ Integer
A primitive wrapper around unshare(2) system call.
-
.files(pid = "self") ⇒ HrrRbLxns::Files
Collects namespace files information in /proc/PID/ns/ directory of a process.
-
.setns(flags, pid, options = {}) ⇒ Integer
A wrapper around setns(2) system call.
-
.unshare(flags, options = {}) ⇒ Integer?
A wrapper around unshare(2) system call.
Class Method Details
.__setns__(fd, nstype) ⇒ Integer
A primitive wrapper around setns(2) system call. Associates the caller with the corresponding namespace of the given fd.
64 65 66 67 68 69 70 71 |
# File 'ext/hrr_rb_lxns/hrr_rb_lxns.c', line 64 VALUE hrr_rb_lxns_setns(VALUE self, VALUE fd, VALUE nstype) { if (setns(NUM2INT(fd), NUM2INT(nstype)) < 0) rb_sys_fail("setns"); return INT2FIX(0); } |
.__unshare__(flags) ⇒ Integer
A primitive wrapper around unshare(2) system call. Disassociates parts of the caller process's execution context.
32 33 34 35 36 37 38 39 |
# File 'ext/hrr_rb_lxns/hrr_rb_lxns.c', line 32 VALUE hrr_rb_lxns_unshare(VALUE self, VALUE flags) { if (unshare(NUM2INT(flags)) < 0) rb_sys_fail("unshare"); return INT2FIX(0); } |
.files(pid = "self") ⇒ HrrRbLxns::Files
Collects namespace files information in /proc/PID/ns/ directory of a process.
34 35 36 |
# File 'lib/hrr_rb_lxns.rb', line 34 def self.files pid="self" Files.new pid end |
.setns(flags, pid, options = {}) ⇒ Integer
A wrapper around setns(2) system call.
142 143 144 145 146 147 |
# File 'lib/hrr_rb_lxns.rb', line 142 def self.setns flags, pid, ={} _flags = interpret_flags flags nstype_file_h = get_nstype_file_h _flags, pid, do_setns nstype_file_h return 0 end |
.unshare(flags, options = {}) ⇒ Integer?
A wrapper around unshare(2) system call.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/hrr_rb_lxns.rb', line 81 def self.unshare flags, ={} _flags = interpret_flags flags bind_ns_files_from_child(_flags, ) do ret = nil map_uid_gid_from_child(_flags, ) do ret = __unshare__ _flags set_timens_offsets(_flags, ) end if fork?() ret = fork end ret end end |