Error while opennig device file

Garcia Jérémie GARCIAJ at 3il.fr
Thu Jun 16 18:35:13 EST 2005


Hi everybody! I'm gonna give you all the info you asked me:

[Dustin]
>> does it work from the command line?  Do both mknod commands work?
--> Yes both mknod seem to work from the command line since they are both created
    root at 10.16.9.232:~# mknod -m 777 /dev/test1 c 122 1
    root at 10.16.9.232:~# mknod -m 777 /dev/test2 c 122 2            
That looks good

>> When you "ls -l /dev/test{1,2}" , what do you get? 
--> root at 10.16.9.232:~# ls -l /dev/test{1,2}
    crwxrwxrwx    1 root     root     122,   1 Jun 16  2005 /dev/test1
    crwxrwxrwx    1 root     root     122,   2 Jun 16  2005 /dev/test2
That looks good

>> What happens when you "cat /dev/test1" ?
--> root at 10.16.9.232:~# cat /dev/test1
    cat: /dev/test1: No such device
That is ok, isn't it?

>> What happens when you "echo > /dev/test1" ?    
--> root at 10.16.9.232:~# echo > /dev/test1
    bash: /dev/test1: No such device
That is ok, isn't it?

[Eugene]
>> How does open routine for your device look like?
-->
static int test_open(struct inode *inode , struct file *file)
{
  int ret_val = 0;
  
  if (Device_open != 0)
    return -EBUSY;
  
  Device_open++;
  printk("%d minor number!\n",MINOR(inode->i_rdev));  
  MOD_INC_USE_COUNT;

  return ret_val;
}

Very traditionnal...

>> What error do you get on second open?
--> I trace the execution of my programm and get the following :
First opened succeeded, open() return code : 3     
Can't open second file, open() return code : -1 , errno = 16

Looking in the errno.h, we have :
#define	EBUSY		16	/* Device or resource busy */


If tou need more tell me.
Tks again for your help guys!


-------- Message d'origine--------
De: Dustin Lang [mailto:dalang at cs.ubc.ca]
Date: mer. 15/06/2005 20:16
À: Eugene Surovegin
Cc: Garcia Jérémie; linuxppc-dev at ozlabs.org
Objet : Re: RE : Error while opennig device file
 

Also - does it work from the command line?  Do both mknod commands work? 
When you "ls -l /dev/test{1,2}" , what do you get?  What happens when you 
"cat /dev/test1" or "echo > /dev/test1" ?

Cheers,
dstn.


>> I'm sorry but this is a "copy to mail" error.
>> Here is the right code:
>>
>> ret_val = system("mknod -m 777 /dev/test1 c 122 1");
>> ret_val = system("mknod -m 777 /dev/test2 c 122 2");
>>
>> file_desc1 = open("/dev/test1", O_RDWR);
>> file_desc2 = open("/dev/test2", O_RDWR);




More information about the Linuxppc-dev mailing list