I think this really is the right solution... usually the process doing
this will *be* init. There are other things that need to be done,
too, like replacing the console fd's after the remount (otherwise you
will hold initrd busy by virtue of having /dev/console open.)
I therefore conclude that doing automatic stuff is pointless and
probably harmful. The recommended sequence for root-switching will
then look something like (error checking omitted):
chdir("/oldroot");
pivot_root("/newroot", "/oldroot");
chroot(".");
new_console = open("/dev/console", O_RDWR);
dup2(new_console, 0);
dup2(new_console, 1);
dup2(new_console, 2);
close(new_console);
execl("/sbin/init", "init", 0);
-- <hpa@transmeta.com> at work, <hpa@zytor.com> in private! "Unix gives you enough rope to shoot yourself in the foot."- 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/