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
|
8
|
|
|
8
|
|
2783
|
use strict; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
229
|
|
11
|
8
|
|
|
8
|
|
25
|
use warnings; |
|
8
|
|
|
|
|
9
|
|
|
8
|
|
|
|
|
147
|
|
12
|
|
|
|
|
|
|
|
13
|
8
|
|
|
8
|
|
26
|
use Filesys::POSIX::Bits; |
|
8
|
|
|
|
|
8
|
|
|
8
|
|
|
|
|
1894
|
|
14
|
8
|
|
|
8
|
|
39
|
use Filesys::POSIX::Path (); |
|
8
|
|
|
|
|
7
|
|
|
8
|
|
|
|
|
111
|
|
15
|
8
|
|
|
8
|
|
2796
|
use Filesys::POSIX::Real::Inode (); |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
128
|
|
16
|
8
|
|
|
8
|
|
2841
|
use Filesys::POSIX::Real::Directory (); |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
210
|
|
17
|
8
|
|
|
8
|
|
45
|
use Filesys::POSIX::Error qw(throw); |
|
8
|
|
|
|
|
9
|
|
|
8
|
|
|
|
|
1269
|
|
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
|
10
|
|
|
10
|
1
|
3605944
|
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
|
10
|
|
|
10
|
1
|
57
|
my ( $self, %data ) = @_; |
134
|
|
|
|
|
|
|
|
135
|
10
|
100
|
|
|
|
54
|
my $path = $data{'path'} or throw &Errno::EINVAL; |
136
|
|
|
|
|
|
|
|
137
|
9
|
|
|
|
|
138
|
my $root = Filesys::POSIX::Real::Inode->from_disk( $path, 'dev' => $self ); |
138
|
|
|
|
|
|
|
|
139
|
9
|
100
|
|
|
|
96
|
throw &Errno::ENOTDIR unless $root->dir; |
140
|
|
|
|
|
|
|
|
141
|
8
|
|
|
|
|
33
|
$self->{'flags'} = \%data; |
142
|
8
|
|
|
|
|
107
|
$self->{'path'} = Filesys::POSIX::Path->full($path); |
143
|
8
|
|
|
|
|
34
|
$self->{'root'} = $root; |
144
|
|
|
|
|
|
|
|
145
|
8
|
|
|
|
|
31
|
return $self; |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
1; |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
__END__ |