Bug 164524 - /etc/init.d/halt doesn't support USB based UPS devices
Summary: /etc/init.d/halt doesn't support USB based UPS devices
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: initscripts
Version: 3
Hardware: i386
OS: Linux
medium
high
Target Milestone: ---
Assignee: Bill Nottingham
QA Contact: Brock Organ
URL:
Whiteboard:
Depends On: 164531
Blocks: FC5Target
TreeView+ depends on / blocked
 
Reported: 2005-07-28 15:10 UTC by Alfred Ganz
Modified: 2014-03-17 02:55 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2006-02-07 22:35:06 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Alfred Ganz 2005-07-28 15:10:38 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.10) Gecko/20050719 Fedora/1.7.10-1.3.1

Description of problem:
At the end of /etc/init.d/halt, a UPS driver program may be called to turn off
the UPS. There are now new UPS driver programs that are USB based. In order for them to work, /proc/bus/usb/devices must be available read/write at that time.

I think there is no problem delaying the umount for /proc/bus/usb/devices and
the remounting of /proc until after the above code. Doing so unfortunately gets
relatively ugly. I will attach my hack, but please do it better!








Version-Release number of selected component (if applicable):
initscripts-7.93.7-1

How reproducible:
Always

Steps to Reproduce:
1.run on the UPS and wait for the low battery shutdown
2.read the error message if you can!
3.
  

Additional info:

--- halt.orig   2004-10-03 23:20:19.000000000 -0400
+++ halt        2005-07-28 09:48:40.000000000 -0400
@@ -193,20 +193,28 @@
        retry=$(($retry-1))
        sig=-9
 done
-[ -f /proc/bus/usb/devices ] && umount /proc/bus/usb
+##AG## We need this for shutting down any USB based UPS's
+##AG## [ -f /proc/bus/usb/devices ] && umount /proc/bus/usb

 # remove the crash indicator flag
 rm -f /.autofsck

 # Try all file systems other than root and RAM disks, one last time.
-mount |  awk '!/( \/ |^\/dev\/root|^\/dev\/ram| \/proc )/ { print $3 }' | \
+##AG## We need to keep /proc/bus/usb around to shut any USB based UPS's
+##AG# mount |  awk '!/( \/ |^\/dev\/root|^\/dev\/ram| \/proc )/ { print $3 }' | \
+mount | awk \
+    '!/( \/ |^\/dev\/root|^\/dev\/ram| \/proc | \/proc\/bus\/usb )/ { print $3 }' | \
   while read line; do
     umount -f $line
 done

 # Remount read only anything that's left mounted.
 # echo $"Remounting remaining filesystems readonly"
-mount | awk '{ print $3 }' | while read line; do
+##AG## Don't do this for /proc and /proc/bus/usb,
+##AG## we need /proc/bus/usb rw for shutting down any USB based UPS's
+##AG## mount | awk '{ print $3 }' | while read line; do
+mount |  awk '!/( \/proc | \/proc\/bus\/usb )/ { print $3 }' | \
+  while read line; do
     mount -n -o ro,remount $line
 done

@@ -225,8 +233,13 @@
        elif [ "$SERVER" = "yes" -a "$MODEL" != "NONE" -a -n "$MODEL" -a -n "$DEVICE" ] ; then
                $MODEL $OPTIONS_HALT -k $DEVICE
        fi
+       sleep 100
 fi

+#AG## Now, if we didn't shut power, this can finally all be sorted out
+[ -f /proc/bus/usb/devices ] && umount /proc/bus/usb
+mount -n -o ro,remount /proc
+
 if [ -x /sbin/halt.local ]; then
    /sbin/halt.local
 fi

Comment 1 Alfred Ganz 2005-07-28 15:37:23 UTC
Note, in addition to the above, said UPS driver programs must be made to work
after /usr has been unmounted. I have filed a bug 164531 for this.

Comment 2 Fabrice Bellet 2006-02-07 20:55:20 UTC
. The problem still exists in FC4
. Additionnal care must be taken with the params taken from /etc/sysconfig/ups,
see bug 164531, comment #1.

Comment 3 Bill Nottingham 2006-02-07 20:58:38 UTC
Why do you need /proc/bus/usb? Is it to write to the device files with libusb?

Comment 4 Alfred Ganz 2006-02-07 22:29:30 UTC
You are correct, the UPS needs to be told to turn off the power to the system, 
AND to set itself ready to catch line power coming back.
In the olden days this typically implied a hardwired tty line, so not much
of a problem, but now we need a significant amount of infrastructure just before
we quit.

Comment 5 Bill Nottingham 2006-02-07 22:35:06 UTC
OK, this should be solved in the devel tree, as libusb has been changed to use
the device nodes udev creates under /dev.

Comment 6 Alfred Ganz 2006-02-07 22:45:20 UTC
I just hope that it will be done in a way that avoids the current
complexity of determining which out of multiple similar devices
that has led to grabbing the device in the usb tree. Have a look
at the machinations that newhidups of the nut package goes through!


Note You need to log in before you can comment on or make changes to this bug.