Re: Open return value - segmentation fault

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
I am sorry, i need to make a small correction. I am returning 1 in open 
when the segmentation faul occurs. If the return value is 0 it doesnt.
Sorry for the mistake.


On Fri, 9 Sep 2005, Vijay Ram Chitrapu (RCVIJAYD) wrote:

> Hi all,
>   I have a query regarding the file descriptor obtained from the open 
> call. I have written a dummy driver code which has open, ioclt and release 
> file operations to it. In the open, i am returning 0. In the user space 
> when i open the device , i get an fd as 3. When i perform an ioctl with 
> the same fd  to the device, a segmentation fault of NULL pointer derefence 
> is thrown. I have tried return 1 in the open and everything worked well. 
> Can anyone please tell me in what way is the return value of open related 
> to the file descriptor. 
> The code is below for reference..
> 
> static struct file_operations this_fops = {
> 	open:this_open,
> 	ioctl:this_ioctl,
> 	release:this_release,
> };
> 
> int this_open (struct inode *ino, struct file *fp)
> {
>  printk("<1> in open");
>  return 0;
> }
> 
> int this_ioctl(struct inode * ino, struct file *fp, unsigned int cmd, 
> unsigned long len)
> {
>   printk("<1> in ioctl function);
>   return 1;
> }
> 
> 
> 
> Thanks In Advance
> Vijay Ram.C
> 
> 
> 
> --
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive:       http://mail.nl.linux.org/kernelnewbies/
> FAQ:           http://kernelnewbies.org/faq/
> 


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux