POSIX/Real.pm

filter: Statementstmt 100% 31 / 31 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 2 / 2 totaltotal 100% 46 / 46 CC 3 SCAR 4.4
CC
3
Cov
100%
init
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.5
« POSIX/Extensions.pm ↑ Summary POSIX/Inode.pm »
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 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 10 ▶use Filesys::POSIX::Bits;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 10 ▶use Filesys::POSIX::Path ();
Subroutine BEGIN: called CC=1 SCAR=0.0
15 10 ▶use Filesys::POSIX::Real::Inode ();
Subroutine BEGIN: called CC=1 SCAR=0.0
16 10 ▶use Filesys::POSIX::Real::Directory ();
Subroutine BEGIN: called CC=1 SCAR=0.0
17 10 ▶use Filesys::POSIX::Error qw(throw);
Subroutine BEGIN: called CC=1 SCAR=0.0
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<path>
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<sticky>
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-E<gt>chmod>
64  
65 =item C<$fs-E<gt>chown>
66  
67 =item C<$fs-E<gt>symlink>
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<size>
77  
78 =item C<atime>
79  
80 =item C<mtime>
81  
82 =item C<ctime>
83  
84 =back
85  
86 =back
87  
88 =head1 CREATING A NEW FILESYSTEM
89  
90 =over
91  
92 =item C<Filesys::POSIX::Real-E<gt>new>
93  
94 Create a new, uninitialized filesystem.
95  
96 =back
97  
98 =cut
99  
100 11 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
101 11 return bless {}, shift;
102 }
103  
104 =head1 INITIALIAZATION
105  
106 =over
107  
108 =item C<$fs-E<gt>init(%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 11 ▶sub init {
Subroutine init: called CC=3 SCAR=11.0
Pod documented
133 11 my ( $self, %data ) = @_;
134  
135 11 ▶ my $path = $data{'path'} or throw &Errno::EINVAL;
Branch: 1 branch
BranchTrueFalseTotal
my $path = $data{"path"} or &throw(scalar &Errno::EINVAL) 10 1 11
136  
137 10 my $root = Filesys::POSIX::Real::Inode->from_disk( $path, 'dev' => $self );
138  
139 10 ▶ throw &Errno::ENOTDIR unless $root->dir;
Branch: 1 branch
BranchTrueFalseTotal
unless $root->dir 1 9 10
140  
141 9 $self->{'flags'} = \%data;
142 9 $self->{'path'} = Filesys::POSIX::Path->full($path);
143 9 $self->{'root'} = $root;
144  
145 9 return $self;
146 }
147  
148 10 1;
149  
150 __END__
« POSIX/Extensions.pm ↑ Summary POSIX/Inode.pm »