Error while opennig device file

Garcia Jérémie GARCIAJ at 3il.fr
Thu Jun 16 02:19:43 EST 2005


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);

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...



More information about the Linuxppc-dev mailing list