]> git.neil.brown.name Git - history.git/commitdiff
misc.c:
authorRichard Gooch <rgooch@atnf.csiro.au>
Sat, 11 May 2002 04:06:34 +0000 (04:06 +0000)
committerRichard Gooch <rgooch@atnf.csiro.au>
Sat, 11 May 2002 04:06:34 +0000 (04:06 +0000)
  Do not put miscellaneous character devices in /dev/misc if they
  specify their own directory (i.e. contain a '/' character)
util.c:
  Copied and used macro for error messages from fs/devfs/base.c
base.c:
  Removed 2.4.x compatibility code
  Added BKL to <devfs_open> because drivers still need it

Documentation/filesystems/devfs/ChangeLog
drivers/char/misc.c
fs/devfs/base.c
fs/devfs/util.c

index 4c4ddd9d2758cd9844c1bcb6bc7e1d86757dbc84..c88e8748b6c7bc03d33a85452f9ff7785c942c1c 100644 (file)
@@ -1912,3 +1912,17 @@ Changes for patch v210
   Thanks to Anton Blanchard <anton@samba.org>
 
 - Updated README from master HTML file
+===============================================================================
+Changes for patch v211
+
+- Do not put miscellaneous character devices in /dev/misc if they
+  specify their own directory (i.e. contain a '/' character)
+
+- Copied macro for error messages from fs/devfs/base.c to
+  fs/devfs/util.c and made use of this macro
+
+- Removed 2.4.x compatibility code from fs/devfs/base.c
+===============================================================================
+Changes for patch v212
+
+- Added BKL to <devfs_open> because drivers still need it
index bb45e919fc01ef77a5704f31aaebc5e4045a02a4..e410c4a65a79b109bbf87a58c08d20ae3ca23fa7 100644 (file)
@@ -170,7 +170,7 @@ static struct file_operations misc_fops = {
  
 int misc_register(struct miscdevice * misc)
 {
-       static devfs_handle_t devfs_handle;
+       static devfs_handle_t devfs_handle, dir;
        struct miscdevice *c;
        
        if (misc->next || misc->prev)
@@ -201,11 +201,12 @@ int misc_register(struct miscdevice * misc)
                misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7);
        if (!devfs_handle)
                devfs_handle = devfs_mk_dir (NULL, "misc", NULL);
+       dir = strchr (misc->name, '/') ? NULL : devfs_handle;
        misc->devfs_handle =
-           devfs_register (devfs_handle, misc->name, DEVFS_FL_NONE,
-                           MISC_MAJOR, misc->minor,
-                           S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP,
-                           misc->fops, NULL);
+               devfs_register (dir, misc->name, DEVFS_FL_NONE,
+                               MISC_MAJOR, misc->minor,
+                               S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP,
+                               misc->fops, NULL);
 
        /*
         * Add it to the front, so that later devices can "override"
index 862f7486cc959aa4826bcabfdcd482d8f06bb03d..7123bc73a9028d2868348cdba1895deb2fc24560 100644 (file)
               unlock_kernel() due to recent VFS locking changes. BKL isn't
               required in devfs.
   v1.13
+    20020428   Richard Gooch <rgooch@atnf.csiro.au>
+              Removed 2.4.x compatibility code.
+  v1.14
+    20020510   Richard Gooch <rgooch@atnf.csiro.au>
+              Added BKL to <devfs_open> because drivers still need it.
+  v1.15
 */
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <asm/bitops.h>
 #include <asm/atomic.h>
 
-#define DEVFS_VERSION            "1.13 (20020406)"
+#define DEVFS_VERSION            "1.15 (20020510)"
 
 #define DEVFS_NAME "devfs"
 
@@ -1400,16 +1406,8 @@ static void free_dentry (struct devfs_entry *de)
 
 static int is_devfsd_or_child (struct fs_info *fs_info)
 {
-    struct task_struct *p;
-
     if (current == fs_info->devfsd_task) return (TRUE);
     if (current->pgrp == fs_info->devfsd_pgrp) return (TRUE);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,1)
-    for (p = current->p_opptr; p != &init_task; p = p->p_opptr)
-    {
-       if (p == fs_info->devfsd_task) return (TRUE);
-    }
-#endif
     return (FALSE);
 }   /*  End Function is_devfsd_or_child  */
 
