&init_config();
do '../ui-lib.pl';
&foreign_require("fdisk", "fdisk-lib.pl");
-$ata_switch = $config{'ata'} ? "-d ata" : "";
+$extra_args = $config{'extra'};
+if ($config{'ata'}) {
+ $extra_args .= " -d ata";
+ }
# get_smart_version()
sub get_smart_version
# Use new command format
# Check support
- local $out = `$config{'smartctl'} $ata_switch -i $qd 2>&1`;
+ local $out = `$config{'smartctl'} $extra_args -i $qd 2>&1`;
if ($out =~ /SMART\s+support\s+is:\s+Available/i) {
$rv{'support'} = 1;
}
}
# Check status
- $out = `$config{'smartctl'} $ata_switch -H $qd 2>&1`;
+ $out = `$config{'smartctl'} $extra_args -H $qd 2>&1`;
if ($out =~ /test result: FAILED/i) {
$rv{'check'} = 0;
}
# Use old command format
# Check status
- local $out = `$config{'smartctl'} $ata_switch -c $qd 2>&1`;
+ local $out = `$config{'smartctl'} $extra_args -c $qd 2>&1`;
if ($out =~ /supports S.M.A.R.T./i) {
$rv{'support'} = 1;
}
# Fetch other attributes
local ($lastline, @attribs);
local $doneknown = 0;
- open(OUT, "$config{'smartctl'} $ata_switch -a $qd |");
+ open(OUT, "$config{'smartctl'} $extra_args -a $qd |");
while(<OUT>) {
s/\r|\n//g;
if (/^\((\s*\d+)\)(.*)\s(0x\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/) {
sub short_test
{
if (&get_smart_version() > 5.0) {
- local $out = &backquote_logged("$config{'smartctl'} $ata_switch -t short $_[0] 2>&1");
+ local $out = &backquote_logged("$config{'smartctl'} $extra_args -t short $_[0] 2>&1");
if ($? || $out !~ /testing has begun/i) {
return (0, $out);
}
}
}
else {
- local $out = &backquote_logged("$config{'smartctl'} $ata_switch -S $_[0] 2>&1");
+ local $out = &backquote_logged("$config{'smartctl'} $extra_args -S $_[0] 2>&1");
if ($? || $out !~ /test has begun/i) {
return (0, $out);
}
sub ext_test
{
if (&get_smart_version() > 5.0) {
- local $out = &backquote_logged("$config{'smartctl'} $ata_switch -t long $_[0] 2>&1");
+ local $out = &backquote_logged("$config{'smartctl'} $extra_args -t long $_[0] 2>&1");
if ($? || $out !~ /testing has begun/i) {
return (0, $out);
}
}
}
else {
- local $out = &backquote_logged("$config{'smartctl'} $ata_switch -X $_[0] 2>&1");
+ local $out = &backquote_logged("$config{'smartctl'} $extra_args -X $_[0] 2>&1");
if ($? || $out !~ /test has begun/i) {
return (0, $out);
}
sub data_test
{
if (&get_smart_version() > 5.0) {
- local $out = &backquote_logged("$config{'smartctl'} $ata_switch -t offline $_[0] 2>&1");
+ local $out = &backquote_logged("$config{'smartctl'} $extra_args -t offline $_[0] 2>&1");
if ($? || $out !~ /testing has begun/i) {
return (0, $out);
}
}
}
else {
- local $out = &backquote_logged("$config{'smartctl'} $ata_switch -O $_[0] 2>&1");
+ local $out = &backquote_logged("$config{'smartctl'} $extra_args -O $_[0] 2>&1");
if ($? || $out !~ /test has begun/i) {
return (0, $out);
}