Re: Undoing chroot?

From: alex@foogod.com
Date: Fri Jan 26 2001 - 13:54:36 EST


On Fri, Jan 26, 2001 at 10:31:40AM -0800, Paul Powell wrote:
> I have a linux bootable CD which executes a custom
> init. The job of init is to figure out on which
> device the CD is located. After finding the CD, init
> mounts the device and executes a CHROOT to set the
> root directory to the CD.
>
> After I'm done I'd like to umount the CD and then
> eject it by sending an IOCTL eject command. But since
> I executed a CHROOT I can't umount the CD, umount
> complains that the device is busy.
>
> So how do you reverse a CHROOT?

By definition, a chroot() is not undoable. There are strong security reasons
for this (chroot() is often used to create protected "jails" for untrusted
code. If the code could just undo the chroot() it wouldn't be very useful).
However, chroot() is per-process, therefore what you probably want to do is
fork(), then do a chroot() in the child and do whatever you want to do there,
when you're done with the CD, exit the child, and have the parent eject it.

-alex
-
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/



This archive was generated by hypermail 2b29 : Wed Jan 31 2001 - 21:00:25 EST