From 0e1be87d683fbeafe1075f957e8271b27fbda43b Mon Sep 17 00:00:00 2001 From: James Page Date: Fri, 27 Jul 2018 13:13:45 +0100 Subject: [PATCH] Resolve symlinks to underlying block devices When checking for holders on a block device, ensure that any by-uuid or by-dname provided paths are resolved to the underlying block device when searching for holders. Change-Id: If0e1fbc62bfe7d0f9e21db9bfdeee761060de846 Closes-Bug: 1782439 --- ceph/utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ceph/utils.py b/ceph/utils.py index 15f54ef..9133ea7 100644 --- a/ceph/utils.py +++ b/ceph/utils.py @@ -1699,8 +1699,10 @@ def is_mapped_luks_device(dev): :param: dev: A full path to a block device to be checked :returns: boolean: indicates whether a device is mapped """ - _, dirs, _ = next(os.walk('/sys/class/block/{}/holders/' - .format(os.path.basename(dev)))) + _, dirs, _ = next(os.walk( + '/sys/class/block/{}/holders/' + .format(os.path.basename(os.path.realpath(dev)))) + ) is_held = len(dirs) > 0 return is_held and is_luks_device(dev)