Skip to content

Commit 9eb3e1e

Browse files
committed
improve non-dm device detection
Signed-off-by: Zen <[email protected]>
1 parent d231ee1 commit 9eb3e1e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/ugrd/fs/mounts.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__author__ = 'desultory'
2-
__version__ = '4.16.3'
2+
__version__ = '4.16.4'
33

44
from pathlib import Path
55
from zenlib.util import contains, pretty_print
@@ -327,6 +327,11 @@ def _autodetect_dm(self, mountpoint, device=None) -> None:
327327
raise FileNotFoundError("Mountpoint not found in host mounts: %s" % mountpoint)
328328

329329
device_name = source_device.split('/')[-1]
330+
if not any(device_name.startswith(prefix) for prefix in ['dm-', 'md']):
331+
if not source_device.startswith('/dev/mapper/'):
332+
self.logger.debug("Mount is not a device mapper mount: %s" % source_device)
333+
return
334+
330335
if source_device not in self['_blkid_info']:
331336
if device_name in self['_dm_info']:
332337
source_name = self['_dm_info'][device_name]['name']
@@ -339,10 +344,6 @@ def _autodetect_dm(self, mountpoint, device=None) -> None:
339344
else:
340345
raise ValueError("[%s] No blkid info for virtual device: %s" % (mountpoint, source_device))
341346

342-
if not any(source_device.startswith(prefix) for prefix in ['/dev/mapper', '/dev/dm-', '/dev/md']):
343-
self.logger.debug("Mount is not a device mapper mount: %s" % source_device)
344-
return
345-
346347
self.logger.info("[%s] Detected virtual block device: %s" % (mountpoint, source_device))
347348
source_device = Path(source_device)
348349
major, minor = _get_device_id(source_device)

0 commit comments

Comments
 (0)