<div dir="ltr"><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(36,39,41);font-family:arial,&quot;helvetica neue&quot;,helvetica,sans-serif">Hi All,</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(36,39,41);font-family:arial,&quot;helvetica neue&quot;,helvetica,sans-serif">          I am trying to write a linux kernel module which can send/receive ATA SMART cmds to a HDD. The kernel module will take a set of actions based on the responses it receives from the HDD. I went through the ATA smart cmds spec and the &quot;smartctl&quot; user space code which sends the ATA cmds from user space via SG_IO ioctl cmd. I am not able to figure out how to open /dev/sda from kernel and achieve similar functionalities line &quot;smartctl&quot; tool from a kernel module.</p><ol style="margin:0px 0px 1em 30px;padding:0px;border:0px;font-size:15px;color:rgb(36,39,41);font-family:arial,&quot;helvetica neue&quot;,helvetica,sans-serif"><li style="margin:0px 0px 0.5em;padding:0px;border:0px;word-wrap:break-word"><p style="margin:0px;padding:0px;border:0px;clear:both">Can someone point me to any sample code which tries to send ATA smart cmds from a kernel module instead of user space via ioctl?</p></li><li style="margin:0px;padding:0px;border:0px;word-wrap:break-word"><p style="margin:0px;padding:0px;border:0px;clear:both">Seems like I need to use some exported API from SG driver or libata. is this the right direction? </p></li><li style="margin:0px;padding:0px;border:0px;word-wrap:break-word"><p style="margin:0px;padding:0px;border:0px;clear:both">Please feel free to suggest how can I achieve this.</p></li></ol><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(36,39,41);font-family:arial,&quot;helvetica neue&quot;,helvetica,sans-serif">Thanks, Sid</p></div>