Bug 164524 - /etc/init.d/halt doesn't support USB based UPS devices
/etc/init.d/halt doesn't support USB based UPS devices
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: initscripts (Show other bugs)
3
i386 Linux
medium Severity high
: ---
: ---
Assigned To: Bill Nottingham
Brock Organ
:
Depends On: 164531
Blocks: FC5Target
  Show dependency treegraph
 
Reported: 2005-07-28 11:10 EDT by Alfred Ganz
Modified: 2014-03-16 22:55 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-02-07 17:35:06 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Alfred Ganz 2005-07-28 11:10:38 EDT
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 11:37:23 EDT
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 15:55:20 EST
. 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 15:58:38 EST
Why do you need /proc/bus/usb? Is it to write to the device files with libusb?
Comment 4 Alfred Ganz 2006-02-07 17:29:30 EST
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 17:35:06 EST
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 17:45:20 EST
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.