[svn-commits] tzafrir: branch tools/tzafrir/sysfs r8219 - in /tools/team/tzafrir/sysfs: ./ ...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Mar 2 14:10:15 CST 2010


Author: tzafrir
Date: Tue Mar  2 14:10:11 2010
New Revision: 8219

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=8219
Log:
Merged revisions 8215 via svnmerge from 
https://origsvn.digium.com/svn/dahdi/tools/trunk

........
  r8215 | tzafrir | 2010-03-02 20:07:37 +0200 (Tue, 02 Mar 2010) | 11 lines
  
  DAHDI-perl: allow setting base of system files with DAHDI_VIRT_TOP
  
  If the user set DAHDI_VIRT_TOP in the environment, consider it as a path
  under which to look for ProcFS and SysFS files. This allows running the
  DAHDI-perl tools on filesystem dumps generated by
  build_tools/dump_sys_state .
  
  To reduce the number of dependencies between various modules, the 'xpd'
  member of a Dahdi::Span is removed. Dahdi::Xpp::xpd_of_span() can be
  used if needed.
........

Modified:
    tools/team/tzafrir/sysfs/   (props changed)
    tools/team/tzafrir/sysfs/xpp/lsdahdi
    tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi.pm
    tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Hardware/PCI.pm
    tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Hardware/USB.pm
    tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Span.pm
    tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Utils.pm
    tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Xpp.pm
    tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Xpp/Xbus.pm

Propchange: tools/team/tzafrir/sysfs/
------------------------------------------------------------------------------
    automerge = YES

Propchange: tools/team/tzafrir/sysfs/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Mar  2 14:10:11 2010
@@ -1,1 +1,1 @@
-/tools/trunk:1-8213
+/tools/trunk:1-8218

Modified: tools/team/tzafrir/sysfs/xpp/lsdahdi
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/sysfs/xpp/lsdahdi?view=diff&rev=8219&r1=8218&r2=8219
==============================================================================
--- tools/team/tzafrir/sysfs/xpp/lsdahdi (original)
+++ tools/team/tzafrir/sysfs/xpp/lsdahdi Tue Mar  2 14:10:11 2010
@@ -22,7 +22,7 @@
 
 foreach my $span (Dahdi::spans()) {
 	my $spanno = $span->num;
-	my $xpd = $span->xpd;
+	my $xpd = Dahdi::Xpp::xpd_of_span($span);
 	my @lines;
 	my $index = 0;
 

Modified: tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi.pm
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi.pm?view=diff&rev=8219&r1=8218&r2=8219
==============================================================================
--- tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi.pm (original)
+++ tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi.pm Tue Mar  2 14:10:11 2010
@@ -32,8 +32,12 @@
   }
 =cut
 
-my $proc_base = "/proc/dahdi";
-my $sysfs_base = '/sys/class/dahdi_span';
+our $virt_base;
+our $proc_dahdi_base;
+our $proc_xpp_base;
+our $proc_usb_base;
+our $sys_base;
+our $sysfs_span_base;
 
 =head1 spans()
 
