[Bug 600740] Re: Don't try to eject non-ejectable devices

Stéphane Graber stgraber at stgraber.org
Wed Dec 14 20:37:45 UTC 2011


I commited (to the packaging branch) a similar change using udisks (when present), checking for the "removable" flag.
If set to 0 for the device we're about to eject, it skips the eject call and the prompt.

Diff below:
=== modified file 'debian/casper.init'
--- debian/casper.init	2011-12-14 18:28:01 +0000
+++ debian/casper.init	2011-12-14 20:35:12 +0000
@@ -93,6 +93,14 @@
         cache_path "$path"
     done
 
+    # If the device isn't marked as removable, skip the prompt
+    if which udisks > /dev/null; then
+        device="$(grep " /cdrom " /proc/mounts | cut -d' ' -f1)" || device=
+        if [ -n "$device" ] && [ "$(udisks --show-info $device | grep removable | awk '{print $NF}')" = "0" ]; then
+            return 0
+        fi
+    fi
+
     eject -p -m /cdrom >/dev/null 2>&1
 
     [ "$prompt" ] || return 0

** Changed in: casper (Ubuntu)
       Status: New => Fix Committed

** Changed in: casper (Ubuntu)
     Assignee: (unassigned) => Stéphane Graber (stgraber)

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to casper in Ubuntu.
https://bugs.launchpad.net/bugs/600740

Title:
  Don't try to eject non-ejectable devices

Status in “casper” package in Ubuntu:
  Fix Committed

Bug description:
  Binary package hint: casper

  I was debugging a shutdown issue on a system where there was a ntfs
  recovery partition on the disk. That is, a casper system and a
  ubiquity install on, say, /dev/sda1.

  During shutdown, the machine would just stop and not finish shutting
  down.  I didn't see any error or message why.  It turns out that
  casper was trying to tell me to eject the machine and press Enter.
  But the message wasn't getting to the console (not sure why) and I
  didn't know what it was waiting for.

  The no-message issue is a separate bug, but not a useful one for me to
  report because my setup is weird and I didn't debug it further.

  But, I did add a workaround for why we were even trying to eject in
  the first place.  It seems to me that casper shouldn't try to eject a
  non-ejectable device like my /dev/sda1.  So I added the hacky solution
  below.  It should be possible to write something really sexy using
  udisks or such, that asks if something is ejectable, right?

  diff -Nru casper-1.236/debian/casper.init casper-1.236test1/debian/casper.init
  --- casper-1.236/debian/casper.init	2010-04-12 15:57:54.000000000 +0100
  +++ casper-1.236test1/debian/casper.init	2010-07-01 02:02:58.000000000 +0100
  @@ -93,6 +93,12 @@
           cache_path "$path"
       done
   
  +    cddev=$(mount | grep /cdrom | cut -d' ' -f1 | tr -d 0-9)
  +    # ideally we'd check if device is non-ejectable, but for now just check if it's sda
  +    if [ "$cddev" = "/dev/sda" ]; then
  +        return
  +    fi
  +
       eject -p -m /cdrom >/dev/null 2>&1
   
       [ "$prompt" ] || return 0

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/casper/+bug/600740/+subscriptions




More information about the foundations-bugs mailing list