As is well known at this point, if you turn on devfs but do not mount it
on /dev, mount-by-label will break.
This is a patch against the 2.4.21-kernel which puts the "old-style"
device names back into /proc/partitions _unless_
1) CONFIG_DEVFS_MOUNT is turned on, meaning devfs is mounted on /dev
at boot time, or
2) the device major # is dynamically allocated by devfs (so, assume
there is no "old" name available)
This still breaks in some corner cases, one that I can think of is if
the user does not mount devfs on /dev at boot time, but later does mount
it, then /proc/partitions will have old names in it, so they can't be
found -if- the user is also not running devfsd to get the old compat
names.
I'm not necessarily asking this to be applied upstream; I know it is not
a perfect solution, and maybe it doesn't make things much better.
But, I thought I'd throw it out there. Does anyone see anything
horribly broken about the approach?
Thanks,
-Eric
===========================================================================
linux/fs/partitions/check.c
===========================================================================
--- /usr/tmp/TmpDir.11207-0/linux/fs/partitions/check.c_1.39 2003-07-21
11:39:51.000000000 -0500
+++ linux/fs/partitions/check.c 2003-07-17 14:16:56.000000000 -0500
@@ -107,7 +107,14 @@
unsigned int unit = (minor >> hd->minor_shift);
unsigned int part = (minor & ((1 << hd->minor_shift) -1 ));
- if ((unit < hd->nr_real) && hd->part[minor].de) {
+ /* Only show devfs names if devfs is mounted at boot time,
+ * or devfs owns this major. Otherwise show old names.
+ */
+ if ((unit < hd->nr_real) && hd->part[minor].de
+#ifndef CONFIG_DEVFS_MOUNT
+ && devfs_owns_block_major(hd->major)
+#endif
+ ) {
int pos;
pos = devfs_generate_path (hd->part[minor].de, buf, 64);
===========================================================================
linux/fs/devfs/util.c
===========================================================================
--- /usr/tmp/TmpDir.11207-0/linux/fs/devfs/util.c_1.9 2003-07-21
11:39:51.000000000 -0500
+++ linux/fs/devfs/util.c 2003-07-17 14:36:02.000000000 -0500
@@ -150,6 +150,16 @@
0-3, 7-9, 11-63, 65-99, 101-113, 120-127, 199, 201, 240-255
Total free: 122
*/
+
+/* pre-assigned majors */
+unsigned long assigned_major_list[] =
+ {INITIALISER64 (0xfffffb8f, 0xffffffff), /* Majors 0-31, 32-63 */
+ INITIALISER64 (0xfffffffe, 0xff03ffef), /* Majors 64-95, 96-127 */
+ INITIALISER64 (0x00000000, 0x00000000), /* Majors 128-159, 160-191 */
+ INITIALISER64 (0x00000280, 0xffff0000), /* Majors 192-223, 224-255 */
+ };
+
+/* currently allocated majors */
static struct major_list block_major_list =
{SPIN_LOCK_UNLOCKED,
{INITIALISER64 (0xfffffb8f, 0xffffffff), /* Majors 0-31, 32-63 */
@@ -174,6 +184,22 @@
/**
+ * devfs_owns_block_major - Test whether a device nr is from devfs' pool
+ * @major: The major number to test
+
+ * Returns 1 if the major number is owned by devfs, 0 otherwise.
+ */
+
+int devfs_owns_block_major (int major)
+{
+ int devfs_major;
+
+ devfs_major = !test_bit (major, &assigned_major_list);
+ printk("major %d is %sowned by devfs (%d)\n", major, devfs_major ? "" :
"not ", devfs_major);
+ return devfs_major;
+} /* End Function devfs_owns_block_major */
+
+/**
* devfs_alloc_major - Allocate a major number.
* @type: The type of the major (DEVFS_SPECIAL_CHR or DEVFS_SPECIAL_BLK)
===========================================================================
linux/include/linux/devfs_fs_kernel.h
===========================================================================
--- /usr/tmp/TmpDir.11207-0/linux/include/linux/devfs_fs_kernel.h_1.9
2003-07-21 11:39:51.000000000 -0500
+++ linux/include/linux/devfs_fs_kernel.h 2003-07-17 14:15:44.000000000
-0500
@@ -107,6 +107,7 @@
unsigned int flags, unsigned int major,
unsigned int minor_start,
umode_t mode, void *ops, void *info);
+extern int devfs_owns_block_major (int major);
extern int devfs_alloc_major (char type);
extern void devfs_dealloc_major (char type, int major);
extern kdev_t devfs_alloc_devnum (char type);
@@ -276,6 +277,11 @@
return;
}
+static inline int devfs_owns_block_major (int major)
+{
+ return 0;
+}
+
static inline int devfs_alloc_major (char type)
{
return -1;
--
Eric Sandeen [C]XFS for Linux http://oss.sgi.com/projects/xfs
sandeen@xxxxxxx SGI, Inc. 651-683-3102
|