@@ -44,14 +48,14 @@
 sub spans() {
 	my @spans;
 
-	if ( -d $sysfs_base) {
-		foreach my $zfile (glob "$sysfs_base/span-*") {
+	if ( -d $sysfs_span_base) {
+		foreach my $zfile (glob "$sysfs_span_base/span-*") {
 			my $span = Dahdi::Span->new($zfile);
 			push(@spans, $span);
 		}
-	} elsif ( -d $proc_base ) {
-		foreach my $zfile (glob "$proc_base/*") {
-			$zfile =~ s:$proc_base/::;
+	} elsif ( -d $proc_dahdi_base ) {
+		foreach my $zfile (glob "$proc_dahdi_base/*") {
+			$zfile =~ s:$proc_dahdi_base/::;
 			next unless ($zfile =~ /^\d+$/);
 			my $span = Dahdi::Span->new_procfs($zfile);
 			push(@spans, $span);
@@ -59,7 +63,6 @@
 	} else {
 		return ();
 	}
-	@spans = sort { $a->num <=> $b->num } @spans;
 	return @spans;
 }
 
@@ -74,6 +77,13 @@
 	return $span;
 }
 
+=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
 
 Span objects: L<Dahdi::Span>.

Modified: tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Hardware/PCI.pm
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Hardware/PCI.pm?view=diff&rev=8219&r1=8218&r2=8219
==============================================================================
--- tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Hardware/PCI.pm (original)
+++ tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Hardware/PCI.pm Tue Mar  2 14:10:11 2010
@@ -170,7 +170,7 @@
 sub scan_devices($) {
 	my @devices;
 
-	while(</sys/bus/pci/devices/*>) {
+	while(<$Dahdi::sys_base/bus/pci/devices/*>) {
 		m,([^/]+)$,,;
 		my $name = $1;
 		my $l = readlink $_ || die;

Modified: tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Hardware/USB.pm
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Hardware/USB.pm?view=diff&rev=8219&r1=8218&r2=8219
==============================================================================
--- tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Hardware/USB.pm (original)
+++ tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Hardware/USB.pm Tue Mar  2 14:10:11 2010
@@ -135,7 +135,7 @@
 	my $pack = shift || die;
 	my @devices = ();
 
-	while (</sys/bus/usb/devices/*-*>) {
+	while (<$Dahdi::sys_base/bus/usb/devices/*-*>) {
 		next unless -r "$_/idVendor"; # endpoints
 
 		# Older kernels, e.g. 2.6.9, don't have the attribute
@@ -165,7 +165,7 @@
 
 sub scan_devices($) {
 	my $pack = shift || die;
-	my $usb_device_list = "/proc/bus/usb/devices";
+	my $usb_device_list = "$Dahdi::proc_usb_base/devices";
 	return $pack->scan_devices_sysfs() unless (-r $usb_device_list);
 
 	my @devices;

Modified: tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Span.pm
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Span.pm?view=diff&rev=8219&r1=8218&r2=8219
==============================================================================
--- tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Span.pm (original)
+++ tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Span.pm Tue Mar  2 14:10:11 2010
@@ -10,7 +10,6 @@
 use strict;
 use Dahdi::Utils;
 use Dahdi::Chans;
-use Dahdi::Xpp::Xpd;
 
 =head1 NAME
 
@@ -112,8 +111,6 @@
 "signalling" is set, look for "SIGNALLING".
 
 =cut
-
-my $proc_base = "/proc/dahdi";
 
 sub chans($) {
 	my $span = shift;
@@ -174,18 +171,6 @@
 	$self->{TYPE} = "${proto}_$self->{TERMTYPE}";
 }
 
-sub _get_span_xpdinfo($) {
-	my $self = shift;
-	$self->{TYPE} = "UNKNOWN";
-	my @xpds = Dahdi::Xpp::Xpd::xpds_by_spanno;
-	my $num = $self->{NUM};
-	my $xpd = $xpds[$num];
-	if(defined $xpd) {
-		die "Spanno mismatch: $xpd->spanno, $num" unless $xpd->spanno == $num;
-		$self->{XPD} = $xpd;
-	}
-}
-
 sub _get_dev_attr($$) {
 	my $self = shift;
 	my $attr = shift;
@@ -212,7 +197,6 @@
 	my $self = { NUM => $num, DEV_DIR => $dev_dir };
 	bless $self, $pack;
 
-	$self->_get_span_xpdinfo();
 	$self->{IS_DIGITAL} = $self->_get_dev_attr('is_digital');
 	$self->{IS_DAHDI_SYNC_MASTER} = $self->_get_dev_attr('is_sync_master');
 	$self->{NAME} = $self->_get_dev_attr('name');
@@ -245,7 +229,8 @@
 	my $num = shift or die "Missing a span number parameter\n";
 	my $self = { NUM => $num };
 	bless $self, $pack;
-	open(F, "$proc_base/$num") or die "Failed to open '$proc_base/$num\n";
+	open(F, "$Dahdi::proc_dahdi_base/$num") or 
+		die "Failed to open '$Dahdi::proc_dahdi_base/$num\n";
 	my $head = <F>;
 	chomp $head;
 	$self->{IS_DIGITAL} = 0;

Modified: tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Utils.pm
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Utils.pm?view=diff&rev=8219&r1=8218&r2=8219
==============================================================================
--- tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Utils.pm (original)
+++ tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Utils.pm Tue Mar  2 14:10:11 2010
@@ -21,6 +21,21 @@
 		#print STDERR "get: $key ($val)\n";
 		return $val;
 	}
+}
+
+# Initialize ProcFS and SysFS pathes, in case the user set
+# DAHDI_VIRT_TOP
+BEGIN {
+	if (exists $ENV{DAHDI_VIRT_TOP}) {
+		$Dahdi::virt_base = $ENV{DAHDI_VIRT_TOP};
+	} else {
+		$Dahdi::virt_base = '';
+	}
+	$Dahdi::proc_dahdi_base = "$Dahdi::virt_base/proc/dahdi";
+	$Dahdi::proc_xpp_base = "$Dahdi::virt_base/proc/xpp";
+	$Dahdi::proc_usb_base = "$Dahdi::virt_base/proc/bus/usb";
+	$Dahdi::sys_base = "$Dahdi::virt_base/sys";
+	$Dahdi::sysfs_span_base = "$Dahdi::sys_base/class/dahdi_span";
 }
 
 sub xpp_dump($) {

Modified: tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Xpp.pm
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Xpp.pm?view=diff&rev=8219&r1=8218&r2=8219
==============================================================================
--- tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Xpp.pm (original)
+++ tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Xpp.pm Tue Mar  2 14:10:11 2010
@@ -34,10 +34,16 @@
 #
 my @xbuses;
 
-my $proc_base = "/proc/xpp";
-our $sysfs_astribanks = "/sys/bus/astribanks/devices";
-our $sysfs_xpds = "/sys/bus/xpds/devices";
-our $sysfs_ab_driver = "/sys/bus/astribanks/drivers/xppdrv";
+our $sysfs_astribanks;
+our $sysfs_xpds;
+our $sysfs_ab_driver;
+
+BEGIN {
+	my $virt_base = $Dahdi::virt_base;
+	$sysfs_astribanks = "$virt_base/sys/bus/astribanks/devices";
+	$sysfs_xpds = "$virt_base/sys/bus/xpds/devices";
+	$sysfs_ab_driver = "$virt_base/sys/bus/astribanks/drivers/xppdrv";
+}
 
 sub scan($) {
 	my $pack = shift || die;
@@ -253,6 +259,7 @@
 	my $result;
 	my $newapi = 0;
 
+	my $proc_base = $Dahdi::proc_xpp_base;
 	my $file = "$proc_base/sync";
 	return '' unless -f $file;
 	# First query

Modified: tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Xpp/Xbus.pm
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Xpp/Xbus.pm?view=diff&rev=8219&r1=8218&r2=8219
==============================================================================
--- tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Xpp/Xbus.pm (original)
+++ tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Xpp/Xbus.pm Tue Mar  2 14:10:11 2010
@@ -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 svn-commits mailing list