Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 104683
Alias:
Product:
Component:
Status: RESOLVED
Resolution: FIXED
Assigned To: Gentoo's Team for Core System packages <base-system@gentoo.org>
Hardware:
OS:
Version:
Priority:
Severity:
Reporter: Antti Mäkelä <zarhan@iki.fi>
Add CC:
CC:
Remove selected CCs
URL:
Summary:
Status Whiteboard:
Keywords:

Filename Description Type Creator Created Size Actions
hdparm-init-7.diff patch patch Matthias Foerste 2006-03-09 06:48 0000 617 bytes Details | Diff
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 104683 depends on: Show dependency tree
Bug 104683 blocks:
Votes: 0    Show votes for this bug    Vote for this bug

Additional Comments: (this is where you put emerge --info)


Not eligible to see or edit group visibility for this bug.






View Bug Activity   |   Format For Printing   |   XML   |   Clone This Bug


Description:   Opened: 2005-09-03 02:17 0000
Setting up hdparm (DMA, UDMA mode, multicount etc) modes with the initscript
fails if configuring an empty CD/DVD drive. The problem stems from this check at
the end of the /etc/init.d/hdparm:

(Using the non-devfs since udev068 has gotten rid of devfs compatibility)

                # non-devfs compatible system
                for device in /dev/hd?
                do
                        # check that the block device really exists
                        # by opening it for reading
                        if [ -b $device ] && ( : <$device ) 2>/dev/null
                        then
                                eval args=\${`basename $device`_args}
                                do_hdparm
                        fi
                done

When addressing a DVD drive the test fails, and the do_hdparm is never executed.
I can set the hdparm parameters manually just fine, but due to this test the
setting up does not work during bootup. 

When accessing a CD/DVD drive without media in, "cat" produces this error
# cat /dev/hdc
cat: /dev/hdc: No medium found

  Suggested fix: Replace the test with something a bit more robust or remove it
entirely.

------- Comment #1 From Joseph Roback 2005-09-06 03:35:28 0000 -------
Yes, I experience the same problem. udev-068 and hdparm-5.9 

------- Comment #2 From Jakub Moc (RETIRED) 2005-09-06 07:26:59 0000 -------
*** Bug 105018 has been marked as a duplicate of this bug. ***

------- Comment #3 From Rodney Gordon II 2005-10-27 23:08:31 0000 -------
This is still a problem, any fix anytime soon?

------- Comment #4 From SpanKY 2005-10-28 16:28:21 0000 -------
heaven forbid you suggest a fix rather than just complain someone else hasnt
done it yet

how does this work for people:
-  if [ -b $device ] && ( : <$device ) 2>/dev/null
+  errmsg=$(head -c 1 $device 2>&1)
+  if [[ -b $device ]] && [[ $? == 0 || ${errmsg} == *: No medium found ]]

------- Comment #5 From Rodney Gordon II 2005-10-28 16:39:58 0000 -------
I wasn't complaining, just wondering.. Your insulting reply wasn't very
warranted anyways.

For a fix, I have just been commenting out the check. If you really need me to
generate a patch of commenting out a few lines, sure.. But there is probably a
more elegant way to fix this.

This bug has been lingering here for a month and nothing has been changed, just
giving a "heads up".. Nice to see one of my first posts here was replied to like
this...

------- Comment #6 From Stefan Illner 2005-10-31 01:26:20 0000 -------
(In reply to comment #4)

> how does this work for people:
> -  if [ -b $device ] && ( : <$device ) 2>/dev/null
> +  errmsg=$(head -c 1 $device 2>&1)
> +  if [[ -b $device ]] && [[ $? == 0 || ${errmsg} == *: No medium found ]]

Taking this approach, you should probably unset LANG/LC_* or whatever affects
the output language, because otherwise on a german system this will fail because
the message is 'Kein Medium gefunden'. (Not sure whether the language settings
are active during execution of boot-scripts per default, but someone might have
done so individually.)

------- Comment #7 From Heiko Baums 2005-12-09 14:33:14 0000 -------
This version works at least for me: 
 
-  if [ -b $device ] && ( : <$device ) 2>/dev/null 
+ errmsg=$(: <$device 2>&1) 
+ if [[ -b $device ]] && [[ $? == 0 || $(errmsg) == "*: No medium found" ]] 
 
The language should not be a problem, at least for now, because also with 
LC_MESSAGES=de_DE `: <$device 2` gives the English error message. 
 
There's only one defective appearance. 
If there's no medium in the drive the line "errmsg=$(: <$device 2>&1)" prints 
the error message "/etc/init.d/hdparm: line 125: /dev/hdc: No medium found" on 
the screen. The hdparm settings are done for this drive anyhow. 

------- Comment #8 From Heiko Baums 2005-12-09 14:35:49 0000 -------
Forgot to say that line 125 in the error message could also be 124 because I 
didn't delete the original line in my script but just commented it out. ;-) 

------- Comment #9 From Heiko Baums 2005-12-11 16:33:17 0000 -------
Now I found the solution without having the error message printed on the 
screen: 
 
- if [ -b $device ] && ( : <$device ) 2>/dev/null 
+ errmsg=$( : 2>/dev/null <$device ) 
+ if [[ -b $device ]] && [[ $? == 0 || $(errmsg) == "*: No medium found" ]] 
 
This works as long as the dummy command : only gives English error messages 
regardless of the LC_MESSAGES value. 

------- Comment #10 From SpanKY 2005-12-28 12:49:26 0000 -------
thanks Heiko and Stefan for actual testing / feedback ... should be fixed with
hdparm-6.3 now

------- Comment #11 From SpanKY 2006-02-14 08:05:34 0000 -------
*** Bug 69284 has been marked as a duplicate of this bug. ***

------- Comment #12 From Matthias Foerste 2006-03-09 06:42:22 0000 -------
latest fix causes annoying error messages and red question marks for me when it
tries to run hdparm on nonexistant devices (/dev/hdd - /dev/hdh) while booting. 

this applied to the current init script works for me:

-                       local errmsg=$( : 2>/dev/null <$device )
-                       if [[ -b $device ]] && [[ $? == 0 || $(errmsg) == "*:
No medium found" ]]
+                       local errmsg status
+                       errmsg=$( : 2>&1 <$device )
+                       status=$?
+                       if [[ -b $device ]] && [[ ${status} == 0 ||
${errmsg:$((-25))} == "${device}: No medium found" ]]

i noticed because i remerged hdparm (5.9) some days ago. maybe the test should
be removed entirely as already suggested here and in another bugreport.

------- Comment #13 From Matthias Foerste 2006-03-09 06:48:09 0000 -------
Created an attachment (id=81767) [details]
patch

linebreak issues in previous comment

------- Comment #14 From SpanKY 2006-03-09 16:59:03 0000 -------
> latest fix causes annoying error messages and red question marks for me when it
> tries to run hdparm on nonexistant devices (/dev/hdd - /dev/hdh) while booting. 

file a new bug in the future

> maybe the test should be removed entirely as already suggested here and in
> another bugreport.

no

applied your fixes to current init.d script

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug