aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-03-20 13:44:50 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-03-20 13:44:50 +0000
commit3c96d0258c4f3321a8fef850587f55ff56032860 (patch)
tree6a16ebb4d5395b05b2dc213f804e9148f408bf14
parent0f3a580c4fec98bd4612dce4d77a9ac53a669fd3 (diff)
downloadbusybox-w32-3c96d0258c4f3321a8fef850587f55ff56032860.tar.gz
busybox-w32-3c96d0258c4f3321a8fef850587f55ff56032860.tar.bz2
busybox-w32-3c96d0258c4f3321a8fef850587f55ff56032860.zip
hdparm: do not lie about supporting -q (quiet)
hdparm: interpret_standby() shrink hdparm: make HDIO_GET/SET_QDMA #ifdef more complete (by Joe Krahn <krahn AT niehs.nih.gov>) function old new delta packed_usage 23798 23776 -22 process_dev 5342 5315 -27
-rw-r--r--include/usage.h2
-rw-r--r--miscutils/hdparm.c46
2 files changed, 26 insertions, 22 deletions
diff --git a/include/usage.h b/include/usage.h
index ad9009763..aa1b8b6da 100644
--- a/include/usage.h
+++ b/include/usage.h
@@ -1415,7 +1415,7 @@
1415 "\n -n Get/set ignore-write-errors flag (0/1)" \ 1415 "\n -n Get/set ignore-write-errors flag (0/1)" \
1416 "\n -p Set PIO mode on IDE interface chipset (0,1,2,3,4,...)" \ 1416 "\n -p Set PIO mode on IDE interface chipset (0,1,2,3,4,...)" \
1417 "\n -P Set drive prefetch count" \ 1417 "\n -P Set drive prefetch count" \
1418 "\n -q Change next setting quietly" \ 1418/* "\n -q Change next setting quietly" - not supported ib bbox */ \
1419 "\n -Q Get/set DMA tagged-queuing depth (if supported)" \ 1419 "\n -Q Get/set DMA tagged-queuing depth (if supported)" \
1420 "\n -r Get/set readonly flag (DANGEROUS to set)" \ 1420 "\n -r Get/set readonly flag (DANGEROUS to set)" \
1421 USE_FEATURE_HDPARM_HDIO_SCAN_HWIF( \ 1421 USE_FEATURE_HDPARM_HDIO_SCAN_HWIF( \
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c
index 0aaff45f2..ec5ede691 100644
--- a/miscutils/hdparm.c
+++ b/miscutils/hdparm.c
@@ -245,7 +245,12 @@ struct globals {
245 smallint set_readonly, get_readonly; 245 smallint set_readonly, get_readonly;
246 smallint set_unmask, get_unmask; 246 smallint set_unmask, get_unmask;
247 smallint set_mult, get_mult; 247 smallint set_mult, get_mult;
248 smallint set_dma_q, get_dma_q; 248#ifdef HDIO_GET_QDMA
249 smallint get_dma_q;
250#ifdef HDIO_SET_QDMA
251 smallint set_dma_q;
252#endif
253#endif
249 smallint set_nowerr, get_nowerr; 254 smallint set_nowerr, get_nowerr;
250 smallint set_keep, get_keep; 255 smallint set_keep, get_keep;
251 smallint set_io32bit, get_io32bit; 256 smallint set_io32bit, get_io32bit;
@@ -254,7 +259,9 @@ struct globals {
254 unsigned long readonly; 259 unsigned long readonly;
255 unsigned long unmask; 260 unsigned long unmask;
256 unsigned long mult; 261 unsigned long mult;
262#ifdef HDIO_SET_QDMA
257 unsigned long dma_q; 263 unsigned long dma_q;
264#endif
258 unsigned long nowerr; 265 unsigned long nowerr;
259 unsigned long keep; 266 unsigned long keep;
260 unsigned long io32bit; 267 unsigned long io32bit;
@@ -278,7 +285,7 @@ struct globals {
278 smallint set_apmmode, get_apmmode; 285 smallint set_apmmode, get_apmmode;
279 int xfermode_requested; 286 int xfermode_requested;
280 unsigned long dkeep; 287 unsigned long dkeep;
281 unsigned long standby_requested; 288 unsigned long standby_requested; /* 0..255 */
282 unsigned long lookahead; 289 unsigned long lookahead;
283 unsigned long prefetch; 290 unsigned long prefetch;
284 unsigned long defects; 291 unsigned long defects;
@@ -1444,29 +1451,22 @@ static void bus_state_value(unsigned value)
1444#endif 1451#endif
1445 1452
1446#ifdef HDIO_DRIVE_CMD 1453#ifdef HDIO_DRIVE_CMD
1447static void interpret_standby(unsigned standby) 1454static void interpret_standby(uint8_t standby)
1448{ 1455{
1449 unsigned t;
1450
1451 printf(" ("); 1456 printf(" (");
1452 if (standby == 0) 1457 if (standby == 0) {
1453 printf("off"); 1458 printf("off");
1454 else if (standby == 252) 1459 } else if (standby <= 240 || standby == 252 || standby == 255) {
1455 printf("21 minutes"); 1460 /* standby is in 5 sec units */
1456 else if (standby == 253) 1461 printf("%u minutes %u seconds", standby / 12, (standby*5) % 60);
1462 } else if (standby <= 251) {
1463 unsigned t = (standby - 240); /* t is in 30 min units */;
1464 printf("%u.%c hours", t / 2, (t & 1) ? '0' : '5');
1465 }
1466 if (standby == 253)
1457 printf("vendor-specific"); 1467 printf("vendor-specific");
1458 else if (standby == 254) 1468 if (standby == 254)
1459 printf("reserved"); 1469 printf("reserved");
1460 else if (standby == 255)
1461 printf("21 minutes + 15 seconds");
1462 else if (standby <= 240) {
1463 t = standby * 5;
1464 printf("%u minutes + %u seconds", t / 60, t % 60);
1465 } else if (standby <= 251) {
1466 t = (standby - 240) * 30;
1467 printf("%u hours + %u minutes", t / 60, t % 60);
1468 } else
1469 printf("illegal value");
1470 printf(")\n"); 1470 printf(")\n");
1471} 1471}
1472 1472
@@ -1604,10 +1604,12 @@ static void process_dev(char *devname)
1604 ioctl_or_warn(fd, HDIO_SET_DMA, (int *)dma); 1604 ioctl_or_warn(fd, HDIO_SET_DMA, (int *)dma);
1605 } 1605 }
1606#endif /* FEATURE_HDPARM_HDIO_GETSET_DMA */ 1606#endif /* FEATURE_HDPARM_HDIO_GETSET_DMA */
1607#ifdef HDIO_SET_QDMA
1607 if (set_dma_q) { 1608 if (set_dma_q) {
1608 print_flag_on_off(get_dma_q, "DMA queue_depth", dma_q); 1609 print_flag_on_off(get_dma_q, "DMA queue_depth", dma_q);
1609 ioctl_or_warn(fd, HDIO_SET_QDMA, (int *)dma_q); 1610 ioctl_or_warn(fd, HDIO_SET_QDMA, (int *)dma_q);
1610 } 1611 }
1612#endif
1611 if (set_nowerr) { 1613 if (set_nowerr) {
1612 print_flag_on_off(get_nowerr, "nowerr", nowerr); 1614 print_flag_on_off(get_nowerr, "nowerr", nowerr);
1613 ioctl_or_warn(fd, HDIO_SET_NOWERR, (int *)nowerr); 1615 ioctl_or_warn(fd, HDIO_SET_NOWERR, (int *)nowerr);
@@ -1780,10 +1782,12 @@ static void process_dev(char *devname)
1780 } 1782 }
1781 } 1783 }
1782#endif 1784#endif
1785#ifdef HDIO_GET_QDMA
1783 if (get_dma_q) { 1786 if (get_dma_q) {
1784 if(!ioctl_or_warn(fd, HDIO_GET_QDMA, &parm)) 1787 if(!ioctl_or_warn(fd, HDIO_GET_QDMA, &parm))
1785 print_value_on_off("queue_depth", parm); 1788 print_value_on_off("queue_depth", parm);
1786 } 1789 }
1790#endif
1787 if (get_keep) { 1791 if (get_keep) {
1788 if(!ioctl_or_warn(fd, HDIO_GET_KEEPSETTINGS, &parm)) 1792 if(!ioctl_or_warn(fd, HDIO_GET_KEEPSETTINGS, &parm))
1789 print_value_on_off("keepsettings", parm); 1793 print_value_on_off("keepsettings", parm);
@@ -2007,7 +2011,7 @@ int hdparm_main(int argc, char **argv)
2007 do_flush |= do_timings |= (c == 't'); 2011 do_flush |= do_timings |= (c == 't');
2008 do_flush |= do_ctimings |= (c == 'T'); 2012 do_flush |= do_ctimings |= (c == 'T');
2009#ifdef HDIO_DRIVE_CMD 2013#ifdef HDIO_DRIVE_CMD
2010 if (c == 'S') parse_opts(&get_standby, &set_standby, &standby_requested, 0, INT_MAX); 2014 if (c == 'S') parse_opts(&get_standby, &set_standby, &standby_requested, 0, 255);
2011 if (c == 'D') parse_opts(&get_defects, &set_defects, &defects, 0, INT_MAX); 2015 if (c == 'D') parse_opts(&get_defects, &set_defects, &defects, 0, INT_MAX);
2012 if (c == 'P') parse_opts(&get_prefetch, &set_prefetch, &prefetch, 0, INT_MAX); 2016 if (c == 'P') parse_opts(&get_prefetch, &set_prefetch, &prefetch, 0, INT_MAX);
2013 parse_xfermode((c == 'X'), &get_xfermode, &set_xfermode, &xfermode_requested); 2017 parse_xfermode((c == 'X'), &get_xfermode, &set_xfermode, &xfermode_requested);