<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://bugs.gentoo.org/bugzilla.dtd">

<bugzilla version="2.22.7"
          urlbase="http://bugs.gentoo.org/"
          maintainer="bugzilla@gentoo.org"
>

    <bug>
          <bug_id>104683</bug_id>
          
          <creation_ts>2005-09-03 02:17 0000</creation_ts>
          <short_desc>Hdparm does not set CD/DVD drive parameters if disc not inserted</short_desc>
          <delta_ts>2006-03-09 16:59:03 0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Gentoo Linux</product>
          <component>Ebuilds</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>zarhan@iki.fi</reporter>
          <assigned_to>base-system@gentoo.org</assigned_to>
          <cc>alonbl@gentoo.org</cc>
    
    <cc>flash3001@yahoo.com</cc>
    
    <cc>halfgaar@gmx.net</cc>
    
    <cc>heiko@baums-on-web.de</cc>
    
    <cc>lanius@gentoo.org</cc>
    
    <cc>matthias.foerste@freenet.de</cc>
    
    <cc>meff@pobox.com</cc>
    
    <cc>paolo.pedroni@iol.it</cc>
    
    <cc>stillner@gmx.de</cc>

      

      
          <long_desc isprivate="0">
            <who>zarhan@iki.fi</who>
            <bug_when>2005-09-03 02:17:20 0000</bug_when>
            <thetext>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 ] &amp;&amp; ( : &lt;$device ) 2&gt;/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, &quot;cat&quot; 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.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>joe.roback@gmail.com</who>
            <bug_when>2005-09-06 03:35:28 0000</bug_when>
            <thetext>Yes, I experience the same problem. udev-068 and hdparm-5.9 </thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>jakub@gentoo.org</who>
            <bug_when>2005-09-06 07:26:59 0000</bug_when>
            <thetext>*** Bug 105018 has been marked as a duplicate of this bug. ***</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>meff@pobox.com</who>
            <bug_when>2005-10-27 23:08:31 0000</bug_when>
            <thetext>This is still a problem, any fix anytime soon?</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>vapier@gentoo.org</who>
            <bug_when>2005-10-28 16:28:21 0000</bug_when>
            <thetext>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 ] &amp;&amp; ( : &lt;$device ) 2&gt;/dev/null
+  errmsg=$(head -c 1 $device 2&gt;&amp;1)
+  if [[ -b $device ]] &amp;&amp; [[ $? == 0 || ${errmsg} == *: No medium found ]]</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>meff@pobox.com</who>
            <bug_when>2005-10-28 16:39:58 0000</bug_when>
            <thetext>I wasn&apos;t complaining, just wondering.. Your insulting reply wasn&apos;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 &quot;heads up&quot;.. Nice to see one of my first posts here was replied to like
this...</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>stillner@gmx.de</who>
            <bug_when>2005-10-31 01:26:20 0000</bug_when>
            <thetext>(In reply to comment #4)

&gt; how does this work for people:
&gt; -  if [ -b $device ] &amp;&amp; ( : &lt;$device ) 2&gt;/dev/null
&gt; +  errmsg=$(head -c 1 $device 2&gt;&amp;1)
&gt; +  if [[ -b $device ]] &amp;&amp; [[ $? == 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 &apos;Kein Medium gefunden&apos;. (Not sure whether the language settings
are active during execution of boot-scripts per default, but someone might have
done so individually.)</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>heiko@baums-on-web.de</who>
            <bug_when>2005-12-09 14:33:14 0000</bug_when>
            <thetext>This version works at least for me: 
 
-  if [ -b $device ] &amp;&amp; ( : &lt;$device ) 2&gt;/dev/null 
+ errmsg=$(: &lt;$device 2&gt;&amp;1) 
+ if [[ -b $device ]] &amp;&amp; [[ $? == 0 || $(errmsg) == &quot;*: No medium found&quot; ]] 
 
The language should not be a problem, at least for now, because also with 
LC_MESSAGES=de_DE `: &lt;$device 2` gives the English error message. 
 
There&apos;s only one defective appearance. 
If there&apos;s no medium in the drive the line &quot;errmsg=$(: &lt;$device 2&gt;&amp;1)&quot; prints 
the error message &quot;/etc/init.d/hdparm: line 125: /dev/hdc: No medium found&quot; on 
the screen. The hdparm settings are done for this drive anyhow. </thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>heiko@baums-on-web.de</who>
            <bug_when>2005-12-09 14:35:49 0000</bug_when>
            <thetext>Forgot to say that line 125 in the error message could also be 124 because I 
didn&apos;t delete the original line in my script but just commented it out. ;-) </thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>heiko@baums-on-web.de</who>
            <bug_when>2005-12-11 16:33:17 0000</bug_when>
            <thetext>Now I found the solution without having the error message printed on the 
screen: 
 
- if [ -b $device ] &amp;&amp; ( : &lt;$device ) 2&gt;/dev/null 
+ errmsg=$( : 2&gt;/dev/null &lt;$device ) 
+ if [[ -b $device ]] &amp;&amp; [[ $? == 0 || $(errmsg) == &quot;*: No medium found&quot; ]] 
 
This works as long as the dummy command : only gives English error messages 
regardless of the LC_MESSAGES value. </thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>vapier@gentoo.org</who>
            <bug_when>2005-12-28 12:49:26 0000</bug_when>
            <thetext>thanks Heiko and Stefan for actual testing / feedback ... should be fixed with hdparm-6.3 now</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>vapier@gentoo.org</who>
            <bug_when>2006-02-14 08:05:34 0000</bug_when>
            <thetext>*** Bug 69284 has been marked as a duplicate of this bug. ***</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>matthias.foerste@freenet.de</who>
            <bug_when>2006-03-09 06:42:22 0000</bug_when>
            <thetext>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&gt;/dev/null &lt;$device )
-			if [[ -b $device ]] &amp;&amp; [[ $? == 0 || $(errmsg) == &quot;*: No medium found&quot; ]]
+			local errmsg status
+			errmsg=$( : 2&gt;&amp;1 &lt;$device )
+			status=$?
+			if [[ -b $device ]] &amp;&amp; [[ ${status} == 0 || ${errmsg:$((-25))} == &quot;${device}: No medium found&quot; ]]

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.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>matthias.foerste@freenet.de</who>
            <bug_when>2006-03-09 06:48:09 0000</bug_when>
            <thetext>Created an attachment (id=81767)
patch

linebreak issues in previous comment</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>vapier@gentoo.org</who>
            <bug_when>2006-03-09 16:59:03 0000</bug_when>
            <thetext>&gt; latest fix causes annoying error messages and red question marks for me when it
&gt; tries to run hdparm on nonexistant devices (/dev/hdd - /dev/hdh) while booting. 

file a new bug in the future

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

no

applied your fixes to current init.d script</thetext>
          </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>81767</attachid>
            <date>2006-03-09 06:48 0000</date>
            <desc>patch</desc>
            <filename>hdparm-init-7.diff</filename>
            <type>text/plain</type>
            <data encoding="base64">LS0tIC91c3IvcG9ydGFnZS9zeXMtYXBwcy9oZHBhcm0vZmlsZXMvaGRwYXJtLWluaXQtNwkyMDA2
LTAyLTIyIDAxOjM2OjQ3LjAwMDAwMDAwMCArMDEwMAorKysgL2V0Yy9pbml0LmQvaGRwYXJtCTIw
MDYtMDMtMDkgMTM6NTg6NTAuMDAwMDAwMDAwICswMTAwCkBAIC0xMTYsOCArMTE2LDEwIEBACiAJ
CWRvCiAJCQkjIGNoZWNrIHRoYXQgdGhlIGJsb2NrIGRldmljZSByZWFsbHkgZXhpc3RzCiAJCQkj
IGJ5IG9wZW5pbmcgaXQgZm9yIHJlYWRpbmcKLQkJCWxvY2FsIGVycm1zZz0kKCA6IDI+L2Rldi9u
dWxsIDwkZGV2aWNlICkKLQkJCWlmIFtbIC1iICRkZXZpY2UgXV0gJiYgW1sgJD8gPT0gMCB8fCAk
KGVycm1zZykgPT0gIio6IE5vIG1lZGl1bSBmb3VuZCIgXV0KKwkJCWxvY2FsIGVycm1zZyBzdGF0
dXMKKwkJCWVycm1zZz0kKCA6IDI+JjEgPCRkZXZpY2UgKQorCQkJc3RhdHVzPSQ/CisJCQlpZiBb
WyAtYiAkZGV2aWNlIF1dICYmIFtbICR7c3RhdHVzfSA9PSAwIHx8ICR7ZXJybXNnOiQoKC0yNSkp
fSA9PSAiJHtkZXZpY2V9OiBObyBtZWRpdW0gZm91bmQiIF1dCiAJCQl0aGVuCiAJCQkJZXZhbCBh
cmdzPVwke2BiYXNlbmFtZSAkZGV2aWNlYF9hcmdzfQogCQkJCWRvX2hkcGFybQo=
</data>        

          </attachment>
    </bug>

</bugzilla>