Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
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
Alias: None
Product: Fedora
Classification: Fedora
Component: initscripts
Version: 3
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Bill Nottingham
QA Contact: Brock Organ
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:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2006-02-07 22:35:06 UTC

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):

How reproducible:

Steps to Reproduce: on the UPS and wait for the low battery shutdown the error message if you can!

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 @@
-[ -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

 # 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

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

+#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

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.