{"action":"created","comment":{"url":"https://api.github.com/repos/virtium/vtStor/pulls/comments/47923936","id":47923936,"diff_hunk":"@@ -27,164 +30,135 @@ namespace vtStor\n namespace Protocol\r\n {\r\n \r\n-    const vtStor::U8 FEATURE_REGISTER_OFFSET = 0;\r\n-    const vtStor::U8 ERROR_REGISTER_OFFSET = 0;\r\n-    const vtStor::U8 COUNT_REGISTER_OFFSET = 1;\r\n-    const vtStor::U8 LBA_LOW_REGISTER_OFFSET = 2;\r\n-    const vtStor::U8 LBA_MID_REGISTER_OFFSET = 3;\r\n-    const vtStor::U8 LBA_HIGH_REGISTER_OFFSET = 4;\r\n-    const vtStor::U8 DEVICE_REGISTER_OFFSET = 5;\r\n-    const vtStor::U8 COMMAND_REGISTER_OFFSET = 6;\r\n-    const vtStor::U8 STATUS_REGISTER_OFFSET = 6;\r\n-    const vtStor::U8 RESERVED_REGISTER_OFFSET = 7;\r\n-    \r\n-   /* eErrorCode cAtaPassThrough::IssueCommand( const DeviceHandle& Handle, std::shared_ptr<const cBufferInterface> Essense, std::shared_ptr<cBufferInterface> DataBuffer )\r\n-    {\r\n-        eErrorCode errorCode = eErrorCode::None;\r\n+eErrorCode cAtaPassThrough::IssueCommand(const DeviceHandle& Handle, std::shared_ptr<const cBufferInterface> Essense, std::shared_ptr<cBufferInterface> DataBuffer)\r\n+{\r\n+    eErrorCode errorCode = eErrorCode::None;\r\n \r\n-        cBufferFormatter bufferFormatter = cBufferFormatter::Reader(Essense);       \r\n-        \r\n-        switch (bufferFormatter.GetHeader().Format)\r\n-        {\r\n-            case 1:\r\n-            {\r\n-                cEssenseAta1 essense = cEssenseAta1::Reader(Essense);\r\n-                \r\n-                InitializePassThroughDirect(\r\n-                    essense.GetCommandCharacteristics(),\r\n-                    essense.GetTaskFileExt(),\r\n-                    essense.GetTaskFile(),\r\n-                    DataBuffer,\r\n-                    60 //TODO: allow configurable timeout\r\n-                    );\r\n-                  \r\n-                U32 bytesReturned = 0;\r\n-                errorCode = IssuePassThroughDirectCommand(Handle, bytesReturned);\r\n-            } break;\r\n-\r\n-            default:\r\n-                errorCode = eErrorCode::FormatNotSupported;\r\n-                break; \r\n-        }        \r\n-\r\n-        return(errorCode);\r\n-    }\r\n-*/\r\n-   /* void cAtaPassThrough::InitializePassThroughDirect( const StorageUtility::Ata::sCommandCharacteristic& CommandCharacteristics, const StorageUtility::Ata::uTaskFileRegister& PreviousTaskFile, const StorageUtility::Ata::uTaskFileRegister& CurrentTaskFile, std::shared_ptr<cBufferInterface> DataBuffer, U32 TimeoutValueInSeconds )\r\n+    cBufferFormatter bufferFormatter = cBufferFormatter::Reader(Essense);\r\n+\r\n+    switch (bufferFormatter.GetHeader().Format)\r\n+    {\r\n+    case 1:\r\n     {\r\n-        m_AtaPassThrough.Length = sizeof( ATA_PASS_THROUGH_DIRECT );\r\n-        m_AtaPassThrough.DataTransferLength = CommandCharacteristics.DataTransferLengthInBytes;\r\n-        m_AtaPassThrough.TimeOutValue = TimeoutValueInSeconds;\r\n-        if (nullptr != DataBuffer)\r\n+        cEssenseAta1 essense = cEssenseAta1::Reader(Essense);\r\n+\r\n+        InitializePassThroughDirect(essense.GetCommandCharacteristics(), essense.GetTaskFileExt(), essense.GetTaskFile(), DataBuffer, 60);\r\n+\r\n+        if (IOCTL_SG_IO_ERROR == ioctl(Handle.Handle, SG_IO, &m_ATAPassThrough))\r\n         {\r\n-            m_AtaPassThrough.DataBuffer = DataBuffer->ToDataBuffer();\r\n+            //! ERROR: IOCTL SG_IO was not successful\r\n+            return(eErrorCode::Io);\r\n         }\r\n-        m_AtaPassThrough.ReservedAsUchar = 0;\r\n-        m_AtaPassThrough.ReservedAsUlong = 0;\r\n+    } break;\r\n \r\n-        InitializeFlags( CommandCharacteristics );\r\n-        InitializeTaskFileInputRegisters( PreviousTaskFile, CurrentTaskFile );\r\n+    default:\r\n+    {\r\n+        errorCode = eErrorCode::FormatNotSupported;\r\n+    } break;\r\n     }\r\n \r\n-    void cAtaPassThrough::InitializeFlags( const StorageUtility::Ata::sCommandCharacteristic& AtaCommandCharacteristic )\r\n-    {\r\n-        // Clear all flags\r\n-        m_AtaPassThrough.AtaFlags = 0;\r\n+    return(errorCode);\r\n+}\r\n \r\n-        if (StorageUtility::Ata::eDeviceReadyFlag::DEVICE_READY_REQUIRED == AtaCommandCharacteristic.DeviceReadyFlag)\r\n-        {\r\n-            m_AtaPassThrough.AtaFlags |= ATA_FLAGS_DRDY_REQUIRED;\r\n-        }\r\n+void cAtaPassThrough::InitializePassThroughDirect(\r\n+        const StorageUtility::Ata::sCommandCharacteristic& CommandCharacteristics,\r\n+        const StorageUtility::Ata::uTaskFileRegister& PreviousTaskFile,\r\n+        const StorageUtility::Ata::uTaskFileRegister& CurrentTaskFile,\r\n+        std::shared_ptr<cBufferInterface> DataBuffer,\r\n+        U32 TimeoutValueInSeconds\r\n+        )\r\n+{\r\n+    memset(&m_SenseData, 0, sizeof(m_SenseData));\r\n+    memset(&m_ATAPassThrough, 0, sizeof(sg_io_hdr));\r\n \r\n-        switch (AtaCommandCharacteristic.DataAccess)\r\n-        {\r\n-        case StorageUtility::Ata::eDataAccess::READ_FROM_DEVICE:\r\n-        {\r\n-            m_AtaPassThrough.AtaFlags |= ATA_FLAGS_DATA_IN;\r\n-        } break;\r\n-        case StorageUtility::Ata::eDataAccess::WRITE_TO_DEVICE:\r\n-        {\r\n-            m_AtaPassThrough.AtaFlags |= ATA_FLAGS_DATA_OUT;\r\n-        } break;\r\n-        }\r\n+    m_ATAPassThrough.interface_id     = 'S';\r","path":"vtStorAtaProtocol/Platform/Linux/ProtocolAtaPassThrough.cpp","position":130,"original_position":130,"commit_id":"7f5d96f9ac914ad3e61d6eb66e692a2a69a35761","original_commit_id":"7f5d96f9ac914ad3e61d6eb66e692a2a69a35761","user":{"login":"tranminhtam","id":12590755,"avatar_url":"https://avatars.githubusercontent.com/u/12590755?v=3","gravatar_id":"","url":"https://api.github.com/users/tranminhtam","html_url":"https://github.com/tranminhtam","followers_url":"https://api.github.com/users/tranminhtam/followers","following_url":"https://api.github.com/users/tranminhtam/following{/other_user}","gists_url":"https://api.github.com/users/tranminhtam/gists{/gist_id}","starred_url":"https://api.github.com/users/tranminhtam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tranminhtam/subscriptions","organizations_url":"https://api.github.com/users/tranminhtam/orgs","repos_url":"https://api.github.com/users/tranminhtam/repos","events_url":"https://api.github.com/users/tranminhtam/events{/privacy}","received_events_url":"https://api.github.com/users/tranminhtam/received_events","type":"User","site_admin":false},"body":"we should define this value also","created_at":"2015-12-17T16:11:00Z","updated_at":"2015-12-17T16:11:00Z","html_url":"https://github.com/virtium/vtStor/pull/49#discussion_r47923936","pull_request_url":"https://api.github.com/repos/virtium/vtStor/pulls/49","_links":{"self":{"href":"https://api.github.com/repos/virtium/vtStor/pulls/comments/47923936"},"html":{"href":"https://github.com/virtium/vtStor/pull/49#discussion_r47923936"},"pull_request":{"href":"https://api.github.com/repos/virtium/vtStor/pulls/49"}}},"pull_request":{"url":"https://api.github.com/repos/virtium/vtStor/pulls/49","id":53957607,"html_url":"https://github.com/virtium/vtStor/pull/49","diff_url":"https://github.com/virtium/vtStor/pull/49.diff","patch_url":"https://github.com/virtium/vtStor/pull/49.patch","issue_url":"https://api.github.com/repos/virtium/vtStor/issues/49","number":49,"state":"open","locked":false,"title":"Issue ata command","user":{"login":"MaiChiemMinh","id":15210308,"avatar_url":"https://avatars.githubusercontent.com/u/15210308?v=3","gravatar_id":"","url":"https://api.github.com/users/MaiChiemMinh","html_url":"https://github.com/MaiChiemMinh","followers_url":"https://api.github.com/users/MaiChiemMinh/followers","following_url":"https://api.github.com/users/MaiChiemMinh/following{/other_user}","gists_url":"https://api.github.com/users/MaiChiemMinh/gists{/gist_id}","starred_url":"https://api.github.com/users/MaiChiemMinh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MaiChiemMinh/subscriptions","organizations_url":"https://api.github.com/users/MaiChiemMinh/orgs","repos_url":"https://api.github.com/users/MaiChiemMinh/repos","events_url":"https://api.github.com/users/MaiChiemMinh/events{/privacy}","received_events_url":"https://api.github.com/users/MaiChiemMinh/received_events","type":"User","site_admin":false},"body":"- Implement Protocol layer for issue ATA command","created_at":"2015-12-17T10:18:50Z","updated_at":"2015-12-17T16:11:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/virtium/vtStor/pulls/49/commits","review_comments_url":"https://api.github.com/repos/virtium/vtStor/pulls/49/comments","review_comment_url":"https://api.github.com/repos/virtium/vtStor/pulls/comments{/number}","comments_url":"https://api.github.com/repos/virtium/vtStor/issues/49/comments","statuses_url":"https://api.github.com/repos/virtium/vtStor/statuses/7f5d96f9ac914ad3e61d6eb66e692a2a69a35761","head":{"label":"MaiChiemMinh:Issue_ATA_Command","ref":"Issue_ATA_Command","sha":"7f5d96f9ac914ad3e61d6eb66e692a2a69a35761","user":{"login":"MaiChiemMinh","id":15210308,"avatar_url":"https://avatars.githubusercontent.com/u/15210308?v=3","gravatar_id":"","url":"https://api.github.com/users/MaiChiemMinh","html_url":"https://github.com/MaiChiemMinh","followers_url":"https://api.github.com/users/MaiChiemMinh/followers","following_url":"https://api.github.com/users/MaiChiemMinh/following{/other_user}","gists_url":"https://api.github.com/users/MaiChiemMinh/gists{/gist_id}","starred_url":"https://api.github.com/users/MaiChiemMinh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MaiChiemMinh/subscriptions","organizations_url":"https://api.github.com/users/MaiChiemMinh/orgs","repos_url":"https://api.github.com/users/MaiChiemMinh/repos","events_url":"https://api.github.com/users/MaiChiemMinh/events{/privacy}","received_events_url":"https://api.github.com/users/MaiChiemMinh/received_events","type":"User","site_admin":false},"repo":{"id":45511669,"name":"vtStor","full_name":"MaiChiemMinh/vtStor","owner":{"login":"MaiChiemMinh","id":15210308,"avatar_url":"https://avatars.githubusercontent.com/u/15210308?v=3","gravatar_id":"","url":"https://api.github.com/users/MaiChiemMinh","html_url":"https://github.com/MaiChiemMinh","followers_url":"https://api.github.com/users/MaiChiemMinh/followers","following_url":"https://api.github.com/users/MaiChiemMinh/following{/other_user}","gists_url":"https://api.github.com/users/MaiChiemMinh/gists{/gist_id}","starred_url":"https://api.github.com/users/MaiChiemMinh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MaiChiemMinh/subscriptions","organizations_url":"https://api.github.com/users/MaiChiemMinh/orgs","repos_url":"https://api.github.com/users/MaiChiemMinh/repos","events_url":"https://api.github.com/users/MaiChiemMinh/events{/privacy}","received_events_url":"https://api.github.com/users/MaiChiemMinh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/MaiChiemMinh/vtStor","description":"This is a library (or set of libraries) to allow easy access and communication to storage devices.","fork":true,"url":"https://api.github.com/repos/MaiChiemMinh/vtStor","forks_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/forks","keys_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/teams","hooks_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/hooks","issue_events_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/issues/events{/number}","events_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/events","assignees_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/assignees{/user}","branches_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/branches{/branch}","tags_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/tags","blobs_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/git/refs{/sha}","trees_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/statuses/{sha}","languages_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/languages","stargazers_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/stargazers","contributors_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/contributors","subscribers_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/subscribers","subscription_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/subscription","commits_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/commits{/sha}","git_commits_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/git/commits{/sha}","comments_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/comments{/number}","issue_comment_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/issues/comments{/number}","contents_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/contents/{+path}","compare_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/merges","archive_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/downloads","issues_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/issues{/number}","pulls_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/pulls{/number}","milestones_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/milestones{/number}","notifications_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/labels{/name}","releases_url":"https://api.github.com/repos/MaiChiemMinh/vtStor/releases{/id}","created_at":"2015-11-04T03:00:36Z","updated_at":"2015-11-04T03:00:37Z","pushed_at":"2015-12-17T10:16:56Z","git_url":"git://github.com/MaiChiemMinh/vtStor.git","ssh_url":"git@github.com:MaiChiemMinh/vtStor.git","clone_url":"https://github.com/MaiChiemMinh/vtStor.git","svn_url":"https://github.com/MaiChiemMinh/vtStor","homepage":"","size":394,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"virtium:master","ref":"master","sha":"0466c02b8c43164cfb21054803cf48acca96f428","user":{"login":"virtium","id":11761410,"avatar_url":"https://avatars.githubusercontent.com/u/11761410?v=3","gravatar_id":"","url":"https://api.github.com/users/virtium","html_url":"https://github.com/virtium","followers_url":"https://api.github.com/users/virtium/followers","following_url":"https://api.github.com/users/virtium/following{/other_user}","gists_url":"https://api.github.com/users/virtium/gists{/gist_id}","starred_url":"https://api.github.com/users/virtium/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/virtium/subscriptions","organizations_url":"https://api.github.com/users/virtium/orgs","repos_url":"https://api.github.com/users/virtium/repos","events_url":"https://api.github.com/users/virtium/events{/privacy}","received_events_url":"https://api.github.com/users/virtium/received_events","type":"Organization","site_admin":false},"repo":{"id":33378855,"name":"vtStor","full_name":"virtium/vtStor","owner":{"login":"virtium","id":11761410,"avatar_url":"https://avatars.githubusercontent.com/u/11761410?v=3","gravatar_id":"","url":"https://api.github.com/users/virtium","html_url":"https://github.com/virtium","followers_url":"https://api.github.com/users/virtium/followers","following_url":"https://api.github.com/users/virtium/following{/other_user}","gists_url":"https://api.github.com/users/virtium/gists{/gist_id}","starred_url":"https://api.github.com/users/virtium/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/virtium/subscriptions","organizations_url":"https://api.github.com/users/virtium/orgs","repos_url":"https://api.github.com/users/virtium/repos","events_url":"https://api.github.com/users/virtium/events{/privacy}","received_events_url":"https://api.github.com/users/virtium/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/virtium/vtStor","description":"This is a library (or set of libraries) to allow easy access and communication to storage devices.","fork":false,"url":"https://api.github.com/repos/virtium/vtStor","forks_url":"https://api.github.com/repos/virtium/vtStor/forks","keys_url":"https://api.github.com/repos/virtium/vtStor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/virtium/vtStor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/virtium/vtStor/teams","hooks_url":"https://api.github.com/repos/virtium/vtStor/hooks","issue_events_url":"https://api.github.com/repos/virtium/vtStor/issues/events{/number}","events_url":"https://api.github.com/repos/virtium/vtStor/events","assignees_url":"https://api.github.com/repos/virtium/vtStor/assignees{/user}","branches_url":"https://api.github.com/repos/virtium/vtStor/branches{/branch}","tags_url":"https://api.github.com/repos/virtium/vtStor/tags","blobs_url":"https://api.github.com/repos/virtium/vtStor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/virtium/vtStor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/virtium/vtStor/git/refs{/sha}","trees_url":"https://api.github.com/repos/virtium/vtStor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/virtium/vtStor/statuses/{sha}","languages_url":"https://api.github.com/repos/virtium/vtStor/languages","stargazers_url":"https://api.github.com/repos/virtium/vtStor/stargazers","contributors_url":"https://api.github.com/repos/virtium/vtStor/contributors","subscribers_url":"https://api.github.com/repos/virtium/vtStor/subscribers","subscription_url":"https://api.github.com/repos/virtium/vtStor/subscription","commits_url":"https://api.github.com/repos/virtium/vtStor/commits{/sha}","git_commits_url":"https://api.github.com/repos/virtium/vtStor/git/commits{/sha}","comments_url":"https://api.github.com/repos/virtium/vtStor/comments{/number}","issue_comment_url":"https://api.github.com/repos/virtium/vtStor/issues/comments{/number}","contents_url":"https://api.github.com/repos/virtium/vtStor/contents/{+path}","compare_url":"https://api.github.com/repos/virtium/vtStor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/virtium/vtStor/merges","archive_url":"https://api.github.com/repos/virtium/vtStor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/virtium/vtStor/downloads","issues_url":"https://api.github.com/repos/virtium/vtStor/issues{/number}","pulls_url":"https://api.github.com/repos/virtium/vtStor/pulls{/number}","milestones_url":"https://api.github.com/repos/virtium/vtStor/milestones{/number}","notifications_url":"https://api.github.com/repos/virtium/vtStor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/virtium/vtStor/labels{/name}","releases_url":"https://api.github.com/repos/virtium/vtStor/releases{/id}","created_at":"2015-04-03T19:21:31Z","updated_at":"2015-05-06T18:57:23Z","pushed_at":"2015-12-17T10:18:51Z","git_url":"git://github.com/virtium/vtStor.git","ssh_url":"git@github.com:virtium/vtStor.git","clone_url":"https://github.com/virtium/vtStor.git","svn_url":"https://github.com/virtium/vtStor","homepage":"","size":1325,"stargazers_count":1,"watchers_count":1,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":6,"forks":6,"open_issues":6,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/virtium/vtStor/pulls/49"},"html":{"href":"https://github.com/virtium/vtStor/pull/49"},"issue":{"href":"https://api.github.com/repos/virtium/vtStor/issues/49"},"comments":{"href":"https://api.github.com/repos/virtium/vtStor/issues/49/comments"},"review_comments":{"href":"https://api.github.com/repos/virtium/vtStor/pulls/49/comments"},"review_comment":{"href":"https://api.github.com/repos/virtium/vtStor/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/virtium/vtStor/pulls/49/commits"},"statuses":{"href":"https://api.github.com/repos/virtium/vtStor/statuses/7f5d96f9ac914ad3e61d6eb66e692a2a69a35761"}}}}