Skip to contentSkip to conversation

umode_t changes from Adam's mini-devfs

PATCH New Christoph Hellwig 1 participant 1 message Jan 15, 2003

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 umode_t changes from Adam's mini-devfs

The use of umode_t instead of devfs-specific char vs block #defines in Adam's mini-devfs patch makes sense independant of whether his patch should get merged. While reviewing his changes I also notices that most of the number allocation functionality in devfs has no business beeing exported. In addition I cleaned up devfs_alloc_devnum/ devfs_dealloc_devnum a bit.

fs/devfs/base.c +9 -9
@@ -685,6 +685,8 @@
 #include <asm/bitops.h>
 #include <asm/atomic.h>
 
+#include "internal.h"
+
 #define DEVFS_VERSION            "1.22 (20021013)"
 
 #define DEVFS_NAME "devfs"
@@ -935,9 +937,9 @@
 	     de->parent ? de->parent->name : "no parent");
     if ( S_ISLNK (de->mode) ) kfree (de->u.symlink.linkname);
     if ( S_ISCHR (de->mode) && de->u.cdev.autogen )
-	devfs_dealloc_devnum (DEVFS_SPECIAL_CHR, de->u.cdev.dev);
+	devfs_dealloc_devnum (de->mode, de->u.cdev.dev);
     if ( S_ISBLK (de->mode) && de->u.bdev.autogen )
-	devfs_dealloc_devnum(DEVFS_SPECIAL_BLK, de->u.bdev.dev);
+	devfs_dealloc_devnum (de->mode, de->u.bdev.dev);
     WRITE_ENTRY_MAGIC (de, 0);
 #ifdef CONFIG_DEVFS_DEBUG
     spin_lock (&stat_lock);
@@ -1102,13 +1104,13 @@
     /*  And create the entry for ".devfsd"  */
     if ( ( new = _devfs_alloc_entry (".devfsd", 0, S_IFCHR |S_IRUSR |S_IWUSR) )
 	 == NULL ) return NULL;
-    new->u.cdev.dev = devfs_alloc_devnum (DEVFS_SPECIAL_CHR);
+    new->u.cdev.dev = devfs_alloc_devnum (S_IFCHR |S_IRUSR |S_IWUSR);
     new->u.cdev.ops = &devfsd_fops;
     _devfs_append_entry (root_entry, new, FALSE, NULL);
 #ifdef CONFIG_DEVFS_DEBUG
     if ( ( new = _devfs_alloc_entry (".stat", 0, S_IFCHR | S_IRUGO | S_IWUGO) )
 	 == NULL ) return NULL;
-    new->u.cdev.dev = devfs_alloc_devnum (DEVFS_SPECIAL_CHR);
+    new->u.cdev.dev = devfs_alloc_devnum (S_IFCHR | S_IRUGO | S_IWUGO);
     new->u.cdev.ops = &stat_fops;
     _devfs_append_entry (root_entry, new, FALSE, NULL);
 #endif
@@ -1469,7 +1471,6 @@
 			       unsigned int major, unsigned int minor,
 			       umode_t mode, void *ops, void *info)
 {
-    char devtype = S_ISCHR (mode) ? DEVFS_SPECIAL_CHR : DEVFS_SPECIAL_BLK;
     int err;
     dev_t devnum = 0, dev = MKDEV(major, minor);
     struct devfs_entry *de;
@@ -1497,7 +1498,7 @@
     if ( ( S_ISCHR (mode) || S_ISBLK (mode) ) &&
 	 (flags & DEVFS_FL_AUTO_DEVNUM) )
     {
-	devnum = devfs_alloc_devnum (devtype);
+	devnum = devfs_alloc_devnum (mode);
 	if (!devnum) {
 	    PRINTK ("(%s): exhausted %s device numbers\n",
 		    name, S_ISCHR (mode) ? "char" : "block");
@@ -1508,7 +1509,7 @@
     if ( ( de = _devfs_prepare_leaf (&dir, name, mode) ) == NULL )
     {
 	PRINTK ("(%s): could not prepare leaf\n", name);
-	if (devnum) devfs_dealloc_devnum (devtype, devnum);
+	if (devnum) devfs_dealloc_devnum (mode, devnum);
 	return NULL;
     }
     if (S_ISCHR (mode)) {
@@ -1544,7 +1545,7 @@
     {
 	PRINTK ("(%s): could not append to parent, err: %d\n", name, err);
 	devfs_put (dir);
-	if (devnum) devfs_dealloc_devnum (devtype, devnum);
+	if (devnum) devfs_dealloc_devnum (mode, devnum);
 	return NULL;
     }
     DPRINTK (DEBUG_REGISTER, "(%s): de: %p dir: %p \"%s\"  pp: %p\n",
@@ -1953,7 +1954,6 @@
 EXPORT_SYMBOL(devfs_mk_dir);
 EXPORT_SYMBOL(devfs_remove);
 EXPORT_SYMBOL(devfs_generate_path);
-EXPORT_SYMBOL(devfs_only);
 
 
 /**

===== fs/devfs/util.c 1.16 vs edited =====

fs/devfs/util.c +86 -140

279 lines not on this page · raw message

include/linux/devfs_fs_kernel.h +0 -30
@@ -21,9 +21,6 @@
 #define DEVFS_FL_DEFAULT        DEVFS_FL_NONE
 
 
-#define DEVFS_SPECIAL_CHR     0
-#define DEVFS_SPECIAL_BLK     1
-
 typedef struct devfs_entry * devfs_handle_t;
 
 #ifdef CONFIG_DEVFS_FS
@@ -58,10 +55,6 @@
 extern int devfs_only (void);
 extern int devfs_register_tape (devfs_handle_t de);
 extern void devfs_unregister_tape(int num);
-extern int devfs_alloc_major (char type);
-extern void devfs_dealloc_major (char type, int major);
-extern dev_t devfs_alloc_devnum (char type);
-extern void devfs_dealloc_devnum (char type, dev_t devnum);
 extern int devfs_alloc_unique_number (struct unique_numspace *space);
 extern void devfs_dealloc_unique_number (struct unique_numspace *space,
 					 int number);
@@ -129,41 +122,18 @@
 static inline void devfs_unregister_tape(int num)
 {
 }
-static inline int devfs_alloc_major (char type)
-{
-    return -1;
-}
-
-static inline void devfs_dealloc_major (char type, int major)
-{
-    return;
-}
-
-static inline dev_t devfs_alloc_devnum (char type)
-{
-    return 0;
-}
-
-static inline void devfs_dealloc_devnum (char type, dev_t devnum)
-{
-    return;
-}
-
 static inline int devfs_alloc_unique_number (struct unique_numspace *space)
 {
     return -1;
 }
-
 static inline void devfs_dealloc_unique_number (struct unique_numspace *space,
 						int number)
 {
     return;
 }
-
 static inline void mount_devfs_fs (void)
 {
     return;
 }
 #endif  /*  CONFIG_DEVFS_FS  */
-
 #endif  /*  _LINUX_DEVFS_FS_KERNEL_H  */
fs/devfs/internal.h new file +3 -0
@@ -0,0 +1,3 @@
+
+extern dev_t devfs_alloc_devnum(umode_t mode);
+extern void devfs_dealloc_devnum(umode_t mode, dev_t devnum);