make a bit more sane and cleaner
This commit is contained in:
parent
d0350c1e73
commit
99a17a36aa
|
@ -46,17 +46,17 @@ sub getdev{
|
||||||
my $dh;
|
my $dh;
|
||||||
my $dir;
|
my $dir;
|
||||||
|
|
||||||
$dev=gosub($dev,":1");
|
$dev=gosub($dev,":1") || return "";
|
||||||
$dev=gosub($dev,"^host");
|
$dev=gosub($dev,"^host");
|
||||||
$dev=gosub($dev,"^target");
|
$dev=gosub($dev,"^target") || return "";
|
||||||
$dev=~/target(.*)/;
|
$dev=~/target(.*)/;
|
||||||
$dev=gosub($dev,$1);
|
$dev=gosub($dev,$1) || return "";
|
||||||
$dev=gosub($dev,"^block");
|
$dev=gosub($dev,"^block") || return "";
|
||||||
$dev=gosub($dev,".");
|
$dev=gosub($dev,".") || return "";
|
||||||
$dev=~m!/([^/]*)$!;
|
$dev=~m!/([^/]*)$!;
|
||||||
my $r=$1;
|
my $r=$1;
|
||||||
if($r!~/^sd/){
|
if($r!~/^sd/){
|
||||||
# print "Strange device? $dev -> $r\n";
|
print "Strange device? $dev -> $r\n";
|
||||||
return "";
|
return "";
|
||||||
};
|
};
|
||||||
return $r;
|
return $r;
|
||||||
|
@ -94,14 +94,10 @@ sub dwim{
|
||||||
if (not defined $pid) {
|
if (not defined $pid) {
|
||||||
die "fork failed\n";
|
die "fork failed\n";
|
||||||
} elsif ($pid == 0) {
|
} elsif ($pid == 0) {
|
||||||
system("./mass $sdev");
|
system("./mass $sdev $dev");
|
||||||
exit(0);
|
exit(0);
|
||||||
} else {
|
} else {
|
||||||
# print "IM THE PARENT $pid\n";
|
|
||||||
$pids{$pid}=1;
|
$pids{$pid}=1;
|
||||||
# print join(",",%pids),"\n";
|
|
||||||
# print scalar keys %pids;
|
|
||||||
# print "\n";
|
|
||||||
}
|
}
|
||||||
$done{$dev}=1;
|
$done{$dev}=1;
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -114,17 +110,18 @@ sub dwim{
|
||||||
return 1;
|
return 1;
|
||||||
};
|
};
|
||||||
print "flash $dev -> $sdev\n";
|
print "flash $dev -> $sdev\n";
|
||||||
system("./flash $sdev");
|
system("./flash $sdev $dev");
|
||||||
$done{$dev}=2;
|
$done{$dev}=2;
|
||||||
return 1;
|
return 1;
|
||||||
};
|
};
|
||||||
|
print "$ve:$pr [$mf] @ ";
|
||||||
return -1;
|
return -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
my %disable;
|
my %disable;
|
||||||
while(1){
|
while(1){
|
||||||
opendir(my $dh, $DEV);
|
opendir(my $dh, $DEV);
|
||||||
my @paths=readdir($dh);
|
my @paths=grep {/^[^.]/} readdir($dh);
|
||||||
close $dh;
|
close $dh;
|
||||||
# print "f: ",join(",",@files),"\n";
|
# print "f: ",join(",",@files),"\n";
|
||||||
device:
|
device:
|
||||||
|
@ -136,7 +133,7 @@ device:
|
||||||
$found{$path}=1;
|
$found{$path}=1;
|
||||||
my $res=dwim($path);
|
my $res=dwim($path);
|
||||||
if($res==-1){
|
if($res==-1){
|
||||||
print "Disabling: $path\n";
|
print "$path -- ignoring it forever\n";
|
||||||
$disable{$path}=1;
|
$disable{$path}=1;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue