From: Loic Dachary Date: Wed, 16 Dec 2015 14:57:03 +0000 (+0100) Subject: ceph-disk: dereference symlinks in destroy and zap X-Git-Tag: v10.0.3~189^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fe71647bc9bd0f9ddc6d470ee7bee1e6b0983e2b;p=ceph.git ceph-disk: dereference symlinks in destroy and zap 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 --- diff --git a/src/ceph-disk b/src/ceph-disk index 21c70b876b5a..9d36259d3472 100755 --- a/src/ceph-disk +++ b/src/ceph-disk @@ -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: