diff options
author | Jeremy Katz <katzj@redhat.com> | 2005-05-23 21:56:54 +0000 |
---|---|---|
committer | Jeremy Katz <katzj@redhat.com> | 2005-05-23 21:56:54 +0000 |
commit | 455dfbe2bc62f6b8b9f43f3298f182ea8ad41d08 (patch) | |
tree | 89ac5b2b6bc945621e8db298de8ef5f3f5f2e014 /isys/isys.py | |
parent | 710f8908353300d295da493d039e5cd443a3dfdf (diff) | |
download | anaconda-455dfbe2bc62f6b8b9f43f3298f182ea8ad41d08.tar.gz anaconda-455dfbe2bc62f6b8b9f43f3298f182ea8ad41d08.tar.xz anaconda-455dfbe2bc62f6b8b9f43f3298f182ea8ad41d08.zip |
2005-05-23 Jeremy Katz <katzj@redhat.com>
* isys/isys.py (oldSwapLabelMunge): Munge old swap label format to
the new version. Elliot's first pass wasn't accepted upstream so
we need to try to do some conversion. We should probably nuke
this code for FC5 or FC6.
Diffstat (limited to 'isys/isys.py')
-rw-r--r-- | isys/isys.py | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/isys/isys.py b/isys/isys.py index 6db63e9ba..2d1f89cee 100644 --- a/isys/isys.py +++ b/isys/isys.py @@ -663,12 +663,48 @@ def readSwapLabel_int(device): label = string.rstrip(buf[1052:1068], "\0x00") return label +# FIXME: we should probably remove this after a release just to avoid +# breaking things +def oldSwapLabelMunge(device): + label = None + try: + fd = os.open(device, os.O_RDWR) + except: + return label + + pagesize = getpagesize() + try: + buf = os.read(fd, pagesize) + except OSError, e: + log("error reading swap label on %s: %s" %(device, e)) + try: + os.close(fd) + except: + pass + return label + + if ((len(buf) == pagesize) and (buf[pagesize - 10:] == "SWAPSPACE2")): + label = string.rstrip(buf[16:31], "\0x00") + os.lseek(fd, 1052, 0) + if len(label) > 0: + os.write(fd, label) + os.close(fd) + return label + def readSwapLabel(device, makeDevNode = 1): if makeDevNode: makeDevInode(device, "/tmp/disk") - label = readSwapLabel_int(device) + try: + oldSwapLabelMunge("/tmp/disk") + except Exception, e: + log("error munging swap label: %s" %(e,)) + label = readSwapLabel_int("/tmp/disk") os.unlink("/tmp/disk") else: + try: + oldSwapLabelMunge(device) + except Exception, e: + log("error munging swap label: %s" %(e,)) label = readSwapLabel_int(device) return label |