X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=dev_interface.cpp;h=71bf8bcd35cf2fe30e0a2a0947649c5785da0afa;hb=6c5eb127c873bd2414f28b25ba1f9bae494cf516;hp=7651244aeb069e88d6bbf16775e3c50e53e7f02d;hpb=f1f0e7e50323445180082be11e9a4d718adc7c8d;p=mirror_smartmontools-debian.git diff --git a/dev_interface.cpp b/dev_interface.cpp index 7651244..71bf8bc 100644 --- a/dev_interface.cpp +++ b/dev_interface.cpp @@ -3,7 +3,7 @@ * * Home page of code is: http://smartmontools.sourceforge.net * - * Copyright (C) 2008-12 Christian Franke + * Copyright (C) 2008-13 Christian Franke * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,7 @@ #include "int64.h" #include "dev_interface.h" #include "dev_tunnelled.h" +#include "atacmds.h" // ATA_SMART_CMD/STATUS #include "utility.h" #include @@ -31,7 +32,7 @@ #include #endif -const char * dev_interface_cpp_cvsid = "$Id: dev_interface.cpp 3554 2012-06-01 20:11:46Z chrfranke $" +const char * dev_interface_cpp_cvsid = "$Id: dev_interface.cpp 3741 2013-01-02 17:06:54Z chrfranke $" DEV_INTERFACE_H_CVSID; ///////////////////////////////////////////////////////////////////////////// @@ -138,10 +139,8 @@ bool ata_device::ata_pass_through(const ata_cmd_in & in) return ata_pass_through(in, dummy); } -bool ata_device::ata_cmd_is_ok(const ata_cmd_in & in, - bool data_out_support /*= false*/, - bool multi_sector_support /*= false*/, - bool ata_48bit_support /*= false*/) +bool ata_device::ata_cmd_is_supported(const ata_cmd_in & in, + unsigned flags, const char * type /* = 0 */) { // Check DATA IN/OUT switch (in.direction) { @@ -167,12 +166,25 @@ bool ata_device::ata_cmd_is_ok(const ata_cmd_in & in, } // Check features - if (in.direction == ata_cmd_in::data_out && !data_out_support) - return set_err(ENOSYS, "DATA OUT ATA commands not supported"); - if (!(in.size == 0 || in.size == 512) && !multi_sector_support) - return set_err(ENOSYS, "Multi-sector ATA commands not supported"); - if (in.in_regs.is_48bit_cmd() && !ata_48bit_support) - return set_err(ENOSYS, "48-bit ATA commands not supported"); + const char * errmsg = 0; + if (in.direction == ata_cmd_in::data_out && !(flags & supports_data_out)) + errmsg = "DATA OUT ATA commands not implemented"; + else if ( in.out_needed.is_set() && !(flags & supports_output_regs) + && !( in.in_regs.command == ATA_SMART_CMD + && in.in_regs.features == ATA_SMART_STATUS + && (flags & supports_smart_status))) + errmsg = "Read of ATA output registers not implemented"; + else if (!(in.size == 0 || in.size == 512) && !(flags & supports_multi_sector)) + errmsg = "Multi-sector ATA commands not implemented"; + else if (in.in_regs.is_48bit_cmd() && !(flags & (supports_48bit_hi_null|supports_48bit))) + errmsg = "48-bit ATA commands not implemented"; + else if (in.in_regs.is_real_48bit_cmd() && !(flags & supports_48bit)) + errmsg = "48-bit ATA commands not fully implemented"; + + if (errmsg) + return set_err(ENOSYS, "%s%s%s%s", errmsg, + (type ? " [" : ""), (type ? type : ""), (type ? "]" : "")); + return true; } @@ -246,7 +258,7 @@ std::string smart_interface::get_valid_dev_types_str() { // default std::string s = - "ata, scsi, sat[,auto][,N][+TYPE], usbcypress[,X], usbjmicron[,x][,N], usbsunplus"; + "ata, scsi, sat[,auto][,N][+TYPE], usbcypress[,X], usbjmicron[,p][,x][,N], usbsunplus"; // append custom std::string s2 = get_valid_custom_dev_types_str(); if (!s2.empty()) {