Open return value - segmentation fault

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

 



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/


[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