* RE : RE : Error while opennig device file
@ 2005-06-16 8:35 Garcia Jérémie
2005-06-16 9:23 ` Marcin Dawidowicz
0 siblings, 1 reply; 4+ messages in thread
From: Garcia Jérémie @ 2005-06-16 8:35 UTC (permalink / raw)
To: Dustin Lang, Eugene Surovegin; +Cc: linuxppc-dev
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@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
>> 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
>> 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?
>> 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]
>> 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...
>> 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.
>> 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);
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: Error while opennig device file
2005-06-16 8:35 RE : RE : Error while opennig device file Garcia Jérémie
@ 2005-06-16 9:23 ` Marcin Dawidowicz
0 siblings, 0 replies; 4+ messages in thread
From: Marcin Dawidowicz @ 2005-06-16 9:23 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Garcia Jérémie
On Thursday 16 of June 2005 10:35, Garcia J=E9r=E9mie wrote:
> static int test_open(struct inode *inode , struct file *file)
> {
> int ret_val =3D 0;
>
> if (Device_open !=3D 0) <------
> return -EBUSY; <------
>
> Device_open++; <------
> printk("%d minor number!\n",MINOR(inode->i_rdev));
> MOD_INC_USE_COUNT;
>
> return ret_val;
> }
>
> Very traditionnal...
>
Have a look on marked lines.
> 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 =A0 =A0
> Can't open second file, open() return code : -1 , errno =3D 16
>
> Looking in the errno.h, we have :
> #define=A0EBUSY=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A016=A0=A0=A0=A0=A0=A0/* De=
vice or resource busy */
This is what I would expect. You can remove marked lines and try again...
Regards,
Marcin
^ permalink raw reply [flat|nested] 4+ messages in thread
* Error while opennig device file
@ 2005-06-15 16:19 Garcia Jérémie
2005-06-15 17:26 ` Eugene Surovegin
0 siblings, 1 reply; 4+ messages in thread
From: Garcia Jérémie @ 2005-06-15 16:19 UTC (permalink / raw)
To: linuxppc-dev
Hi everybody,
I'd like to have your opinion on such a stupid question. Indeed, it must =
be very easy to see but
I can't find out what goes on.
I'm writing a device driver. In the init_module(), I register it with =
TEST_DEV_MAJOR =3D 122=20
ret_val =3D register_chrdev(TEST_DEV_MAJOR, TEST_DEV_PROC_NAME, =
&lcd_fops);
In the user space, I have a programm that creates two device files using =
the same major number but with=20
different minor numbers:
ret_val =3D system("mknod -m 777 /dev/Test1 c 122 1");
ret_val =3D system("mknod -m 777 /dev/Test1 c 122 2");
Then I try to open both files :
file_desc1 =3D open("/dev/test1", O_RDWR);
file_desc2 =3D open("/dev/test2", O_RDWR);
Unfortunately, I go through an error on the second open. It seems that I =
can't get those 2 files opened
at the same time. I'm a newbie in linux kernel development, so could you =
explain me why?
What I want to do is to have 2 device files that use the same driver =
module. In my module, I test the minor number
and handle an array of 2 structures (1 for each minor number).
For example, it could represent 2 communication channels ; I could have =
1 device file by channel on which I
could do read/write operation. My module will write/read in array[0] for =
channel 0 and in array[1] for channel 1.
Tks a lot and sorry for such a question but nobody can help me there and =
I can't find out browsing forums and books...
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: Error while opennig device file
2005-06-15 16:19 Garcia Jérémie
@ 2005-06-15 17:26 ` Eugene Surovegin
0 siblings, 0 replies; 4+ messages in thread
From: Eugene Surovegin @ 2005-06-15 17:26 UTC (permalink / raw)
To: Garcia J?r?mie; +Cc: linuxppc-dev
On Wed, Jun 15, 2005 at 06:19:43PM +0200, Garcia J?r?mie wrote:
> Hi everybody,
> I'd like to have your opinion on such a stupid question. Indeed, it must be very easy to see but
> I can't find out what goes on.
> I'm writing a device driver. In the init_module(), I register it with TEST_DEV_MAJOR = 122
>
> ret_val = register_chrdev(TEST_DEV_MAJOR, TEST_DEV_PROC_NAME, &lcd_fops);
>
> In the user space, I have a programm that creates two device files using the same major number but with
> different minor numbers:
>
> ret_val = system("mknod -m 777 /dev/Test1 c 122 1");
> ret_val = system("mknod -m 777 /dev/Test1 c 122 2");
^
> Then I try to open both files :
> file_desc1 = open("/dev/test1", O_RDWR);
> file_desc2 = open("/dev/test2", O_RDWR);
You must be kidding.
You create /dev/Test1 twice, and then open /dev/test1 and /dev/test2.
First of all, Linux fs are case sensitive, second, you don't create
test2 (even with wrong case).
--
Eugene
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-06-16 9:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-16 8:35 RE : RE : Error while opennig device file Garcia Jérémie
2005-06-16 9:23 ` Marcin Dawidowicz
-- strict thread matches above, loose matches on Subject: below --
2005-06-15 16:19 Garcia Jérémie
2005-06-15 17:26 ` Eugene Surovegin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox