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
|
|
3141
|
use strict; |
|
10
|
|
|
|
|
10
|
|
|
10
|
|
|
|
|
229
|
|
11
|
10
|
|
|
10
|
|
28
|
use warnings; |
|
10
|
|
|
|
|
11
|
|
|
10
|
|
|
|
|
186
|
|
12
|
|
|
|
|
|
|
|
13
|
10
|
|
|
10
|
|
32
|
use Filesys::POSIX::Bits; |
|
10
|
|
|
|
|
9
|
|
|
10
|
|
|
|
|
2296
|
|
14
|
10
|
|
|
10
|
|
40
|
use Filesys::POSIX::Path (); |
|
10
|
|
|
|
|
6
|
|
|
10
|
|
|
|
|
135
|
|
15
|
10
|
|
|
10
|
|
2982
|
use Filesys::POSIX::Real::Inode (); |
|
10
|
|
|
|
|
13
|
|
|
10
|
|
|
|
|
157
|
|
16
|
10
|
|
|
10
|
|
3057
|
use Filesys::POSIX::Real::Directory (); |
|
10
|
|
|
|
|
18
|
|
|
10
|
|
|
|
|
168
|
|
17
|
10
|
|
|
10
|
|
41
|
use Filesys::POSIX::Error qw(throw); |
|
10
|
|
|
|
|
13
|
|
|
10
|
|
|
|
|
1293
|
|
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
|
3013067
|
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
|
|
|
|
47
|
my $path = $data{'path'} or throw &Errno::EINVAL; |
136
|
|
|
|
|
|
|
|
137
|
10
|
|
|
|
|
117
|
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
|
|
|
|
|
28
|
$self->{'flags'} = \%data; |
142
|
9
|
|
|
|
|
81
|
$self->{'path'} = Filesys::POSIX::Path->full($path); |
143
|
9
|
|
|
|
|
21
|
$self->{'root'} = $root; |
144
|
|
|
|
|
|
|
|
145
|
9
|
|
|
|
|
28
|
return $self; |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
1; |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
__END__ |