diff options
author | Jeremy Katz <katzj@redhat.com> | 2004-09-28 21:08:30 +0000 |
---|---|---|
committer | Jeremy Katz <katzj@redhat.com> | 2004-09-28 21:08:30 +0000 |
commit | 1f952d96968d3cf2f149badd57bf7e9fb49b90d1 (patch) | |
tree | 604842fb4c6f093ce71d36551f0a74a82b294ede /isys | |
parent | 8dbbd50d7a9a05d4c28b2fa3c25b1045cee02b7e (diff) | |
download | anaconda-1f952d96968d3cf2f149badd57bf7e9fb49b90d1.tar.gz anaconda-1f952d96968d3cf2f149badd57bf7e9fb49b90d1.tar.xz anaconda-1f952d96968d3cf2f149badd57bf7e9fb49b90d1.zip |
2004-09-28 Jeremy Katz <katzj@redhat.com>
* isys/isys.py (readSwapLabel): Add function to read label from
swap filesystems.
(readFSLabel): Read swap and JFS labels too.
* fsset.py: Add support for label'ing swap filesystems (#127892).
Diffstat (limited to 'isys')
-rw-r--r-- | isys/isys.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/isys/isys.py b/isys/isys.py index f07043b34..6fa0d6755 100644 --- a/isys/isys.py +++ b/isys/isys.py @@ -596,6 +596,28 @@ def readJFSLabel(device, makeDevNode = 1): label = readJFSLabel_int(device) return label +def readSwapLabel_int(device): + label = None + try: + fd = os.open(device, os.O_RDONLY) + except: + return label + + buf = os.read(fd, getpagesize()) + os.close(fd) + + if ((len(buf) == getpagesize()) and (buf[pagesize - 10:] == "SWAPSPACE2")): + label = string.rstrip(buf[32:48], "\0x00") + return label + +def readSwapLabel(device, makeDevNode = 1): + if makeDevNode: + makeDevInode(device, "/tmp/disk") + label = readSwapLabel_int(device) + os.unlink("/tmp/disk") + else: + label = readSwapLabel_int(device) + return label def readExt2Label(device, makeDevNode = 1): if makeDevNode: @@ -609,7 +631,11 @@ def readExt2Label(device, makeDevNode = 1): def readFSLabel(device, makeDevNode = 1): label = readExt2Label(device, makeDevNode) if label is None: + label = readSwapLabel(device, makeDevNode) + if label is None: label = readXFSLabel(device, makeDevNode) + if label is None: + label = readJFSLabel(device, makeDevNode) return label def ext2IsDirty(device): |