Block-level access

From: Alex Austin
Date: Thu Sep 01 2016 - 17:43:20 EST


Hello,
What is the most performant way to directly interface with an attached hard
drive? I've so far used read()/write() on /dev/sd_ but I find error handling
exceedingly difficult, as I don't always even get errors reported, even if the
open() call includes O_DIRECT. I've also used ioctl(SG_IO), but find that it's
extremely slow due to the lack of queuing support in the API. Is there a
mid-level API that will get me decent error handling while allowing command
queuing, or do I just need to make multiple threads all doing separate SG_IO
ioctls?

Thank you,
- Alex Austin

--
Intelligence is knowing that a tomato is a fruit; wisdom is knowing that it
doesn't go in a fruit salad; charisma is selling a tomato-based fruit salad.