devfs support in char/raw.c
PATCH 1/1 devfs support in char/raw.c
[please cc me on reply]
Hi,
the following patch enables devfs support for the raw devices. It is a blatant cut-and-copy from other drivers, and it passed the basic tests I could figure out (mainly xine dvd raw access) - with and without devfs.
Without devfs I find the raw devices under /dev on my Debian box, but man raw(8) itself introduces the /dev/raw/ directory. So, the proposed devices naming scheme is:
/dev/raw/rawctl/dev/raw/raw1
.../dev/raw/raw64
I would like to submit the patch to the maintainer, but I failed to find who he is! (Stephen Tweedie?)
Alessandro
char/raw.c renamed from char/raw.c-orig +18 -1
@@ -15,6 +15,7 @@#include <linux/raw.h> #include <linux/capability.h> #include <linux/smp_lock.h> +#include <linux/devfs_fs_kernel.h> #include <asm/uaccess.h> #define dprintk(x...)
@@ -51,10 +52,26 @@static int __init raw_init (void ) {int i; -register_chrdev (RAW_MAJOR ,"raw" , &raw_fops); +devfs_handle_t devfs_handle; +char name_buf[8 ]; + +if (devfs_register_chrdev (RAW_MAJOR ,"raw" , &raw_fops)) +printk ("unable to get major %d for raw devs\n" ,RAW_MAJOR ); + + devfs_handle =devfs_mk_dir (NULL ,"raw" ,NULL ); +devfs_register (devfs_handle,"rawctl" ,DEVFS_FL_DEFAULT , +RAW_MAJOR ,0 ,S_IFCHR |S_IRUGO |S_IWUGO , + &raw_fops,NULL );for (i =0 ; i <256 ; i++)init_MUTEX (&raw_devices[i].mutex); + +for (i =1 ; i <64 ; i++) { +sprintf (name_buf,"raw%d" , i); +devfs_register (devfs_handle, name_buf,DEVFS_FL_DEFAULT , +RAW_MAJOR , i,S_IFCHR |S_IRUGO |S_IWUGO , + &raw_fops,NULL ); + }return 0 ; }