[dahdi-commits] tzafrir: branch tools/tzafrir/perl-sysstate r7719 - in /tools/team/tzafrir/pe...
SVN commits to the DAHDI project
dahdi-commits at lists.digium.com
Mon Dec 21 16:41:09 CST 2009
Author: tzafrir
Date: Mon Dec 21 16:41:08 2009
New Revision: 7719
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=7719
Log:
Optionally get the root from DAHDI_VIRT_TOP; Fix propcfs handling
* Set up variables in Dahdi.pm to access /proc files.
* They are initialized when Dahdi::set_virt_base() is run.
* Convert all remaining usage of /proc files to the new variables.
* Set the root in Dahdi::spans() .
Modified:
tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi.pm
tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi/Xpp/Xbus.pm
Modified: tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi.pm
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi.pm?view=diff&rev=7719&r1=7718&r2=7719
==============================================================================
--- tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi.pm (original)
+++ tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi.pm Mon Dec 21 16:41:08 2009
@@ -32,7 +32,26 @@
}
=cut
-my $proc_base = "/proc/dahdi";
+our $virt_base;
+our $proc_dahdi_base;
+our $proc_xpp_base;
+
+# Initializes procfs and sysfs system root. Should be called before
+# any of those variables are used.
+#
+# Other modules should use e.g. $Dahdi::proc_dahdi_base instead of
+# '/proc/dahdi' directly.
+sub set_virt_base() {
+ return if defined $virt_base;
+
+ if (exists $ENV{DAHDI_VIRT_TOP}) {
+ $virt_base = $ENV{DAHDI_VIRT_TOP};
+ } else {
+ $virt_base = '';
+ }
+ $proc_dahdi_base = "$virt_base/proc/dahdi";
+ $proc_xpp_base = "$virt_base/proc/xpp";
+}
=head1 spans()
@@ -43,15 +62,23 @@
sub spans() {
my @spans;
- -d $proc_base or return ();
- foreach my $zfile (glob "$proc_base/*") {
- next unless ($zfile =~ m{^$proc_base/\d+$});
+ set_virt_base();
+ -d $proc_dahdi_base or return ();
+ foreach my $zfile (glob "$proc_dahdi_base/*") {
+ next unless ($zfile =~ m{^$proc_dahdi_base/\d+$});
my $span = Dahdi::Span->new($zfile);
push(@spans, $span);
}
@spans = sort { $a->num <=> $b->num } @spans;
return @spans;
}
+
+=head1 ENVIRONMENT
+
+If C<DAHDI_VIRT_TOP> is set in the environment, it will be considered
+as a path to a directory that holds a dump (copy) of all the required
+files from /proc and /sys . You can generate that directory using the
+script C<build_tools/dump_sys_state> .
=head1 SEE ALSO
Modified: tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi/Xpp/Xbus.pm
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi/Xpp/Xbus.pm?view=diff&rev=7719&r1=7718&r2=7719
==============================================================================
--- tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi/Xpp/Xbus.pm (original)
+++ tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi/Xpp/Xbus.pm Mon Dec 21 16:41:08 2009
@@ -12,8 +12,6 @@
use Dahdi::Hardware;
use Dahdi::Xpp::Xpd;
-my $proc_base = "/proc/xpp";
-
sub xpds($) {
my $xbus = shift;
return @{$xbus->{XPDS}};
@@ -54,7 +52,7 @@
foreach my $attr (@attr) {
my $file = sprintf "$Dahdi::Xpp::sysfs_astribanks/xbus-%02d/$attr", $busnum;
unless(-f $file) {
- my $procfile = sprintf "/proc/xpp/XBUS-%02d/$attr", $busnum;
+ my $procfile = sprintf "$Dahdi::proc_xpp_base/XBUS-%02d/$attr", $busnum;
warn "$0: warning - OLD DRIVER: missing '$file'. Fall back to '$procfile'\n"
unless $file_warned{$attr}++;
$file = $procfile;
@@ -113,7 +111,7 @@
sub read_xpdnames_old($) {
my $xbus_num = shift || die;
- my $pat = sprintf "/proc/xpp/XBUS-%02d/XPD-[0-9][0-9]", $xbus_num;
+ my $pat = sprintf "$Dahdi::proc_xpp_base/XBUS-%02d/XPD-[0-9][0-9]", $xbus_num;
my @xpdnames;
#print STDERR "read_xpdnames_old($xbus_num): $pat\n";
@@ -175,7 +173,7 @@
}
foreach my $xpdstr (@xpdnames) {
my ($busnum, $unit, $subunit) = split(/:/, $xpdstr);
- my $procdir = "/proc/xpp/XBUS-$busnum/XPD-$unit$subunit";
+ my $procdir = "$Dahdi::proc_xpp_base/XBUS-$busnum/XPD-$unit$subunit";
my $xpd = Dahdi::Xpp::Xpd->new($self, $unit, $subunit, $procdir, "$xbus_dir/$xpdstr");
push(@xpds, $xpd);
}
More information about the dahdi-commits
mailing list