]> git.hungrycats.org Git - linux/commit
[PATCH] LOOP_CHANGE_FD ioctl
authorAndrew Morton <akpm@osdl.org>
Fri, 12 Mar 2004 00:16:06 +0000 (16:16 -0800)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Fri, 12 Mar 2004 00:16:06 +0000 (16:16 -0800)
commit275da6a305c6b1ee5283011ed5757d4cc45c5994
tree1122ecedc469a3b15f7a587c9cec11951b30e0a4
parent0c8846a53ed60c87cd952db80c7613c21959b960
[PATCH] LOOP_CHANGE_FD ioctl

From: Arjan van de Ven <arjanv@redhat.com>

The patch below (written by Al Viro) solves a nasty chicken-and-egg issue
for operating system installers (well at least anaconda but the problem
domain is not exclusive to that)

The basic problem is this:

- The small first stage installer locates the image file of the second
  stage installer (which has X and all the graphical stuff); this image can
  be on the same CD, but it can come via NFS, http or ftp or ...  as well.

- The first stage installer loop-back mounts this image and gives control
  to the second stage installer by calling some binary there.

- The graphical installer then asks the user all those questions and
  starts installing packages.  Again the packages can come from the CD but
  also from NFS or http or ...

Now in case of a CD install, once all requested packages from the first CD
are installed, the installer wants to unmount and eject the CD and prompt
the user to put CD 2 in.......  EXCEPT that the unmount can't work since
the installer is actually running from a loopback mount of this cd.

The solution is a "LOOP_CHANGE_FD" ioctl, where basically the installer
copies the image to the harddisk (which can only be done late since only
late the target harddisk is mkfs'd) and then magically switches the backing
store FD from underneath the loop device to the one on the target harddisk
(and thus unbusying the CD mount).

This is obviously only allowed if the size of the new image is identical
and if the loop image is read-only in the first place.  It's the
responsibility of root to make sure the contents is the same (but that's of
the give-root-enough-rope kind)
drivers/block/loop.c
include/linux/loop.h