LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 02-28-2008, 07:40 AM   #1
ashok449
Member
 
Registered: Sep 2007
Location: noida
Distribution: suse
Posts: 63

Rep: Reputation: 16
read/write file_operation problem


Dear All,

I have a character driver compiled successfully but giving problem while reading/writting oprations.

Here is the code
Code:
struct a_sample
{
        char *buffer;
 };


static ssize_t device_read(struct file *flip, char *buff,size_t length,loff_t *offset)
{

struct a_sample *dev = flip->private_data;


 if(copy_to_user (buff,dev->buffer,sizeof(dev->buffer)))
               return -EFAULT;

printk("read data-----> %s\n", buff);

return 100;
}



static ssize_t device_write (struct file *flip, const char *buff, size_t len, loff_t *off)
{  
struct a_sample *dev = flip->private_data;
 
        if(copy_from_user(dev->buffer,buff,len))
        {
                return -EFAULT;
        }


printk("written data is = %s\n", buff);

 return len;

}
mknod /dev/sampl1 c 243 0


Issues:
1. while writting echo "test" > /dev/sampl1 terminal was closed/exit
2. on reading showing error segmentation fault.



Thanks in advance ...
 
Old 02-29-2008, 03:28 AM   #2
ashok449
Member
 
Registered: Sep 2007
Location: noida
Distribution: suse
Posts: 63

Original Poster
Rep: Reputation: 16
This Issue is closed, there was a problem in my structure and allocation of kernel memory.




Thanks ...
 
  


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
MEPIS 6.01 read/write permissions problem bluesman2333 MEPIS 2 01-13-2007 06:30 PM
Read write problem on CD-RW and floppy in FC4 anthonyt Fedora 1 10-28-2005 02:21 AM
mount vfat read/write problem dhammika Linux - General 4 08-27-2004 06:25 AM
SMB Read/Write Problem dhammika Linux - Networking 3 05-12-2004 11:03 AM
Open office read only, K-write read/write mode lwtvh Linux - Newbie 1 07-19-2003 11:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 05:57 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