aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2006-05-05 16:52:28 +0000
committerRob Landley <rob@landley.net>2006-05-05 16:52:28 +0000
commit39cf645ce0773e8fc5babb69550d8815064c76f8 (patch)
tree27305ed71e7341e91940d6f615bf2c7360951d4e
parent2381f702c9b0cc02f136b08b24069e8bb4382407 (diff)
downloadbusybox-w32-39cf645ce0773e8fc5babb69550d8815064c76f8.tar.gz
busybox-w32-39cf645ce0773e8fc5babb69550d8815064c76f8.tar.bz2
busybox-w32-39cf645ce0773e8fc5babb69550d8815064c76f8.zip
Patch from Dennis Vlasenko resetting values that get reused.
-rw-r--r--miscutils/hdparm.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c
index f237d32f5..f473add90 100644
--- a/miscutils/hdparm.c
+++ b/miscutils/hdparm.c
@@ -1325,11 +1325,8 @@ static void dump_identity(const struct hd_driveid *id)
1325 1325
1326 } 1326 }
1327 if_printf((!(id->field_valid&1))," (maybe):"); 1327 if_printf((!(id->field_valid&1))," (maybe):");
1328#if __BYTE_ORDER == __BIG_ENDIAN 1328 if (BB_BIG_ENDIAN) capacity = (id->cur_capacity0 << 16) | id->cur_capacity1;
1329 capacity = (id->cur_capacity0 << 16) | id->cur_capacity1; 1329 else capacity = (id->cur_capacity1 << 16) | id->cur_capacity0;
1330#else
1331 capacity = (id->cur_capacity1 << 16) | id->cur_capacity0;
1332#endif
1333 printf(" CurCHS=%u/%u/%u, CurSects=%lu, LBA=%s",id->cur_cyls, id->cur_heads, 1330 printf(" CurCHS=%u/%u/%u, CurSects=%lu, LBA=%s",id->cur_cyls, id->cur_heads,
1334 id->cur_sectors, capacity , 1331 id->cur_sectors, capacity ,
1335 ((id->capability&2)==0)?"no":"yes"); 1332 ((id->capability&2)==0)?"no":"yes");
@@ -1827,6 +1824,8 @@ static void process_dev(char *devname)
1827#ifndef HDIO_DRIVE_CMD 1824#ifndef HDIO_DRIVE_CMD
1828 int force_operation = 0; 1825 int force_operation = 0;
1829#endif 1826#endif
1827 /* Please restore args[n] to these values after each ioctl
1828 except for args[2] */
1830 unsigned char args[4] = {WIN_SETFEATURES,0,0,0}; 1829 unsigned char args[4] = {WIN_SETFEATURES,0,0,0};
1831 1830
1832 fd = bb_xopen(devname, O_RDONLY|O_NONBLOCK); 1831 fd = bb_xopen(devname, O_RDONLY|O_NONBLOCK);
@@ -1852,6 +1851,8 @@ static void process_dev(char *devname)
1852 args[1] = hwif_ctrl; 1851 args[1] = hwif_ctrl;
1853 args[2] = hwif_irq; 1852 args[2] = hwif_irq;
1854 bb_ioctl(fd, HDIO_SCAN_HWIF, args, "HDIO_SCAN_HWIF"); 1853 bb_ioctl(fd, HDIO_SCAN_HWIF, args, "HDIO_SCAN_HWIF");
1854 args[0] = WIN_SETFEATURES;
1855 args[1] = 0;
1855 } 1856 }
1856#endif 1857#endif
1857 if (set_piomode) 1858 if (set_piomode)
@@ -1921,8 +1922,10 @@ static void process_dev(char *devname)
1921 if (set_doorlock) 1922 if (set_doorlock)
1922 { 1923 {
1923 args[0] = doorlock ? WIN_DOORLOCK : WIN_DOORUNLOCK; 1924 args[0] = doorlock ? WIN_DOORLOCK : WIN_DOORUNLOCK;
1925 args[2] = 0;
1924 if_printf_on_off(get_doorlock," setting drive doorlock to %ld", doorlock); 1926 if_printf_on_off(get_doorlock," setting drive doorlock to %ld", doorlock);
1925 bb_ioctl(fd, HDIO_DRIVE_CMD, &args,"HDIO_DRIVE_CMD(doorlock)"); 1927 bb_ioctl(fd, HDIO_DRIVE_CMD, &args,"HDIO_DRIVE_CMD(doorlock)");
1928 args[0] = WIN_SETFEATURES;
1926 } 1929 }
1927 if (set_dkeep) 1930 if (set_dkeep)
1928 { 1931 {
@@ -1943,6 +1946,7 @@ static void process_dev(char *devname)
1943 args[2] = 0xab; 1946 args[2] = 0xab;
1944 if_printf(get_prefetch," setting drive prefetch to %ld\n", prefetch); 1947 if_printf(get_prefetch," setting drive prefetch to %ld\n", prefetch);
1945 bb_ioctl(fd, HDIO_DRIVE_CMD, &args, "HDIO_DRIVE_CMD(setprefetch)"); 1948 bb_ioctl(fd, HDIO_DRIVE_CMD, &args, "HDIO_DRIVE_CMD(setprefetch)");
1949 args[1] = 0;
1946 } 1950 }
1947 if (set_xfermode) 1951 if (set_xfermode)
1948 { 1952 {
@@ -1954,6 +1958,7 @@ static void process_dev(char *devname)
1954 interpret_xfermode(xfermode_requested); 1958 interpret_xfermode(xfermode_requested);
1955 } 1959 }
1956 bb_ioctl(fd, HDIO_DRIVE_CMD, &args,"HDIO_DRIVE_CMD(setxfermode)"); 1960 bb_ioctl(fd, HDIO_DRIVE_CMD, &args,"HDIO_DRIVE_CMD(setxfermode)");
1961 args[1] = 0;
1957 } 1962 }
1958 if (set_lookahead) 1963 if (set_lookahead)
1959 { 1964 {
@@ -1980,6 +1985,7 @@ static void process_dev(char *devname)
1980 if_printf(get_apmmode," 0x%02lX (%ld)\n",apmmode,apmmode); 1985 if_printf(get_apmmode," 0x%02lX (%ld)\n",apmmode,apmmode);
1981 } 1986 }
1982 bb_ioctl(fd, HDIO_DRIVE_CMD, &args,"HDIO_DRIVE_CMD"); 1987 bb_ioctl(fd, HDIO_DRIVE_CMD, &args,"HDIO_DRIVE_CMD");
1988 args[1] = 0;
1983 } 1989 }
1984 if (set_wcache) 1990 if (set_wcache)
1985 { 1991 {
@@ -2001,6 +2007,11 @@ static void process_dev(char *devname)
2001 bb_ioctl(fd, HDIO_DRIVE_CMD, &flushcache, "HDIO_DRIVE_CMD(flushcache)"); 2007 bb_ioctl(fd, HDIO_DRIVE_CMD, &flushcache, "HDIO_DRIVE_CMD(flushcache)");
2002#endif /* DO_FLUSHCACHE */ 2008#endif /* DO_FLUSHCACHE */
2003 } 2009 }
2010
2011 /* In code below, we do not preserve args[0], but the rest
2012 is preserved, including args[2] */
2013 args[2] = 0;
2014
2004 if (set_standbynow) 2015 if (set_standbynow)
2005 { 2016 {
2006#ifndef WIN_STANDBYNOW1 2017#ifndef WIN_STANDBYNOW1
@@ -2041,6 +2052,7 @@ static void process_dev(char *devname)
2041 interpret_standby(standby_requested); 2052 interpret_standby(standby_requested);
2042 } 2053 }
2043 bb_ioctl(fd, HDIO_DRIVE_CMD, &args, "HDIO_DRIVE_CMD(setidle1)"); 2054 bb_ioctl(fd, HDIO_DRIVE_CMD, &args, "HDIO_DRIVE_CMD(setidle1)");
2055 args[1] = 0;
2044 } 2056 }
2045#else /* HDIO_DRIVE_CMD */ 2057#else /* HDIO_DRIVE_CMD */
2046 if (force_operation) 2058 if (force_operation)
@@ -2173,6 +2185,7 @@ static void process_dev(char *devname)
2173 } 2185 }
2174 else 2186 else
2175 state = (args[2] == 255) ? "active/idle" : "standby"; 2187 state = (args[2] == 255) ? "active/idle" : "standby";
2188 args[1] = args[2] = 0;
2176 2189
2177 printf(" drive state is: %s\n", state); 2190 printf(" drive state is: %s\n", state);
2178 } 2191 }