From: Michael Prokop Date: Tue, 24 Mar 2009 16:41:15 +0000 (+0100) Subject: Support older kernel versions in check for removable usb device X-Git-Tag: v0.9.3~4 X-Git-Url: https://git.grml.org/?p=grml2usb.git;a=commitdiff_plain;h=afcc7b22dfdecb49ca05ac4cb8758cd98889ef4f Support older kernel versions in check for removable usb device --- diff --git a/debian/changelog b/debian/changelog index bbd13af..61b0ff9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,8 +11,10 @@ grml2usb (0.9.3) UNRELEASED; urgency=low * Mention the Debian package in the error message (thanks to Lothar Speil for the bugreport). * Mention grml-repository in the docs. + * Support older kernel versions in check for removable usb device. + (Thanks to Ralf Gross for the report and relevant information.) - -- Michael Prokop Thu, 12 Mar 2009 23:10:02 +0100 + -- Michael Prokop Tue, 24 Mar 2009 17:40:08 +0100 grml2usb (0.9.2) unstable; urgency=low diff --git a/grml2usb b/grml2usb index 3c7bfb3..3e9475e 100755 --- a/grml2usb +++ b/grml2usb @@ -894,13 +894,18 @@ def check_for_usbdevice(device): """ usbdevice = re.match(r'/dev/(.*?)\d*$', device).group(1) - usbdevice = os.path.realpath('/sys/class/block/' + usbdevice + '/removable') - if os.path.isfile(usbdevice): - is_usb = open(usbdevice).readline() - if is_usb == "1": + # newer systems: + usbdev = os.path.realpath('/sys/class/block/' + usbdevice + '/removable') + if not os.path.isfile(usbdev): + # Ubuntu with kernel 2.6.24 for example: + usbdev = os.path.realpath('/sys/block/' + usbdevice + '/removable') + + if os.path.isfile(usbdev): + is_usb = open(usbdev).readline() + if is_usb.find("1"): return 0 - else: - return 1 + + return 1 def check_for_fat(partition):