[rhel6-branch] [PATCH] Try multiple /dev/loop* devices, not only loop1/loop2
Vratislav Podzimek
vpodzime at redhat.com
Mon Sep 10 09:00:38 UTC 2012
On Fri, 2012-09-07 at 14:31 -0700, Brian C. Lane wrote:
> 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.
Yeah, I was trying to use that, bug "losetup -f" doesn't work on our
RHEL 6.4 images. It just prints usage info and using "losetup -h"
displays only "-h" and "-d" (detach) options.
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list