On Tue, Feb 19, 2008 at 11:13:38AM +0200, Dan Shimshoni wrote: > Hi, > > Is there a way I can test, from a kernel module, the existence of a > device file ? > > A kernel module I write is a character device module, which depends > on getting ioctls. In order that it will work, "mknod ... /dev/myDev" > should be issued before to create the device file. > > Is there a way to check, in the init() method of this module, the > existence of /dev/myDev (and exit with a proper printk if /dev/myDev > does not exist)?
I do not know if that's possible or not, but I do not think you should. It's usually considered bad practice to put policy in the kernel (or a module, for that matter). The fact that this device node exists or not does not have anything to do with your module, its ability to work, whether it should exit or not, etc. Administrators (or udevd, or whatever other means) can decide to create or delete this device before or after loading your module, or not at all. They can decide on another place for that module - /dev/somedir/yourDev, under a chroot, whatever. Having to create this node to make the module load properly is a major pain that will cause an endless amount of bug reports. Don't. -- Didi ================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]