diff -ruN linux-2.4.17/fs/devfs/base.c linux-2.4.17-fixup/fs/devfs/base.c --- linux-2.4.17/fs/devfs/base.c Thu Dec 27 19:53:05 2001 +++ linux-2.4.17-fixup/fs/devfs/base.c Wed Feb 6 17:49:00 2002 @@ -2318,6 +2318,7 @@ if (*str != ',') return 0; /* No more options */ ++str; } + devfs_init_major_lists(); return 1; } /* End Function devfs_setup */ diff -ruN linux-2.4.17/fs/devfs/util.c linux-2.4.17-fixup/fs/devfs/util.c --- linux-2.4.17/fs/devfs/util.c Fri Oct 26 20:00:52 2001 +++ linux-2.4.17-fixup/fs/devfs/util.c Wed Feb 6 18:02:29 2002 @@ -185,42 +185,88 @@ struct major_list { - spinlock_t lock; - __u32 bits[8]; + spinlock_t lock; + long bits[32/sizeof(long)]; }; +typedef struct _major_preallocated_entry +{ + int first_major; + int last_major; +} major_preallocated_entry_t; + /* Block majors already assigned: 0-3, 7-9, 11-63, 65-99, 101-113, 120-127, 199, 201, 240-255 Total free: 122 */ + +static major_preallocated_entry_t block_major_preassigned_list[]= +{ + {0,3}, + {7,9}, + {11,63}, + {65,99}, + {101,113}, + {120,127}, + {199,199}, + {201,201}, + {240,255}, + {-1,-1} /* end of list marker */ +}; + + static struct major_list block_major_list = -{SPIN_LOCK_UNLOCKED, - {0xfffffb8f, /* Majors 0 to 31 */ - 0xffffffff, /* Majors 32 to 63 */ - 0xfffffffe, /* Majors 64 to 95 */ - 0xff03ffef, /* Majors 96 to 127 */ - 0x00000000, /* Majors 128 to 159 */ - 0x00000000, /* Majors 160 to 191 */ - 0x00000280, /* Majors 192 to 223 */ - 0xffff0000} /* Majors 224 to 255 */ +{SPIN_LOCK_UNLOCKED, }; /* Char majors already assigned: 0-7, 9-151, 154-158, 160-211, 216-221, 224-230, 240-255 Total free: 19 */ + +static major_preallocated_entry_t char_major_preassigned_list[]= +{ + {0,7}, + {9,151}, + {154,158}, + {160,211}, + {224,230}, + {240,255}, + {-1,-1} /* end of list marker */ +}; + static struct major_list char_major_list = {SPIN_LOCK_UNLOCKED, - {0xfffffeff, /* Majors 0 to 31 */ - 0xffffffff, /* Majors 32 to 63 */ - 0xffffffff, /* Majors 64 to 95 */ - 0xffffffff, /* Majors 96 to 127 */ - 0x7cffffff, /* Majors 128 to 159 */ - 0xffffffff, /* Majors 160 to 191 */ - 0x3f0fffff, /* Majors 192 to 223 */ - 0xffff007f} /* Majors 224 to 255 */ }; +/** + * devfs_init_major_lists - Initialize major used bitmaps + * + */ +void devfs_init_major_lists (void) +{ + int i; + major_preallocated_entry_t* entry; + // clear all bits + for (i=0; i<(32/sizeof(long)) ; i++) { + block_major_list.bits[i] = 0; + char_major_list.bits[i] = 0; + } + // set bits in block_major_list and char_major_list of preassigned majors + for (entry=&char_major_preassigned_list[0]; + (entry->first_major!=-1) && (entry->last_major!=-1); + entry++) { + for (i=entry->first_major; i<=entry->last_major; i++) + __set_bit (i, char_major_list.bits); + } + // set bits in block_major_list and char_major_list of preassigned majors + for (entry=&block_major_preassigned_list[0]; + (entry->first_major!=-1) && (entry->last_major!=-1); + entry++) { + for (i=entry->first_major; i<=entry->last_major; i++) + __set_bit (i, block_major_list.bits); + } +} /** * devfs_alloc_major - Allocate a major number. diff -ruN linux-2.4.17/include/linux/devfs_fs_kernel.h linux-2.4.17-fixup/include/linux/devfs_fs_kernel.h --- linux-2.4.17/include/linux/devfs_fs_kernel.h Thu Dec 27 19:53:07 2001 +++ linux-2.4.17-fixup/include/linux/devfs_fs_kernel.h Thu Feb 7 15:58:00 2002 @@ -115,6 +115,7 @@ unsigned int flags, unsigned int major, unsigned int minor_start, umode_t mode, void *ops, void *info); +extern void devfs_init_major_lists (void); extern int devfs_alloc_major (char type); extern void devfs_dealloc_major (char type, int major); extern kdev_t devfs_alloc_devnum (char type);