diff options
Diffstat (limited to 'perl-install/resize_fat/io.pm')
-rw-r--r-- | perl-install/resize_fat/io.pm | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/perl-install/resize_fat/io.pm b/perl-install/resize_fat/io.pm index 7643a0953..78e3a3724 100644 --- a/perl-install/resize_fat/io.pm +++ b/perl-install/resize_fat/io.pm @@ -1,4 +1,4 @@ -package resize_fat::io; # $Id$ +package resize_fat::io; use diagnostics; use strict; @@ -11,14 +11,13 @@ use c; sub read($$$) { my ($fs, $pos, $size) = @_; - print "reading $size bytes at $pos\n"; my $buf = "\0" x $size; sysseek $fs->{fd}, $pos, 0 or die "seeking to byte #$pos failed on device $fs->{fs_name}"; sysread $fs->{fd}, $buf, $size or die "reading at byte #$pos failed on device $fs->{fs_name}"; $buf; } sub write($$$$) { - my ($fs, $pos, $size, $buf) = @_; + my ($fs, $pos, $_size, $buf) = @_; sysseek $fs->{fd}, $pos, 0 or die "seeking to byte #$pos failed on device $fs->{fs_name}"; syswrite $fs->{fd}, $buf or die "writing at byte #$pos failed on device $fs->{fs_name}"; } @@ -44,28 +43,16 @@ sub read_file($$) { my ($fs, $cluster) = @_; my $buf = ''; - for (; !resize_fat::fat::is_eof($cluster); $cluster = resize_fat::fat::next ($fs, $cluster)) { + for (; !resize_fat::fat::is_eof($cluster); $cluster = resize_fat::fat::next($fs, $cluster)) { $cluster == 0 and die "Bad FAT: unterminated chain\n"; $buf .= read_cluster($fs, $cluster); } $buf; } -sub check_mounted($) { - my ($f) = @_; - - local *F; - open F, "/proc/mounts" or die "error opening /proc/mounts\n"; - foreach (<F>) { - /^$f\s/ and die "device is mounted"; - } -} - -sub open($) { +sub open { my ($fs) = @_; - check_mounted($fs->{device}); - - sysopen F, $fs->{fs_name}, 2 or sysopen F, $fs->{fs_name}, 0 or die "error opening device $fs->{fs_name} for writing\n"; - $fs->{fd} = *F; + sysopen $fs->{fd}, $fs->{fs_name}, 2 or + sysopen $fs->{fd}, $fs->{fs_name}, 0 or die "error opening device $fs->{fs_name} for writing\n"; } |