aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-01-11 16:27:12 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2017-01-11 16:27:12 +0100
commit6c1f348fa792a33d5a98e68c139df65c2d4c1628 (patch)
treee0918eb74a6b01baa3cd44e28d7999c970e66ed9
parent01ccdd1d3c5221789f1ac62ced12b7984d910705 (diff)
downloadbusybox-w32-6c1f348fa792a33d5a98e68c139df65c2d4c1628.tar.gz
busybox-w32-6c1f348fa792a33d5a98e68c139df65c2d4c1628.tar.bz2
busybox-w32-6c1f348fa792a33d5a98e68c139df65c2d4c1628.zip
Move FEATURE_USE_TERMIOS config option to two applets which use it
No code changes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--Config.in9
-rw-r--r--configs/TEST_nommu_defconfig1
-rw-r--r--configs/TEST_noprintf_defconfig1
-rw-r--r--configs/TEST_rh9_defconfig1
-rw-r--r--configs/android2_defconfig1
-rw-r--r--configs/android_502_defconfig1
-rw-r--r--configs/android_defconfig1
-rw-r--r--configs/android_ndk_defconfig1
-rw-r--r--configs/cygwin_defconfig1
-rw-r--r--configs/freebsd_defconfig1
-rw-r--r--procps/powertop.c18
-rw-r--r--procps/top.c28
12 files changed, 31 insertions, 33 deletions
diff --git a/Config.in b/Config.in
index db1587169..ec302ffdf 100644
--- a/Config.in
+++ b/Config.in
@@ -61,15 +61,6 @@ config FEATURE_AUTOWIDTH
61 If you leave this disabled, your utilities will be especially 61 If you leave this disabled, your utilities will be especially
62 primitive and will be unable to determine the current screen width. 62 primitive and will be unable to determine the current screen width.
63 63
64#fixme: delete, create suboptions for applets which use this
65config FEATURE_USE_TERMIOS
66 bool "Use termios for one-stroke input"
67 default y
68 help
69 This option allows utilities such as 'top' to accept keyboard
70 commands. Without this option, they simply refresh display
71 after a fixed period.
72
73config SHOW_USAGE 64config SHOW_USAGE
74 bool "Show applet usage messages" 65 bool "Show applet usage messages"
75 default y 66 default y
diff --git a/configs/TEST_nommu_defconfig b/configs/TEST_nommu_defconfig
index d7a9cfe25..37f3df019 100644
--- a/configs/TEST_nommu_defconfig
+++ b/configs/TEST_nommu_defconfig
@@ -524,7 +524,6 @@ CONFIG_FEATURE_MDEV_LOAD_FIRMWARE=y
524CONFIG_MKSWAP=y 524CONFIG_MKSWAP=y
525CONFIG_FEATURE_MKSWAP_UUID=y 525CONFIG_FEATURE_MKSWAP_UUID=y
526CONFIG_MORE=y 526CONFIG_MORE=y
527CONFIG_FEATURE_USE_TERMIOS=y
528CONFIG_VOLUMEID=y 527CONFIG_VOLUMEID=y
529CONFIG_FEATURE_VOLUMEID_EXT=y 528CONFIG_FEATURE_VOLUMEID_EXT=y
530CONFIG_FEATURE_VOLUMEID_BTRFS=y 529CONFIG_FEATURE_VOLUMEID_BTRFS=y
diff --git a/configs/TEST_noprintf_defconfig b/configs/TEST_noprintf_defconfig
index adb6b7036..b03f6250e 100644
--- a/configs/TEST_noprintf_defconfig
+++ b/configs/TEST_noprintf_defconfig
@@ -527,7 +527,6 @@ CONFIG_FDISK_SUPPORT_LARGE_DISKS=y
527# CONFIG_MKSWAP is not set 527# CONFIG_MKSWAP is not set
528# CONFIG_FEATURE_MKSWAP_UUID is not set 528# CONFIG_FEATURE_MKSWAP_UUID is not set
529# CONFIG_MORE is not set 529# CONFIG_MORE is not set
530# CONFIG_FEATURE_USE_TERMIOS is not set
531CONFIG_VOLUMEID=y 530CONFIG_VOLUMEID=y
532# CONFIG_FEATURE_VOLUMEID_EXT is not set 531# CONFIG_FEATURE_VOLUMEID_EXT is not set
533# CONFIG_FEATURE_VOLUMEID_BTRFS is not set 532# CONFIG_FEATURE_VOLUMEID_BTRFS is not set
diff --git a/configs/TEST_rh9_defconfig b/configs/TEST_rh9_defconfig
index 0d72cdac9..3fc137787 100644
--- a/configs/TEST_rh9_defconfig
+++ b/configs/TEST_rh9_defconfig
@@ -540,7 +540,6 @@ CONFIG_FEATURE_MDEV_LOAD_FIRMWARE=y
540CONFIG_MKSWAP=y 540CONFIG_MKSWAP=y
541CONFIG_FEATURE_MKSWAP_UUID=y 541CONFIG_FEATURE_MKSWAP_UUID=y
542CONFIG_MORE=y 542CONFIG_MORE=y
543CONFIG_FEATURE_USE_TERMIOS=y
544CONFIG_VOLUMEID=y 543CONFIG_VOLUMEID=y
545CONFIG_FEATURE_VOLUMEID_EXT=y 544CONFIG_FEATURE_VOLUMEID_EXT=y
546CONFIG_FEATURE_VOLUMEID_BTRFS=y 545CONFIG_FEATURE_VOLUMEID_BTRFS=y
diff --git a/configs/android2_defconfig b/configs/android2_defconfig
index 866a87989..1846bb764 100644
--- a/configs/android2_defconfig
+++ b/configs/android2_defconfig
@@ -94,7 +94,6 @@ CONFIG_PASSWORD_MINLEN=6
94CONFIG_MD5_SMALL=1 94CONFIG_MD5_SMALL=1
95# CONFIG_FEATURE_FAST_TOP is not set 95# CONFIG_FEATURE_FAST_TOP is not set
96# CONFIG_FEATURE_ETC_NETWORKS is not set 96# CONFIG_FEATURE_ETC_NETWORKS is not set
97CONFIG_FEATURE_USE_TERMIOS=y
98# CONFIG_FEATURE_EDITING is not set 97# CONFIG_FEATURE_EDITING is not set
99CONFIG_FEATURE_EDITING_MAX_LEN=0 98CONFIG_FEATURE_EDITING_MAX_LEN=0
100# CONFIG_FEATURE_EDITING_VI is not set 99# CONFIG_FEATURE_EDITING_VI is not set
diff --git a/configs/android_502_defconfig b/configs/android_502_defconfig
index 8d8dd250f..2cf4cd86c 100644
--- a/configs/android_502_defconfig
+++ b/configs/android_502_defconfig
@@ -174,7 +174,6 @@ CONFIG_MD5_SMALL=1
174CONFIG_SHA3_SMALL=1 174CONFIG_SHA3_SMALL=1
175# CONFIG_FEATURE_FAST_TOP is not set 175# CONFIG_FEATURE_FAST_TOP is not set
176# CONFIG_FEATURE_ETC_NETWORKS is not set 176# CONFIG_FEATURE_ETC_NETWORKS is not set
177CONFIG_FEATURE_USE_TERMIOS=y
178CONFIG_FEATURE_EDITING=y 177CONFIG_FEATURE_EDITING=y
179CONFIG_FEATURE_EDITING_MAX_LEN=1024 178CONFIG_FEATURE_EDITING_MAX_LEN=1024
180# CONFIG_FEATURE_EDITING_VI is not set 179# CONFIG_FEATURE_EDITING_VI is not set
diff --git a/configs/android_defconfig b/configs/android_defconfig
index 1eaab9eae..8316b2efb 100644
--- a/configs/android_defconfig
+++ b/configs/android_defconfig
@@ -112,7 +112,6 @@ CONFIG_PASSWORD_MINLEN=6
112CONFIG_MD5_SMALL=1 112CONFIG_MD5_SMALL=1
113# CONFIG_FEATURE_FAST_TOP is not set 113# CONFIG_FEATURE_FAST_TOP is not set
114# CONFIG_FEATURE_ETC_NETWORKS is not set 114# CONFIG_FEATURE_ETC_NETWORKS is not set
115CONFIG_FEATURE_USE_TERMIOS=y
116# CONFIG_FEATURE_EDITING is not set 115# CONFIG_FEATURE_EDITING is not set
117CONFIG_FEATURE_EDITING_MAX_LEN=0 116CONFIG_FEATURE_EDITING_MAX_LEN=0
118# CONFIG_FEATURE_EDITING_VI is not set 117# CONFIG_FEATURE_EDITING_VI is not set
diff --git a/configs/android_ndk_defconfig b/configs/android_ndk_defconfig
index dc9d21ce5..d8b994ed4 100644
--- a/configs/android_ndk_defconfig
+++ b/configs/android_ndk_defconfig
@@ -102,7 +102,6 @@ CONFIG_MD5_SMALL=1
102CONFIG_SHA3_SMALL=1 102CONFIG_SHA3_SMALL=1
103# CONFIG_FEATURE_FAST_TOP is not set 103# CONFIG_FEATURE_FAST_TOP is not set
104# CONFIG_FEATURE_ETC_NETWORKS is not set 104# CONFIG_FEATURE_ETC_NETWORKS is not set
105CONFIG_FEATURE_USE_TERMIOS=y
106# CONFIG_FEATURE_EDITING is not set 105# CONFIG_FEATURE_EDITING is not set
107CONFIG_FEATURE_EDITING_MAX_LEN=0 106CONFIG_FEATURE_EDITING_MAX_LEN=0
108# CONFIG_FEATURE_EDITING_VI is not set 107# CONFIG_FEATURE_EDITING_VI is not set
diff --git a/configs/cygwin_defconfig b/configs/cygwin_defconfig
index 37e3e210f..352ed90ad 100644
--- a/configs/cygwin_defconfig
+++ b/configs/cygwin_defconfig
@@ -94,7 +94,6 @@ CONFIG_PASSWORD_MINLEN=6
94CONFIG_MD5_SMALL=1 94CONFIG_MD5_SMALL=1
95CONFIG_FEATURE_FAST_TOP=y 95CONFIG_FEATURE_FAST_TOP=y
96# CONFIG_FEATURE_ETC_NETWORKS is not set 96# CONFIG_FEATURE_ETC_NETWORKS is not set
97CONFIG_FEATURE_USE_TERMIOS=y
98CONFIG_FEATURE_EDITING=y 97CONFIG_FEATURE_EDITING=y
99CONFIG_FEATURE_EDITING_MAX_LEN=1024 98CONFIG_FEATURE_EDITING_MAX_LEN=1024
100# CONFIG_FEATURE_EDITING_VI is not set 99# CONFIG_FEATURE_EDITING_VI is not set
diff --git a/configs/freebsd_defconfig b/configs/freebsd_defconfig
index 90e0a8bda..b19a9fd49 100644
--- a/configs/freebsd_defconfig
+++ b/configs/freebsd_defconfig
@@ -93,7 +93,6 @@ CONFIG_PASSWORD_MINLEN=6
93CONFIG_MD5_SMALL=1 93CONFIG_MD5_SMALL=1
94CONFIG_FEATURE_FAST_TOP=y 94CONFIG_FEATURE_FAST_TOP=y
95# CONFIG_FEATURE_ETC_NETWORKS is not set 95# CONFIG_FEATURE_ETC_NETWORKS is not set
96CONFIG_FEATURE_USE_TERMIOS=y
97CONFIG_FEATURE_EDITING=y 96CONFIG_FEATURE_EDITING=y
98CONFIG_FEATURE_EDITING_MAX_LEN=1024 97CONFIG_FEATURE_EDITING_MAX_LEN=1024
99# CONFIG_FEATURE_EDITING_VI is not set 98# CONFIG_FEATURE_EDITING_VI is not set
diff --git a/procps/powertop.c b/procps/powertop.c
index ee806161f..413806836 100644
--- a/procps/powertop.c
+++ b/procps/powertop.c
@@ -18,6 +18,14 @@
18//config: default y 18//config: default y
19//config: help 19//config: help
20//config: Analyze power consumption on Intel-based laptops 20//config: Analyze power consumption on Intel-based laptops
21//config:
22//config:config FEATURE_POWERTOP_INTERACTIVE
23//config: bool "Accept keyboard commands"
24//config: default y
25//config: depends on POWERTOP
26//config: help
27//config: Without this, powertop will only refresh display every 10 seconds.
28//config: No keyboard commands will work, only ^C to terminate.
21 29
22// XXX This should be configurable 30// XXX This should be configurable
23#define ENABLE_FEATURE_POWERTOP_PROCIRQ 1 31#define ENABLE_FEATURE_POWERTOP_PROCIRQ 1
@@ -82,7 +90,7 @@ struct globals {
82 ullong last_usage[MAX_CSTATE_COUNT]; 90 ullong last_usage[MAX_CSTATE_COUNT];
83 ullong start_duration[MAX_CSTATE_COUNT]; 91 ullong start_duration[MAX_CSTATE_COUNT];
84 ullong last_duration[MAX_CSTATE_COUNT]; 92 ullong last_duration[MAX_CSTATE_COUNT];
85#if ENABLE_FEATURE_USE_TERMIOS 93#if ENABLE_FEATURE_POWERTOP_INTERACTIVE
86 struct termios init_settings; 94 struct termios init_settings;
87#endif 95#endif
88}; 96};
@@ -91,7 +99,7 @@ struct globals {
91 SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ 99 SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
92} while (0) 100} while (0)
93 101
94#if ENABLE_FEATURE_USE_TERMIOS 102#if ENABLE_FEATURE_POWERTOP_INTERACTIVE
95static void reset_term(void) 103static void reset_term(void)
96{ 104{
97 tcsetattr_stdin_TCSANOW(&G.init_settings); 105 tcsetattr_stdin_TCSANOW(&G.init_settings);
@@ -682,7 +690,7 @@ int powertop_main(int UNUSED_PARAM argc, char UNUSED_PARAM **argv)
682 ullong cur_usage[MAX_CSTATE_COUNT]; 690 ullong cur_usage[MAX_CSTATE_COUNT];
683 ullong cur_duration[MAX_CSTATE_COUNT]; 691 ullong cur_duration[MAX_CSTATE_COUNT];
684 char cstate_lines[MAX_CSTATE_COUNT + 2][64]; 692 char cstate_lines[MAX_CSTATE_COUNT + 2][64];
685#if ENABLE_FEATURE_USE_TERMIOS 693#if ENABLE_FEATURE_POWERTOP_INTERACTIVE
686 struct pollfd pfd[1]; 694 struct pollfd pfd[1];
687 695
688 pfd[0].fd = 0; 696 pfd[0].fd = 0;
@@ -705,7 +713,7 @@ int powertop_main(int UNUSED_PARAM argc, char UNUSED_PARAM **argv)
705 713
706 puts("Collecting data for "DEFAULT_SLEEP_STR" seconds"); 714 puts("Collecting data for "DEFAULT_SLEEP_STR" seconds");
707 715
708#if ENABLE_FEATURE_USE_TERMIOS 716#if ENABLE_FEATURE_POWERTOP_INTERACTIVE
709 /* Turn on unbuffered input; turn off echoing, ^C ^Z etc */ 717 /* Turn on unbuffered input; turn off echoing, ^C ^Z etc */
710 set_termios_to_raw(STDIN_FILENO, &G.init_settings, TERMIOS_CLEAR_ISIG); 718 set_termios_to_raw(STDIN_FILENO, &G.init_settings, TERMIOS_CLEAR_ISIG);
711 bb_signals(BB_FATAL_SIGS, sig_handler); 719 bb_signals(BB_FATAL_SIGS, sig_handler);
@@ -735,7 +743,7 @@ int powertop_main(int UNUSED_PARAM argc, char UNUSED_PARAM **argv)
735 int i; 743 int i;
736 744
737 G.cant_enable_timer_stats |= start_timer(); /* 1 on error */ 745 G.cant_enable_timer_stats |= start_timer(); /* 1 on error */
738#if !ENABLE_FEATURE_USE_TERMIOS 746#if !ENABLE_FEATURE_POWERTOP_INTERACTIVE
739 sleep(DEFAULT_SLEEP); 747 sleep(DEFAULT_SLEEP);
740#else 748#else
741 if (safe_poll(pfd, 1, DEFAULT_SLEEP * 1000) > 0) { 749 if (safe_poll(pfd, 1, DEFAULT_SLEEP * 1000) > 0) {
diff --git a/procps/top.c b/procps/top.c
index 91bb8a883..ff2fddeea 100644
--- a/procps/top.c
+++ b/procps/top.c
@@ -56,6 +56,14 @@
56//config: The top program provides a dynamic real-time view of a running 56//config: The top program provides a dynamic real-time view of a running
57//config: system. 57//config: system.
58//config: 58//config:
59//config:config FEATURE_TOP_INTERACTIVE
60//config: bool "Accept keyboard commands"
61//config: default y
62//config: depends on TOP
63//config: help
64//config: Without this, top will only refresh display every 5 seconds.
65//config: No keyboard commands will work, only ^C to terminate.
66//config:
59//config:config FEATURE_TOP_CPU_USAGE_PERCENTAGE 67//config:config FEATURE_TOP_CPU_USAGE_PERCENTAGE
60//config: bool "Show CPU per-process usage percentage" 68//config: bool "Show CPU per-process usage percentage"
61//config: default y 69//config: default y
@@ -158,7 +166,7 @@ struct globals {
158 smallint smp_cpu_info; /* one/many cpu info lines? */ 166 smallint smp_cpu_info; /* one/many cpu info lines? */
159#endif 167#endif
160 unsigned lines; /* screen height */ 168 unsigned lines; /* screen height */
161#if ENABLE_FEATURE_USE_TERMIOS 169#if ENABLE_FEATURE_TOP_INTERACTIVE
162 struct termios initial_settings; 170 struct termios initial_settings;
163 int scroll_ofs; 171 int scroll_ofs;
164#define G_scroll_ofs G.scroll_ofs 172#define G_scroll_ofs G.scroll_ofs
@@ -181,7 +189,7 @@ struct globals {
181 jiffy_counts_t *cpu_jif, *cpu_prev_jif; 189 jiffy_counts_t *cpu_jif, *cpu_prev_jif;
182 int num_cpus; 190 int num_cpus;
183#endif 191#endif
184#if ENABLE_FEATURE_USE_TERMIOS 192#if ENABLE_FEATURE_TOP_INTERACTIVE
185 char kbd_input[KEYCODE_BUFFER_SIZE]; 193 char kbd_input[KEYCODE_BUFFER_SIZE];
186#endif 194#endif
187 char line_buf[80]; 195 char line_buf[80];
@@ -220,7 +228,7 @@ enum {
220#define OPT_BATCH_MODE (option_mask32 & OPT_b) 228#define OPT_BATCH_MODE (option_mask32 & OPT_b)
221 229
222 230
223#if ENABLE_FEATURE_USE_TERMIOS 231#if ENABLE_FEATURE_TOP_INTERACTIVE
224static int pid_sort(top_status_t *P, top_status_t *Q) 232static int pid_sort(top_status_t *P, top_status_t *Q)
225{ 233{
226 /* Buggy wrt pids with high bit set */ 234 /* Buggy wrt pids with high bit set */
@@ -725,7 +733,7 @@ static void clearmems(void)
725 top = NULL; 733 top = NULL;
726} 734}
727 735
728#if ENABLE_FEATURE_USE_TERMIOS 736#if ENABLE_FEATURE_TOP_INTERACTIVE
729static void reset_term(void) 737static void reset_term(void)
730{ 738{
731 if (!OPT_BATCH_MODE) 739 if (!OPT_BATCH_MODE)
@@ -737,7 +745,7 @@ static void sig_catcher(int sig)
737 reset_term(); 745 reset_term();
738 kill_myself_with_sig(sig); 746 kill_myself_with_sig(sig);
739} 747}
740#endif /* FEATURE_USE_TERMIOS */ 748#endif /* FEATURE_TOP_INTERACTIVE */
741 749
742/* 750/*
743 * TOPMEM support 751 * TOPMEM support
@@ -892,7 +900,7 @@ enum {
892 EXIT_MASK = (unsigned)-1, 900 EXIT_MASK = (unsigned)-1,
893}; 901};
894 902
895#if ENABLE_FEATURE_USE_TERMIOS 903#if ENABLE_FEATURE_TOP_INTERACTIVE
896static unsigned handle_input(unsigned scan_mask, unsigned interval) 904static unsigned handle_input(unsigned scan_mask, unsigned interval)
897{ 905{
898 if (option_mask32 & OPT_EOF) { 906 if (option_mask32 & OPT_EOF) {
@@ -1041,7 +1049,7 @@ static unsigned handle_input(unsigned scan_mask, unsigned interval)
1041//usage: "\n""Read the status of all processes from /proc each SECONDS" 1049//usage: "\n""Read the status of all processes from /proc each SECONDS"
1042//usage: "\n""and display a screenful of them." 1050//usage: "\n""and display a screenful of them."
1043//usage: "\n" 1051//usage: "\n"
1044//usage: IF_FEATURE_USE_TERMIOS( 1052//usage: IF_FEATURE_TOP_INTERACTIVE(
1045//usage: "Keys:" 1053//usage: "Keys:"
1046//usage: "\n"" N/M" 1054//usage: "\n"" N/M"
1047//usage: IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE("/P") 1055//usage: IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE("/P")
@@ -1136,7 +1144,7 @@ int top_main(int argc UNUSED_PARAM, char **argv)
1136 if (OPT_BATCH_MODE) { 1144 if (OPT_BATCH_MODE) {
1137 option_mask32 |= OPT_EOF; 1145 option_mask32 |= OPT_EOF;
1138 } 1146 }
1139#if ENABLE_FEATURE_USE_TERMIOS 1147#if ENABLE_FEATURE_TOP_INTERACTIVE
1140 else { 1148 else {
1141 /* Turn on unbuffered input; turn off echoing, ^C ^Z etc */ 1149 /* Turn on unbuffered input; turn off echoing, ^C ^Z etc */
1142 set_termios_to_raw(STDIN_FILENO, &initial_settings, TERMIOS_CLEAR_ISIG); 1150 set_termios_to_raw(STDIN_FILENO, &initial_settings, TERMIOS_CLEAR_ISIG);
@@ -1237,7 +1245,7 @@ int top_main(int argc UNUSED_PARAM, char **argv)
1237 clearmems(); 1245 clearmems();
1238 if (iterations >= 0 && !--iterations) 1246 if (iterations >= 0 && !--iterations)
1239 break; 1247 break;
1240#if !ENABLE_FEATURE_USE_TERMIOS 1248#if !ENABLE_FEATURE_TOP_INTERACTIVE
1241 sleep(interval); 1249 sleep(interval);
1242#else 1250#else
1243 scan_mask = handle_input(scan_mask, interval); 1251 scan_mask = handle_input(scan_mask, interval);
@@ -1245,7 +1253,7 @@ int top_main(int argc UNUSED_PARAM, char **argv)
1245 } /* end of "while (not Q)" */ 1253 } /* end of "while (not Q)" */
1246 1254
1247 bb_putchar('\n'); 1255 bb_putchar('\n');
1248#if ENABLE_FEATURE_USE_TERMIOS 1256#if ENABLE_FEATURE_TOP_INTERACTIVE
1249 reset_term(); 1257 reset_term();
1250#endif 1258#endif
1251 if (ENABLE_FEATURE_CLEAN_UP) { 1259 if (ENABLE_FEATURE_CLEAN_UP) {