line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright (c) 2014, cPanel, Inc. |
2
|
|
|
|
|
|
|
# All rights reserved. |
3
|
|
|
|
|
|
|
# http://cpanel.net/ |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under the same |
6
|
|
|
|
|
|
|
# terms as Perl itself. See the LICENSE file for further details. |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package Filesys::POSIX::Real; |
9
|
|
|
|
|
|
|
|
10
|
10
|
|
|
10
|
|
3181
|
use strict; |
|
10
|
|
|
|
|
11
|
|
|
10
|
|
|
|
|
217
|
|
11
|
10
|
|
|
10
|
|
29
|
use warnings; |
|
10
|
|
|
|
|
11
|
|
|
10
|
|
|
|
|
179
|
|
12
|
|
|
|
|
|
|
|
13
|
10
|
|
|
10
|
|
34
|
use Filesys::POSIX::Bits; |
|
10
|
|
|
|
|
6
|
|
|
10
|
|
|
|
|
2257
|
|
14
|
10
|
|
|
10
|
|
39
|
use Filesys::POSIX::Path (); |
|
10
|
|
|
|
|
6
|
|
|
10
|
|
|
|
|
160
|
|
15
|
10
|
|
|
10
|
|
2962
|
use Filesys::POSIX::Real::Inode (); |
|
10
|
|
|
|
|
11
|
|
|
10
|
|
|
|
|
146
|
|
16
|
10
|
|
|
10
|
|
3040
|
use Filesys::POSIX::Real::Directory (); |
|
10
|
|
|
|
|
17
|
|
|
10
|
|
|
|
|
175
|
|
17
|
10
|
|
|
10
|
|
40
|
use Filesys::POSIX::Error qw(throw); |
|
10
|
|
|
|
|
10
|
|
|
10
|
|
|
|
|
1405
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 NAME |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Filesys::POSIX::Real - Portal to actual underlying filesystem |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SYNOPSIS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
use Filesys::POSIX; |
26
|
|
|
|
|
|
|
use Filesys::POSIX::Real; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $fs = Filesys::POSIX->new(Filesys::POSIX::Real->new, |
29
|
|
|
|
|
|
|
'path' => '/home/foo/test', |
30
|
|
|
|
|
|
|
'noatime' => 1 |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 DESCRIPTION |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
This module implements the filesystem device type which provides a portal to |
36
|
|
|
|
|
|
|
the actual system's underlying filesystem. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 MOUNT OPTIONS |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
The following value is mandatory: |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=over |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=item C |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
The path, in the real filesystem, upon which the new filesystem to be mounted |
47
|
|
|
|
|
|
|
will be based. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=back |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
The following value is not mandatory: |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=over |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=item C |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
When set to a value evaluating to true, any updates to certain attributes of any |
58
|
|
|
|
|
|
|
inode brought to life by this module are not committed to disk. When this flag |
59
|
|
|
|
|
|
|
is used, the following calls only affect the inode in memory, but not on disk: |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=over |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=item C<$fs-Echmod> |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=item C<$fs-Echown> |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=item C<$fs-Esymlink> |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=back |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Furthermore, only the following attributes are synced from disk onto their |
72
|
|
|
|
|
|
|
corresponding memory inodes: |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=over |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=item C |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item C |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=item C |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item C |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=back |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=back |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 CREATING A NEW FILESYSTEM |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=over |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item Cnew> |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Create a new, uninitialized filesystem. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=back |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub new { |
101
|
14
|
|
|
14
|
1
|
3162451
|
return bless {}, shift; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 INITIALIAZATION |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=over |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item C<$fs-Einit(%data)> |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Initializes the new filesystem. A reference to the C<%data> argument is saved |
111
|
|
|
|
|
|
|
in the filesystem object. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Exceptions will be thrown for the following: |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=over |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item * EINVAL (Invalid argument) |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
No value was specified for C<$data{'path'}>. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item * ENOTDIR (Not a directory) |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
The path specified in C<$data{'path'}> on the real filesystem does not |
124
|
|
|
|
|
|
|
correspond to an actual directory. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=back |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=back |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub init { |
133
|
11
|
|
|
11
|
1
|
34
|
my ( $self, %data ) = @_; |
134
|
|
|
|
|
|
|
|
135
|
11
|
100
|
|
|
|
51
|
my $path = $data{'path'} or throw &Errno::EINVAL; |
136
|
|
|
|
|
|
|
|
137
|
10
|
|
|
|
|
122
|
my $root = Filesys::POSIX::Real::Inode->from_disk( $path, 'dev' => $self ); |
138
|
|
|
|
|
|
|
|
139
|
10
|
100
|
|
|
|
67
|
throw &Errno::ENOTDIR unless $root->dir; |
140
|
|
|
|
|
|
|
|
141
|
9
|
|
|
|
|
26
|
$self->{'flags'} = \%data; |
142
|
9
|
|
|
|
|
80
|
$self->{'path'} = Filesys::POSIX::Path->full($path); |
143
|
9
|
|
|
|
|
23
|
$self->{'root'} = $root; |
144
|
|
|
|
|
|
|
|
145
|
9
|
|
|
|
|
29
|
return $self; |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
1; |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
__END__ |