]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-disk: dereference symlinks in destroy and zap
authorLoic Dachary <ldachary@redhat.com>
Wed, 16 Dec 2015 14:57:03 +0000 (15:57 +0100)
committerLoic Dachary <ldachary@redhat.com>
Mon, 21 Dec 2015 10:31:25 +0000 (11:31 +0100)
The behavior of partprobe or sgdisk may be subtly different if given a
symbolic link to a device instead of an actual device. The debug output
is also more confusing when the symlink shows instead of the device it
points to.

Always dereference the symlink before running destroy and zap.

Signed-off-by: Loic Dachary <loic@dachary.org>
src/ceph-disk

index 21c70b876b5a1c153a622ef932dd5ff9ecbad6a0..9d36259d34729d1e32111f6d400c86957f0c15c8 100755 (executable)
@@ -1268,6 +1268,7 @@ def zap(dev):
     """
     Destroy the partition table and content of a given disk.
     """
+    dev = os.path.realpath(dev)
     dmode = os.stat(dev).st_mode
     if not stat.S_ISBLK(dmode) or is_partition(dev):
         raise Error('not full block device; cannot zap', dev)
@@ -2769,8 +2770,10 @@ def main_destroy(args):
     dmcrypt = False
     target_dev = None
 
-    if path and not is_partition(path):
-        raise Error("It should input the partition dev!!")
+    if path:
+        if not is_partition(path):
+            raise Error(path + " must be a partition device")
+        path = os.path.realpath(path)
 
     devices = list_devices([])
     for device in devices: