Commit 3b635d89 authored by chrfranke's avatar chrfranke
Browse files

Linux: Allow smartd 'DEVICESCAN -d sat' (ticket #13).

git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@3042 4ea69e1a-61f1-4043-bf83-b5c94c648137
parent 5773d267
......@@ -43,6 +43,12 @@ NOTES FOR FUTURE RELEASES: see TODO file.
<DEVELOPERS: ADDITIONS TO THE CHANGE LOG GO JUST BELOW HERE, PLEASE>
[CF] Linux: Allow smartd 'DEVICESCAN -d sat' (ticket #13).
Detects (S)ATA devices behind a standard SAT layer
(Vendor ID: "ATA "), but not USB bridges with SAT support.
Only added for backward compatibility with 5.38.
No longer needed as 'DEVICESCAN' without '-d' includes these devices.
[CF] Add USB ID of Seagate FreeAgent Desktop.
[CF] smartd: Fix directive '-l selftest' (ticket #36)
......
......@@ -14,6 +14,7 @@ Summary: smartmontools release 5.40
which can be downloaded from SVN.
- Fix regression in smartctl option '-q, --quietmode'.
- Fix regression in smartd directive '-l selftest'.
- Linux: Allow smartd 'DEVICESCAN -d sat'.
Date 2009-12-09
Summary: smartmontools release 5.39 (UNSTABLE/EXPERIMENTAL)
......
......@@ -831,17 +831,22 @@ class linux_scsi_device
public /*extends*/ linux_smart_device
{
public:
linux_scsi_device(smart_interface * intf, const char * dev_name, const char * req_type);
linux_scsi_device(smart_interface * intf, const char * dev_name,
const char * req_type, bool scanning = false);
virtual smart_device * autodetect_open();
virtual bool scsi_pass_through(scsi_cmnd_io * iop);
private:
bool m_scanning; ///< true if created within scan_smart_devices
};
linux_scsi_device::linux_scsi_device(smart_interface * intf,
const char * dev_name, const char * req_type)
const char * dev_name, const char * req_type, bool scanning /*= false*/)
: smart_device(intf, dev_name, "scsi", req_type),
linux_smart_device(O_RDWR | O_NONBLOCK, O_RDONLY | O_NONBLOCK)
linux_smart_device(O_RDWR | O_NONBLOCK, O_RDONLY | O_NONBLOCK),
m_scanning(scanning)
{
}
......@@ -2646,8 +2651,13 @@ smart_device * linux_scsi_device::autodetect_open()
return this;
// No Autodetection if device type was specified by user
if (*get_req_type())
bool sat_only = false;
if (*get_req_type()) {
// Detect SAT if device object was created by scan_smart_devices().
if (!(m_scanning && !strcmp(get_req_type(), "sat")))
return this;
sat_only = true;
}
// The code below is based on smartd.cpp:SCSIFilterKnown()
......@@ -2668,10 +2678,16 @@ smart_device * linux_scsi_device::autodetect_open()
int avail_len = req_buff[4] + 5;
int len = (avail_len < req_len ? avail_len : req_len);
if (len < 36)
if (len < 36) {
if (sat_only) {
close();
set_err(EIO, "INQUIRY too short for SAT");
}
return this;
}
// Use INQUIRY to detect type
if (!sat_only) {
// 3ware ?
if (!memcmp(req_buff + 8, "3ware", 5) || !memcmp(req_buff + 8, "AMCC", 4)) {
......@@ -2699,6 +2715,7 @@ smart_device * linux_scsi_device::autodetect_open()
delete this;
return newdev.release();
}
}
// SAT or USB ?
{
......@@ -2709,6 +2726,11 @@ smart_device * linux_scsi_device::autodetect_open()
}
// Nothing special found
if (sat_only) {
close();
set_err(EIO, "Not a SAT device");
}
return this;
}
......@@ -2891,7 +2913,7 @@ bool linux_smart_interface::get_dev_list(smart_device_list & devlist,
if (autodetect)
dev = autodetect_smart_device(name);
else if (is_scsi)
dev = new linux_scsi_device(this, name, req_type);
dev = new linux_scsi_device(this, name, req_type, true /*scanning*/);
else
dev = new linux_ata_device(this, name, req_type);
if (dev) // autodetect_smart_device() may return nullptr.
......@@ -2917,7 +2939,8 @@ bool linux_smart_interface::scan_smart_devices(smart_device_list & devlist,
type = "";
bool scan_ata = (!*type || !strcmp(type, "ata" ));
bool scan_scsi = (!*type || !strcmp(type, "scsi"));
// "sat" detection will be later handled in linux_scsi_device::autodetect_open()
bool scan_scsi = (!*type || !strcmp(type, "scsi") || !strcmp(type, "sat"));
if (!(scan_ata || scan_scsi))
return true;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment