RE : RE : Error while opennig device file
From: Garcia Jérémie <hidden>
Date: 2005-06-16 08:37:01
Hi everybody! I'm gonna give you all the info you asked me: [Dustin]
quoted
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@10.16.9.232:~# mknod -m 777 /dev/test1 c 122 1
root@10.16.9.232:~# mknod -m 777 /dev/test2 c 122 2 =20
That looks good
quoted
When you "ls -l /dev/test{1,2}" , what do you get?=20
--> root@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
quoted
What happens when you "cat /dev/test1" ?
--> root@10.16.9.232:~# cat /dev/test1
cat: /dev/test1: No such device
That is ok, isn't it?
quoted
What happens when you "echo > /dev/test1" ? =20
--> root@10.16.9.232:~# echo > /dev/test1
bash: /dev/test1: No such device
That is ok, isn't it?
[Eugene]quoted
How does open routine for your device look like?
-->
static int test_open(struct inode *inode , struct file *file)
{
int ret_val =3D 0;
=20
if (Device_open !=3D 0)
return -EBUSY;
=20
Device_open++;
printk("%d minor number!\n",MINOR(inode->i_rdev)); =20
MOD_INC_USE_COUNT;
return ret_val;
}
Very traditionnal...
quoted
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 =20
Can't open second file, open() return code : -1 , errno =3D 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@cs.ubc.ca]
Date: mer. 15/06/2005 20:16
=C0: Eugene Surovegin
Cc: Garcia J=E9r=E9mie; linuxppc-dev@ozlabs.org
Objet : Re: RE : Error while opennig device file
=20
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=20
"cat /dev/test1" or "echo > /dev/test1" ?
Cheers,
dstn.
quoted
I'm sorry but this is a "copy to mail" error. Here is the right code: ret_val =3D system("mknod -m 777 /dev/test1 c 122 1"); ret_val =3D system("mknod -m 777 /dev/test2 c 122 2"); file_desc1 =3D open("/dev/test1", O_RDWR); file_desc2 =3D open("/dev/test2", O_RDWR);