line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Eixo::Zone::Driver; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
44381
|
use 5.014002; |
|
1
|
|
|
|
|
3
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
521
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
require XSLoader; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
XSLoader::load('Eixo::Zone::Driver', $VERSION); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# this is actually a very bad idea, we should define them using /usr/include/linux/sched.h defs |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
0
|
|
0
|
sub CLONE_NEWUTS { 0x04000000 } |
20
|
0
|
|
|
0
|
|
0
|
sub CLONE_NEWIPC { 0x08000000 } |
21
|
0
|
|
|
0
|
|
0
|
sub CLONE_NEWUSER { 0x10000000 } |
22
|
1
|
|
|
1
|
|
16
|
sub CLONE_NEWPID { 0x20000000 } |
23
|
0
|
|
|
0
|
|
0
|
sub CLONE_NEWNET { 0x40000000 } |
24
|
0
|
|
|
0
|
|
0
|
sub CLONE_IO { 0x80000000 } |
25
|
0
|
|
|
0
|
|
0
|
sub CLONE_NEWFS { 0x00000200 } |
26
|
0
|
|
|
0
|
|
0
|
sub CLONE_NEWNS { 0x00020000 } |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my %ERRORS = ( |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1 => ['EPERM', ''], |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
9 => ['EBADF'], |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
12 => ['ENOMEM'], |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
22 => ['EINVAL', ''], |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# |
41
|
|
|
|
|
|
|
# low level functions' wrappers |
42
|
|
|
|
|
|
|
# |
43
|
|
|
|
|
|
|
sub setns{ |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
0
|
|
0
|
my ($self, $fd, $ns_type, $f_error) = @_; |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
0
|
my $file_handle; |
48
|
|
|
|
|
|
|
|
49
|
0
|
0
|
|
|
|
0
|
if(ref($fd)){ |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
0
|
$file_handle = $fd; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
else{ |
54
|
|
|
|
|
|
|
|
55
|
0
|
0
|
|
|
|
0
|
open($file_handle, $fd) || return $f_error->("ERROR opening filehandle " . $!); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
0
|
my $status = mi_setns($file_handle, $ns_type); |
59
|
|
|
|
|
|
|
|
60
|
0
|
0
|
|
|
|
0
|
if($status == 0){ |
61
|
0
|
|
|
|
|
0
|
return 1; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
$f_error->( |
65
|
|
|
|
|
|
|
|
66
|
0
|
0
|
|
|
|
0
|
@{$ERRORS{$status} || []} |
|
0
|
|
|
|
|
0
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub getPid{ |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
0
|
|
0
|
mi_getpid(); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub clone{ |
78
|
1
|
|
|
1
|
|
2
|
my ($self, $sub, $flags) = @_; |
79
|
|
|
|
|
|
|
|
80
|
1
|
|
|
|
|
2
|
my $pid = 0; |
81
|
|
|
|
|
|
|
|
82
|
1
|
|
|
|
|
100
|
my $ret = mi_clone($sub, 0, $flags, \$pid); |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
$ret; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub unshare{ |
89
|
0
|
|
|
0
|
|
|
my ($self, $flags, $f_error) = @_; |
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
my $status = mi_unshare($flags); |
92
|
|
|
|
|
|
|
|
93
|
0
|
0
|
|
|
|
|
if($status == 0){ |
94
|
0
|
|
|
|
|
|
return 1; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
$f_error->( |
98
|
|
|
|
|
|
|
|
99
|
0
|
0
|
|
|
|
|
@{$ERRORS{$status} || []} |
|
0
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub caps{ |
105
|
|
|
|
|
|
|
|
106
|
0
|
|
|
0
|
|
|
my $text = mi_caps(); |
107
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
$text =~ s/^\s*\=//; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
my %caps = map { |
111
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
$_ => 1 |
|
0
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
} split(/\s*\,\s*/, $text); |
115
|
|
|
|
|
|
|
|
116
|
0
|
0
|
|
|
|
|
wantarray ? %caps : \%caps; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
1; |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
__END__ |