Send/receive ATA cmds from a linux kernel module

Siddhartha Baral baralsg at gmail.com
Mon Jan 30 14:38:01 EST 2017


Hi All,

          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 "smartctl" 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 "smartctl"
tool from a kernel module.

   1.

   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?
   2.

   Seems like I need to use some exported API from SG driver or libata. is
   this the right direction?
   3.

   Please feel free to suggest how can I achieve this.

Thanks, Sid
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20170130/90b72956/attachment.html 


More information about the Kernelnewbies mailing list