I recently inherited some code at work, these are old Linux 2.4.X kernel drivers, and I was instructed to get them to work on a newer kernel 2.6 or higher. I work on OpenSUSE 12.1 with the kernel 3.1.10.
I updated the source code from register_chrdev () to use the class_create () / device_create () calls, and I see that my devices are displayed in / dev correctly. My current problem is that the permissions for my device are set to r / w only for the user:
crw------- 1 root root 244, 0 Aug 7 07:57 gcanain
I know that I can "chmod" the file through the command line, and I can also configure the udev permissions ... but is there anyway to do this programmatically, for example, when I issue the insmod command, will dev be installed with the correct rules already?
Are there any APIs that can exist that I can call for this, any parameters that are missing from one of these creation APIs?
Just to clarify, part of the reason I don’t want to use udev rules is because I don’t know the names of the device drivers in advance. Device drivers are generated in a loop, so names are added using a number, nNumDevs can be almost anything:
for (i = 0; i < nNumDevs; i++) {
strcpy(Modname,GC_ANAIN_MODULE_NAME);
strcat(Modname,"%d");
device_create(c1, NULL, MKDEV(nMajor, GC_ANAIN_MINOR_VERSION+i), NULL, Modname, i);
}