Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.