lkml.org 
[lkml]   [2000]   [Oct]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subjectreal_root_dev

`real_root_dev' must be `int', not `kdev_t'.

The reason for this is that we still have (in <linux/kdev_t.h>):

typedef unsigned short kdev_t;

while kernel/sysctl.c has the following line:

{KERN_REALROOTDEV, "real-root-dev", &real_root_dev, sizeof(int), 0644, NULL, &proc_dointvec},

This causes a nice endianness problem on big-endian machines. It can even
cause weird results on little-endian machines where the alignment rule for int
is a 2 byte-boundary.

We've had this patch in the m68k tree since ages (at least 2.0.x), so it's time
to share it to the world :-) I think it was originally by Andreas Schwab.

--- linux-2.4.0-test10-pre3/init/main.c Sat Sep 23 17:31:22 2000
+++ geert-real_root_dev-2.4.0-test10-pre3/init/main.c Thu Oct 19 21:39:07 2000
@@ -124,7 +124,7 @@
int rows, cols;

#ifdef CONFIG_BLK_DEV_INITRD
-kdev_t real_root_dev;
+int real_root_dev; /* MUST be int for sysctl! */
#endif

int root_mountflags = MS_RDONLY;
@@ -717,7 +717,7 @@

#ifdef CONFIG_BLK_DEV_INITRD
root_mountflags = real_root_mountflags;
- if (mount_initrd && ROOT_DEV != real_root_dev
+ if (mount_initrd && ROOT_DEV != (kdev_t)real_root_dev
&& MAJOR(ROOT_DEV) == RAMDISK_MAJOR && MINOR(ROOT_DEV) == 0) {
int error;
int i, pid;
@@ -725,9 +725,9 @@
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 (MAJOR((kdev_t)real_root_dev) != RAMDISK_MAJOR
+ || MINOR((kdev_t)real_root_dev) != 0) {
+ error = change_root((kdev_t)real_root_dev,"/initrd");
if (error)
printk(KERN_ERR "Change root to /initrd: "
"error %d\n",error);
--- linux-2.4.0-test10-pre3/include/linux/devfs_fs_kernel.h Tue Jul 18 14:07:34 2000
+++ geert-real_root_dev-2.4.0-test10-pre3/include/linux/devfs_fs_kernel.h Thu Oct 19 21:38:06 2000
@@ -46,7 +46,7 @@


#ifdef CONFIG_BLK_DEV_INITRD
-# define ROOT_DEVICE_NAME ((real_root_dev ==ROOT_DEV) ? root_device_name:NULL)
+# define ROOT_DEVICE_NAME (((kdev_t)real_root_dev ==ROOT_DEV) ? root_device_name:NULL)
#else
# define ROOT_DEVICE_NAME root_device_name
#endif
--- linux-2.4.0-test10-pre3/include/linux/fs.h Sat Oct 14 19:03:33 2000
+++ geert-real_root_dev-2.4.0-test10-pre3/include/linux/fs.h Thu Oct 19 21:38:21 2000
@@ -1228,7 +1228,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, const char *);
#endif

--- linux-2.4.0-test10-pre3/drivers/block/rd.c Tue Jul 18 14:08:53 2000
+++ geert-real_root_dev-2.4.0-test10-pre3/drivers/block/rd.c Thu Oct 19 21:37:58 2000
@@ -704,7 +704,7 @@
static void __init rd_load_disk(int n)
{
#ifdef CONFIG_BLK_DEV_INITRD
- extern kdev_t real_root_dev;
+ extern int real_root_dev;
#endif

if (rd_doload == 0)
@@ -712,7 +712,7 @@

if (MAJOR(ROOT_DEV) != FLOPPY_MAJOR
#ifdef CONFIG_BLK_DEV_INITRD
- && MAJOR(real_root_dev) != FLOPPY_MAJOR
+ && MAJOR((kdev_t)real_root_dev) != FLOPPY_MAJOR
#endif
)
return;
@@ -724,8 +724,8 @@
#ifdef CONFIG_MAC_FLOPPY
if(MAJOR(ROOT_DEV) == FLOPPY_MAJOR)
swim3_fd_eject(MINOR(ROOT_DEV));
- else if(MAJOR(real_root_dev) == FLOPPY_MAJOR)
- swim3_fd_eject(MINOR(real_root_dev));
+ else if(MAJOR((kdev_t)real_root_dev) == FLOPPY_MAJOR)
+ swim3_fd_eject(MINOR((kdev_t)real_root_dev));
#endif
printk(KERN_NOTICE
"VFS: Insert root floppy disk to be loaded into RAM disk and press ENTER\n");
Gr{oetje,eeting}s,
Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

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

\
 
 \ /
  Last update: 2005-03-22 12:41    [W:0.200 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site