@@ -1829,16 +1827,6 @@ devfs_handle_t devfs_mk_dir (devfs_handle_t dir, const char *name, void *info)
     de->info = info;
     if ( ( err = _devfs_append_entry (dir, de, FALSE, &old) ) != 0 )
     {
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,1)
-       if ( old && S_ISDIR (old->mode) )
-       {
-           PRINTK ("(%s): using old entry in dir: %p \"%s\"\n",
-                   name, dir, dir->name);
-           old->vfs_deletable = FALSE;
-           devfs_put (dir);
-           return old;
-       }
-#endif
        PRINTK ("(%s): could not append to dir: %p \"%s\", err: %d\n",
                name, dir, dir->name, err);
        devfs_put (old);
@@ -2739,15 +2727,22 @@ static int devfs_open (struct inode *inode, struct file *file)
     {
        file->f_op = &def_blk_fops;
        if (df->ops) inode->i_bdev->bd_op = df->ops;
+       err = def_blk_fops.open (inode, file);
     }
-    else file->f_op = fops_get ( (struct file_operations *) df->ops );
-    if (file->f_op)
-       err = file->f_op->open ? (*file->f_op->open) (inode, file) : 0;
     else
     {
-       /*  Fallback to legacy scheme  */
-       if ( S_ISCHR (inode->i_mode) ) err = chrdev_open (inode, file);
-       else err = -ENODEV;
+       file->f_op = fops_get ( (struct file_operations *) df->ops );
+       if (file->f_op)
+       {
+           lock_kernel ();
+           err = file->f_op->open ? (*file->f_op->open) (inode, file) : 0;
+           unlock_kernel ();
+       }
+       else
+       {   /*  Fallback to legacy scheme  */
+           if ( S_ISCHR (inode->i_mode) ) err = chrdev_open (inode, file);
+           else err = -ENODEV;
+       }
     }
     if (err < 0) return err;
     /*  Open was successful  */
index f9c955f6b61c3ed5c49388a4f45547da44369ef1..9431e7d903b2b25c8f7daf0097e0d6501d237a67 100644 (file)
@@ -56,6 +56,8 @@
                Made major bitfield type and initialiser 64 bit safe.
     20020413   Richard Gooch <rgooch@atnf.csiro.au>
                Fixed shift warning on 64 bit machines.
+    20020428   Richard Gooch <rgooch@atnf.csiro.au>
+               Copied and used macro for error messages from fs/devfs/base.c 
 */
 #include <linux/module.h>
 #include <linux/init.h>
@@ -65,6 +67,9 @@
 
 #include <asm/bitops.h>
 
+#define PRINTK(format, args...) \
+   {printk (KERN_ERR "%s" format, __FUNCTION__ , ## args);}
+
 
 /*  Private functions follow  */
 
@@ -209,9 +214,7 @@ void devfs_dealloc_major (char type, int major)
     spin_lock (&list->lock);
     was_set = __test_and_clear_bit (major, list->bits);
     spin_unlock (&list->lock);
-    if (!was_set)
-       printk (KERN_ERR __FUNCTION__ "(): major %d was already free\n",
-               major);
+    if (!was_set) PRINTK ("(): major %d was already free\n", major);
 }   /*  End Function devfs_dealloc_major  */
 EXPORT_SYMBOL(devfs_dealloc_major);
 
@@ -339,12 +342,11 @@ void devfs_dealloc_devnum (char type, kdev_t devnum)
        if (was_set) list->none_free = 0;
        up (semaphore);
        if (!was_set)
-           printk ( KERN_ERR __FUNCTION__ "(): device %s was already free\n",
-                    kdevname (devnum) );
+           PRINTK ( "(): device %s was already free\n", kdevname (devnum) );
        return;
     }
     up (semaphore);
-    printk ( KERN_ERR __FUNCTION__ "(): major for %s not previously allocated\n",
+    PRINTK ( "(): major for %s not previously allocated\n",
             kdevname (devnum) );
 }   /*  End Function devfs_dealloc_devnum  */
 EXPORT_SYMBOL(devfs_dealloc_devnum);
@@ -419,8 +421,6 @@ void devfs_dealloc_unique_number (struct unique_numspace *space, int number)
     was_set = __test_and_clear_bit (number, space->bits);
     if (was_set) ++space->num_free;
     up (&space->semaphore);
-    if (!was_set)
-       printk (KERN_ERR __FUNCTION__ "(): number %d was already free\n",
-               number);
+    if (!was_set) PRINTK ("(): number %d was already free\n", number);
 }   /*  End Function devfs_dealloc_unique_number  */
 EXPORT_SYMBOL(devfs_dealloc_unique_number);