X-Git-Url: https://git.grml.org/?p=grml2usb.git;a=blobdiff_plain;f=grml2usb;fp=grml2usb;h=7e68b183936f496a18816f35a180e438edc6f1f5;hp=7afeb4881b76f0f48184bc008385c7498dc0367f;hb=6f3eb526aad869050f24159dc46e5d3bfe7cf952;hpb=e73d9be6caed76c6fe1b97c4465f400a5a9b5926 diff --git a/grml2usb b/grml2usb index 7afeb48..7e68b18 100755 --- a/grml2usb +++ b/grml2usb @@ -906,13 +906,21 @@ def unmount(target, unmount_options): unregister_mountpoint(target) +def extract_device_name(device): + """Extract the device name of a given path + + @device: device name, like /dev/sda1 or /dev/sda + """ + return re.match(r"/dev/(.*?)\d*$", device).group(1) + + def check_for_usbdevice(device): """Check whether the specified device is a removable USB device @device: device name, like /dev/sda1 or /dev/sda """ - usbdevice = re.match(r"/dev/(.*?)\d*$", device).group(1) + usbdevice = extract_device_name(device) # newer systems: usbdev = os.path.realpath("/sys/class/block/" + usbdevice + "/removable") if not os.path.isfile(usbdev):