blib/lib/Linux/Setns.pm

filter: Statementstmt 83.3% 25 / 30 Branchbran 58.3% 7 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 77.0% 37 / 48 SCAR 20.4
CC
7
Cov
76%
setns
12.3
BEGIN
1.0
BEGIN
1.0
CRAP 7.7
↑ Summary Setns.xs »
1 package Linux::Setns;
2  
3 1 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 require Exporter;
8  
9 1 our @ISA = qw(Exporter);
10  
11 # Items to export into callers namespace by default. Note: do not export
12 # names by default without a very good reason. Use EXPORT_OK instead.
13 # Do not simply export all your public functions/methods/constants.
14  
15 # This allows declaration use Linux::Setns ':all';
16 # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
17 # will save memory.
18 1 our %EXPORT_TAGS = ( 'all' => [ qw(
19
20 ) ] );
21  
22 1 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
23  
24 1 our @EXPORT = qw(
25 setns CLONE_ALL CLONE_NEWNS CLONE_NEWIPC CLONE_NEWNET CLONE_NEWUTS CLONE_NEWPID CLONE_NEWUSER CLONE_NEWCGROUP
26 );
27  
28 1 our $VERSION = '2.00';
29  
30 use constant {
31 1 CLONE_ALL => 0,
32 CLONE_NEWNS => 0x00020000,
33 CLONE_NEWIPC => 0x08000000,
34 CLONE_NEWNET => 0x40000000,
35 CLONE_NEWUTS => 0x04000000,
36 CLONE_NEWPID => 0x20000000,
37 CLONE_NEWUSER => 0x10000000,
38 CLONE_NEWCGROUP => 0x02000000
39 1 ▶};
Subroutine BEGIN: called CC=1 SCAR=0.0
40  
41 1 require XSLoader;
42 1 XSLoader::load('Linux::Setns', $VERSION);
43  
44 # Preloaded methods go here.
45  
46 sub setns {
47 2 ▶ my $ret = setns_wrapper($_[0], $_[1]);
Subroutine setns: called CC=7 SCAR=25.1
Pod undocumented
48 2 ▶ if ($ret == 0) {
Branch: 6 branches
BranchTrueFalseTotal
if ($ret == 0) { } 0 2 2
elsif ($ret == 1) { } 0 2 2
elsif ($ret == 2) { } 1 1 2
elsif ($ret == 9) { } 0 1 1
elsif ($ret == 12) { } 0 1 1
elsif ($ret == 22) { } 0 1 1
49 0 return 1;
50 } elsif ($ret == 1) {
51 0 print STDERR "Error: setns() The calling thread did not have the required privilege (CAP_SYS_ADMIN) for this operation\n";
52 } elsif ($ret == 2) {
53 1 print STDERR "Error: setns() Unable to open file $_[0]\n";
54 } elsif ($ret == 9) {
55 0 print STDERR "Error: setns() FD is not a valid file descriptor\n";
56 } elsif ($ret == 12) {
57 0 print STDERR "Error: setns() Cannot allocate sufficient memory to change the specified namespace\n";
58 } elsif ($ret == 22) {
59 0 print STDERR "Error: setns() FD refers to a namespace whose type does not match that specified in nstype, or there is problem with reassociating the the thread with the specified namespace\n";
60 }
61 2 return 0;
62 }
63  
64 1 1;
65 __END__
↑ Summary Setns.xs »