line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl -w |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package BoxBackup::Config::DiskSets; |
4
|
1
|
|
|
1
|
|
3535
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
5
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
47
|
|
6
|
1
|
|
|
1
|
|
926
|
use Config::Scoped; |
|
1
|
|
|
|
|
119534
|
|
|
1
|
|
|
|
|
17
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
BoxBackup::Config::DiskSets - Access to Box Backup diskset config files |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use BoxBackup::Config::DiskSets; |
15
|
|
|
|
|
|
|
$diskSets = BoxBackup::Config::DiskSets->new(); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
or |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use BoxBackup::Config::DiskSets; |
20
|
|
|
|
|
|
|
$file = "/etc/bbox/raidfile.conf"; |
21
|
|
|
|
|
|
|
$diskSets = BoxBackup::Config::DiskSets->new($file); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
@diskNames = $diskSets->getListofDisks(); |
24
|
|
|
|
|
|
|
foreach $i (@diskNames) |
25
|
|
|
|
|
|
|
{ |
26
|
|
|
|
|
|
|
print "Block size of " . $i . " is " . $disksets->getParamVal($i, "BlockSize) . " bytes.\n"; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 ABSTRACT |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
BoxBackup::Config::DiskSets is a rather simple package that lets the user |
32
|
|
|
|
|
|
|
have access to the data from the disk set configuration file for |
33
|
|
|
|
|
|
|
Box Backup. It provides methods to retrieve the data only. No creation |
34
|
|
|
|
|
|
|
or editing is supported. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 REQUIRES |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
L. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 DESCRIPTION |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Allows for programmatic access to the information stored in the Box |
43
|
|
|
|
|
|
|
Backup 'disk set' config file, which holds the information related to |
44
|
|
|
|
|
|
|
each disk set in the Box Backup installation. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 Methods |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=over |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=item * |
51
|
|
|
|
|
|
|
new(). The new() method parses the disksets file given as the first (and only) |
52
|
|
|
|
|
|
|
parameter, or, if no parameter is given, parses /etc/box/raidfile.conf, and |
53
|
|
|
|
|
|
|
creates the object. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=item * |
56
|
|
|
|
|
|
|
getListofDisks(). The getListofDisks() method returns an array of the names of all the disk sets |
57
|
|
|
|
|
|
|
found in the config file. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=item * |
60
|
|
|
|
|
|
|
getParamVal(). The getParamVal() method returns the value of a paramter for a given disk. |
61
|
|
|
|
|
|
|
2 paramters are passed to this method |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=over |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=item * |
66
|
|
|
|
|
|
|
disk. This diskset for which the parameter should be retrieved. Normally |
67
|
|
|
|
|
|
|
'disc0' or 'disc1', although anything is possible. Use getListofDisks() to |
68
|
|
|
|
|
|
|
retrieve the names from the file. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item * |
71
|
|
|
|
|
|
|
parameter. The parameter you wish to retrieve from the config file, for a |
72
|
|
|
|
|
|
|
given disk (see above). Currently, the following parameters are available |
73
|
|
|
|
|
|
|
in the file: |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=over |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=item - |
78
|
|
|
|
|
|
|
SetNumber. This is the disk set number, that's used in the accounts config file. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=item - |
81
|
|
|
|
|
|
|
BlockSize. The size of the data blocks used on this diskset. Measured in bytes. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item - |
84
|
|
|
|
|
|
|
Dir0. The first of the RAID drives. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item - |
87
|
|
|
|
|
|
|
Dir1. The second RAID drive. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=item - |
90
|
|
|
|
|
|
|
Dir2. The third RAID drive. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=back |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=back |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=back |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 AUTHOR |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Per Reedtz Thomsen (L) |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
our $VERSION = v0.03; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub new |
107
|
|
|
|
|
|
|
{ |
108
|
1
|
|
|
1
|
1
|
16
|
my ($self, @args) = @_; |
109
|
1
|
|
50
|
|
|
5
|
my $disksetFile = $args[0] || "/etc/box/raidfile.conf"; |
110
|
|
|
|
|
|
|
|
111
|
1
|
|
|
|
|
13
|
my $parser = Config::Scoped->new( file => $disksetFile ); |
112
|
|
|
|
|
|
|
|
113
|
1
|
|
|
|
|
2321
|
$self = $parser->parse; |
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
return bless $self; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub getListofDisks |
121
|
|
|
|
|
|
|
{ |
122
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
# Return an array of disk names from $self. |
125
|
0
|
|
|
|
|
|
return keys %$self; |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub getParamVal |
130
|
|
|
|
|
|
|
{ |
131
|
0
|
|
|
0
|
1
|
|
my ($self, $disk, $parm) = @_; |
132
|
0
|
0
|
0
|
|
|
|
return 0 if(!defined($disk) || !defined($parm)); |
133
|
|
|
|
|
|
|
|
134
|
0
|
0
|
|
|
|
|
return -1 if(!defined($self->{$disk}{$parm})); |
135
|
|
|
|
|
|
|
|
136
|
0
|
|
|
|
|
|
return $self->{$disk}{$parm}; |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
1; |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
|