/[smeserver]/rpms/e-smith-lib/sme8/e-smith-lib-2.2.0-hwaddr.patch
ViewVC logotype

Contents of /rpms/e-smith-lib/sme8/e-smith-lib-2.2.0-hwaddr.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Fri Feb 5 08:16:59 2010 UTC (14 years, 3 months ago) by dungog
Branch: MAIN
CVS Tags: e-smith-lib-2_2_0-7_el5_sme, e-smith-lib-2_2_0-9_el5_sme, e-smith-lib-2_2_0-10_el5_sme, e-smith-lib-2_2_0-8_el5_sme, e-smith-lib-2_2_0-6_el5_sme, HEAD
* Fri Feb 5 2010 Stephen Noble <support@dungog.net> 2.2.0-6.sme
- adds the hwaddr parameter to probeAdapters() [SME: 4528]

1 --- e-smith-lib-2.2.0/root/usr/lib/perl5/site_perl/esmith/ethernet.pm 2006-10-12 01:14:18.000000000 +1000
2 +++ e-smith-lib-2.2.0/root/usr/lib/perl5/site_perl/esmith/ethernet.pm.new 2010-02-05 18:59:46.000000000 +1100
3 @@ -26,204 +26,6 @@
4
5 This module contains routines for
6
7 -=cut
8 -
9 -#----------------------------------------------------------------------
10 -# Private variables
11 -#----------------------------------------------------------------------
12 -
13 -my %private_pci_network_cards;
14 -my %private_pci_network_drivers;
15 -
16 -BEGIN
17 -{
18 -
19 - # All the routines below need the arrays, so populate them on entry.
20 -
21 - my $proc_version = "/proc/version";
22 -
23 - open( VERSION, "$proc_version" )
24 - or warn "Could not open $proc_version for reading. $!\n";
25 -
26 - my $kernel = ( split( ' ', <VERSION> ) )[2];
27 - close VERSION;
28 -
29 - my @modules_path = (
30 - "/lib/modules/" . $kernel . "/kernel/net",
31 - "/lib/modules/" . $kernel . "/kernel/drivers/net",
32 - "/lib/modules/" . $kernel . "/unsupported/drivers/net",
33 - "/lib/modules/" . $kernel . "/kernel/drivers/addon",
34 - );
35 -
36 - sub find_modules
37 - {
38 - my @paths = @_;
39 - my %modules_hash = ();
40 - local *DIR;
41 - foreach my $path (@paths)
42 - {
43 - next unless -d $path;
44 - opendir (DIR, $path)
45 - or die "Failed to open directory $path: $!\n";
46 - while (my $entry = readdir(DIR))
47 - {
48 - next if $entry =~ /^\./;
49 - my $fullpath = "$path/$entry";
50 - if (-d $fullpath)
51 - {
52 - %modules_hash = (%modules_hash, find_modules($fullpath));
53 - }
54 - else
55 - {
56 - if ($entry =~ /\.k?o$/)
57 - {
58 - $entry =~ s/(.+)\.k?o$//;
59 - $modules_hash{$1} = 1;
60 - }
61 - }
62 - }
63 - closedir(DIR);
64 - }
65 - return %modules_hash;
66 - }
67 -
68 - my %network_drivers = find_modules(@modules_path);
69 -
70 - my $pcitable = "/usr/share/hwdata/pcitable";
71 -
72 - unless ( open( PCITABLE, $pcitable )
73 - || open( PCITABLE, $pcitable = "/usr/share/kudzu/pcitable" ) )
74 - {
75 - warn "Could not open pci table $pcitable: $!\n";
76 - return;
77 - }
78 -
79 - my %descriptions;
80 -
81 - while (<PCITABLE>)
82 - {
83 - next if (/^\s*#|^\s*$/);
84 -
85 - chomp;
86 - my @f = split(/\t/);
87 -
88 - next if ( $f[2] =~ /^0x/ ); # Can't handle sub vendor IDs yet.
89 -
90 - $f[0] =~ s/^0x//;
91 - $f[1] =~ s/^0x//;
92 - $f[2] =~ s/"//g;
93 - # Gracefully handle CentOS4 pcitable format
94 - $f[3] ||= "(no description)";
95 - $f[3] =~ s/"//g;
96 -
97 - if ( exists $network_drivers{ $f[2] } )
98 - {
99 - my $card = $f[0] . ":" . $f[1];
100 - $private_pci_network_cards{$card}{driver} = $f[2];
101 - $private_pci_network_cards{$card}{description} = $f[3];
102 -
103 - my $description = $f[3];
104 - $description =~ s/\|.*//;
105 -
106 - if ( exists $private_pci_network_drivers{ $f[2] } )
107 - {
108 - unless ( exists $descriptions{ $f[2] . $description } )
109 - {
110 - $private_pci_network_drivers{ $f[2] } .= " or $description";
111 - ++$descriptions{ $f[2] . $description };
112 - }
113 - }
114 - else
115 - {
116 - $private_pci_network_drivers{ $f[2] } = $description;
117 - ++$descriptions{ $f[2] . $description };
118 - }
119 -
120 - }
121 - }
122 -
123 - close PCITABLE;
124 -}
125 -
126 -=pod
127 -
128 -=head2 listDrivers();
129 -
130 -List the available drivers
131 -
132 -=cut
133 -
134 -sub listDrivers ()
135 -{
136 - my $driver;
137 - my $drivers = '';
138 -
139 - return "\"unknown driver\"\t\"unknown description\" "
140 - unless ( scalar keys %private_pci_network_drivers );
141 -
142 - foreach $driver ( sort keys %private_pci_network_drivers )
143 - {
144 - $drivers .=
145 - "\"" . $driver . "\"\t\""
146 - . $private_pci_network_drivers{$driver}
147 - . " based adapter\" ";
148 - }
149 -
150 - return $drivers;
151 -}
152 -
153 -=pod
154 -
155 -=head2 listAdapters();
156 -
157 -List the available adapter cards
158 -
159 -=cut
160 -
161 -sub listAdapters ()
162 -{
163 - my $cards = '';
164 -
165 - return "\"unknown driver\"\t\"unknown adapter card\" "
166 - unless ( scalar keys %private_pci_network_cards );
167 -
168 - foreach ( sort private_card_by_driver keys %private_pci_network_cards )
169 - {
170 - $cards .= "\""
171 - . $private_pci_network_cards{$_}{driver}
172 - . "\"\t\""
173 - . $private_pci_network_cards{$_}{description} . "\" ";
174 - }
175 -
176 - return $cards;
177 -}
178 -
179 -=pod
180 -
181 -=head2 lookupAdapter($adapter);
182 -
183 -Find the driver for a particular card
184 -
185 -=cut
186 -
187 -sub lookupAdapter ($)
188 -{
189 - my $adapter = shift;
190 -
191 - return "unknown"
192 - unless ( scalar keys %private_pci_network_cards
193 - && $adapter );
194 -
195 - foreach ( sort keys %private_pci_network_cards )
196 - {
197 - if ( $private_pci_network_cards{$_}{description} eq $adapter )
198 - {
199 - return $private_pci_network_cards{$_}{driver};
200 - }
201 - }
202 -
203 - return "unknown";
204 -}
205
206 =pod
207
208 @@ -237,6 +39,7 @@
209 {
210 my @devs;
211 my $r;
212 + local $ENV{PATH} = "/bin:/sbin:/usr/bin:/usr/sbin";
213 unless (open(HWC, "/usr/sbin/kudzu --probe --class network|"))
214 {
215 warn "Could not run kudzu probe: $!";
216 @@ -263,28 +66,11 @@
217 {
218 $adapters .=
219 "EthernetDriver" . $index++ . "\t" . $nic->{driver} . "\t"
220 - . $nic->{desc} . "\n";
221 + . $nic->{'network.hwaddr'} . "\t" . $nic->{desc} . "\n";
222 }
223 return $adapters;
224 }
225
226 -#----------------------------------------------------------------------
227 -# Private method. Sort adapters by their driver type.
228 -#----------------------------------------------------------------------
229 -
230 -sub private_card_by_driver ()
231 -{
232 -
233 - # Sort the network cards by their driver type
234 -
235 - $private_pci_network_cards{$a}{driver}
236 - cmp $private_pci_network_cards{$b}{driver};
237 -}
238 -
239 -
240 -END
241 -{
242 -}
243
244 #----------------------------------------------------------------------
245 # Return one to make the import process return success.

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed