summaryrefslogtreecommitdiffstats
path: root/storage/devicelibs
diff options
context:
space:
mode:
authorDavid Cantrell <dcantrell@redhat.com>2009-09-04 13:26:53 -1000
committerDavid Cantrell <dcantrell@redhat.com>2009-09-07 09:58:53 -1000
commitb7eb44ac00ae74bedf37c4a20c3ca49fbbb95d2f (patch)
treeb94ed2085a92d8bf8e220443eb9b2250ec230684 /storage/devicelibs
parent2ecf5ea19cbac48cfaa9a0731e61c79a94fd9f73 (diff)
downloadanaconda-b7eb44ac00ae74bedf37c4a20c3ca49fbbb95d2f.tar.gz
anaconda-b7eb44ac00ae74bedf37c4a20c3ca49fbbb95d2f.tar.xz
anaconda-b7eb44ac00ae74bedf37c4a20c3ca49fbbb95d2f.zip
Raise exception if detected swap volumes are not Linux v1 swap space.
Safety net for detected swap volumes. We trap v0 swap space and swap partitions currently in use for software suspend. After all that verify that the detected volume is v1 swap space. If not, raise UnknownSwapError.
Diffstat (limited to 'storage/devicelibs')
-rw-r--r--storage/devicelibs/swap.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/storage/devicelibs/swap.py b/storage/devicelibs/swap.py
index dadeb0a0c..1afd20913 100644
--- a/storage/devicelibs/swap.py
+++ b/storage/devicelibs/swap.py
@@ -48,6 +48,8 @@ def mkswap(device, label=''):
def swapon(device, priority=None):
pagesize = resource.getpagesize()
buf = None
+ sig = None
+
if pagesize > 2048:
num = pagesize
else:
@@ -71,6 +73,9 @@ def swapon(device, priority=None):
if sig == 'S1SUSPEND\x00' or sig == 'S2SUSPEND\x00':
raise SuspendError
+ if sig != 'SWAPSPACE2':
+ raise UnknownSwapError
+
argv = []
if isinstance(priority, int) and 0 <= priority <= 32767:
argv.extend(["-p", "%d" % priority])