summaryrefslogtreecommitdiffstats
path: root/perl-install/devices.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2002-12-03 12:46:27 +0000
committerPascal Rigaux <pixel@mandriva.com>2002-12-03 12:46:27 +0000
commit7a352652b5b1a5711b1fd3e0a918f84ea6f1fc95 (patch)
tree1ce8aed7358699a4698da8c0de75b15aa9ec2de0 /perl-install/devices.pm
parent49c020779005ca18fffc440a76dfdea0217b4541 (diff)
downloaddrakx-7a352652b5b1a5711b1fd3e0a918f84ea6f1fc95.tar
drakx-7a352652b5b1a5711b1fd3e0a918f84ea6f1fc95.tar.gz
drakx-7a352652b5b1a5711b1fd3e0a918f84ea6f1fc95.tar.bz2
drakx-7a352652b5b1a5711b1fd3e0a918f84ea6f1fc95.tar.xz
drakx-7a352652b5b1a5711b1fd3e0a918f84ea6f1fc95.zip
do not use "local *F"
Diffstat (limited to 'perl-install/devices.pm')
-rw-r--r--perl-install/devices.pm27
1 files changed, 12 insertions, 15 deletions
diff --git a/perl-install/devices.pm b/perl-install/devices.pm
index bc84710f8..153017cdc 100644
--- a/perl-install/devices.pm
+++ b/perl-install/devices.pm
@@ -8,14 +8,14 @@ use run_program;
use log;
use c;
-sub size($) {
- local *F;
- sysopen F, $_[0], 0 or log::l("open $_[0]: $!"), return 0;
+sub size {
+ my ($dev) = @_;
+ sysopen(my $F, $dev, 0) or log::l("open $dev: $!"), return 0;
- my $valid_offset = sub { sysseek(F, $_[0], 0) && sysread(F, my $a, 1) };
+ my $valid_offset = sub { sysseek($F, $_[0], 0) && sysread($F, my $a, 1) };
#- first try getting the size nicely
- if (my $size = c::total_sectors(fileno F)) {
+ if (my $size = c::total_sectors(fileno $F)) {
return $size * $common::SECTORSIZE;
}
@@ -24,11 +24,11 @@ sub size($) {
my ($high, $mid);
#- first find n where 2^n < size <= 2^n+1
- for ($high = 1; $high > 0 && &$valid_offset($high); $high *= 2) { $low = $high }
+ for ($high = 1; $high > 0 && $valid_offset->($high); $high *= 2) { $low = $high }
while ($low < $high - 1) {
$mid = int(($low + $high) / 2);
- &$valid_offset($mid) ? $low : $high = $mid;
+ $valid_offset->($mid) ? $low : $high = $mid;
}
$low + 1;
}
@@ -40,10 +40,8 @@ sub del_loop {
sub find_free_loop {
foreach (0..7) {
my $dev = make("loop$_");
- local *F;
- sysopen F, $dev, 2 or next;
- !ioctl(F, c::LOOP_GET_STATUS(), my $tmp) && $! == 6 or next; #- 6 == ENXIO
- close F;
+ sysopen(my $F, $dev, 2) or next;
+ !ioctl($F, c::LOOP_GET_STATUS(), my $tmp) && $! == 6 or next; #- 6 == ENXIO
return $dev;
}
die "no free loop found";
@@ -55,10 +53,9 @@ sub set_loop {
if ($encrypt_key && $encryption) {
my $cmd = "losetup -p 0 -e $encryption $dev $file";
log::l("calling $cmd");
- local *F;
- open F, "|$cmd";
- print F $encrypt_key;
- close F or die "losetup failed";
+ open my $F, "|$cmd";
+ print $F $encrypt_key;
+ close $F or die "losetup failed";
} else {
run_program::run("losetup", $dev, $file) or return;
}