[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#255128: cdrom-detect: Bad handling of mount error



Package: cdrom-detect
Version: CVS:20040616
Severity: important
Tags: patch

Summary:
This bug does not affect normal HW.  But current error handling makes
it impossible to recover from CD mount error just by using installer menu.

Details and patch:
As reported in Bug#254764: sarge-i386-netinst (20040616) fails:
  http://lists.debian.org/debian-boot/2004/06/msg01323.html
  http://lists.debian.org/debian-boot/2004/06/msg01417.html

Old Dell Latitude CPi with P2 and extremely slow and buggy CDROM drive
had mounting problem.  Current cdrom-detect.postinst is not robust
enough to let user recover with minimal efforts.

Basically, the CDROM drive on machine machine can not mount cleanly
first time.  This is my problem but installer should not be self-defeating
either.  (Otherwise, why offer to try again!)

As I see the key part of cdrom-detect.postinst:
----
        if mount -t iso9660 -o ro,exec $device /cdrom >/target/buglog.txt 2&>1
        then
            mounted=1
            db_set cdrom-detect/cdrom_device $device
            break
        fi
----
If mount lead to some error code while making CD mounted on /cdrom, this
script eventually run function fail later and exit with message.

But since /cdrom is mounted (I checked it on installer shell), second
run of this script after CD stabilizes will not try to mount CD due to
self-defeating code. (Actually existance of mounted CD is checked twice
as below at the top of cdrom-detect.postinst)
----
# Is a cdrom already mounted?  If so, assume it's the right one..
mount | grep -q ^/dev/cdroms/ && exit 0
if [ -e /cdrom/.disk/info ] ; then
   CDNAME=`cat /cdrom/.disk/info`
   log "Detected CD '$CDNAME'"
   exit 0
fi
-------
(I guess this is to allow alternative mounting methods.)

Since it is freezed package I propose the following least intrusive
patch which should not affect anyone who did not experience mount error
but ensures unmounted /cdrom for the second run.  (I did check that this
type of action worked to install on my system from the shell but I have
not tested this by making iso image yet.  I will test it if someone
makes ISO for me or I finish understanding how to build it my self.
Any simple guide just to build i386 netinst only?)

--- cdrom-detect.postinst.org   2004-06-18 00:27:01.000000000 +0200
+++ cdrom-detect.postinst       2004-06-19 00:00:00.000000000 +0200
@@ -45,6 +45,9 @@
             mounted=1
            db_set cdrom-detect/cdrom_device $device
             break
+        else
+            # Ensure nothing mounted on /cdrom
+            umount /cdrom >/dev/null 2>&1 || true
         fi
     done
------------------------------------------------------------

This is needed because error code 64 etc may result partial mount.
    mount RETURN CODES
        mount has the following return codes (the bits can be ORed):
        0      success
        1      incorrect invocation or permissions
        2      system error (out of memory, cannot fork, no more loop devices)
        4      internal mount bug or missing nfs support in mount
        8      user interrupt
        16     problems writing or locking /etc/mtab
        32     mount failure
        64     some mount succeeded

FYI: Here is example of my buggy CDROM HW response to mount:
........... as system booted ................
tintin:~# mount
/dev/hda1 on / type ext3 (rw,errors=remount-ro)
proc on /proc type proc (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
usbfs on /proc/bus/usb type usbfs (rw)
............  try mounting CD while noisy ...........
tintin:~# mount /dev/cdrom /cdrom
mount: you must specify the filesystem type
tintin:~# mount
/dev/hda1 on / type ext3 (rw,errors=remount-ro)
proc on /proc type proc (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
usbfs on /proc/bus/usb type usbfs (rw)
............  reinsert and try mounting CD while noisy ...........
tintin:~# mount -t iso9660 /dev/cdrom /cdrom
mount: block device /dev/cdrom is write-protected, mounting read-only
mount: No medium found
tintin:~# echo $?
32
............  eject and re-insert CD, wait to be quiet
tintin:~# mount -t iso9660 /dev/cdrom /cdrom
mount: block device /dev/cdrom is write-protected, mounting read-only
tintin:~# echo $?
0
>>>> Finally mounted.


-- 
~\^o^/~~~ ~\^.^/~~~ ~\^*^/~~~ ~\^_^/~~~ ~\^+^/~~~ ~\^:^/~~~ ~\^v^/~~~ +++++
        Osamu Aoki <osamu@debian.org>  Brussels Belgium, GPG-key: A8061F32
 .''`.  Debian Reference: post-installation user's guide for non-developers
 : :' : http://qref.sf.net and http://people.debian.org/~osamu
 `. `'  "Our Priorities are Our Users and Free Software" --- Social Contract




Reply to: