Followup to: <20000126011602.A1070@win.tue.nl>
By author: Guest section DW <dwguest@win.tue.nl>
In newsgroup: linux.dev.kernel
>
> and Peter answered
>
> > > Right... everyone on the old / move to the new /, although I guess
> > > that's technically not 100% necessary.
>
> but I wonder.
> Usually in such a situation not many processes will be around, but still..
> It would be strange if the interpretation of paths suddenly changed for
> processes other than the one doing this pivot_root.
> So, I would prefer these old processes all to remain where they are,
> with the same root inode (that just got a new name, namely /old_root).
>
> Thus, the only process that would get the new / as root would be the
> process doing this pivot_root() (and perhaps init?).
>
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/
This archive was generated by hypermail 2b29 : Mon Jan 31 2000 - 21:00:15 EST