annotate bin/cek.pl @ 526:f579b5310a1b

Add script to map linux ata drive numbering.
author edogawaconan <me@myconan.net>
date Sat, 09 Aug 2014 00:24:45 +0900
parents 5bafb912837e
children 1a996b35eaab
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
124
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
1 #!/usr/bin/env perl
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
2
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
3 use strict;
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
4 use warnings;
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
5 use String::CRC32;
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
6 use File::Basename;
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
7
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
8 my @files = @ARGV or print("Usage: ",basename($0)," file1 file2 ... fileN\n") && exit(1);
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
9 my $num_ok=0;
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
10 my $num_err=0;
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
11 my $num_nf=0;
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
12 my $num_na=@files;
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
13
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
14 foreach(@files) {
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
15 my $filename = $_;
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
16 my ($name_crc,$real_crc);
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
17 unless (-f $filename) {
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
18 $num_nf++;$num_na--;
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
19 print(qq(Could not find "$filename", skipping\n));
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
20 next();
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
21 }
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
22 if(/(\[|\()([0-9A-F]{8})(\]|\))/i){
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
23 $name_crc=uc($2);
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
24 }
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
25 open(FILE,"<",$filename);
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
26 binmode(FILE);
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
27 $real_crc=sprintf("%08X",crc32(*FILE));
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
28 close(FILE);
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
29 if($name_crc) {
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
30 $num_na--;
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
31 if($name_crc eq $real_crc) {
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
32 $num_ok++;
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
33 print("$filename: OK - $real_crc\n");
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
34 } else {
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
35 $num_err++;
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
36 print("$filename: NOT OK - $real_crc, should be $name_crc\n");
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
37 }
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
38 } else {
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
39 print("$filename: $real_crc\n");
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
40 }
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
41 }
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
42
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
43 printf("%s\n","-"x40);
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
44 if($num_ok > 0) { print("Files OK: $num_ok\n"); }
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
45 if($num_err > 0) { print("Files error: $num_err\n"); }
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
46 if($num_nf > 0) { print("Files not found: $num_nf\n"); }
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
47 if($num_na > 0) { print("Files without crc information: $num_na\n"); }
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
48
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
49 exit(0);