def umountImage(self): if self.currentMedia: isys.umount(self.mntPoint) isys.makeDevInode("loop3", "/tmp/loop3") isys.unlosetup("/tmp/loop3") self.mntPoint = None self.currentMedia = []
def umountMedia(self): if self.mediaIsMounted: isys.umount(self.tree) isys.makeDevInode("loop3", "/tmp/loop3") isys.unlosetup("/tmp/loop3") self.umountDirectory() self.mediaIsMounted = 0
def umountImage(self): if self.imageMounted: isys.umount(self.mntPoint) isys.makeDevInode("loop3", "/tmp/loop3") isys.unlosetup("/tmp/loop3") self.mntPoint = None self.imageMounted = 0
def umountMedia(self): if self.mediaIsMounted: isys.umount(self.tree) isys.makeDevInode("loop3", "/tmp/loop3") isys.unlosetup("/tmp/loop3") self.umountDirectory() self.tree = None self.mediaIsMounted = 0
def findIsoImages(path, messageWindow): flush = os.stat(path) files = os.listdir(path) arch = _arch discImages = {} for file in files: what = path + '/' + file 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) for num in range(1, 10): if os.access("/mnt/cdimage/.discinfo", os.R_OK): f = open("/mnt/cdimage/.discinfo") try: f.readline() # skip timestamp f.readline() # skip release description discArch = string.strip(f.readline()) # read architecture discNum = getDiscNums(f.readline().strip()) except: discArch = None discNum = [ 0 ] f.close() if num not in discNum or discArch != arch: continue # if it's disc1, it needs to have images/install.img if (num == 1 and not os.access("/mnt/cdimage/images/install.img", os.R_OK)): log.warning("%s doesn't have a install.img, skipping" %(what,)) continue # we only install binary packages, so let's look for a # product/ dir and hope that this avoids getting # discs from the src.rpm set if not os.path.isdir("/mnt/cdimage/%s" %(productPath,)): log.warning("%s doesn't have binary RPMS, skipping" %(what,)) continue # warn user if images appears to be wrong size if os.stat(what)[stat.ST_SIZE] % 2048: rc = messageWindow(_("Warning"), _("The ISO image %s has a size which is not " "a multiple of 2048 bytes. This may mean " "it was corrupted on transfer to this computer." "\n\n" "It is recommended that you exit and abort your " "installation, but you can choose to continue if " "you think this is in error.") % (file,), type="custom", custom_icon="warning", custom_buttons= [_("_Exit installer"), _("_Continue")]) if rc == 0: sys.exit(0) discImages[num] = file isys.umount("/mnt/cdimage", removeDir=False) except SystemError: pass isys.unlosetup("/dev/loop2") return discImages
def umountImage(tree, currentMedia): if currentMedia is not None: isys.umount(tree, removeDir=False) isys.unlosetup("/dev/loop1")
def umountImage(tree, currentMedia, loopdev): if currentMedia is not None: isys.umount(tree, removeDir=False) if loopdev: isys.unlosetup(loopdev)
def findIsoImages(path, messageWindow): files = os.listdir(path) arch = _arch discImages = {} for file in files: what = path + '/' + file if not isys.isIsoImage(what): continue isys.makeDevInode("loop2", "/tmp/loop2") try: isys.losetup("/tmp/loop2", what, readOnly = 1) except SystemError: continue try: isys.mount("loop2", "/mnt/cdimage", fstype = "iso9660", readOnly = 1) for num in range(1, 10): if os.access("/mnt/cdimage/.discinfo", os.R_OK): f = open("/mnt/cdimage/.discinfo") try: f.readline() # skip timestamp f.readline() # skip release description discArch = string.strip(f.readline()) # read architecture discNum = getDiscNums(f.readline().strip()) except: discArch = None discNum = [ 0 ] f.close() if num not in discNum or discArch != arch: continue # if it's disc1, it needs to have RedHat/base/stage2.img if (num == 1 and not os.access("/mnt/cdimage/%s/base/stage2.img" % (productPath,), os.R_OK)): continue # warn user if images appears to be wrong size if os.stat(what)[stat.ST_SIZE] % 2048: rc = messageWindow(_("Warning"), "The ISO image %s has a size which is not " "a multiple of 2048 bytes. This may mean " "it was corrupted on transfer to this computer." "\n\n" "It is recommended that you reboot and abort your " "installation, but you can choose to continue if " "you think this is in error." % (file,), type="custom", custom_icon="warning", custom_buttons= [_("_Reboot"), _("_Continue")]) if rc == 0: sys.exit(0) discImages[num] = file isys.umount("/mnt/cdimage") except SystemError: pass isys.makeDevInode("loop2", '/tmp/' + "loop2") isys.unlosetup("/tmp/loop2") return discImages
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.makeDevInode(argv[2][-5:], argv[2]) 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.makeDevInode(argv[1][-5:], argv[1]) isys.losetup(argv[1], argv[2]) except SystemError, (errno, msg): print msg sys.exit(1) sys.exit(0) usage()