diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2001-01-07 14:35:06 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2001-01-07 14:35:06 +0000 |
commit | 74bc44f61e05b3ff2aaa2632cf3560682c51cbf4 (patch) | |
tree | 4f4caddc6682593966af7aee6f52425df0b2fd52 | |
parent | e60ed33ff9d02df22dfba05ace0a1a1fa6b506e5 (diff) | |
download | drakx-backup-do-not-use-74bc44f61e05b3ff2aaa2632cf3560682c51cbf4.tar drakx-backup-do-not-use-74bc44f61e05b3ff2aaa2632cf3560682c51cbf4.tar.gz drakx-backup-do-not-use-74bc44f61e05b3ff2aaa2632cf3560682c51cbf4.tar.bz2 drakx-backup-do-not-use-74bc44f61e05b3ff2aaa2632cf3560682c51cbf4.tar.xz drakx-backup-do-not-use-74bc44f61e05b3ff2aaa2632cf3560682c51cbf4.zip |
(test_for_bad_drives): created
- ugly stuff needed mainly for Western Digital IDE drives
- try writing what we've just read, yells if it fails
- testing on last sector of head #0 (unused in 99% cases)
-rw-r--r-- | perl-install/partition_table_raw.pm | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/perl-install/partition_table_raw.pm b/perl-install/partition_table_raw.pm index aae6f843c..0b3ec41b5 100644 --- a/perl-install/partition_table_raw.pm +++ b/perl-install/partition_table_raw.pm @@ -3,7 +3,7 @@ package partition_table_raw; # $Id$ use diagnostics; use strict; -use common qw(:common :system :file); +use common qw(:common :system :file :constant); use devices; use c; @@ -133,4 +133,32 @@ sub zero_MBR_and_dirty { } +#- ugly stuff needed mainly for Western Digital IDE drives +#- try writing what we've just read, yells if it fails +#- testing on last sector of head #0 (unused in 99% cases) +sub test_for_bad_drives { + my ($hd) = @_; + + log::l("test_for_bad_drives($hd->{file})"); + my $sector = $hd->{geom}{sectors} - 1; + + + local *F; partition_table_raw::openit($hd, *F, 2) or die "error opening device $hd->{device} for writing"; + + my $seek = sub { + c::lseek_sector(fileno(F), $sector, 0) or die "seeking to sector $sector failed"; + }; + my $tmp; + + &$seek; sysread F, $tmp, $SECTORSIZE or die "test_for_bad_drives: can't even read ($!)"; + &$seek; syswrite F, $tmp or die "test_for_bad_drives: can't even write ($!)"; + + my $tmp2; + &$seek; sysread F, $tmp2, $SECTORSIZE or die "test_for_bad_drives: can't even read again ($!)"; + $tmp eq $tmp2 or die +_("Something bad is happening on your drive. +A test to check the integrity of data has failed. +It means writing anything on the disk will end up with random trash"); +} + 1; |