/[mdap]/bin/fw-info.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /bin/fw-info.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 34 by dpavlin, Tue Apr 24 20:43:36 2007 UTC revision 59 by dpavlin, Fri Nov 16 23:44:29 2007 UTC
# Line 12  push @images, '/srv/tftp/BANT-R' unless Line 12  push @images, '/srv/tftp/BANT-R' unless
12    
13  my $magic = 'BLI223QH0';  my $magic = 'BLI223QH0';
14    
15    sub get_from {
16            my ($fh,$seek,$len) = @_;
17            my $b;
18            seek($fh, $seek, 0) || die "can't seek to $seek: $!";
19            read($fh, $b, $len) || die "can't read $len bytes: $!";
20            return $b;
21    }
22    
23  for my $path ( @images ) {  for my $path ( @images ) {
24            next unless -f $path;
25          open(my $fh, $path) || die "Can't open $path: $!";          open(my $fh, $path) || die "Can't open $path: $!";
26          my $b;          my $b;
27          read($fh, $b, length($magic));          read($fh, $b, length($magic));
28          warn "# $path not a firmware image\n" unless ($b eq $magic);          warn "# $path not a firmware image\n" unless ($b eq $magic);
29          seek($fh, 32, 0) || die "can't seek to 32: $!";          my $version     = get_from($fh, 32, 4);
30          read($fh, $b, 4);          my $board       = get_from($fh, 0x136, 6);
31          printf("%8s %s\n", join('.',unpack('CCCC', $b)), $path);          my $name        = get_from($fh, 0x144, 15);
32            chomp($name);
33    
34            printf("%8s %6s %s\t%s\n", join('.',unpack('CCCC', $version)), $board, $name, $path);
35  }  }

Legend:
Removed from v.34  
changed lines
  Added in v.59

  ViewVC Help
Powered by ViewVC 1.1.26