Date: Wed, 3 Jan 2007 11:51:22 +0200 From: "Erik Udo" <erik.udo@gmail.com> To: freebsd-hackers@freebsd.org Subject: Re: Init.c, making it chroot Message-ID: <6e3d78920701030151o3bcbf129yeff694d9f064985f@mail.gmail.com> In-Reply-To: <4592C91C.2040801@gmail.com> References: <4592C91C.2040801@gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
------=_Part_120572_3556868.1167817882653 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline I just made patch. It's supposed to run /etc/rc before chrooting. This is the NetBSD "way" of doing it. All i can say is that it compiled. So if anyone can look at it before i get to test it becouse i might be forgetting something. (i can't even test it now) diff attached. On 12/27/06, Erik Udo <erik.udo@gmail.com> wrote: > > How can i make init chroot after executing /etc/rc, and executing > /etc/rc again in the chrooted enviroment? > > For this to work, i'd like to know at what point do i call chroot(), > becouse init.c uses fork() at the point where it runs the rc script. > > The thing is, i want to run a whole system in a chrooted enviroment in > this livecd i'm making. But the command "chroot /mnt/root /etc/rc" > returns after the /etc/rc has been run, dropping me back from the > chrooted enviroment. And if it doesn't, init never starts the multiuser > mode. > > So how can i go to the multiuser mode in a chrooted enviroment? I guess > the only way to do that is to modify init.c > > Any help/feedback is appreciated. > > Cheers, Erik > > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" > ------=_Part_120572_3556868.1167817882653 Content-Type: application/octet-stream; name=init.diff Content-Transfer-Encoding: base64 X-Attachment-Id: f_ewhkki9n Content-Disposition: attachment; filename="init.diff" LS0tIGluaXQuYy5vcmlnCVdlZCBKYW4gIDMgMDk6MTc6MzMgMjAwNworKysgaW5pdC5jCVdlZCBK YW4gIDMgMTA6MDg6MzggMjAwNwpAQCAtNjcsNiArNjcsNyBAQAogI2luY2x1ZGUgPHVuaXN0ZC5o PgogI2luY2x1ZGUgPHN5cy9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mlu ZygiQ2FuJ3QgY2hyb290IHRvICVzOiAlbSIsIGluaXRfY2hyb290KTsKKwkJcmV0dXJuIDA7CisJ fQorCisJcmV0dXJuIDE7Cit9Cg== ------=_Part_120572_3556868.1167817882653--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6e3d78920701030151o3bcbf129yeff694d9f064985f>