Accessing the hard disk using the /dev/sda interface
Hi,
I am developing a program which can access the SATA-hard disk. I have to use the /dev/sda interface for accessing the hard disk. What are all the commands i can use to perform the sector read, write (Both DMA and PIO), sending the smart commands etc. Or is there any easier way? I saw that i can make use of hdparm call for getting some of the attributes. Regards, Aneesh |
Hi,
You query is not very clear. Why do you need device level access? What exactly are you attempting to do? Please expand with more detail. :hattip: |
Quote:
Thanks for the reply. Sorry i could not respond fast. Actually i am working on a target platform onto which a SATA disk will be connected. Unfortunately the platform doesn't have the drivers to directly communicate to the hard disk. So i was thinking about accessing the hardware via the device file interface. Regards, Aneesh |
You don't say if you want (or already have) a filesystem on the device.
Regardless, if you can access the raw data using a tool like dd, then I would think you need a filesystem driver and not a SATA driver. My assumption is that the /dev/sda interface does not work if there is no SATA driver. First, can you read from the drive using dd?---eg: Code:
dd if=/dev/sda bs=1024 count=50 | hexdump -C |
Hi,
Quote:
Again your formulation of the original Thread/query with lack of information not describing the problem so we can aid you. Please read the referenced link. Please explain the problem in detail and what you are attempting and how you attempt to perform the action that resulted in the presented error(s). |
Quote:
What exactly do you mean when you say "communicate to the hard disk"? No use land tool in the Linux world has such kind of direct access to the hardware. The only way to do that is by writing a kernel driver just like virtualbox or qemu, or vhba or fuse-based stuff do. Another possibility is that the HD is formated (in the most generic meaning of the term "format") on a way that Linux can't understand, in that case you'll see the device nodes, but you won't be able to mount them, and hence you won't be able to interact with the contents of the disk with regular tools. Here writing your own tool can be of help, yes. |
Quote:
Hi, Thanks for all the inputs. To be more specific for Linux OS the platform does not have the exact APIs to communicate to hard disk. But for another OS, this support is available. Hence i need to access the HDD through any other interface. By communicating to hard disk, i mean performing the read/write operations to the HDD. Also sending the smart commands and getting the attributes. Regards, Aneesh |
Quote:
I still don't get what exactly do you want to do, unless you are using some kind of esoteric device that I am not aware of. Quote:
For the rest, read my comments above. Again, once the driver is handling the device and you have a device node, what else do you need? |
All times are GMT -5. The time now is 02:05 AM. |