diff options
author | Erik Troan <ewt@redhat.com> | 2001-01-12 21:17:37 +0000 |
---|---|---|
committer | Erik Troan <ewt@redhat.com> | 2001-01-12 21:17:37 +0000 |
commit | eeb5e813cddfc38f247ff04b2b289452aa4bfefc (patch) | |
tree | 8606afdf6fbb5b49b4ca8559496920ca606b985a /upgrade.py | |
parent | e1e4d459287dbdc90b0de0957229b492d46b6305 (diff) | |
download | anaconda-eeb5e813cddfc38f247ff04b2b289452aa4bfefc.tar.gz anaconda-eeb5e813cddfc38f247ff04b2b289452aa4bfefc.tar.xz anaconda-eeb5e813cddfc38f247ff04b2b289452aa4bfefc.zip |
reworked rescue mode to automatically mount the user's system
Diffstat (limited to 'upgrade.py')
-rw-r--r-- | upgrade.py | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/upgrade.py b/upgrade.py new file mode 100644 index 000000000..f505fb196 --- /dev/null +++ b/upgrade.py @@ -0,0 +1,100 @@ +import isys +import _balkan +import os +from translate import _ +import raid +import fstab + +def findExistingRoots (intf, theFstab): + rootparts = [] + win = intf.waitWindow (_("Searching"), + _("Searching for Red Hat Linux installations...")) + + drives = theFstab.driveList() + mdList = raid.startAllRaid(drives) + + for dev in mdList: + if theFstab.isValidExt2 (dev): + try: + isys.mount(dev, '/mnt/sysimage', readOnly = 1) + except SystemError, (errno, msg): + intf.messageWindow(_("Error"), + _("Error mounting ext2 filesystem on %s: %s") % (dev, msg)) + continue + if os.access ('/mnt/sysimage/etc/fstab', os.R_OK): + rootparts.append ((dev, "ext2")) + isys.umount('/mnt/sysimage') + + raid.stopAllRaid(mdList) + + for drive in drives: + isys.makeDevInode(drive, '/tmp/' + drive) + + try: + table = _balkan.readTable ('/tmp/' + drive) + except SystemError: + pass + else: + for i in range (len (table)): + (type, sector, size) = table[i] + if size and type == _balkan.EXT2: + # for RAID arrays of format c0d0p1 + if drive [:3] == "rd/" or drive [:4] == "ida/" or drive [:6] == "cciss/": + dev = drive + 'p' + str (i + 1) + else: + dev = drive + str (i + 1) + try: + isys.mount(dev, '/mnt/sysimage') + except SystemError, (errno, msg): + intf.messageWindow(_("Error"), + _("Error mounting ext2 filesystem on %s: %s") % (dev, msg)) + continue + if os.access ('/mnt/sysimage/etc/fstab', os.R_OK): + rootparts.append ((dev, "ext2")) + isys.umount('/mnt/sysimage') + elif size and type == _balkan.DOS: + dev = drive + str (i + 1) + try: + isys.mount(dev, '/mnt/sysimage', fstype = "vfat", + readOnly = 1) + except SystemError, (errno, msg): + log("failed to mount vfat filesystem on %s\n" + % dev) + continue + + if os.access('/mnt/sysimage/redhat.img', os.R_OK): + rootparts.append((dev, "vfat")) + + isys.umount('/mnt/sysimage') + os.remove ('/tmp/' + drive) + win.pop () + return rootparts + +def mountRootPartition(rootInfo, theFstab, instPath, allowDirty = 0): + (root, rootFs) = rootInfo + + mdList = raid.startAllRaid(theFstab.driveList()) + + if rootFs == "vfat": + theFstab.mountLoopbackRoot(root) + else: + isys.mount(root, '/mnt/sysimage') + + fstab.readFstab('/mnt/sysimage/etc/fstab', theFstab) + + if rootFs == "vfat": + theFstab.unmountLoopbackRoot() + else: + isys.umount('/mnt/sysimage') + + raid.stopAllRaid(mdList) + + if not allowDirty and theFstab.hasDirtyFilesystems(): + intf.messageWindow(("Dirty Filesystems"), + _("One or more of the filesystems for your Linux system " + "was not unmounted cleanly. Please boot your Linux " + "installation, let the filesystems be checked, and " + "shut down cleanly to upgrade.")) + sys.exit(0) + + theFstab.mountFilesystems (instPath) |