LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Hard disk data transfer accessing error... (https://www.linuxquestions.org/questions/linux-newbie-8/hard-disk-data-transfer-accessing-error-816726/)

aneeshcav 06-28-2010 12:06 AM

Hard disk data transfer accessing error...
 
Hi,
I am using an embedded platform in which i have connected an external harddisk (/dev/sda). The SCSI driver is present and i am using the SG_IO interface for performing the SMART commands with the Hard Disk. (Unfortunately not all the HDIO ioclts are present. So i opted for the SG_IO ioctl).

But the data transfer (reading/write data from/to sector) is not working with the SG_IO ioctls. So i searched for some other options.

Later in one of the places, i found that we can actually mount the /dev/sda to some mount point in /mnt and then make a XFS file system (mkfs.xfs) of this. And then we can create the directories and do file operations on this mounted directory. Here the simple read/write systems calls can be used for this.

I was thinking about this implementation. But i am confused how i can map the actual LBA (Logical Block Address) to the device file offset. I mean if i want to write to the sector 5, there will be a LBA for it. So i can do lseek on my device and then write the data there. So how the mapping between LBA and device file offset can be calculated.

Please let me know if you need any clarification on the query.

Regards,
Aneesh

business_kid 06-28-2010 03:54 AM

If you can actually write, and you are using something embedded, have you investigated yaffs and the other formats aimed at such machines?

aneeshcav 06-28-2010 04:06 AM

Hi,
Thanks for the reply.

No. I have not yet tried out YAFFS. But I have seen that the XFS allows the read/write operations successfully. But my main problem is mapping the Device File Offset with the LBA. ie, instead of writing to the mounted directories/files i want to access the particular HDD sectors.

Regards,
Aneesh

business_kid 06-29-2010 04:32 AM

No small task, as the drives lie blind all the time. There is a history to it, in that dos (and bios) allowed a max of 1024 tracks and 63 sectors. People quickly started using first 63, then 255 heads to accomodate the extra space beyond whet the standard makers ever imagined. Now it's gone ape altogether, with zillions of tracks & sectors. There is bound to be gpl code out there doing this already. I suggest you go there.

aneeshcav 06-29-2010 07:54 AM

Oh ok. I will do some searching for the same. If you have came across any link for the same, please share the same. Thanks.

Regards,
Aneesh


All times are GMT -5. The time now is 04:44 PM.