[rhel6-branch] [PATCH] Try multiple /dev/loop* devices, not only loop1/loop2
Brian C. Lane
bcl at redhat.com
Fri Sep 7 21:31:45 UTC 2012
On Wed, Sep 05, 2012 at 03:16:23PM +0200, Vratislav Podzimek wrote:
> People may use /dev/loop* devices in their %pre sections of kickstart,
> so we cannot rely on having /dev/loop[12] available for us.
>
> Resolves: rhbz#846336
> ---
> image.py | 75 +++++++++++++++++++++++++++++++++++++++++++---------------------
> 1 file changed, 51 insertions(+), 24 deletions(-)
>
> diff --git a/image.py b/image.py
> index fb2f083..645d9eb 100644
> --- a/image.py
> +++ b/image.py
> @@ -40,13 +40,26 @@ def findIsoImages(path, messageWindow):
> if not isys.isIsoImage(what):
> continue
>
> - try:
> - isys.losetup("/dev/loop2", what, readOnly = 1)
> - except SystemError:
> + loop_dev_num = 2
> + loop_dev = "/dev/loop2"
> + found_loop = False
> + while os.path.exists("/dev/loop%d" % loop_dev_num):
> + try:
> + isys.losetup("/dev/loop%d" % loop_dev_num, what, readOnly = 1)
> + found_loop = True
> + loop_dev = "/dev/loop%d" % loop_dev_num
> + break
> + except SystemError as syserr:
> + if syserr.args[0] == 16:
> + # device busy, try next one
> + loop_dev_num += 1
> + continue
> +
> + if not found_loop:
> continue
It would be easier to just call "losetup -f" which returns the next free
loop device.
--
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 482 bytes
Desc: not available
URL: <https://lists.fedorahosted.org/pipermail/anaconda-patches/attachments/20120907/405bdc0f/attachment.sig>
More information about the anaconda-patches
mailing list