Also added some debugging output.
losetup isn't needed anymore. mount figures out how to mount the iso on its own. This prevents any race conditions between lo operations and mount/umount operations. --- pyanaconda/image.py | 20 +++++++++----------- 1 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/pyanaconda/image.py b/pyanaconda/image.py index 60f03aa..1a82013 100644 --- a/pyanaconda/image.py +++ b/pyanaconda/image.py @@ -37,19 +37,16 @@ def findIsoImages(path, messageWindow):
for file in files: what = path + '/' + file + log.debug("Checking %s" % (what)) if not isys.isIsoImage(what): continue
try: - isys.losetup("/dev/loop2", what, readOnly = 1) - except SystemError: - continue - - try: - isys.mount("/dev/loop2", "/mnt/cdimage", fstype = "iso9660", - readOnly = True) + log.debug("mounting %s on /mnt/cdimage", what) + isys.mount(what, "/mnt/cdimage", fstype = "iso9660", readOnly = True) for num in range(1, 10): if os.access("/mnt/cdimage/.discinfo", os.R_OK): + log.debug("Reading .discinfo") f = open("/mnt/cdimage/.discinfo") try: f.readline() # skip timestamp @@ -62,6 +59,7 @@ def findIsoImages(path, messageWindow):
f.close()
+ log.debug("discArch = %s | discNum = %s" % (discArch, discNum)) if num not in discNum or discArch != arch: continue
@@ -94,13 +92,14 @@ def findIsoImages(path, messageWindow): sys.exit(0)
discImages[num] = file + log.info("Found disc %d at %s" % (num, file))
+ log.info("unmounting /mnt/cdimage") isys.umount("/mnt/cdimage", removeDir=False) except SystemError: pass
- isys.unlosetup("/dev/loop2") - + log.info("Returning with %s" % (discImages)) return discImages
def getDiscNums(line): @@ -178,8 +177,7 @@ def mountImage(isodir, tree, discnum, messageWindow, discImages={}): while True: try: isoImage = "%s/%s" % (isodir, discImages[discnum]) - isys.losetup("/dev/loop1", isoImage, readOnly = 1) - isys.mount("/dev/loop1", tree, fstype = 'iso9660', readOnly = True) + isys.mount(isoImage, tree, fstype = 'iso9660', readOnly = True) break except: ans = messageWindow(_("Missing ISO 9660 Image"),
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 08/30/2010 02:53 PM, Brian C. Lane wrote:
Also added some debugging output.
losetup isn't needed anymore. mount figures out how to mount the iso on its own. This prevents any race conditions between lo operations and mount/umount operations.
Note, this fixes 627789 for me.
- -- Brian C. Lane bcl@redhat.com Red Hat / Port Orchard, WA
On 08/30/2010 11:53 PM, Brian C. Lane wrote:
Also added some debugging output.
losetup isn't needed anymore. mount figures out how to mount the iso on its own. This prevents any race conditions between lo operations and
Looks good to me. Will you be able to remove the losetup method from isys now?
Ales
On Wed, Sep 01, 2010 at 01:39:56PM +0200, Ales Kozumplik wrote:
On 08/30/2010 11:53 PM, Brian C. Lane wrote:
Also added some debugging output.
losetup isn't needed anymore. mount figures out how to mount the iso on its own. This prevents any race conditions between lo operations and
Looks good to me. Will you be able to remove the losetup method from isys now?
Probably so. Do you think I should?
On 09/01/2010 06:33 PM, Brian C. Lane wrote:
On Wed, Sep 01, 2010 at 01:39:56PM +0200, Ales Kozumplik wrote:
On 08/30/2010 11:53 PM, Brian C. Lane wrote:
Also added some debugging output.
losetup isn't needed anymore. mount figures out how to mount the iso on its own. This prevents any race conditions between lo operations and
Looks good to me. Will you be able to remove the losetup method from isys now?
Probably so. Do you think I should?
Yes,
mount figures those things out automatically doesn't it? There are also remnants of ioctl loop operations in loader which I plan to remove one day.
Ales
No longer used. mount can now handle loop devices itself. --- pyanaconda/isys/__init__.py | 28 ---------------------------- scripts/upd-instroot | 1 - 2 files changed, 0 insertions(+), 29 deletions(-)
diff --git a/pyanaconda/isys/__init__.py b/pyanaconda/isys/__init__.py index 3f026fc..aebcad1 100755 --- a/pyanaconda/isys/__init__.py +++ b/pyanaconda/isys/__init__.py @@ -80,24 +80,6 @@ EARLY_SWAP_RAM = _isys.EARLY_SWAP_RAM def pathSpaceAvailable(path): return _isys.devSpaceFree(path)
-## Set up an already existing device node to be used as a loopback device. -# @param device The full path to a device node to set up as a loopback device. -# @param file The file to mount as loopback on device. -# @param readOnly Should this loopback device be used read-only? -def losetup(device, file, readOnly = 0): - # FIXME: implement this as a storage.devices.Device subclass - if readOnly: - mode = os.O_RDONLY - else: - mode = os.O_RDWR - targ = os.open(file, mode) - loop = os.open(device, mode) - try: - _isys.losetup(loop, targ, file) - finally: - os.close(loop) - os.close(targ) - def lochangefd(device, file): # FIXME: implement this as a storage.devices.Device subclass loop = os.open(device, os.O_RDONLY) @@ -108,16 +90,6 @@ def lochangefd(device, file): os.close(loop) os.close(targ)
-## Disable a previously setup loopback device. -# @param device The full path to an existing loopback device node. -def unlosetup(device): - # FIXME: implement this as a storage.devices.Device subclass - loop = os.open(device, os.O_RDONLY) - try: - _isys.unlosetup(loop) - finally: - os.close(loop) - ## Mount a filesystem, similar to the mount system call. # @param device The device to mount. If bindMount is True, this should be an # already mounted directory. Otherwise, it should be a device diff --git a/scripts/upd-instroot b/scripts/upd-instroot index 3a28b26..937f513 100755 --- a/scripts/upd-instroot +++ b/scripts/upd-instroot @@ -1107,7 +1107,6 @@ ln -snf /modules $DEST/lib/modules ln -snf /firmware $DEST/lib/firmware cp $DEST/usr/share/anaconda/raidstart-stub $DEST/usr/bin/raidstart cp $DEST/usr/share/anaconda/raidstop-stub $DEST/usr/bin/raidstop -cp $DEST/usr/share/anaconda/losetup-stub $DEST/usr/bin/losetup cp $DEST/usr/share/anaconda/list-harddrives-stub $DEST/usr/bin/list-harddrives cp $DEST/usr/share/anaconda/loadkeys-stub $DEST/usr/bin/loadkeys cp $DEST/usr/share/anaconda/mknod-stub $DEST/usr/bin/mknod
diff --git a/scripts/upd-instroot b/scripts/upd-instroot index 3a28b26..937f513 100755 --- a/scripts/upd-instroot +++ b/scripts/upd-instroot @@ -1107,7 +1107,6 @@ ln -snf /modules $DEST/lib/modules ln -snf /firmware $DEST/lib/firmware cp $DEST/usr/share/anaconda/raidstart-stub $DEST/usr/bin/raidstart cp $DEST/usr/share/anaconda/raidstop-stub $DEST/usr/bin/raidstop -cp $DEST/usr/share/anaconda/losetup-stub $DEST/usr/bin/losetup cp $DEST/usr/share/anaconda/list-harddrives-stub $DEST/usr/bin/list-harddrives cp $DEST/usr/share/anaconda/loadkeys-stub $DEST/usr/bin/loadkeys cp $DEST/usr/share/anaconda/mknod-stub $DEST/usr/bin/mknod
Make sure you also remove data/command-stubs/losetup-stub from the repo.
- Chris
On Thu, Sep 02, 2010 at 03:18:52PM -0400, Chris Lumens wrote:
Make sure you also remove data/command-stubs/losetup-stub from the repo.
oops, that got squashed into the previous patch when I rebased.
mount can handle loop mounts itself now. No need for losetup, which was causing a race condition between umount and unlosetup (rhbz#627789)
Add some more debugging output to the image handling code. --- pyanaconda/image.py | 21 +++++++++------------ 1 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/pyanaconda/image.py b/pyanaconda/image.py index 60f03aa..9341192 100644 --- a/pyanaconda/image.py +++ b/pyanaconda/image.py @@ -37,19 +37,16 @@ def findIsoImages(path, messageWindow):
for file in files: what = path + '/' + file + log.debug("Checking %s" % (what)) if not isys.isIsoImage(what): continue
try: - isys.losetup("/dev/loop2", what, readOnly = 1) - except SystemError: - continue - - try: - isys.mount("/dev/loop2", "/mnt/cdimage", fstype = "iso9660", - readOnly = True) + log.debug("mounting %s on /mnt/cdimage", what) + isys.mount(what, "/mnt/cdimage", fstype = "iso9660", readOnly = True) for num in range(1, 10): if os.access("/mnt/cdimage/.discinfo", os.R_OK): + log.debug("Reading .discinfo") f = open("/mnt/cdimage/.discinfo") try: f.readline() # skip timestamp @@ -62,6 +59,7 @@ def findIsoImages(path, messageWindow):
f.close()
+ log.debug("discArch = %s | discNum = %s" % (discArch, discNum)) if num not in discNum or discArch != arch: continue
@@ -94,13 +92,14 @@ def findIsoImages(path, messageWindow): sys.exit(0)
discImages[num] = file + log.info("Found disc %d at %s" % (num, file))
+ log.info("unmounting /mnt/cdimage") isys.umount("/mnt/cdimage", removeDir=False) except SystemError: pass
- isys.unlosetup("/dev/loop2") - + log.info("Returning with %s" % (discImages)) return discImages
def getDiscNums(line): @@ -178,8 +177,7 @@ def mountImage(isodir, tree, discnum, messageWindow, discImages={}): while True: try: isoImage = "%s/%s" % (isodir, discImages[discnum]) - isys.losetup("/dev/loop1", isoImage, readOnly = 1) - isys.mount("/dev/loop1", tree, fstype = 'iso9660', readOnly = True) + isys.mount(isoImage, tree, fstype = 'iso9660', readOnly = True) break except: ans = messageWindow(_("Missing ISO 9660 Image"), @@ -274,7 +272,6 @@ def scanForMedia(tree, storage): def umountImage(tree, currentMedia): if currentMedia is not None: isys.umount(tree, removeDir=False) - isys.unlosetup("/dev/loop1")
def unmountCD(dev, messageWindow): if not dev:
No longer used. mount can now handle loop devices itself. --- data/command-stubs/losetup-stub | 50 --------------------------------------- pyanaconda/isys/__init__.py | 28 --------------------- scripts/upd-instroot | 1 - 3 files changed, 0 insertions(+), 79 deletions(-) delete mode 100755 data/command-stubs/losetup-stub
diff --git a/data/command-stubs/losetup-stub b/data/command-stubs/losetup-stub deleted file mode 100755 index 27c6bbc..0000000 --- a/data/command-stubs/losetup-stub +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/python -# -# losetup-stub -# -# Copyright (C) 2007 Red Hat, Inc. All rights reserved. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see http://www.gnu.org/licenses/. -# - -import os -import sys - -from pyanaconda import isys -from sys import argv - -def usage(): - print "usage: losetup [-d] /dev/loopN [image]" - sys.exit(1) - -if len(argv) < 3: - usage() - -if argv[1] == "-d" and len(argv[2]) > 4 and argv[2][-5:-1] == "loop": - try: - isys.unlosetup(argv[2]) - except SystemError, (errno, msg): - print msg - sys.exit (1) - sys.exit(0) - -if len(argv[1]) > 4 and argv[1][-5:-1] == "loop": - try: - isys.losetup(argv[1], argv[2]) - except SystemError, (errno, msg): - print msg - sys.exit (1) - sys.exit(0) - -usage() diff --git a/pyanaconda/isys/__init__.py b/pyanaconda/isys/__init__.py index 3f026fc..aebcad1 100755 --- a/pyanaconda/isys/__init__.py +++ b/pyanaconda/isys/__init__.py @@ -80,24 +80,6 @@ EARLY_SWAP_RAM = _isys.EARLY_SWAP_RAM def pathSpaceAvailable(path): return _isys.devSpaceFree(path)
-## Set up an already existing device node to be used as a loopback device. -# @param device The full path to a device node to set up as a loopback device. -# @param file The file to mount as loopback on device. -# @param readOnly Should this loopback device be used read-only? -def losetup(device, file, readOnly = 0): - # FIXME: implement this as a storage.devices.Device subclass - if readOnly: - mode = os.O_RDONLY - else: - mode = os.O_RDWR - targ = os.open(file, mode) - loop = os.open(device, mode) - try: - _isys.losetup(loop, targ, file) - finally: - os.close(loop) - os.close(targ) - def lochangefd(device, file): # FIXME: implement this as a storage.devices.Device subclass loop = os.open(device, os.O_RDONLY) @@ -108,16 +90,6 @@ def lochangefd(device, file): os.close(loop) os.close(targ)
-## Disable a previously setup loopback device. -# @param device The full path to an existing loopback device node. -def unlosetup(device): - # FIXME: implement this as a storage.devices.Device subclass - loop = os.open(device, os.O_RDONLY) - try: - _isys.unlosetup(loop) - finally: - os.close(loop) - ## Mount a filesystem, similar to the mount system call. # @param device The device to mount. If bindMount is True, this should be an # already mounted directory. Otherwise, it should be a device diff --git a/scripts/upd-instroot b/scripts/upd-instroot index 3a28b26..937f513 100755 --- a/scripts/upd-instroot +++ b/scripts/upd-instroot @@ -1107,7 +1107,6 @@ ln -snf /modules $DEST/lib/modules ln -snf /firmware $DEST/lib/firmware cp $DEST/usr/share/anaconda/raidstart-stub $DEST/usr/bin/raidstart cp $DEST/usr/share/anaconda/raidstop-stub $DEST/usr/bin/raidstop -cp $DEST/usr/share/anaconda/losetup-stub $DEST/usr/bin/losetup cp $DEST/usr/share/anaconda/list-harddrives-stub $DEST/usr/bin/list-harddrives cp $DEST/usr/share/anaconda/loadkeys-stub $DEST/usr/bin/loadkeys cp $DEST/usr/share/anaconda/mknod-stub $DEST/usr/bin/mknod
On 09/02/2010 08:59 PM, Brian C. Lane wrote:
Ack for the set.
Ales
anaconda-devel@lists.stg.fedoraproject.org