aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2005-08-13 01:22:03 +0000
committerRob Landley <rob@landley.net>2005-08-13 01:22:03 +0000
commit0be69b16932c5adafb0c031515d9d4d9cb982aae (patch)
tree4b25ce6936f308a26c99452186ee533a21fa68a5
parentc7cba1ae3bacb11de6a11df8c2fc98a69e423d7d (diff)
downloadbusybox-w32-0be69b16932c5adafb0c031515d9d4d9cb982aae.tar.gz
busybox-w32-0be69b16932c5adafb0c031515d9d4d9cb982aae.tar.bz2
busybox-w32-0be69b16932c5adafb0c031515d9d4d9cb982aae.zip
More backports:
10957 start-stop-daemon -q 10981, 10982, 10994, 10996, 10997: dumpkmap cleanup 10983: top tweak 11000 traceroute
-rw-r--r--busybox/console-tools/dumpkmap.c43
-rw-r--r--busybox/debianutils/start_stop_daemon.c3
-rw-r--r--busybox/networking/traceroute.c2
-rw-r--r--busybox/procps/top.c23
4 files changed, 35 insertions, 36 deletions
diff --git a/busybox/console-tools/dumpkmap.c b/busybox/console-tools/dumpkmap.c
index 6085a446b..5b5b296b4 100644
--- a/busybox/console-tools/dumpkmap.c
+++ b/busybox/console-tools/dumpkmap.c
@@ -35,11 +35,11 @@ struct kbentry {
35 unsigned char kb_index; 35 unsigned char kb_index;
36 unsigned short kb_value; 36 unsigned short kb_value;
37}; 37};
38static const int KDGKBENT = 0x4B46; /* gets one entry in translation table */ 38#define KDGKBENT 0x4B46 /* gets one entry in translation table */
39 39
40/* From <linux/keyboard.h> */ 40/* From <linux/keyboard.h> */
41static const int NR_KEYS = 128; 41#define NR_KEYS 128
42static const int MAX_NR_KEYMAPS = 256; 42#define MAX_NR_KEYMAPS 256
43 43
44int dumpkmap_main(int argc, char **argv) 44int dumpkmap_main(int argc, char **argv)
45{ 45{
@@ -47,28 +47,21 @@ int dumpkmap_main(int argc, char **argv)
47 int i, j, fd; 47 int i, j, fd;
48 char flags[MAX_NR_KEYMAPS], magic[] = "bkeymap"; 48 char flags[MAX_NR_KEYMAPS], magic[] = "bkeymap";
49 49
50 if (argc>=2 && *argv[1]=='-') { 50 if (argc >= 2 && *argv[1] == '-')
51 bb_show_usage(); 51 bb_show_usage();
52 }
53 52
54 fd=bb_xopen(CURRENT_VC, O_RDWR); 53 fd = bb_xopen(CURRENT_VC, O_RDWR);
55 54
56 write(1, magic, 7); 55 write(1, magic, 7);
57 56
58 for (i=0; i < MAX_NR_KEYMAPS; i++) flags[i]=0; 57 /* Here we want to set everything to 0 except for indexes:
59 flags[0]=1; 58 * [0-2] [4-6] [8-10] [12] */
60 flags[1]=1; 59 memset(flags, 0x00, MAX_NR_KEYMAPS);
61 flags[2]=1; 60 memset(flags, 0x01, 13);
62 flags[4]=1; 61 flags[3] = flags[7] = flags[11] = 0;
63 flags[5]=1;
64 flags[6]=1;
65 flags[8]=1;
66 flags[9]=1;
67 flags[10]=1;
68 flags[12]=1;
69 62
70 /* dump flags */ 63 /* dump flags */
71 for (i=0; i < MAX_NR_KEYMAPS; i++) write(1,&flags[i],1); 64 write(1, flags, MAX_NR_KEYMAPS);
72 65
73 for (i = 0; i < MAX_NR_KEYMAPS; i++) { 66 for (i = 0; i < MAX_NR_KEYMAPS; i++) {
74 if (flags[i] == 1) { 67 if (flags[i] == 1) {
@@ -76,13 +69,13 @@ int dumpkmap_main(int argc, char **argv)
76 ke.kb_index = j; 69 ke.kb_index = j;
77 ke.kb_table = i; 70 ke.kb_table = i;
78 if (ioctl(fd, KDGKBENT, &ke) < 0) { 71 if (ioctl(fd, KDGKBENT, &ke) < 0) {
79 72 bb_perror_msg("ioctl failed with %s, %s, %p",
80 bb_error_msg("ioctl returned: %m, %s, %s, %xqq", (char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value); 73 (char *)&ke.kb_index,
81 } 74 (char *)&ke.kb_table,
82 else { 75 &ke.kb_value);
83 write(1,(void*)&ke.kb_value,2); 76 } else {
84 } 77 write(1, (void*)&ke.kb_value, 2);
85 78 }
86 } 79 }
87 } 80 }
88 } 81 }
diff --git a/busybox/debianutils/start_stop_daemon.c b/busybox/debianutils/start_stop_daemon.c
index 1eaf0d78c..03f49165c 100644
--- a/busybox/debianutils/start_stop_daemon.c
+++ b/busybox/debianutils/start_stop_daemon.c
@@ -242,6 +242,9 @@ start_stop_daemon_main(int argc, char **argv)
242 bb_show_usage(); 242 bb_show_usage();
243 } 243 }
244 244
245 if (opt & SSD_OPT_QUIET)
246 quiet = 1;
247
245 if (signame) { 248 if (signame) {
246 signal_nr = bb_xgetlarg(signame, 10, 0, NSIG); 249 signal_nr = bb_xgetlarg(signame, 10, 0, NSIG);
247 } 250 }
diff --git a/busybox/networking/traceroute.c b/busybox/networking/traceroute.c
index cf90ec088..628b13492 100644
--- a/busybox/networking/traceroute.c
+++ b/busybox/networking/traceroute.c
@@ -418,7 +418,7 @@ traceroute_main(int argc, char *argv[])
418 datalen = atoi(*argv); 418 datalen = atoi(*argv);
419 if (datalen < 0 || datalen >= MAXPACKET - sizeof(struct opacket)) 419 if (datalen < 0 || datalen >= MAXPACKET - sizeof(struct opacket))
420 bb_error_msg_and_die("packet size must be 0 <= s < %d.", 420 bb_error_msg_and_die("packet size must be 0 <= s < %d.",
421 MAXPACKET - sizeof(struct opacket)); 421 (int)(MAXPACKET - sizeof(struct opacket)));
422 datalen += sizeof(struct opacket); 422 datalen += sizeof(struct opacket);
423 outpacket = (struct opacket *)xmalloc((unsigned)datalen); 423 outpacket = (struct opacket *)xmalloc((unsigned)datalen);
424 memset(outpacket, 0, datalen); 424 memset(outpacket, 0, datalen);
diff --git a/busybox/procps/top.c b/busybox/procps/top.c
index 5963c3554..6a129efcf 100644
--- a/busybox/procps/top.c
+++ b/busybox/procps/top.c
@@ -52,11 +52,12 @@ typedef int (*cmp_t)(procps_status_t *P, procps_status_t *Q);
52static procps_status_t *top; /* Hehe */ 52static procps_status_t *top; /* Hehe */
53static int ntop; 53static int ntop;
54 54
55 55#ifdef CONFIG_FEATURE_USE_TERMIOS
56static int pid_sort (procps_status_t *P, procps_status_t *Q) 56static int pid_sort (procps_status_t *P, procps_status_t *Q)
57{ 57{
58 return (Q->pid - P->pid); 58 return (Q->pid - P->pid);
59} 59}
60#endif
60 61
61static int mem_sort (procps_status_t *P, procps_status_t *Q) 62static int mem_sort (procps_status_t *P, procps_status_t *Q)
62{ 63{
@@ -410,7 +411,7 @@ static void clearmems(void)
410 ntop = 0; 411 ntop = 0;
411} 412}
412 413
413#if defined CONFIG_FEATURE_USE_TERMIOS 414#ifdef CONFIG_FEATURE_USE_TERMIOS
414#include <termios.h> 415#include <termios.h>
415#include <sys/time.h> 416#include <sys/time.h>
416#include <signal.h> 417#include <signal.h>
@@ -439,7 +440,7 @@ static void sig_catcher (int sig)
439int top_main(int argc, char **argv) 440int top_main(int argc, char **argv)
440{ 441{
441 int opt, interval, lines, col; 442 int opt, interval, lines, col;
442#if defined CONFIG_FEATURE_USE_TERMIOS 443#ifdef CONFIG_FEATURE_USE_TERMIOS
443 struct termios new_settings; 444 struct termios new_settings;
444 struct timeval tv; 445 struct timeval tv;
445 fd_set readfds; 446 fd_set readfds;
@@ -473,7 +474,7 @@ int top_main(int argc, char **argv)
473 if (chdir("/proc") < 0) { 474 if (chdir("/proc") < 0) {
474 bb_perror_msg_and_die("chdir('/proc')"); 475 bb_perror_msg_and_die("chdir('/proc')");
475 } 476 }
476#if defined CONFIG_FEATURE_USE_TERMIOS 477#ifdef CONFIG_FEATURE_USE_TERMIOS
477 tcgetattr(0, (void *) &initial_settings); 478 tcgetattr(0, (void *) &initial_settings);
478 memcpy(&new_settings, &initial_settings, sizeof(struct termios)); 479 memcpy(&new_settings, &initial_settings, sizeof(struct termios));
479 new_settings.c_lflag &= ~(ISIG | ICANON); /* unbuffered input */ 480 new_settings.c_lflag &= ~(ISIG | ICANON); /* unbuffered input */
@@ -499,13 +500,15 @@ int top_main(int argc, char **argv)
499#endif 500#endif
500 } 501 }
501#endif /* CONFIG_FEATURE_USE_TERMIOS */ 502#endif /* CONFIG_FEATURE_USE_TERMIOS */
503
502#ifdef FEATURE_CPU_USAGE_PERCENTAGE 504#ifdef FEATURE_CPU_USAGE_PERCENTAGE
503 sort_function[0] = pcpu_sort; 505 sort_function[0] = pcpu_sort;
504 sort_function[1] = mem_sort; 506 sort_function[1] = mem_sort;
505 sort_function[2] = time_sort; 507 sort_function[2] = time_sort;
506#else 508#else
507 sort_function = mem_sort; 509 sort_function = mem_sort;
508#endif 510#endif /* FEATURE_CPU_USAGE_PERCENTAGE */
511
509 while (1) { 512 while (1) {
510 /* read process IDs & status for all the processes */ 513 /* read process IDs & status for all the processes */
511 procps_status_t * p; 514 procps_status_t * p;
@@ -534,14 +537,14 @@ int top_main(int argc, char **argv)
534 do_stats(); 537 do_stats();
535#else 538#else
536 qsort(top, ntop, sizeof(procps_status_t), (void*)sort_function); 539 qsort(top, ntop, sizeof(procps_status_t), (void*)sort_function);
537#endif 540#endif /* FEATURE_CPU_USAGE_PERCENTAGE */
538 opt = lines; 541 opt = lines;
539 if (opt > ntop) { 542 if (opt > ntop) {
540 opt = ntop; 543 opt = ntop;
541 } 544 }
542 /* show status for each of the processes */ 545 /* show status for each of the processes */
543 display_status(opt, col); 546 display_status(opt, col);
544#if defined CONFIG_FEATURE_USE_TERMIOS 547#ifdef CONFIG_FEATURE_USE_TERMIOS
545 tv.tv_sec = interval; 548 tv.tv_sec = interval;
546 tv.tv_usec = 0; 549 tv.tv_usec = 0;
547 FD_ZERO (&readfds); 550 FD_ZERO (&readfds);
@@ -549,8 +552,8 @@ int top_main(int argc, char **argv)
549 select (1, &readfds, NULL, NULL, &tv); 552 select (1, &readfds, NULL, NULL, &tv);
550 if (FD_ISSET (0, &readfds)) { 553 if (FD_ISSET (0, &readfds)) {
551 if (read (0, &c, 1) <= 0) { /* signal */ 554 if (read (0, &c, 1) <= 0) { /* signal */
552 return EXIT_FAILURE; 555 return EXIT_FAILURE;
553 } 556 }
554 if(c == 'q' || c == initial_settings.c_cc[VINTR]) 557 if(c == 'q' || c == initial_settings.c_cc[VINTR])
555 return EXIT_SUCCESS; 558 return EXIT_SUCCESS;
556 if(c == 'M') { 559 if(c == 'M') {
@@ -584,7 +587,7 @@ int top_main(int argc, char **argv)
584 } 587 }
585#else 588#else
586 sleep(interval); 589 sleep(interval);
587#endif /* CONFIG_FEATURE_USE_TERMIOS */ 590#endif /* CONFIG_FEATURE_USE_TERMIOS */
588 clearmems(); 591 clearmems();
589 } 592 }
590 593