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