diff options
author | David Lehman <dlehman@redhat.com> | 2009-06-30 17:14:35 -0500 |
---|---|---|
committer | David Lehman <dlehman@redhat.com> | 2009-07-01 12:53:25 -0500 |
commit | c44cd82d9744303aad2e88371a41e532433478fa (patch) | |
tree | 228d5e505e204973a9656ad4e33373c61cc8da6c /storage/udev.py | |
parent | 8e4349a391307e73abf3beb8b27fc822fe6fe884 (diff) | |
download | anaconda-c44cd82d9744303aad2e88371a41e532433478fa.tar.gz anaconda-c44cd82d9744303aad2e88371a41e532433478fa.tar.xz anaconda-c44cd82d9744303aad2e88371a41e532433478fa.zip |
Add function storage.udev.udev_resolve_devspec.
This function resolves an arbitrary device specification (name, path, uuid,
or label) to a device name. It returns None if there is a failure.
Diffstat (limited to 'storage/udev.py')
-rw-r--r-- | storage/udev.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/storage/udev.py b/storage/udev.py index 5c17a34c7..af3ee122a 100644 --- a/storage/udev.py +++ b/storage/udev.py @@ -29,6 +29,29 @@ from errors import * import logging log = logging.getLogger("storage") +def udev_resolve_devspec(devspec): + if not devspec: + return None + + import devices as _devices + ret = None + for dev in udev_get_block_devices(): + if devspec.startswith("LABEL="): + if udev_device_get_label(dev) == devspec[6:]: + ret = dev + break + elif devspec.startswith("UUID="): + if udev_device_get_uuid(dev) == devspec[5:]: + ret = dev + break + else: + if udev_device_get_name(dev) == _devices.devicePathToName(devspec): + ret = dev + break + + del _devices + if ret: + return udev_device_get_name(dev) def udev_get_block_devices(): udev_settle(timeout=30) |