issue in init/main.c - prepare_namespace

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Consider the following from init/main.c - prepare_namespace in 2.4.17:

        root_mountflags = real_root_mountflags;
        if (mount_initrd && ROOT_DEV != real_root_dev
            && MAJOR(ROOT_DEV) == RAMDISK_MAJOR && MINOR(ROOT_DEV) == 0) {
                int error;
                int i, pid;

                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 (error)
                                printk(KERN_ERR "Change root to /initrd: "
                                    "error %d\n",error);
                }
        }

I'm working on a pet project in my spare time in which the root device is
not known at kernel compile time. So, I load the ramdisk and linuxrc does
the work of finding the root device and mounting it and so on. When my
linuxrc exits; however, the code above tries to mount what it thinks
should be the root device (and usually panics). Am I doing something wrong
here?

Second, the inner if doesn't seem necessary to me. Since the outer if
determines that ROOT_DEV is a ramdisk and that real_root_dev is not the
same as ROOT_DEV, the inner if will always succeed.

It looks like this is being changed in 2.5, but I'm currently using 2.4
and was hoping to not have to modify the kernel to get it working. Any
help or pointer or explanation as to what I'm doing wrong is welcome.

Thanks,
John Tyner
jtyner@cs.ucr.edu

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.kernelnewbies.org/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux