Package: hdparm
Version: 7.7-1
Severity: wishlist
Tags: patch

Hi,

the following patch for /etc/init.d/hdparm adds support for easier
entering of spindown times. You can use the suffixes s, m and h to define
the spindown time.

--- /etc/init.d/hdparm  2006-10-31 12:00:20.000000000 +0100
+++ /tmp/hdparm 2008-01-26 22:37:43.542443636 +0100
@@ -221,6 +221,47 @@
               eval_value $VALUE -r
               ;;
             spindown_time) 
+              case "$VALUE" in
+                *[hms])
+                  case "$VALUE" in
+                    *h)
+                    time=$((${VALUE%h} * 3600))
+                    ;;
+                    *m)
+                    time=$((${VALUE%m} * 60))
+                    ;;
+                    *s)
+                    time=${VALUE%s}
+                    ;;
+                  esac
+                  if [ $time -lt 1260 ]; then # up to 21 minutes
+                      new_VALUE=$(($time / 5))
+                      if [ $new_VALUE -gt 240 ]; then
+                          new_VALUE=240
+                      fi
+                      if [ $(($new_VALUE * 5)) -ne $time ]; then
+                          log_warning_msg $VALUE not possible, \
+                            using $(($new_VALUE * 5)) seconds
+                      fi
+                      VALUE=$new_VALUE
+                  elif [ $time -lt 1800 ]; then
+                      if [ $time -ne 1260 ]; then
+                          log_warning_msg $VALUE not possible, using 21 minutes
+                      fi
+                      VALUE=252
+                  else
+                      new_time=$(($time / 1800))
+                      if [ $new_time -gt 11 ]; then
+                          new_time=11
+                      fi
+                      if [ $((new_time * 1800)) -ne $time ]; then
+                          log_warning_msg $VALUE not possible, \
+                            using $(($new_time * 30)) minutes
+                      fi
+                      VALUE=$((new_time + 240))
+                  fi
+                  ;;
+              esac
               set_option -S$VALUE
               ;;
             poweron_standby) 

This is a snippet for hdparm.conf

# -S standby (spindown) timeout for the drive
#  you can use the suffix' s for seconds, m for minutes and h for hours
#spindown_time = 2m

Bye, Jörg.

-- System Information:
Debian Release: unstable/experimental
  APT prefers unstable
  APT policy: (900, 'unstable'), (700, 'experimental')
Architecture: powerpc (ppc)

Kernel: Linux 2.6.24-rc6
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages hdparm depends on:
ii  libc6                         2.7-6      GNU C Library: Shared libraries
ii  lsb-base                      3.1-24     Linux Standard Base 3.1 init scrip

hdparm recommends no packages.

-- no debconf information

Attachment: signature.asc
Description: Digital signature

Reply via email to