LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-30-2006, 05:26 AM   #1
nutanj
LQ Newbie
 
Registered: Oct 2006
Posts: 1

Rep: Reputation: 0
Smile What r the functions used to read data from the all the sectors of hdd


Hi,
Since last two year i m working in c,c++ on keil compiler. I don't know much about Linux Programming.

In my current project i would like to code in C language which will tst the functionality of hard disk.

Like,
1. Address each sector of the HDD (used and unused )
2..Read the data form used sector
3..write that data to some tem. buffer
4..write some new data to the sector
5..Read the data back from the sector
6..Compare the data to test the read and write operation
7..Writr the original data from the tem. buffer to the sector
8..Then apply the same procedure to next sector and so on.....

I know in the linux dd command can be used for the same purpose, but i want to write the code in "C"

Can any one please tell me that how to find the source code for the dd command??

What r the different functions used to access the perticular sector,read the data from that sector, write the data......

Please help me....

Thanks and Regards,
Nutty
 
Old 10-30-2006, 05:47 AM   #2
bernied
Member
 
Registered: Mar 2006
Location: Edinburgh, UK
Distribution: debian
Posts: 304

Rep: Reputation: 30
It might be in coreutils:
http://www.gnu.org/software/coreutils/
 
Old 10-30-2006, 11:03 AM   #3
soggycornflake
Member
 
Registered: May 2006
Location: England
Distribution: Slackware 10.2, Slamd64
Posts: 249

Rep: Reputation: 31
Quote:
It might be in coreutils:
Indeed it is.

nutanj, the package manager in most (if not all) distros can show what package a command comes from. Read up on rpm/apt or whatever your distro uses.

Here in Slackware-land, I just need to

Code:
(~) grep 'bin/dd$' /var/log/packages/*
/var/log/packages/coreutils-5.2.1-i486-1:bin/dd
Quote:
What r the different functions used to access the perticular sector,read the data from that sector, write the data......
I pretty sure that Linux block device drivers abstract away the concept of a 'sector'. Disks just behave like big files. i.e. to read 'sector' 10 (assuming 512 byte sectors) just use somethig like 'lseek(fd, 512*10, 0); read(fd, buf, 512);'.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bad sectors in RAID 5 HDD arunabh_biswas Linux - Software 2 06-16-2006 12:25 PM
Read data from ntfs hdd jreniel Linux - Hardware 3 06-06-2006 09:42 PM
Advice needed on transferring data from HDD to HDD denimglen Linux - Newbie 3 03-04-2006 07:33 PM
How to access raw sectors on HDD with no file system? prasanthpooyath Programming 4 01-08-2005 10:53 AM
my dvd is read as hdd and my ide cd-rw is read as scsi??? spyghost Linux - Hardware 11 07-16-2003 04:03 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration