Summary: | Hdparm does not set CD/DVD drive parameters if disc not inserted | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Antti Mäkelä <zarhan> |
Component: | New packages | Assignee: | Gentoo's Team for Core System packages <base-system> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | alonbl, flash3001, heiko.baums, lanius, matthias.foerste, meff, paolo.pedroni, stillner, wiebe |
Priority: | High | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Attachments: | patch |
Description
Antti Mäkelä
2005-09-03 02:17:20 UTC
Yes, I experience the same problem. udev-068 and hdparm-5.9 *** Bug 105018 has been marked as a duplicate of this bug. *** This is still a problem, any fix anytime soon? 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 ]] 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... (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.) 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. 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. ;-) 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. thanks Heiko and Stefan for actual testing / feedback ... should be fixed with hdparm-6.3 now *** Bug 69284 has been marked as a duplicate of this bug. *** 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. Created attachment 81767 [details, diff]
patch
linebreak issues in previous comment
> 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 |