LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 05-10-2010, 05:36 AM   #1
chxooi
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.

/dev/sample_hdd0
/dev/sample_hdd1
/dev/sample_hdd2


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
}



application


if ((fd = open("/dev/sample_hdd0", O_RDWR)) < 0){
/*someting....*/
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
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,857

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


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
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

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 09:38 AM.

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