[PATCH] real-root-dev broken on big endian

Andreas Schwab (schwab@issan.informatik.uni-dortmund.de)
09 Oct 1998 10:42:31 +0200


Here's another endian bug: /proc/sys/kernel/real-root-dev does not work on
big endian machines because real_root_dev has the wrong type. The sysctl
interface can only cope with pointers to int, but real_root_dev is a
kdev_t, ie. short.

--- linux-2.1/include/linux/fs.h.~1~ Mon Sep 28 18:27:15 1998
+++ linux-2.1/include/linux/fs.h Mon Sep 28 19:11:08 1998
@@ -840,7 +840,7 @@
extern void mount_root(void);

#ifdef CONFIG_BLK_DEV_INITRD
-extern kdev_t real_root_dev;
+extern int real_root_dev;
extern int change_root(kdev_t new_root_dev,const char *put_old);
#endif

--- linux-2.1/init/main.c.~1~ Mon Oct 5 18:49:50 1998
+++ linux-2.1/init/main.c Thu Oct 8 16:04:28 1998
@@ -339,7 +339,7 @@
extern int rd_size; /* Size of the ramdisk(s) */
extern int rd_image_start; /* starting block # of image */
#ifdef CONFIG_BLK_DEV_INITRD
-kdev_t real_root_dev;
+int real_root_dev; /* MUST be int for sysctl */
#endif
#endif

@@ -1217,7 +1217,7 @@

#ifdef CONFIG_BLK_DEV_INITRD

- real_root_dev = ROOT_DEV;
+ real_root_dev = (MAJOR(ROOT_DEV) << 8) | MINOR(ROOT_DEV);
real_root_mountflags = root_mountflags;
if (initrd_start && mount_initrd) root_mountflags &= ~MS_RDONLY;
else mount_initrd =0;
@@ -1252,7 +1252,8 @@

#ifdef CONFIG_BLK_DEV_INITRD
root_mountflags = real_root_mountflags;
- if (mount_initrd && ROOT_DEV != real_root_dev
+ if (mount_initrd
+ && (MAJOR(ROOT_DEV) != (real_root_dev >> 8) || MINOR(ROOT_DEV) != (real_root_dev & 0xff))
&& MAJOR(ROOT_DEV) == RAMDISK_MAJOR && MINOR(ROOT_DEV) == 0) {
int error;
int i, pid;
@@ -1260,9 +1261,11 @@
pid = kernel_thread(do_linuxrc, "/linuxrc", SIGCHLD);
if (pid>0)
while (pid != wait(&i));
- if (MAJOR(real_root_dev) != RAMDISK_MAJOR
- || MINOR(real_root_dev) != 0) {
- error = change_root(real_root_dev,"/initrd");
+ if ((real_root_dev >> 8) != RAMDISK_MAJOR
+ || (real_root_dev & 0xff) != 0) {
+ error = change_root(MKDEV(real_root_dev >> 8,
+ real_root_dev & 0xff),
+ "/initrd");
if (error)
printk(KERN_ERR "Change root to /initrd: "
"error %d\n",error);

-- 
Andreas Schwab                                      "And now for something
schwab@issan.cs.uni-dortmund.de                      completely different"
schwab@gnu.org

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/