diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 8f3729f71..7b3f27c36 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c @@ -633,15 +633,14 @@ static int busybox_main(char **argv) if (!argv[1]) { /* Called without arguments */ const char *a; - unsigned col, output_width; + int col; + unsigned output_width; help: output_width = 80; if (ENABLE_FEATURE_AUTOWIDTH) { /* Obtain the terminal width */ get_terminal_width_height(0, &output_width, NULL); } - /* leading tab and room to wrap */ - output_width -= MAX_APPLET_NAME_LEN + 8; dup2(1, 2); full_write2_str(bb_banner); /* reuse const string... */ @@ -661,17 +660,23 @@ static int busybox_main(char **argv) "Currently defined functions:\n"); col = 0; a = applet_names; + /* prevent last comma to be in the very last pos */ + output_width--; while (*a) { - int len; - if (col > output_width) { + int len2 = strlen(a) + 2; + if (col >= (int)output_width - len2) { full_write2_str(",\n"); col = 0; } - full_write2_str(col ? ", " : "\t"); + if (col == 0) { + col = 6; + full_write2_str("\t"); + } else { + full_write2_str(", "); + } full_write2_str(a); - len = strlen(a); - col += len + 2; - a += len + 1; + col += len2; + a += len2 - 1; } full_write2_str("\n\n"); return 0; diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c index f9638887a..7034778e7 100644 --- a/miscutils/hdparm.c +++ b/miscutils/hdparm.c @@ -11,7 +11,6 @@ * hdparm.c - Command line interface to get/set hard disk parameters * - by Mark Lord (C) 1994-2002 -- freely distributable */ - #include "libbb.h" #include @@ -232,6 +231,10 @@ #undef DO_FLUSHCACHE /* under construction: force cache flush on -W0 */ +#define IS_GET 1 +#define IS_SET 2 + + enum { fd = 3 }; @@ -241,19 +244,16 @@ struct globals { smallint do_ctimings, do_timings; smallint reread_partn; smallint set_piomode, noisy_piomode; - smallint set_readahead, get_readahead; - smallint set_readonly, get_readonly; - smallint set_unmask, get_unmask; - smallint set_mult, get_mult; + smallint getset_readahead; + smallint getset_readonly; + smallint getset_unmask; + smallint getset_mult; #ifdef HDIO_GET_QDMA - smallint get_dma_q; -#ifdef HDIO_SET_QDMA - smallint set_dma_q; + smallint getset_dma_q; #endif -#endif - smallint set_nowerr, get_nowerr; - smallint set_keep, get_keep; - smallint set_io32bit, get_io32bit; + smallint getset_nowerr; + smallint getset_keep; + smallint getset_io32bit; int piomode; unsigned long Xreadahead; unsigned long readonly; @@ -267,22 +267,22 @@ struct globals { unsigned long io32bit; #if ENABLE_FEATURE_HDPARM_HDIO_GETSET_DMA unsigned long dma; - smallint set_dma, get_dma; + smallint getset_dma; #endif #ifdef HDIO_DRIVE_CMD smallint set_xfermode, get_xfermode; - smallint set_dkeep, get_dkeep; - smallint set_standby, get_standby; - smallint set_lookahead, get_lookahead; - smallint set_prefetch, get_prefetch; - smallint set_defects, get_defects; - smallint set_wcache, get_wcache; - smallint set_doorlock, get_doorlock; - smallint set_seagate, get_seagate; - smallint set_standbynow, get_standbynow; - smallint set_sleepnow, get_sleepnow; + smallint getset_dkeep; + smallint getset_standby; + smallint getset_lookahead; + smallint getset_prefetch; + smallint getset_defects; + smallint getset_wcache; + smallint getset_doorlock; + smallint set_seagate; + smallint set_standbynow; + smallint set_sleepnow; smallint get_powermode; - smallint set_apmmode, get_apmmode; + smallint getset_apmmode; int xfermode_requested; unsigned long dkeep; unsigned long standby_requested; /* 0..255 */ @@ -294,7 +294,7 @@ struct globals { unsigned long apmmode; #endif IF_FEATURE_HDPARM_GET_IDENTITY( smallint get_IDentity;) - IF_FEATURE_HDPARM_HDIO_TRISTATE_HWIF( smallint set_busstate, get_busstate;) + IF_FEATURE_HDPARM_HDIO_TRISTATE_HWIF( smallint getset_busstate;) IF_FEATURE_HDPARM_HDIO_DRIVE_RESET( smallint perform_reset;) IF_FEATURE_HDPARM_HDIO_TRISTATE_HWIF( smallint perform_tristate;) IF_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF(smallint unregister_hwif;) @@ -323,22 +323,14 @@ struct BUG_G_too_big { #define reread_partn (G.reread_partn ) #define set_piomode (G.set_piomode ) #define noisy_piomode (G.noisy_piomode ) -#define set_readahead (G.set_readahead ) -#define get_readahead (G.get_readahead ) -#define set_readonly (G.set_readonly ) -#define get_readonly (G.get_readonly ) -#define set_unmask (G.set_unmask ) -#define get_unmask (G.get_unmask ) -#define set_mult (G.set_mult ) -#define get_mult (G.get_mult ) -#define set_dma_q (G.set_dma_q ) -#define get_dma_q (G.get_dma_q ) -#define set_nowerr (G.set_nowerr ) -#define get_nowerr (G.get_nowerr ) -#define set_keep (G.set_keep ) -#define get_keep (G.get_keep ) -#define set_io32bit (G.set_io32bit ) -#define get_io32bit (G.get_io32bit ) +#define getset_readahead (G.getset_readahead ) +#define getset_readonly (G.getset_readonly ) +#define getset_unmask (G.getset_unmask ) +#define getset_mult (G.getset_mult ) +#define getset_dma_q (G.getset_dma_q ) +#define getset_nowerr (G.getset_nowerr ) +#define getset_keep (G.getset_keep ) +#define getset_io32bit (G.getset_io32bit ) #define piomode (G.piomode ) #define Xreadahead (G.Xreadahead ) #define readonly (G.readonly ) @@ -349,33 +341,21 @@ struct BUG_G_too_big { #define keep (G.keep ) #define io32bit (G.io32bit ) #define dma (G.dma ) -#define set_dma (G.set_dma ) -#define get_dma (G.get_dma ) +#define getset_dma (G.getset_dma ) #define set_xfermode (G.set_xfermode ) #define get_xfermode (G.get_xfermode ) -#define set_dkeep (G.set_dkeep ) -#define get_dkeep (G.get_dkeep ) -#define set_standby (G.set_standby ) -#define get_standby (G.get_standby ) -#define set_lookahead (G.set_lookahead ) -#define get_lookahead (G.get_lookahead ) -#define set_prefetch (G.set_prefetch ) -#define get_prefetch (G.get_prefetch ) -#define set_defects (G.set_defects ) -#define get_defects (G.get_defects ) -#define set_wcache (G.set_wcache ) -#define get_wcache (G.get_wcache ) -#define set_doorlock (G.set_doorlock ) -#define get_doorlock (G.get_doorlock ) +#define getset_dkeep (G.getset_dkeep ) +#define getset_standby (G.getset_standby ) +#define getset_lookahead (G.getset_lookahead ) +#define getset_prefetch (G.getset_prefetch ) +#define getset_defects (G.getset_defects ) +#define getset_wcache (G.getset_wcache ) +#define getset_doorlock (G.getset_doorlock ) #define set_seagate (G.set_seagate ) -#define get_seagate (G.get_seagate ) #define set_standbynow (G.set_standbynow ) -#define get_standbynow (G.get_standbynow ) #define set_sleepnow (G.set_sleepnow ) -#define get_sleepnow (G.get_sleepnow ) #define get_powermode (G.get_powermode ) -#define set_apmmode (G.set_apmmode ) -#define get_apmmode (G.get_apmmode ) +#define getset_apmmode (G.getset_apmmode ) #define xfermode_requested (G.xfermode_requested ) #define dkeep (G.dkeep ) #define standby_requested (G.standby_requested ) @@ -386,8 +366,7 @@ struct BUG_G_too_big { #define doorlock (G.doorlock ) #define apmmode (G.apmmode ) #define get_IDentity (G.get_IDentity ) -#define set_busstate (G.set_busstate ) -#define get_busstate (G.get_busstate ) +#define getset_busstate (G.getset_busstate ) #define perform_reset (G.perform_reset ) #define perform_tristate (G.perform_tristate ) #define unregister_hwif (G.unregister_hwif ) @@ -870,16 +849,27 @@ static void identify(uint16_t *val) } else { /* addressing...CHS? See section 6.2 of ATA specs 4 or 5 */ ll = (uint32_t)val[LBA_SECTS_MSB] << 16 | val[LBA_SECTS_LSB]; - mm = 0; bbbig = 0; + mm = 0; + bbbig = 0; if ((ll > 0x00FBFC10) && (!val[LCYLS])) printf("\tCHS addressing not supported\n"); else { jj = val[WHATS_VALID] & OK_W54_58; - printf("\tLogical\t\tmax\tcurrent\n\tcylinders\t%u\t%u\n\theads\t\t%u\t%u\n\tsectors/track\t%u\t%u\n\t--\n", - val[LCYLS],jj?val[LCYLS_CUR]:0, val[LHEADS],jj?val[LHEADS_CUR]:0, val[LSECTS],jj?val[LSECTS_CUR]:0); + printf("\tLogical\t\tmax\tcurrent\n" + "\tcylinders\t%u\t%u\n" + "\theads\t\t%u\t%u\n" + "\tsectors/track\t%u\t%u\n" + "\t--\n", + val[LCYLS], + jj ? val[LCYLS_CUR] : 0, + val[LHEADS], + jj ? val[LHEADS_CUR] : 0, + val[LSECTS], + jj ? val[LSECTS_CUR] : 0); if ((min_std == 1) && (val[TRACK_BYTES] || val[SECT_BYTES])) - printf("\tbytes/track: %u\tbytes/sector: %u\n", val[TRACK_BYTES], val[SECT_BYTES]); + printf("\tbytes/track: %u\tbytes/sector: %u\n", + val[TRACK_BYTES], val[SECT_BYTES]); if (jj) { mm = (uint32_t)val[CAPACITY_MSB] << 16 | val[CAPACITY_LSB]; @@ -921,22 +911,24 @@ static void identify(uint16_t *val) printf("Capabilities:\n\t"); if (dev == ATAPI_DEV) { - if (eqpt != CDROM && (val[CAPAB_0] & CMD_Q_SUP)) printf("Cmd queuing, "); - if (val[CAPAB_0] & OVLP_SUP) printf("Cmd overlap, "); + if (eqpt != CDROM && (val[CAPAB_0] & CMD_Q_SUP)) + printf("Cmd queuing, "); + if (val[CAPAB_0] & OVLP_SUP) + printf("Cmd overlap, "); } if (val[CAPAB_0] & LBA_SUP) printf("LBA, "); if (like_std != 1) { printf("IORDY%s(can%s be disabled)\n", - !(val[CAPAB_0] & IORDY_SUP) ? "(may be)" : "", - (val[CAPAB_0] & IORDY_OFF) ? "" :"not"); + !(val[CAPAB_0] & IORDY_SUP) ? "(may be)" : "", + (val[CAPAB_0] & IORDY_OFF) ? "" :"not"); } else printf("no IORDY\n"); if ((like_std == 1) && val[BUF_TYPE]) { printf("\tBuffer type: %04x: %s%s\n", val[BUF_TYPE], - (val[BUF_TYPE] < 2) ? "single port, single-sector" : "dual port, multi-sector", - (val[BUF_TYPE] > 2) ? " with read caching ability" : ""); + (val[BUF_TYPE] < 2) ? "single port, single-sector" : "dual port, multi-sector", + (val[BUF_TYPE] > 2) ? " with read caching ability" : ""); } if ((min_std == 1) && (val[BUFFER__SIZE] && (val[BUFFER__SIZE] != NOVAL_1))) { @@ -953,9 +945,11 @@ static void identify(uint16_t *val) if (like_std == 1) printf("\tCan%s perform double-word IO\n", (!val[DWORD_IO]) ? "not" : ""); else { - printf("\tStandby timer values: spec'd by %s", (val[CAPAB_0] & STD_STBY) ? "Standard" : "Vendor"); + printf("\tStandby timer values: spec'd by %s", + (val[CAPAB_0] & STD_STBY) ? "standard" : "vendor"); if ((like_std > 3) && ((val[CAPAB_1] & VALID) == VALID_VAL)) - printf(", %s device specific minimum\n", (val[CAPAB_1] & MIN_STANDBY_TIMER) ? "with" : "no"); + printf(", %s device specific minimum\n", + (val[CAPAB_1] & MIN_STANDBY_TIMER) ? "with" : "no"); else bb_putchar('\n'); } @@ -983,7 +977,8 @@ static void identify(uint16_t *val) } if (like_std > 5 && val[ACOUSTIC]) { printf("\tRecommended acoustic management value: %u, current value: %u\n", - (val[ACOUSTIC] >> 8) & 0x00ff, val[ACOUSTIC] & 0x00ff); + (val[ACOUSTIC] >> 8) & 0x00ff, + val[ACOUSTIC] & 0x00ff); } } else { /* ATAPI */ @@ -992,8 +987,11 @@ static void identify(uint16_t *val) if (val[PKT_REL] || val[SVC_NBSY]) { printf("\tOverlap support:"); - if (val[PKT_REL]) printf(" %uus to release bus.", val[PKT_REL]); - if (val[SVC_NBSY]) printf(" %uus to clear BSY after SERVICE cmd.", val[SVC_NBSY]); + if (val[PKT_REL]) + printf(" %uus to release bus.", val[PKT_REL]); + if (val[SVC_NBSY]) + printf(" %uus to clear BSY after SERVICE cmd.", + val[SVC_NBSY]); bb_putchar('\n'); } } @@ -1057,14 +1055,17 @@ static void identify(uint16_t *val) if (val[WHATS_VALID] & OK_W64_70) { if (val[PIO_NO_FLOW] || val[PIO_FLOW]) { printf("\t\tCycle time:"); - if (val[PIO_NO_FLOW]) printf(" no flow control=%uns", val[PIO_NO_FLOW]); - if (val[PIO_FLOW]) printf(" IORDY flow control=%uns", val[PIO_FLOW]); + if (val[PIO_NO_FLOW]) + printf(" no flow control=%uns", val[PIO_NO_FLOW]); + if (val[PIO_FLOW]) + printf(" IORDY flow control=%uns", val[PIO_FLOW]); bb_putchar('\n'); } } if ((val[CMDS_SUPP_1] & VALID) == VALID_VAL) { - printf("Commands/features:\n\tEnabled\tSupported:\n"); + printf("Commands/features:\n" + "\tEnabled\tSupported:\n"); jj = val[CMDS_SUPP_0]; kk = val[CMDS_EN_0]; for (ii = 0; ii < NUM_CMD_FEAT_STR; ii++) { @@ -1098,11 +1099,14 @@ static void identify(uint16_t *val) jj = val[SECU_STATUS]; if (jj) { for (ii = 0; ii < NUM_SECU_STR; ii++) { - printf("\t%s\t%s\n", (!(jj & 0x0001)) ? "not" : "", nth_string(secu_str, ii)); + printf("\t%s\t%s\n", + (!(jj & 0x0001)) ? "not" : "", + nth_string(secu_str, ii)); jj >>=1; } if (val[SECU_STATUS] & SECU_ENABLED) { - printf("\tSecurity level %s\n", (val[SECU_STATUS] & SECU_LEVEL) ? "maximum" : "high"); + printf("\tSecurity level %s\n", + (val[SECU_STATUS] & SECU_LEVEL) ? "maximum" : "high"); } } jj = val[ERASE_TIME] & ERASE_BITS; @@ -1127,16 +1131,20 @@ static void identify(uint16_t *val) strng = " determined by CSEL"; else strng = ""; - printf("HW reset results:\n\tCBLID- %s Vih\n\tDevice num = %i%s\n", - (val[HWRST_RSLT] & CBLID) ? "above" : "below", !(oo), strng); + printf("HW reset results:\n" + "\tCBLID- %s Vih\n" + "\tDevice num = %i%s\n", + (val[HWRST_RSLT] & CBLID) ? "above" : "below", + !(oo), strng); } /* more stuff from std 5 */ if ((like_std > 4) && (eqpt != CDROM)) { if (val[CFA_PWR_MODE] & VALID_W160) { - printf("CFA power mode 1:\n\t%s%s\n", (val[CFA_PWR_MODE] & PWR_MODE_OFF) ? "disabled" : "enabled", - (val[CFA_PWR_MODE] & PWR_MODE_REQ) ? " and required by some commands" : ""); - + printf("CFA power mode 1:\n" + "\t%s%s\n", + (val[CFA_PWR_MODE] & PWR_MODE_OFF) ? "disabled" : "enabled", + (val[CFA_PWR_MODE] & PWR_MODE_REQ) ? " and required by some commands" : ""); if (val[CFA_PWR_MODE] & MAX_AMPS) printf("\tMaximum current = %uma\n", val[CFA_PWR_MODE] & MAX_AMPS); } @@ -1184,11 +1192,12 @@ static void dump_identity(const struct hd_driveid *id) printf(" %s", nth_string(cfg_str, i)); } printf(" }\n RawCHS=%u/%u/%u, TrkSize=%u, SectSize=%u, ECCbytes=%u\n" - " BuffType=(%u) %s, BuffSize=%ukB, MaxMultSect=%u", - id->cyls, id->heads, id->sectors, id->track_bytes, - id->sector_bytes, id->ecc_bytes, - id->buf_type, nth_string(BuffType, (id->buf_type > 3) ? 0 : id->buf_type), - id->buf_size/2, id->max_multsect); + " BuffType=(%u) %s, BuffSize=%ukB, MaxMultSect=%u", + id->cyls, id->heads, id->sectors, id->track_bytes, + id->sector_bytes, id->ecc_bytes, + id->buf_type, + nth_string(BuffType, (id->buf_type > 3) ? 0 : id->buf_type), + id->buf_size/2, id->max_multsect); if (id->max_multsect) { printf(", MultSect="); if (!(id->multsect_valid & 1)) @@ -1213,7 +1222,10 @@ static void dump_identity(const struct hd_driveid *id) if (id->capability & 2) printf(", LBAsects=%u", id->lba_capacity); - printf("\n IORDY=%s", (id->capability & 8) ? (id->capability & 4) ? "on/off" : "yes" : "no"); + printf("\n IORDY=%s", + (id->capability & 8) + ? ((id->capability & 4) ? "on/off" : "yes") + : "no"); if (((id->capability & 8) || (id->field_valid & 2)) && (id->field_valid & 2)) printf(", tPIO={min:%u,w/IORDY:%u}", id->eide_pio, id->eide_pio_iordy); @@ -1242,7 +1254,7 @@ static void dump_identity(const struct hd_driveid *id) "*\0""sdma0 \0""*\0""sdma1 \0""*\0""sdma2 \0""*\0""sdma? \0", id->dma_1word, NULL); print_flags_separated(dma_wmode_masks, - "*\0""mdma0\0""*\0""mdma1\0""*\0""mdma2\0""*\0""mdma?\0", + "*\0""mdma0 \0""*\0""mdma1 \0""*\0""mdma2 \0""*\0""mdma? \0", id->dma_mword, NULL); } } @@ -1285,12 +1297,14 @@ static void dump_identity(const struct hd_driveid *id) if ((id->minor_rev_num && id->minor_rev_num <= 31) || (id->major_rev_num && id->minor_rev_num <= 31) ) { - printf("\n Drive conforms to: %s: ", (id->minor_rev_num <= 31) ? nth_string(minor_str, id->minor_rev_num) : "unknown"); - if (id->major_rev_num != 0x0000 && /* NOVAL_0 */ - id->major_rev_num != 0xFFFF) { /* NOVAL_1 */ + printf("\n Drive conforms to: %s: ", + (id->minor_rev_num <= 31) ? nth_string(minor_str, id->minor_rev_num) : "unknown"); + if (id->major_rev_num != 0x0000 /* NOVAL_0 */ + && id->major_rev_num != 0xFFFF /* NOVAL_1 */ + ) { for (i = 0; i <= 15; i++) { if (id->major_rev_num & (1< -1); @@ -1991,49 +2008,47 @@ int hdparm_main(int argc, char **argv) IF_FEATURE_HDPARM_GET_IDENTITY(get_identity |= (c == 'i')); get_geom |= (c == 'g'); do_flush |= (c == 'f'); - if (c == 'u') parse_opts(&get_unmask, &set_unmask, &unmask, 0, 1); - IF_FEATURE_HDPARM_HDIO_GETSET_DMA(if (c == 'd') parse_opts(&get_dma, &set_dma, &dma, 0, 9)); - if (c == 'n') parse_opts(&get_nowerr, &set_nowerr, &nowerr, 0, 1); + if (c == 'u') getset_unmask = parse_opts_0_1(&unmask); + IF_FEATURE_HDPARM_HDIO_GETSET_DMA( + if (c == 'd') getset_dma = parse_opts_0_max(&dma, 9); + ) + if (c == 'n') getset_nowerr = parse_opts_0_1(&nowerr); parse_xfermode((c == 'p'), &noisy_piomode, &set_piomode, &piomode); - if (c == 'r') parse_opts(&get_readonly, &set_readonly, &readonly, 0, 1); - if (c == 'm') parse_opts(&get_mult, &set_mult, &mult, 0, INT_MAX /*32*/); - if (c == 'c') parse_opts(&get_io32bit, &set_io32bit, &io32bit, 0, INT_MAX /*8*/); - if (c == 'k') parse_opts(&get_keep, &set_keep, &keep, 0, 1); - if (c == 'a') parse_opts(&get_readahead, &set_readahead, &Xreadahead, 0, INT_MAX); - if (c == 'B') parse_opts(&get_apmmode, &set_apmmode, &apmmode, 1, 255); + if (c == 'r') getset_readonly = parse_opts_0_1(&readonly); + if (c == 'm') getset_mult = parse_opts_0_INTMAX(&mult /*32*/); + if (c == 'c') getset_io32bit = parse_opts_0_INTMAX(&io32bit /*8*/); + if (c == 'k') getset_keep = parse_opts_0_1(&keep); + if (c == 'a') getset_readahead = parse_opts_0_INTMAX(&Xreadahead); + if (c == 'B') getset_apmmode = parse_opts(&apmmode, 1, 255); do_flush |= do_timings |= (c == 't'); do_flush |= do_ctimings |= (c == 'T'); #ifdef HDIO_DRIVE_CMD - if (c == 'S') parse_opts(&get_standby, &set_standby, &standby_requested, 0, 255); - if (c == 'D') parse_opts(&get_defects, &set_defects, &defects, 0, INT_MAX); - if (c == 'P') parse_opts(&get_prefetch, &set_prefetch, &prefetch, 0, INT_MAX); + if (c == 'S') getset_standby = parse_opts_0_max(&standby_requested, 255); + if (c == 'D') getset_defects = parse_opts_0_INTMAX(&defects); + if (c == 'P') getset_prefetch = parse_opts_0_INTMAX(&prefetch); parse_xfermode((c == 'X'), &get_xfermode, &set_xfermode, &xfermode_requested); - if (c == 'K') parse_opts(&get_dkeep, &set_dkeep, &prefetch, 0, 1); - if (c == 'A') parse_opts(&get_lookahead, &set_lookahead, &lookahead, 0, 1); - if (c == 'L') parse_opts(&get_doorlock, &set_doorlock, &doorlock, 0, 1); - if (c == 'W') parse_opts(&get_wcache, &set_wcache, &wcache, 0, 1); + if (c == 'K') getset_dkeep = parse_opts_0_1(&prefetch); + if (c == 'A') getset_lookahead = parse_opts_0_1(&lookahead); + if (c == 'L') getset_doorlock = parse_opts_0_1(&doorlock); + if (c == 'W') getset_wcache = parse_opts_0_1(&wcache); get_powermode |= (c == 'C'); - get_standbynow = set_standbynow |= (c == 'y'); - get_sleepnow = set_sleepnow |= (c == 'Y'); + set_standbynow |= (c == 'y'); + set_sleepnow |= (c == 'Y'); reread_partn |= (c == 'z'); - get_seagate = set_seagate |= (c == 'Z'); + set_seagate |= (c == 'Z'); #endif - IF_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF(if (c == 'U') parse_opts(NULL, &unregister_hwif, &hwif, 0, INT_MAX)); + IF_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF(if (c == 'U') unregister_hwif = parse_opts_0_INTMAX(&hwif)); #ifdef HDIO_GET_QDMA if (c == 'Q') { -#ifdef HDIO_SET_QDMA - parse_opts(&get_dma_q, &set_dma_q, &dma_q, 0, INT_MAX); -#else - parse_opts(&get_dma_q, NULL, NULL, 0, 0); -#endif + getset_dma_q = parse_opts_0_INTMAX(&dma_q); } #endif IF_FEATURE_HDPARM_HDIO_DRIVE_RESET(perform_reset = (c == 'r')); - IF_FEATURE_HDPARM_HDIO_TRISTATE_HWIF(if (c == 'x') parse_opts(NULL, &perform_tristate, &tristate, 0, 1)); - IF_FEATURE_HDPARM_HDIO_TRISTATE_HWIF(if (c == 'b') parse_opts(&get_busstate, &set_busstate, &busstate, 0, 2)); + IF_FEATURE_HDPARM_HDIO_TRISTATE_HWIF(if (c == 'x') perform_tristate = parse_opts_0_1(&tristate)); + IF_FEATURE_HDPARM_HDIO_TRISTATE_HWIF(if (c == 'b') getset_busstate = parse_opts_0_max(&busstate, 2)); #if ENABLE_FEATURE_HDPARM_HDIO_SCAN_HWIF if (c == 'R') { - parse_opts(NULL, &scan_hwif, &hwif_data, 0, INT_MAX); + scan_hwif = parse_opts_0_INTMAX(&hwif_data); hwif_ctrl = xatoi_u((argv[optind]) ? argv[optind] : ""); hwif_irq = xatoi_u((argv[optind+1]) ? argv[optind+1] : ""); /* Move past the 2 additional arguments */ @@ -2044,8 +2059,8 @@ int hdparm_main(int argc, char **argv) } /* When no flags are given (flagcount = 0), -acdgkmnru is assumed. */ if (!flagcount) { - get_mult = get_io32bit = get_unmask = get_keep = get_readonly = get_readahead = get_geom = 1; - IF_FEATURE_HDPARM_HDIO_GETSET_DMA(get_dma = 1); + getset_mult = getset_io32bit = getset_unmask = getset_keep = getset_readonly = getset_readahead = get_geom = IS_GET; + IF_FEATURE_HDPARM_HDIO_GETSET_DMA(getset_dma = IS_GET); } argv += optind;