Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.


  Search this Thread
Old 05-10-2010, 05:36 AM   #1
LQ Newbie
Registered: May 2010
Posts: 24

Rep: Reputation: 0
how can I control the HDD using read(), write() in the kernel mode...?

I want to read and write "sometext" to the hard disk using my device driver.


my_read(uint32_t partition_id, char * buf, size_t count, loff_t offset)
/*Error Handling*/
numBytes = count;
pStart = pPartition->buffer + offset;
/* read from hard disk. */ <<--- I don't know how to read from my hard disk
__copy_to_user((void*)buf, pStart, numBytes);


my_write(uint32_t partition_id, const char * buf, size_t count, loff_t offset)
/*Error handling*/
numBytes = count;
pStart = pPartition->buffer + offset;
__copy_from_user((void*)pStart, buf, numBytes)
/*Write to hard disk*/ <<--- I don't know how to write to my hard disk


if ((fd = open("/dev/sample_hdd0", O_RDWR)) < 0){
if(read(fd,buff,1)==1) <<--- if I want to read...
/*something ...*/

my Question are

1) Is it possible to make the driver this way?
2) Do I need to make more program except for the device driver and the application?
3) How can I make the read(), write() function for this .....
4) IOCTL is ok .....Can I use this one ?? how ??

I just want to write and read something to hard disk using read(),write() in the kernel mode....

4)If I make the wrong way, can I get the sample code? or could you let me know the link for this program?

This is my first time to make the thread, if I did worng...let me know....
I'll modify that asap...

Last edited by chxooi; 05-10-2010 at 06:08 AM.
Old 05-10-2010, 05:10 PM   #2
Senior Member
Registered: Apr 2009
Posts: 1,497

Rep: Reputation: 136Reputation: 136
Why do you use your driver to read and write to hard disk? You can use raw device to access hard disk.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Permission to control read/write in Samba problem. uncle-c Linux - Newbie 1 10-28-2009 07:26 PM
No read/write perms for HDD duryodhan Slackware 3 10-19-2006 04:15 PM
firewire hdd will not stay read-write solemar Mandriva 4 07-04-2005 06:46 AM
Open office read only, K-write read/write mode lwtvh Linux - Newbie 1 07-19-2003 11:33 AM
Fs mounted in Read Only , Read Write Mode benjaminrtz Linux - General 2 07-31-2002 02:52 AM > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 03:19 AM.

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