summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perl-install/install_steps.pm5
-rw-r--r--perl-install/keyboard.pm11
-rw-r--r--perl-install/loopback.pm5
-rw-r--r--perl-install/modules.pm5
-rw-r--r--perl-install/partition_table/bsd.pm16
-rw-r--r--perl-install/partition_table/dos.pm20
-rw-r--r--perl-install/partition_table/empty.pm6
-rw-r--r--perl-install/partition_table/gpt.pm34
-rw-r--r--perl-install/partition_table/lvm_PV.pm6
-rw-r--r--perl-install/partition_table/mac.pm38
-rw-r--r--perl-install/partition_table/raw.pm27
-rw-r--r--perl-install/partition_table/sun.pm16
12 files changed, 93 insertions, 96 deletions
diff --git a/perl-install/install_steps.pm b/perl-install/install_steps.pm
index 838694be8..9aed7ba4e 100644
--- a/perl-install/install_steps.pm
+++ b/perl-install/install_steps.pm
@@ -745,9 +745,8 @@ sub addUser {
any::write_passwd_user($p, $_, $o->{authentication}{md5}) foreach @$users;
- local *F;
- open F, ">> $p/etc/group" or die "can't append to group file: $!";
- print F "$_->{name}:x:$_->{gid}:\n" foreach grep { ! getgrgid($_->{gid}) } @$users;
+ append_to_file("$p/etc/group",
+ map { "$_->{name}:x:$_->{gid}:\n" } grep { ! getgrgid($_->{gid}) } @$users);
foreach my $u (@$users) {
if (! -d "$p$u->{home}") {
diff --git a/perl-install/keyboard.pm b/perl-install/keyboard.pm
index 43da34803..74dc03cce 100644
--- a/perl-install/keyboard.pm
+++ b/perl-install/keyboard.pm
@@ -371,8 +371,7 @@ sub load {
$magic != $KMAP_MAGIC and die "failed to read kmap magic";
- local *F;
- sysopen F, "/dev/console", 2 or die "failed to open /dev/console: $!";
+ sysopen(my $F, "/dev/console", 2) or die "failed to open /dev/console: $!";
my $count = 0;
foreach (0 .. c::MAX_NR_KEYMAPS() - 1) {
@@ -385,7 +384,7 @@ sub load {
foreach my $value (@keymap) {
$key++;
c::KTYP($value) != c::KT_SPEC() or next;
- ioctl(F, c::KDSKBENT(), pack("CCS", $_, $key, $value)) or die "keymap ioctl failed ($_ $key $value): $!";
+ ioctl($F, c::KDSKBENT(), pack("CCS", $_, $key, $value)) or die "keymap ioctl failed ($_ $key $value): $!";
}
$count++;
}
@@ -445,10 +444,10 @@ sub setup {
if (-e (my $f = "$ENV{SHARE_PATH}/keymaps/$kmap.bkmap")) {
load(scalar cat_($f));
} else {
- local *F;
- if (my $pid = open F, "-|") {
+ my $F;
+ if (my $pid = open $F, "-|") {
local $/ = undef;
- eval { load(join('', <F>)) };
+ eval { load(join('', <$F>)) };
waitpid $pid, 0;
} else {
eval {
diff --git a/perl-install/loopback.pm b/perl-install/loopback.pm
index 5d1200d90..90097e3eb 100644
--- a/perl-install/loopback.pm
+++ b/perl-install/loopback.pm
@@ -76,12 +76,11 @@ sub create {
log::l("creating loopback file $f ($part->{size} sectors)");
- local *F;
my $block_size = 128;
my $s = "\0" x (512 * $block_size);
- sysopen F, $f, 2 | c::O_CREAT() or die "failed to create loopback file";
+ sysopen(my $F, $f, 2 | c::O_CREAT()) or die "failed to create loopback file";
for (my $i = 0; $i < $part->{size}; $i += $block_size) {
- syswrite F, $s or die "failed to create loopback file";
+ syswrite $F, $s or die "failed to create loopback file";
}
}
diff --git a/perl-install/modules.pm b/perl-install/modules.pm
index 7733eb582..96bae97ac 100644
--- a/perl-install/modules.pm
+++ b/perl-install/modules.pm
@@ -246,12 +246,11 @@ sub write_conf {
my $written = read_conf($file);
- local *F;
- open F, ">> $file" or die("cannot write module config file $file: $!\n");
+ open(my $F, ">> $file") or die("cannot write module config file $file: $!\n");
while (my ($mod, $h) = each %conf) {
while (my ($type, $v) = each %$h) {
my $v2 = join(' ', uniq(deref($v)));
- print F "$type $mod $v2\n"
+ print $F "$type $mod $v2\n"
if $v2 && !$written->{$mod}{$type};
}
}
diff --git a/perl-install/partition_table/bsd.pm b/perl-install/partition_table/bsd.pm
index dc85ab3cf..d08cd57aa 100644
--- a/perl-install/partition_table/bsd.pm
+++ b/perl-install/partition_table/bsd.pm
@@ -62,10 +62,10 @@ sub read($$) {
my ($hd, $sector) = @_;
my $tmp;
- local *F; partition_table::raw::openit($hd, *F) or die "failed to open device";
- c::lseek_sector(fileno(F), $sector, $offset) or die "reading of partition in sector $sector failed";
+ my $F = partition_table::raw::openit($hd) or die "failed to open device";
+ c::lseek_sector(fileno($F), $sector, $offset) or die "reading of partition in sector $sector failed";
- sysread F, $tmp, psizeof($main_format) or die "error while reading partition table in sector $sector";
+ sysread $F, $tmp, psizeof($main_format) or die "error while reading partition table in sector $sector";
my %info; @info{@$main_fields} = unpack $main_format, $tmp;
#- TODO verify checksum
@@ -90,13 +90,13 @@ sub write($$$;$) {
my ($hd, $sector, $pt, $info) = @_;
#- handle testing for writing partition table on file only!
- local *F;
+ my $F;
if ($::testing) {
my $file = "/tmp/partition_table_$hd->{device}";
- open F, ">$file" or die "error opening test file $file";
+ open $F, ">$file" or die "error opening test file $file";
} else {
- partition_table::raw::openit($hd, *F, 2) or die "error opening device $hd->{device} for writing";
- c::lseek_sector(fileno(F), $sector, $offset) or return 0;
+ $F = partition_table::raw::openit($hd, 2) or die "error opening device $hd->{device} for writing";
+ c::lseek_sector(fileno($F), $sector, $offset) or return 0;
}
#- TODO compute checksum
@@ -109,7 +109,7 @@ sub write($$$;$) {
pack $format, @$_{@fields};
} @$pt;
- syswrite F, pack($main_format, @$info{@$main_fields}), psizeof($main_format) or return 0;
+ syswrite $F, pack($main_format, @$info{@$main_fields}), psizeof($main_format) or return 0;
1;
}
diff --git a/perl-install/partition_table/dos.pm b/perl-install/partition_table/dos.pm
index b5f16df87..e448ad841 100644
--- a/perl-install/partition_table/dos.pm
+++ b/perl-install/partition_table/dos.pm
@@ -58,17 +58,17 @@ sub read {
my ($hd, $sector) = @_;
my $tmp;
- local *F; partition_table::raw::openit($hd, *F) or die "failed to open device";
- c::lseek_sector(fileno(F), $sector, $offset) or die "reading of partition in sector $sector failed";
+ my $F = partition_table::raw::openit($hd) or die "failed to open device";
+ c::lseek_sector(fileno($F), $sector, $offset) or die "reading of partition in sector $sector failed";
my @pt = map {
- sysread F, $tmp, psizeof($format) or die "error while reading partition table in sector $sector";
+ sysread $F, $tmp, psizeof($format) or die "error while reading partition table in sector $sector";
my %h; @h{@fields} = unpack $format, $tmp;
\%h;
} (1..$nb_primary);
#- check magic number
- sysread F, $tmp, length $magic or die "error reading magic number on disk $hd->{device}";
+ sysread $F, $tmp, length $magic or die "error reading magic number on disk $hd->{device}";
$tmp eq $magic or die "bad magic number on disk $hd->{device}";
[ @pt ];
@@ -80,13 +80,13 @@ sub write($$$;$) {
my ($hd, $sector, $pt) = @_;
#- handle testing for writing partition table on file only!
- local *F;
+ my $F;
if ($::testing) {
my $file = "/tmp/partition_table_$hd->{device}";
- open F, ">$file" or die "error opening test file $file";
+ open $F, ">$file" or die "error opening test file $file";
} else {
- partition_table::raw::openit($hd, *F, 2) or die "error opening device $hd->{device} for writing";
- c::lseek_sector(fileno(F), $sector, $offset) or return 0;
+ $F = partition_table::raw::openit($hd, 2) or die "error opening device $hd->{device} for writing";
+ c::lseek_sector(fileno($F), $sector, $offset) or return 0;
}
@$pt == $nb_primary or die "partition table does not have $nb_primary entries";
@@ -94,9 +94,9 @@ sub write($$$;$) {
compute_CHS($hd, $_);
local $_->{start} = $_->{local_start} || 0;
$_->{active} ||= 0; $_->{type} ||= 0; $_->{size} ||= 0; #- for no warning
- syswrite F, pack($format, @$_{@fields}), psizeof($format) or return 0;
+ syswrite $F, pack($format, @$_{@fields}), psizeof($format) or return 0;
}
- syswrite F, $magic, length $magic or return 0;
+ syswrite $F, $magic, length $magic or return 0;
1;
}
diff --git a/perl-install/partition_table/empty.pm b/perl-install/partition_table/empty.pm
index e90991684..596088619 100644
--- a/perl-install/partition_table/empty.pm
+++ b/perl-install/partition_table/empty.pm
@@ -21,11 +21,11 @@ sub read($$) {
my ($hd, $sector) = @_;
my $tmp;
- local *F; partition_table::raw::openit($hd, *F) or die "failed to open device";
- c::lseek_sector(fileno(F), $sector, 0) or die "reading of partition in sector $sector failed";
+ my $F = partition_table::raw::openit($hd) or die "failed to open device";
+ c::lseek_sector(fileno($F), $sector, 0) or die "reading of partition in sector $sector failed";
#- check magic number
- sysread F, $tmp, 512 or die "error reading magic number on disk $hd->{device}";
+ sysread $F, $tmp, 512 or die "error reading magic number on disk $hd->{device}";
$tmp eq substr($tmp, 0, 1) x 512 or die "bad magic number on disk $hd->{device}";
partition_table::raw::zero_MBR($hd);
diff --git a/perl-install/partition_table/gpt.pm b/perl-install/partition_table/gpt.pm
index ef8ddb187..0f60fce07 100644
--- a/perl-install/partition_table/gpt.pm
+++ b/perl-install/partition_table/gpt.pm
@@ -65,9 +65,8 @@ my $magic = "EFI PART";
sub generate_guid {
my $tmp;
- local *F;
- open F, devices::make("random") or die "Could not open /dev/random for GUID generation";
- read F, $tmp, psizeof($guid_format);
+ open(my $F, devices::make("random")) or die "Could not open /dev/random for GUID generation";
+ read $F, $tmp, psizeof($guid_format);
my %guid; @guid{@$guid_fields} = unpack $guid_format, $tmp;
$guid{clock_seq} = ($guid{clock_seq} & 0x3fff) | 0x8000;
@@ -148,13 +147,13 @@ sub read {
$l[0]{type} == 0xee or die "bad PMBR";
my $myLBA = $l[0]{start};
- local *F; partition_table::raw::openit($hd, *F) or die "failed to open device";
- my $info1 = eval { read_header($myLBA, *F) };
- my $info2 = eval { read_header($info1->{alternateLBA} || $l[0]{start} + $l[0]{size} - 1, *F) }; #- what about using $hd->{totalsectors} ???
+ my $F = partition_table::raw::openit($hd) or die "failed to open device";
+ my $info1 = eval { read_header($myLBA, $F) };
+ my $info2 = eval { read_header($info1->{alternateLBA} || $l[0]{start} + $l[0]{size} - 1, $F) }; #- what about using $hd->{totalsectors} ???
my $info = $info1 || { %$info2, myLBA => $info2->{alternateLBA}, alternateLBA => $info2->{myLBA}, partitionEntriesLBA => $info2->{alternateLBA} + 1 } or die;
my $pt = $info1 && $info2 ?
- eval { $info1 && read_partitionEntries($info1, *F) } || read_partitionEntries($info2, *F) :
- read_partitionEntries($info, *F);
+ eval { $info1 && read_partitionEntries($info1, $F) } || read_partitionEntries($info2, $F) :
+ read_partitionEntries($info, $F);
$hd->raw_removed($pt);
$pt, $info;
@@ -190,22 +189,21 @@ sub write {
partition_table::dos::write($hd, $sector, $pmbr->{raw});
}
- local *F;
- partition_table::raw::openit($hd, *F, 2) or die "error opening device $hd->{device} for writing";
+ my $F = partition_table::raw::openit($hd, 2) or die "error opening device $hd->{device} for writing";
- c::lseek_sector(fileno(F), $info->{myLBA}, 0) or return 0;
+ c::lseek_sector(fileno($F), $info->{myLBA}, 0) or return 0;
#- pad with 0's
- syswrite F, pack($main_format, @$info{@$main_fields}) . "\0" x 512, 512 or return 0;
+ syswrite $F, pack($main_format, @$info{@$main_fields}) . "\0" x 512, 512 or return 0;
- c::lseek_sector(fileno(F), $info->{alternateLBA}, 0) or return 0;
+ c::lseek_sector(fileno($F), $info->{alternateLBA}, 0) or return 0;
#- pad with 0's
- syswrite F, pack($main_format, @$info2{@$main_fields}) . "\0" x 512, 512 or return 0;
+ syswrite $F, pack($main_format, @$info2{@$main_fields}) . "\0" x 512, 512 or return 0;
- c::lseek_sector(fileno(F), $info->{partitionEntriesLBA}, 0) or return 0;
- syswrite F, $partitionEntries or return 0;
+ c::lseek_sector(fileno($F), $info->{partitionEntriesLBA}, 0) or return 0;
+ syswrite $F, $partitionEntries or return 0;
- c::lseek_sector(fileno(F), $info2->{partitionEntriesLBA}, 0) or return 0;
- syswrite F, $partitionEntries or return 0;
+ c::lseek_sector(fileno($F), $info2->{partitionEntriesLBA}, 0) or return 0;
+ syswrite $F, $partitionEntries or return 0;
common::sync();
1;
diff --git a/perl-install/partition_table/lvm_PV.pm b/perl-install/partition_table/lvm_PV.pm
index dc84e74dc..c2ff30fb6 100644
--- a/perl-install/partition_table/lvm_PV.pm
+++ b/perl-install/partition_table/lvm_PV.pm
@@ -23,10 +23,10 @@ my $offset = 0;
sub read {
my ($hd, $sector) = @_;
- local *F; partition_table::raw::openit($hd, *F) or die "failed to open device";
- c::lseek_sector(fileno(F), $sector, $offset) or die "reading of partition in sector $sector failed";
+ my $F = partition_table::raw::openit($hd) or die "failed to open device";
+ c::lseek_sector(fileno($F), $sector, $offset) or die "reading of partition in sector $sector failed";
- sysread F, my $tmp, length $magic or die "error reading magic number on disk $hd->{file}";
+ sysread $F, my $tmp, length $magic or die "error reading magic number on disk $hd->{file}";
$tmp eq $magic or die "bad magic number on disk $hd->{file}";
[];
diff --git a/perl-install/partition_table/mac.pm b/perl-install/partition_table/mac.pm
index d455584cf..4ba83faf2 100644
--- a/perl-install/partition_table/mac.pm
+++ b/perl-install/partition_table/mac.pm
@@ -100,14 +100,14 @@ sub read($$) {
my ($hd, $sector) = @_;
my $tmp;
- local *F; partition_table::raw::openit($hd, *F) or die "failed to open device";
- c::lseek_sector(fileno(F), $sector, 0) or die "reading of partition in sector $sector failed";
+ my $F = partition_table::raw::openit($hd) or die "failed to open device";
+ c::lseek_sector(fileno($F), $sector, 0) or die "reading of partition in sector $sector failed";
- sysread F, $tmp, psizeof($bz_format) or die "error while reading bz \(Block Zero\) in sector $sector";
+ sysread $F, $tmp, psizeof($bz_format) or die "error while reading bz \(Block Zero\) in sector $sector";
my %info; @info{@$bz_fields} = unpack $bz_format, $tmp;
foreach my $i (0 .. $info{bzDrvrCnt}-1) {
- sysread F, $tmp, psizeof($dd_format) or die "error while reading driver data in sector $sector";
+ sysread $F, $tmp, psizeof($dd_format) or die "error while reading driver data in sector $sector";
my %dd; @dd{@$dd_fields} = unpack $dd_format, $tmp;
push @{$info{ddMap}}, \%dd;
}
@@ -116,21 +116,21 @@ sub read($$) {
$info{bzSig} == $magic or die "bad magic number on disk $hd->{device}";
my $numparts;
- c::lseek_sector(fileno(F), $sector, 516) or die "reading of partition in sector $sector failed";
- sysread F, $tmp, 4 or die "error while reading partition info in sector $sector";
+ c::lseek_sector(fileno($F), $sector, 516) or die "reading of partition in sector $sector failed";
+ sysread $F, $tmp, 4 or die "error while reading partition info in sector $sector";
$numparts = unpack "N", $tmp;
my $partmapsize;
- c::lseek_sector(fileno(F), $sector, 524) or die "reading of partition in sector $sector failed";
- sysread F, $tmp, 4 or die "error while reading partition info in sector $sector";
+ c::lseek_sector(fileno($F), $sector, 524) or die "reading of partition in sector $sector failed";
+ sysread $F, $tmp, 4 or die "error while reading partition info in sector $sector";
$partmapsize = ((unpack "N", $tmp) * $info{bzBlkSize}) / psizeof($p_format);
- c::lseek_sector(fileno(F), $sector, 512) or die "reading of partition in sector $sector failed";
+ c::lseek_sector(fileno($F), $sector, 512) or die "reading of partition in sector $sector failed";
my @pt;
for (my $i = 0; $i < $partmapsize; $i++) {
my $part;
- sysread F, $part, psizeof($p_format) or die "error while reading partition info in sector $sector";
+ sysread $F, $part, psizeof($p_format) or die "error while reading partition info in sector $sector";
push @pt, map {
my %h; @h{@$p_fields} = unpack $p_format, $part;
@@ -194,13 +194,13 @@ sub write($$$;$) {
my ($hd, $sector, $pt, $info) = @_;
#- handle testing for writing partition table on file only!
- local *F;
+ my $F;
if ($::testing) {
my $file = "/tmp/partition_table_$hd->{device}";
- open F, ">$file" or die "error opening test file $file";
+ open $F, ">$file" or die "error opening test file $file";
} else {
- partition_table::raw::openit($hd, *F, 2) or die "error opening device $hd->{device} for writing";
- c::lseek_sector(fileno(F), $sector, 0) or return 0;
+ $F = partition_table::raw::openit($hd, 2) or die "error opening device $hd->{device} for writing";
+ c::lseek_sector(fileno($F), $sector, 0) or return 0;
}
# Find the partition map.
@@ -250,17 +250,17 @@ sub write($$$;$) {
}
# Now let's write our first block.
- syswrite F, pack($bz_format, @$info{@$bz_fields}), psizeof($bz_format) or return 0;
+ syswrite $F, pack($bz_format, @$info{@$bz_fields}), psizeof($bz_format) or return 0;
# ...and now the driver information.
foreach (@ddstowrite) {
- syswrite F, pack($dd_format, @$_{@$dd_fields}), psizeof($dd_format) or return 0;
+ syswrite $F, pack($dd_format, @$_{@$dd_fields}), psizeof($dd_format) or return 0;
}
# zero the rest of the data in the first block.
foreach (1 .. (494 - ((@ddstowrite) * 8))) {
- syswrite F, "\0", 1 or return 0;
+ syswrite $F, "\0", 1 or return 0;
}
- #c::lseek_sector(fileno(F), $sector, 512) or return 0;
+ #c::lseek_sector(fileno($F), $sector, 512) or return 0;
# Now, we iterate thru the partstowrite and write them.
foreach (@partstowrite) {
if (!defined $_->{pSig}) {
@@ -329,7 +329,7 @@ sub write($$$;$) {
}
};
$_->{pMapEntry} = @partstowrite;
- syswrite F, pack($p_format, @$_{@$p_fields}), psizeof($p_format) or return 0;
+ syswrite $F, pack($p_format, @$_{@$p_fields}), psizeof($p_format) or return 0;
}
common::sync();
diff --git a/perl-install/partition_table/raw.pm b/perl-install/partition_table/raw.pm
index 0456c8c26..a10d6d568 100644
--- a/perl-install/partition_table/raw.pm
+++ b/perl-install/partition_table/raw.pm
@@ -91,14 +91,14 @@ sub get_geometry($) {
my ($dev) = @_;
my $g = "";
- local *F; sysopen F, $dev, 0 or return;
- ioctl(F, c::HDIO_GETGEO(), $g) or return;
+ sysopen(my $F, $dev, 0) or return;
+ ioctl($F, c::HDIO_GETGEO(), $g) or return;
my %geom; @geom{qw(heads sectors cylinders start)} = unpack "CCSL", $g;
$geom{totalcylinders} = $geom{cylinders};
my $total;
#- $geom{cylinders} is no good (only a ushort, that means less than 2^16 => at best 512MB)
- if ($total = c::total_sectors(fileno F)) {
+ if ($total = c::total_sectors(fileno $F)) {
$geom{cylinders} = int $total / $geom{heads} / $geom{sectors};
} else {
$total = $geom{heads} * $geom{sectors} * $geom{cylinders}
@@ -107,17 +107,20 @@ sub get_geometry($) {
{ geom => \%geom, totalsectors => $total };
}
-sub openit($$;$) { sysopen $_[1], $_[0]{file}, $_[2] || 0 }
+sub openit {
+ my ($hd, $mode) = @_;
+ my $F; sysopen($F, $hd->{file}, $mode || 0) and $F;
+}
# cause kernel to re-read partition table
sub kernel_read($) {
my ($hd) = @_;
common::sync();
- local *F; openit($hd, *F) or return 0;
+ my $F = openit($hd) or return 0;
common::sync(); sleep(1);
- $hd->{rebootNeeded} = !ioctl(F, c::BLKRRPART(), 0);
+ $hd->{rebootNeeded} = !ioctl($F, c::BLKRRPART(), 0);
common::sync();
- close F;
+ close $F;
common::sync(); sleep(1);
}
@@ -172,19 +175,19 @@ sub test_for_bad_drives {
sub error { die "$_[0] error: $_[1]" }
- local *F; openit($hd, *F, 2) or error(openit($hd, *F, 0) ? 'write' : 'read', "can't open device");
+ my $F = openit($hd, 2) or error(openit($hd) ? 'write' : 'read', "can't open device");
my $seek = sub {
- c::lseek_sector(fileno(F), $sector, 0) or error('read', "seeking to sector $sector failed");
+ c::lseek_sector(fileno($F), $sector, 0) or error('read', "seeking to sector $sector failed");
};
my $tmp;
- &$seek; sysread F, $tmp, $SECTORSIZE or error('read', "can't even read ($!)");
+ &$seek; sysread $F, $tmp, $SECTORSIZE or error('read', "can't even read ($!)");
return if $hd->{readonly} || $::testing;
- &$seek; syswrite F, $tmp or error('write', "can't even write ($!)");
+ &$seek; syswrite $F, $tmp or error('write', "can't even write ($!)");
my $tmp2;
- &$seek; sysread F, $tmp2, $SECTORSIZE or die "test_for_bad_drives: can't even read again ($!)";
+ &$seek; sysread $F, $tmp2, $SECTORSIZE or die "test_for_bad_drives: can't even read again ($!)";
$tmp eq $tmp2 or die
N("Something bad is happening on your drive.
A test to check the integrity of data has failed.
diff --git a/perl-install/partition_table/sun.pm b/perl-install/partition_table/sun.pm
index 2302b905b..bcae6d296 100644
--- a/perl-install/partition_table/sun.pm
+++ b/perl-install/partition_table/sun.pm
@@ -75,10 +75,10 @@ sub read($$) {
my ($hd, $sector) = @_;
my $tmp;
- local *F; partition_table::raw::openit($hd, *F) or die "failed to open device";
- c::lseek_sector(fileno(F), $sector, $offset) or die "reading of partition in sector $sector failed";
+ my $F = partition_table::raw::openit($hd) or die "failed to open device";
+ c::lseek_sector(fileno($F), $sector, $offset) or die "reading of partition in sector $sector failed";
- sysread F, $tmp, psizeof($main_format) or die "error while reading partition table in sector $sector";
+ sysread $F, $tmp, psizeof($main_format) or die "error while reading partition table in sector $sector";
my %info; @info{@$main_fields} = unpack $main_format, $tmp;
#- check magic number
@@ -120,13 +120,13 @@ sub write($$$;$) {
# my ($csize, $wdsize) = (0, 0);
#- handle testing for writing partition table on file only!
- local *F;
+ my $F;
if ($::testing) {
my $file = "/tmp/partition_table_$hd->{device}";
- open F, ">$file" or die "error opening test file $file";
+ open $F, ">$file" or die "error opening test file $file";
} else {
- partition_table::raw::openit($hd, *F, 2) or die "error opening device $hd->{device} for writing";
- c::lseek_sector(fileno(F), $sector, $offset) or return 0;
+ $F = partition_table::raw::openit($hd, 2) or die "error opening device $hd->{device} for writing";
+ c::lseek_sector(fileno($F), $sector, $offset) or return 0;
}
($info->{infos}, $info->{partitions}) = map { join '', @$_ } list2kv map {
@@ -145,7 +145,7 @@ sub write($$$;$) {
$info->{csum} = 0;
$info->{csum} = compute_crc(pack($main_format, @$info{@$main_fields}));
- syswrite F, pack($main_format, @$info{@$main_fields}), psizeof($main_format) or return 0;
+ syswrite $F, pack($main_format, @$info{@$main_fields}), psizeof($main_format) or return 0;
common::sync();