line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sys::Linux::Mount; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
5
|
1
|
|
|
1
|
|
4
|
use Carp qw/croak/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
122
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
8
|
|
|
|
|
|
|
our @ISA = qw/Exporter/; |
9
|
|
|
|
|
|
|
require XSLoader; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
XSLoader::load(); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my @mount_consts = qw/MS_RDONLY MS_NOSUID MS_NODEV MS_NOEXEC MS_SYNCHRONOUS MS_REMOUNT MS_MANDLOCK MS_DIRSYNC MS_NOATIME MS_NODIRATIME MS_BIND MS_MOVE MS_REC MS_SILENT MS_POSIXACL MS_UNBINDABLE MS_PRIVATE MS_SLAVE MS_SHARED MS_RELATIME MS_KERNMOUNT MS_I_VERSION MS_STRICTATIME MS_LAZYTIME MS_ACTIVE MS_NOUSER MS_MGC_VAL/; |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
|
|
351
|
use constant {MS_RDONLY => 1, |
16
|
|
|
|
|
|
|
MS_NOSUID => 2, |
17
|
|
|
|
|
|
|
MS_NODEV => 4, |
18
|
|
|
|
|
|
|
MS_NOEXEC => 8, |
19
|
|
|
|
|
|
|
MS_SYNCHRONOUS => 16, |
20
|
|
|
|
|
|
|
MS_REMOUNT => 32, |
21
|
|
|
|
|
|
|
MS_MANDLOCK => 64, |
22
|
|
|
|
|
|
|
MS_DIRSYNC => 128, |
23
|
|
|
|
|
|
|
MS_NOATIME => 1024, |
24
|
|
|
|
|
|
|
MS_NODIRATIME => 2048, |
25
|
|
|
|
|
|
|
MS_BIND => 4096, |
26
|
|
|
|
|
|
|
MS_MOVE => 8192, |
27
|
|
|
|
|
|
|
MS_REC => 16384, |
28
|
|
|
|
|
|
|
MS_SILENT => 32768, |
29
|
|
|
|
|
|
|
MS_POSIXACL => 1 << 16, |
30
|
|
|
|
|
|
|
MS_UNBINDABLE => 1 << 17, |
31
|
|
|
|
|
|
|
MS_PRIVATE => 1 << 18, |
32
|
|
|
|
|
|
|
MS_SLAVE => 1 << 19, |
33
|
|
|
|
|
|
|
MS_SHARED => 1 << 20, |
34
|
|
|
|
|
|
|
MS_RELATIME => 1 << 21, |
35
|
|
|
|
|
|
|
MS_KERNMOUNT => 1 << 22, |
36
|
|
|
|
|
|
|
MS_I_VERSION => 1 << 23, |
37
|
|
|
|
|
|
|
MS_STRICTATIME => 1 << 24, |
38
|
|
|
|
|
|
|
MS_LAZYTIME => 1 << 25, |
39
|
|
|
|
|
|
|
MS_ACTIVE => 1 << 30, |
40
|
|
|
|
|
|
|
MS_NOUSER => 1 << 31, |
41
|
|
|
|
|
|
|
MS_MGC_VAL => 0xc0ed0000 # /* Magic flag number to indicate "new" flags */ |
42
|
1
|
|
|
1
|
|
6
|
}; |
|
1
|
|
|
|
|
2
|
|
43
|
|
|
|
|
|
|
our @EXPORT_OK = (@mount_consts, qw/mount umount/); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
46
|
|
|
|
|
|
|
'consts' => \@mount_consts, |
47
|
|
|
|
|
|
|
'all' => [@mount_consts, qw/mount umount/], |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub mount { |
51
|
0
|
|
|
0
|
0
|
|
my ($source, $target, $filesystem, $flags, $options_hr) = @_; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
my $options_str = ""; |
54
|
0
|
0
|
|
|
|
|
if ($options_hr) { |
55
|
0
|
|
|
|
|
|
$options_str = join ',', map {"$_=".$options_hr->{$_}} keys %$options_hr; |
|
0
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
0
|
|
|
|
my $ret = _mount_sys($source//"", $target//"", $filesystem//"", $flags//0xc0ed0000, $options_str); |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
0
|
0
|
|
|
|
|
if ($ret != 0) { |
61
|
0
|
|
|
|
|
|
croak "mount failed: $ret $!"; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
return 1; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub umount { |
68
|
0
|
|
|
0
|
0
|
|
my ($target) = @_; |
69
|
|
|
|
|
|
|
|
70
|
0
|
0
|
|
|
|
|
croak "No argument given to umount()" unless $target; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
my $ret = _umount_sys($target); |
73
|
0
|
|
|
|
|
|
return 1; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |