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. --- storage/devicelibs/swap.py | 5 +++++ storage/errors.py | 3 +++ 2 files changed, 8 insertions(+), 0 deletions(-) diff --git a/storage/devicelibs/swap.py b/storage/devicelibs/swap.py index dadeb0a..1afd209 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]) diff --git a/storage/errors.py b/storage/errors.py index fbc2188..d9fe4c8 100644 --- a/storage/errors.py +++ b/storage/errors.py @@ -104,6 +104,9 @@ class SuspendError(SwapError): class OldSwapError(SwapError): pass +class UnknownSwapError(SwapError): + pass + class MDRaidError(StorageError): pass -- 1.6.2.5 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list