From: Sage Weil Date: Tue, 5 Mar 2013 00:08:15 +0000 (-0800) Subject: ceph-disk-prepare: use os.path.realpath() X-Git-Tag: v0.56.5~5^2~56 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ea07b0e1047a4ac1b4dde88c795709190bd048be;p=ceph.git ceph-disk-prepare: use os.path.realpath() My janky symlink resolution is broken in various ways. Signed-off-by: Sage Weil (cherry picked from commit 59505546e52a175435881b431bd349d532ae627e) --- diff --git a/src/ceph-disk-prepare b/src/ceph-disk-prepare index b0f003b6e5c8..0eca7c0cafb8 100755 --- a/src/ceph-disk-prepare +++ b/src/ceph-disk-prepare @@ -75,13 +75,7 @@ def is_partition(dev): """ Check whether a given device is a partition or a full disk. """ - # resolve symlink(s) - max = 10 - while stat.S_ISLNK(os.lstat(dev).st_mode): - dev = os.readlink(dev) - max -= 1 - if max == 0: - raise PrepareError('%s is a rats nest of symlinks' % dev) + dev = os.path.realpath(dev) if not stat.S_ISBLK(os.lstat(dev).st_mode): raise PrepareError('not a block device', dev)