Changeset 3232 in MondoRescue for branches/3.2/mindi-busybox/miscutils
- Timestamp:
- Jan 1, 2014, 12:47:38 AM (11 years ago)
- Location:
- branches/3.2/mindi-busybox/miscutils
- Files:
-
- 43 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mindi-busybox/miscutils/Config.src
r2725 r3232 11 11 bool "adjtimex" 12 12 default y 13 depends onPLATFORM_LINUX13 select PLATFORM_LINUX 14 14 help 15 15 Adjtimex reads and optionally sets adjustment parameters for … … 40 40 bool "beep" 41 41 default y 42 depends onPLATFORM_LINUX42 select PLATFORM_LINUX 43 43 help 44 44 The beep applets beeps in a given freq/Hz. … … 195 195 bool "devfsd (obsolete)" 196 196 default n 197 depends onPLATFORM_LINUX197 select PLATFORM_LINUX 198 198 select FEATURE_SYSLOG 199 199 help … … 239 239 bool "Use devfs names for all devices (obsolete)" 240 240 default n 241 depends onPLATFORM_LINUX241 select PLATFORM_LINUX 242 242 help 243 243 This is obsolete and should NOT be used anymore. … … 259 259 bool "eject" 260 260 default y 261 depends onPLATFORM_LINUX261 select PLATFORM_LINUX 262 262 help 263 263 Used to eject cdroms. (defaults to /dev/cdrom) … … 274 274 bool "fbsplash" 275 275 default y 276 depends onPLATFORM_LINUX276 select PLATFORM_LINUX 277 277 help 278 278 Shows splash image and progress bar on framebuffer device. … … 324 324 bool "ionice" 325 325 default y 326 depends onPLATFORM_LINUX326 select PLATFORM_LINUX 327 327 help 328 328 Set/set program io scheduling class and priority … … 361 361 endchoice 362 362 363 config LESS364 bool "less"365 default y366 help367 'less' is a pager, meaning that it displays text files. It possesses368 a wide array of features, and is an improvement over 'more'.369 370 config FEATURE_LESS_MAXLINES371 int "Max number of input lines less will try to eat"372 default 9999999373 depends on LESS374 375 config FEATURE_LESS_BRACKETS376 bool "Enable bracket searching"377 default y378 depends on LESS379 help380 This option adds the capability to search for matching left and right381 brackets, facilitating programming.382 383 config FEATURE_LESS_FLAGS384 bool "Enable extra flags"385 default y386 depends on LESS387 help388 The extra flags provided do the following:389 390 The -M flag enables a more sophisticated status line.391 The -m flag enables a simpler status line with a percentage.392 393 config FEATURE_LESS_MARKS394 bool "Enable marks"395 default y396 depends on LESS397 help398 Marks enable positions in a file to be stored for easy reference.399 400 config FEATURE_LESS_REGEXP401 bool "Enable regular expressions"402 default y403 depends on LESS404 help405 Enable regular expressions, allowing complex file searches.406 407 config FEATURE_LESS_WINCH408 bool "Enable automatic resizing on window size changes"409 default y410 depends on LESS411 help412 Makes less track window size changes.413 414 config FEATURE_LESS_DASHCMD415 bool "Enable flag changes ('-' command)"416 default y417 depends on LESS418 help419 This enables the ability to change command-line flags within420 less itself ('-' keyboard command).421 422 config FEATURE_LESS_LINENUMS423 bool "Enable dynamic switching of line numbers"424 default y425 depends on FEATURE_LESS_DASHCMD426 help427 Enables "-N" command.428 429 363 config HDPARM 430 364 bool "hdparm" 431 365 default y 432 depends onPLATFORM_LINUX366 select PLATFORM_LINUX 433 367 help 434 368 Get/Set hard drive parameters. Primarily intended for ATA … … 547 481 bool "raidautorun" 548 482 default y 549 depends onPLATFORM_LINUX483 select PLATFORM_LINUX 550 484 help 551 485 raidautorun tells the kernel md driver to … … 555 489 bool "readahead" 556 490 default y 557 depends on LFS && PLATFORM_LINUX 491 depends on LFS 492 select PLATFORM_LINUX 558 493 help 559 494 Preload the files listed on the command line into RAM cache so that … … 572 507 bool "rfkill" 573 508 default n # doesn't build on Ubuntu 9.04 574 depends onPLATFORM_LINUX509 select PLATFORM_LINUX 575 510 help 576 511 Enable/disable wireless devices. … … 584 519 bool "runlevel" 585 520 default y 521 depends on FEATURE_UTMP 586 522 help 587 523 find the current and previous system runlevel. … … 593 529 bool "rx" 594 530 default y 595 depends onPLATFORM_LINUX531 select PLATFORM_LINUX 596 532 help 597 533 Receive files using the Xmodem protocol. … … 659 595 bool "wall" 660 596 default y 597 depends on FEATURE_UTMP 661 598 help 662 599 Write a message to all users that are logged in. … … 665 602 bool "watchdog" 666 603 default y 667 depends onPLATFORM_LINUX604 select PLATFORM_LINUX 668 605 help 669 606 The watchdog utility is used with hardware or software watchdog -
branches/3.2/mindi-busybox/miscutils/adjtimex.c
r2725 r3232 12 12 */ 13 13 14 //usage:#define adjtimex_trivial_usage 15 //usage: "[-q] [-o OFF] [-f FREQ] [-p TCONST] [-t TICK]" 16 //usage:#define adjtimex_full_usage "\n\n" 17 //usage: "Read and optionally set system timebase parameters. See adjtimex(2)\n" 18 //usage: "\n -q Quiet" 19 //usage: "\n -o OFF Time offset, microseconds" 20 //usage: "\n -f FREQ Frequency adjust, integer kernel units (65536 is 1ppm)" 21 //usage: "\n (positive values make clock run faster)" 22 //usage: "\n -t TICK Microseconds per tick, usually 10000" 23 //usage: "\n -p TCONST" 24 14 25 #include "libbb.h" 15 #include <sys/timex.h> 26 #ifdef __BIONIC__ 27 # include <linux/timex.h> 28 #else 29 # include <sys/timex.h> 30 #endif 16 31 17 32 static const uint16_t statlist_bit[] = { -
branches/3.2/mindi-busybox/miscutils/bbconfig.c
r2725 r3232 2 2 /* This file was released into the public domain by Paul Fox. 3 3 */ 4 5 //usage:#define bbconfig_trivial_usage 6 //usage: "" 7 //usage:#define bbconfig_full_usage "\n\n" 8 //usage: "Print the config file used by busybox build" 9 4 10 #include "libbb.h" 5 11 #include "bbconfigopts.h" 6 12 #if ENABLE_FEATURE_COMPRESS_BBCONFIG 7 # include " archive.h"13 # include "bb_archive.h" 8 14 # include "bbconfigopts_bz2.h" 9 15 #endif -
branches/3.2/mindi-busybox/miscutils/beep.c
r2725 r3232 8 8 * 9 9 */ 10 11 //usage:#define beep_trivial_usage 12 //usage: "-f FREQ -l LEN -d DELAY -r COUNT -n" 13 //usage:#define beep_full_usage "\n\n" 14 //usage: " -f Frequency in Hz" 15 //usage: "\n -l Length in ms" 16 //usage: "\n -d Delay in ms" 17 //usage: "\n -r Repetitions" 18 //usage: "\n -n Start new tone" 19 10 20 #include "libbb.h" 11 21 -
branches/3.2/mindi-busybox/miscutils/chat.c
r2725 r3232 8 8 * Licensed under GPLv2, see file LICENSE in this source tree. 9 9 */ 10 11 //usage:#define chat_trivial_usage 12 //usage: "EXPECT [SEND [EXPECT [SEND...]]]" 13 //usage:#define chat_full_usage "\n\n" 14 //usage: "Useful for interacting with a modem connected to stdin/stdout.\n" 15 //usage: "A script consists of one or more \"expect-send\" pairs of strings,\n" 16 //usage: "each pair is a pair of arguments. Example:\n" 17 //usage: "chat '' ATZ OK ATD123456 CONNECT '' ogin: pppuser word: ppppass '~'" 18 10 19 #include "libbb.h" 11 20 -
branches/3.2/mindi-busybox/miscutils/chrt.c
r2725 r3232 6 6 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 7 7 */ 8 9 //usage:#define chrt_trivial_usage 10 //usage: "[-prfom] [PRIO] [PID | PROG ARGS]" 11 //usage:#define chrt_full_usage "\n\n" 12 //usage: "Change scheduling priority and class for a process\n" 13 //usage: "\n -p Operate on PID" 14 //usage: "\n -r Set SCHED_RR class" 15 //usage: "\n -f Set SCHED_FIFO class" 16 //usage: "\n -o Set SCHED_OTHER class" 17 //usage: "\n -m Show min/max priorities" 18 //usage: 19 //usage:#define chrt_example_usage 20 //usage: "$ chrt -r 4 sleep 900; x=$!\n" 21 //usage: "$ chrt -f -p 3 $x\n" 22 //usage: "You need CAP_SYS_NICE privileges to set scheduling attributes of a process" 23 8 24 #include <sched.h> 9 25 #include "libbb.h" … … 54 70 int policy = SCHED_RR; 55 71 56 /* at least 1 arg;only one policy accepted */57 opt_complementary = " -1:r--fo:f--ro:r--fo";72 /* only one policy accepted */ 73 opt_complementary = "r--fo:f--ro:o--rf"; 58 74 opt = getopt32(argv, "+mprfo"); 75 if (opt & OPT_m) { /* print min/max and exit */ 76 show_min_max(SCHED_FIFO); 77 show_min_max(SCHED_RR); 78 show_min_max(SCHED_OTHER); 79 fflush_stdout_and_exit(EXIT_SUCCESS); 80 } 59 81 if (opt & OPT_r) 60 82 policy = SCHED_RR; … … 63 85 if (opt & OPT_o) 64 86 policy = SCHED_OTHER; 65 if (opt & OPT_m) { /* print min/max */66 show_min_max(SCHED_FIFO);67 show_min_max(SCHED_RR);68 show_min_max(SCHED_OTHER);69 fflush_stdout_and_exit(EXIT_SUCCESS);70 }71 87 72 88 argv += optind; 89 if (!argv[0]) 90 bb_show_usage(); 73 91 if (opt & OPT_p) { 74 92 pid_str = *argv++; … … 91 109 pol = sched_getscheduler(pid); 92 110 if (pol < 0) 93 bb_perror_msg_and_die("can't %cet pid %d's policy", 'g', pid);111 bb_perror_msg_and_die("can't %cet pid %d's policy", 'g', (int)pid); 94 112 printf("pid %d's %s scheduling policy: %s\n", 95 113 pid, current_new, policies[pol].name); 96 114 if (sched_getparam(pid, &sp)) 97 bb_perror_msg_and_die("can't get pid %d's attributes", pid);115 bb_perror_msg_and_die("can't get pid %d's attributes", (int)pid); 98 116 printf("pid %d's %s scheduling priority: %d\n", 99 pid, current_new, sp.sched_priority);117 (int)pid, current_new, sp.sched_priority); 100 118 if (!*argv) { 101 119 /* Either it was just "-p <pid>", … … 116 134 117 135 if (sched_setscheduler(pid, policy, &sp) < 0) 118 bb_perror_msg_and_die("can't %cet pid %d's policy", 's', pid);136 bb_perror_msg_and_die("can't %cet pid %d's policy", 's', (int)pid); 119 137 120 138 if (!argv[0]) /* "-p <priority> <pid> [...]" */ -
branches/3.2/mindi-busybox/miscutils/conspy.c
r2725 r3232 11 11 */ 12 12 13 //applet:IF_CONSPY(APPLET(conspy, _BB_DIR_BIN, _BB_SUID_DROP))13 //applet:IF_CONSPY(APPLET(conspy, BB_DIR_BIN, BB_SUID_DROP)) 14 14 15 15 //kbuild:lib-$(CONFIG_CONSPY) += conspy.o … … 17 17 //config:config CONSPY 18 18 //config: bool "conspy" 19 //config: default n20 //config: depends onPLATFORM_LINUX19 //config: default y 20 //config: select PLATFORM_LINUX 21 21 //config: help 22 22 //config: A text-mode VNC like program for Linux virtual terminals. … … 26 26 27 27 //usage:#define conspy_trivial_usage 28 //usage: "[-vcsndf ] [-x COL] [-y LINE] [CONSOLE_NO]"28 //usage: "[-vcsndfFQ] [-x COL] [-y LINE] [CONSOLE_NO]" 29 29 //usage:#define conspy_full_usage "\n\n" 30 30 //usage: "A text-mode VNC like program for Linux virtual consoles." 31 31 //usage: "\nTo exit, quickly press ESC 3 times." 32 32 //usage: "\n" 33 //usage: "\nOptions:"34 33 //usage: "\n -v Don't send keystrokes to the console" 35 //usage: "\n -c Create missing devices in /dev"34 //usage: "\n -c Create missing /dev/{tty,vcsa}N" 36 35 //usage: "\n -s Open a SHELL session" 37 36 //usage: "\n -n Black & white" 38 37 //usage: "\n -d Dump console to stdout" 39 38 //usage: "\n -f Follow cursor" 39 //usage: "\n -F Assume console is on a framebuffer device" 40 //usage: "\n -Q Disable exit on ESC-ESC-ESC" 40 41 //usage: "\n -x COL Starting column" 41 42 //usage: "\n -y LINE Starting line" … … 44 45 #include <sys/kd.h> 45 46 46 47 47 #define ESC "\033" 48 #define CURSOR_ON -1 49 #define CURSOR_OFF 1 50 51 #define DEV_TTY "/dev/tty" 52 #define DEV_VCSA "/dev/vcsa" 48 53 49 54 struct screen_info { … … 74 79 unsigned line; 75 80 smallint curoff; // unknown:0 cursor on:-1 cursor off:1 76 char attrbuf[sizeof( ESC"[0;1;5;30;40m")];81 char attrbuf[sizeof("0;1;5;30;40m")]; 77 82 // remote console 78 83 struct screen_info remote; 79 84 // saved local tty terminfo 80 85 struct termios term_orig; 81 char vcsa_name[sizeof( "/dev/vcsaNN")];86 char vcsa_name[sizeof(DEV_VCSA "NN")]; 82 87 }; 83 88 … … 85 90 #define INIT_G() do { \ 86 91 SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ 87 G.attrbuf[0] = '\033'; \88 G.attrbuf[1] = '['; \89 92 G.width = G.height = UINT_MAX; \ 90 93 G.last_attr--; \ … … 94 97 FLAG_v, // view only 95 98 FLAG_c, // create device if need 99 FLAG_Q, // never exit 96 100 FLAG_s, // session 97 101 FLAG_n, // no colors 98 102 FLAG_d, // dump screen 99 103 FLAG_f, // follow cursor 104 FLAG_F, // framebuffer 100 105 }; 101 106 #define FLAG(x) (1 << FLAG_##x) 102 107 #define BW (option_mask32 & FLAG(n)) 103 108 109 static void putcsi(const char *s) 110 { 111 fputs(ESC"[", stdout); 112 fputs(s, stdout); 113 } 114 104 115 static void clrscr(void) 105 116 { 106 117 // Home, clear till end of screen 107 fputs(ESC"[1;1H" ESC"[J", stdout);118 putcsi("1;1H" ESC"[J"); 108 119 G.col = G.line = 0; 109 120 } … … 113 124 if (G.curoff != state) { 114 125 G.curoff = state; 115 fputs(ESC"[?25", stdout);126 putcsi("?25"); 116 127 bb_putchar("h?l"[1 + state]); 117 128 } … … 127 138 } 128 139 140 static void cleanup(int code) NORETURN; 129 141 static void cleanup(int code) 130 142 { 131 set_cursor( -1); // cursor on143 set_cursor(CURSOR_ON); 132 144 tcsetattr(G.kbd_fd, TCSANOW, &G.term_orig); 133 145 if (ENABLE_FEATURE_CLEAN_UP) { … … 136 148 // Reset attributes 137 149 if (!BW) 138 fputs(ESC"[0m", stdout);150 putcsi("0m"); 139 151 bb_putchar('\n'); 140 if (code > 1)152 if (code > EXIT_FAILURE) 141 153 kill_myself_with_sig(code); 142 154 exit(code); … … 159 171 G.data = xzalloc(2 * i); 160 172 } 161 elseif (G.size != i) {162 cleanup( 1);173 if (G.size != i) { 174 cleanup(EXIT_FAILURE); 163 175 } 164 176 data = G.data + G.current; … … 170 182 unsigned y = i - G.y; // if will catch i < G.y too 171 183 172 if (CHAR(data) < ' ')173 CHAR(data) = ' ';174 184 if (y >= G.height || x >= G.width) 175 185 DATA(data) = 0; 186 else { 187 uint8_t ch = CHAR(data); 188 if (ch < ' ') 189 CHAR(data) = ch | 0x40; 190 else if (ch > 0x7e) 191 CHAR(data) = '?'; 192 } 176 193 } 177 194 } … … 181 198 { 182 199 if (!BW) { 200 uint8_t attr_diff; 183 201 uint8_t attr = ATTR(data); 184 //uint8_t attr = ATTR(data) >> 1; // for framebuffer console 185 uint8_t attr_diff = G.last_attr ^ attr; 186 202 203 if (option_mask32 & FLAG(F)) { 204 attr >>= 1; 205 } 206 attr_diff = G.last_attr ^ attr; 187 207 if (attr_diff) { 188 208 // Attribute layout for VGA compatible text videobuffer: … … 215 235 char *ptr; 216 236 217 ptr = G.attrbuf + 2; // skip "ESC ["237 ptr = G.attrbuf; 218 238 219 239 // (G.last_attr & ~attr) has 1 only where … … 246 266 *ptr++ = '4'; 247 267 *ptr++ = color[(attr & bg_mask) >> 4]; 248 *ptr++ = ';';249 } 250 if (ptr != G.attrbuf + 2) {268 ptr++; // last attribute 269 } 270 if (ptr != G.attrbuf) { 251 271 ptr[-1] = 'm'; 252 272 *ptr = '\0'; 253 fputs(G.attrbuf, stdout);273 putcsi(G.attrbuf); 254 274 } 255 275 } … … 294 314 unsigned cx = G.remote.cursor_x - G.x; 295 315 unsigned cy = G.remote.cursor_y - G.y; 296 int cursor = 1;316 int cursor = CURSOR_OFF; 297 317 298 318 if (cx < G.width && cy < G.height) { 299 319 gotoxy(cx, cy); 300 cursor = -1;320 cursor = CURSOR_ON; 301 321 } 302 322 set_cursor(cursor); … … 317 337 if (pid == 0) { 318 338 struct termios termchild; 319 char *shell = getenv("SHELL"); 320 321 if (!shell) 322 shell = (char *) DEFAULT_SHELL; 339 const char *shell = get_shell_name(); 340 323 341 signal(SIGHUP, SIG_IGN); 324 342 // set tty as a controlling tty … … 345 363 int conspy_main(int argc UNUSED_PARAM, char **argv) 346 364 { 347 char tty_name[sizeof( "/dev/ttyNN")];365 char tty_name[sizeof(DEV_TTY "NN")]; 348 366 #define keybuf bb_common_bufsiz1 349 367 struct termios termbuf; … … 355 373 "viewonly\0" No_argument "v" 356 374 "createdevice\0" No_argument "c" 375 "neverquit\0" No_argument "Q" 357 376 "session\0" No_argument "s" 358 377 "nocolors\0" No_argument "n" 359 378 "dump\0" No_argument "d" 360 379 "follow\0" No_argument "f" 380 "framebuffer\0" No_argument "F" 361 381 ; 362 382 … … 364 384 #endif 365 385 INIT_G(); 366 strcpy(G.vcsa_name, "/dev/vcsa");386 strcpy(G.vcsa_name, DEV_VCSA); 367 387 368 388 opt_complementary = "x+:y+"; // numeric params 369 opts = getopt32(argv, "vc sndfx:y:", &G.x, &G.y);389 opts = getopt32(argv, "vcQsndfFx:y:", &G.x, &G.y); 370 390 argv += optind; 371 391 ttynum = 0; 372 392 if (argv[0]) { 373 393 ttynum = xatou_range(argv[0], 0, 63); 374 sprintf(G.vcsa_name + sizeof( "/dev/vcsa")-1, "%u", ttynum);375 } 376 sprintf(tty_name, "%s%u", "/dev/tty", ttynum);394 sprintf(G.vcsa_name + sizeof(DEV_VCSA)-1, "%u", ttynum); 395 } 396 sprintf(tty_name, "%s%u", DEV_TTY, ttynum); 377 397 if (opts & FLAG(c)) { 378 398 if ((opts & (FLAG(s)|FLAG(v))) != FLAG(v)) … … 485 505 case -1: 486 506 if (errno != EINTR) 487 cleanup(1);507 goto abort; 488 508 break; 489 509 case 0: … … 496 516 bytes_read = read(G.kbd_fd, k, sizeof(keybuf) - G.key_count); 497 517 if (bytes_read < 0) 498 cleanup(1);518 goto abort; 499 519 500 520 // Do exit processing 501 for (i = 0; i < bytes_read; i++) { 502 if (k[i] != '\033') 503 G.escape_count = 0; 504 else if (++G.escape_count >= 3) 505 cleanup(0); 521 if (!(option_mask32 & FLAG(Q))) { 522 for (i = 0; i < bytes_read; i++) { 523 if (k[i] != '\033') 524 G.escape_count = -1; 525 if (++G.escape_count >= 3) 526 cleanup(EXIT_SUCCESS); 527 } 506 528 } 507 529 } 508 530 poll_timeout_ms = 250; 531 if (option_mask32 & FLAG(v)) continue; 509 532 510 533 // Insert all keys pressed into the virtual console's input … … 512 535 // code mode - giving ASCII characters to a program expecting 513 536 // scan codes will confuse it. 514 if (!(option_mask32 & FLAG(v)) && G.escape_count == 0) { 537 G.key_count += bytes_read; 538 if (G.escape_count == 0) { 515 539 int handle, result; 516 540 long kbd_mode; 517 541 518 G.key_count += bytes_read;519 542 handle = xopen(tty_name, O_WRONLY); 520 543 result = ioctl(handle, KDGKBMODE, &kbd_mode); … … 522 545 char *p = keybuf; 523 546 547 G.ioerror_count = 0; 524 548 if (kbd_mode != K_XLATE && kbd_mode != K_UNICODE) { 525 549 G.key_count = 0; // scan code mode … … 537 561 } 538 562 } 563 // We sometimes get spurious IO errors on the TTY 564 // as programs close and re-open it 565 else if (errno != EIO || ++G.ioerror_count > 4) { 566 if (ENABLE_FEATURE_CLEAN_UP) 567 close(handle); 568 goto abort; 569 } 539 570 // Close & re-open tty in case they have 540 571 // swapped virtual consoles 541 572 close(handle); 542 543 // We sometimes get spurious IO errors on the TTY544 // as programs close and re-open it545 if (result >= 0)546 G.ioerror_count = 0;547 else if (errno != EIO || ++G.ioerror_count > 4)548 cleanup(1);549 573 } 550 574 } /* while (1) */ 551 } 575 abort: 576 cleanup(EXIT_FAILURE); 577 } -
branches/3.2/mindi-busybox/miscutils/crond.c
r2725 r3232 11 11 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 12 12 */ 13 14 //usage:#define crond_trivial_usage 15 //usage: "-fbS -l N " IF_FEATURE_CROND_D("-d N ") "-L LOGFILE -c DIR" 16 //usage:#define crond_full_usage "\n\n" 17 //usage: " -f Foreground" 18 //usage: "\n -b Background (default)" 19 //usage: "\n -S Log to syslog (default)" 20 //usage: "\n -l Set log level. 0 is the most verbose, default 8" 21 //usage: IF_FEATURE_CROND_D( 22 //usage: "\n -d Set log level, log to stderr" 23 //usage: ) 24 //usage: "\n -L Log to file" 25 //usage: "\n -c Working dir" 13 26 14 27 #include "libbb.h" … … 849 862 /* "-b after -f is ignored", and so on for every pair a-b */ 850 863 opt_complementary = "f-b:b-f:S-L:L-S" IF_FEATURE_CROND_D(":d-l") 851 ":l+:d+"; /* -l and -d have numeric param */ 864 /* -l and -d have numeric param */ 865 ":l+" IF_FEATURE_CROND_D(":d+"); 852 866 opts = getopt32(argv, "l:L:fbSc:" IF_FEATURE_CROND_D("d:"), 853 867 &G.log_level, &G.log_filename, &G.crontab_dir_name … … 872 886 crondlog(LVL8 "crond (busybox "BB_VER") started, log level %d", G.log_level); 873 887 rescan_crontab_dir(); 874 write_pidfile( "/var/run/crond.pid");888 write_pidfile(CONFIG_PID_FILE_PATH "/crond.pid"); 875 889 876 890 /* Main loop */ -
branches/3.2/mindi-busybox/miscutils/crontab.c
r2725 r3232 11 11 */ 12 12 13 //usage:#define crontab_trivial_usage 14 //usage: "[-c DIR] [-u USER] [-ler]|[FILE]" 15 //usage:#define crontab_full_usage "\n\n" 16 //usage: " -c Crontab directory" 17 //usage: "\n -u User" 18 //usage: "\n -l List crontab" 19 //usage: "\n -e Edit crontab" 20 //usage: "\n -r Delete crontab" 21 //usage: "\n FILE Replace crontab by FILE ('-': stdin)" 22 13 23 #include "libbb.h" 14 24 … … 21 31 { 22 32 const char *ptr; 23 int pid = xvfork(); 24 33 pid_t pid; 34 35 pid = xvfork(); 25 36 if (pid) { /* parent */ 26 37 wait4pid(pid); … … 31 42 /* initgroups, setgid, setuid */ 32 43 change_identity(pas); 33 setup_environment( DEFAULT_SHELL,44 setup_environment(pas->pw_shell, 34 45 SETUP_ENV_CHANGEENV | SETUP_ENV_TO_TMP, 35 46 pas); … … 42 53 43 54 BB_EXECLP(ptr, ptr, file, NULL); 44 bb_perror_msg_and_die(" exec %s", ptr);55 bb_perror_msg_and_die("can't execute '%s'", ptr); 45 56 } 46 57 -
branches/3.2/mindi-busybox/miscutils/dc.c
r2725 r3232 12 12 //usage:#define dc_full_usage "\n\n" 13 13 //usage: "Tiny RPN calculator. Operations:\n" 14 //usage: "+, add, -, sub, *, mul, /, div, %, mod, **, exp, and, or, not, eor,\n"14 //usage: "+, add, -, sub, *, mul, /, div, %, mod, "IF_FEATURE_DC_LIBM("**, exp, ")"and, or, not, xor,\n" 15 15 //usage: "p - print top of the stack (without popping),\n" 16 16 //usage: "f - print entire stack,\n" 17 17 //usage: "o - pop the value and set output radix (must be 10, 16, 8 or 2).\n" 18 //usage: "Examples: 'dc 2 2 add ' -> 4, 'dc 8 8 * 2 2 + /' -> 16"18 //usage: "Examples: 'dc 2 2 add p' -> 4, 'dc 8 8 mul 2 2 + / p' -> 16" 19 19 //usage: 20 20 //usage:#define dc_example_usage … … 220 220 {"f", print_stack_no_pop}, 221 221 {"o", set_output_base}, 222 { "", NULL }223 222 }; 224 223 225 224 static void stack_machine(const char *argument) 226 225 { 227 char *end Pointer;226 char *end; 228 227 double d; 229 const struct op *o = operators; 230 231 d = strtod(argument, &endPointer); 232 233 if (endPointer != argument && *endPointer == '\0') { 228 const struct op *o; 229 230 d = strtod(argument, &end); 231 if (end != argument && *end == '\0') { 234 232 push(d); 235 233 return; 236 234 } 237 235 238 while (o->function) { 236 o = operators; 237 do { 239 238 if (strcmp(o->name, argument) == 0) { 240 239 o->function(); … … 242 241 } 243 242 o++; 244 } 243 } while (o != operators + ARRAY_SIZE(operators)); 244 245 245 bb_error_msg_and_die("syntax error at '%s'", argument); 246 }247 248 /* return pointer to next token in buffer and set *buffer to one char249 * past the end of the above mentioned token250 */251 static char *get_token(char **buffer)252 {253 char *current = skip_whitespace(*buffer);254 if (*current != '\0') {255 *buffer = skip_non_whitespace(current);256 return current;257 }258 return NULL;259 246 } 260 247 … … 273 260 cursor = line; 274 261 while (1) { 275 token = get_token(&cursor);276 if ( !token)262 token = skip_whitespace(cursor); 263 if (*token == '\0') 277 264 break; 278 *cursor++ = '\0'; 265 cursor = skip_non_whitespace(token); 266 if (*cursor != '\0') 267 *cursor++ = '\0'; 279 268 stack_machine(token); 280 269 } … … 282 271 } 283 272 } else { 284 // why? it breaks "dc -2 2 *p"273 // why? it breaks "dc -2 2 + p" 285 274 //if (argv[0][0] == '-') 286 275 // bb_show_usage(); -
branches/3.2/mindi-busybox/miscutils/devfsd.c
r2725 r3232 54 54 Richard Gooch, c/o ATNF, P. O. Box 76, Epping, N.S.W., 2121, Australia. 55 55 */ 56 57 //usage:#define devfsd_trivial_usage 58 //usage: "mntpnt [-v]" IF_DEVFSD_FG_NP("[-fg][-np]") 59 //usage:#define devfsd_full_usage "\n\n" 60 //usage: "Manage devfs permissions and old device name symlinks\n" 61 //usage: "\n mntpnt The mount point where devfs is mounted" 62 //usage: "\n -v Print the protocol version numbers for devfsd" 63 //usage: "\n and the kernel-side protocol version and exit" 64 //usage: IF_DEVFSD_FG_NP( 65 //usage: "\n -fg Run in foreground" 66 //usage: "\n -np Exit after parsing the configuration file" 67 //usage: "\n and processing synthetic REGISTER events," 68 //usage: "\n don't poll for events" 69 //usage: ) 70 56 71 #include "libbb.h" 57 72 #include "xregex.h" … … 205 220 static void action_modload(const struct devfsd_notify_struct *info, const struct config_entry_struct *entry); 206 221 static void action_copy(const struct devfsd_notify_struct *, const struct config_entry_struct *, 207 222 const regmatch_t *, unsigned); 208 223 static void action_compat(const struct devfsd_notify_struct *, unsigned); 209 224 static void free_config(void); … … 215 230 static int make_dir_tree(const char *); 216 231 static int expand_expression(char *, unsigned, const char *, const char *(*)(const char *, void *), void *, 217 232 const char *, const regmatch_t *, unsigned); 218 233 static void expand_regexp(char *, size_t, const char *, const char *, const regmatch_t *, unsigned); 219 234 static const char *expand_variable( char *, unsigned, unsigned *, const char *, 220 235 const char *(*)(const char *, void *), void *); 221 236 static const char *get_variable_v2(const char *, const char *(*)(const char *, void *), void *); 222 static char get_old_ide_name(unsigned 237 static char get_old_ide_name(unsigned, unsigned); 223 238 static char *write_old_sd_name(char *, unsigned, unsigned, const char *); 224 239 … … 566 581 the device name) to the module loading facility. In addition, 567 582 the /etc/modules.devfs configuration file is used.*/ 568 583 if (ENABLE_DEVFSD_MODLOAD) 569 584 new->action.what = AC_MODLOAD; 570 585 break; 571 586 case 6: /* EXECUTE */ 572 587 new->action.what = AC_EXECUTE; … … 736 751 737 752 static void action_modload(const struct devfsd_notify_struct *info, 738 753 const struct config_entry_struct *entry UNUSED_PARAM) 739 754 /* [SUMMARY] Load a module. 740 755 <info> The devfs change. … … 757 772 758 773 static void action_execute(const struct devfsd_notify_struct *info, 759 760 774 const struct config_entry_struct *entry, 775 const regmatch_t *regexpr, unsigned int numexpr) 761 776 /* [SUMMARY] Execute a programme. 762 777 <info> The devfs change. … … 789 804 790 805 static void action_copy(const struct devfsd_notify_struct *info, 791 792 806 const struct config_entry_struct *entry, 807 const regmatch_t *regexpr, unsigned int numexpr) 793 808 /* [SUMMARY] Copy permissions. 794 809 <info> The devfs change. … … 1245 1260 1246 1261 static int expand_expression(char *output, unsigned int outsize, 1247 1248 1249 1250 1251 1262 const char *input, 1263 const char *(*get_variable_func)(const char *variable, void *info), 1264 void *info, 1265 const char *devname, 1266 const regmatch_t *ex, unsigned int numexp) 1252 1267 /* [SUMMARY] Expand environment variables and regular subexpressions in string. 1253 1268 <output> The output expanded expression is written here. … … 1274 1289 1275 1290 static void expand_regexp(char *output, size_t outsize, const char *input, 1276 1277 1291 const char *devname, 1292 const regmatch_t *ex, unsigned int numex) 1278 1293 /* [SUMMARY] Expand all occurrences of the regular subexpressions \0 to \9. 1279 1294 <output> The output expanded expression is written here. … … 1371 1386 1372 1387 const char *get_old_name(const char *devname, unsigned int namelen, 1373 1388 char *buffer, unsigned int major, unsigned int minor) 1374 1389 /* [SUMMARY] Translate a kernel-supplied name into an old name. 1375 1390 <devname> The device name provided by the kernel. … … 1409 1424 1410 1425 for (trans = translate_table; trans->match != NULL; ++trans) { 1411 1426 len = strlen(trans->match); 1412 1427 1413 1428 if (strncmp(devname, trans->match, len) == 0) { … … 1535 1550 1536 1551 int st_expr_expand(char *output, unsigned int length, const char *input, 1537 1538 1539 1552 const char *(*get_variable_func)(const char *variable, 1553 void *info), 1554 void *info) 1540 1555 /* [SUMMARY] Expand an expression using Borne Shell-like unquoted rules. 1541 1556 <output> The output expanded expression is written here. … … 1627 1642 1628 1643 static const char *expand_variable(char *buffer, unsigned int length, 1629 1630 1631 1632 1644 unsigned int *out_pos, const char *input, 1645 const char *(*func)(const char *variable, 1646 void *info), 1647 void *info) 1633 1648 /* [SUMMARY] Expand a variable. 1634 1649 <buffer> The buffer to write to. … … 1772 1787 1773 1788 static const char *get_variable_v2(const char *variable, 1774 1775 1789 const char *(*func)(const char *variable, void *info), 1790 void *info) 1776 1791 /* [SUMMARY] Get a variable from the environment or . 1777 1792 <variable> The variable name. -
branches/3.2/mindi-busybox/miscutils/devmem.c
r2725 r3232 4 4 * Copyright (C) 2008, BusyBox Team. -solar 4/26/08 5 5 */ 6 7 //usage:#define devmem_trivial_usage 8 //usage: "ADDRESS [WIDTH [VALUE]]" 9 //usage:#define devmem_full_usage "\n\n" 10 //usage: "Read/write from physical address\n" 11 //usage: "\n ADDRESS Address to act upon" 12 //usage: "\n WIDTH Width (8/16/...)" 13 //usage: "\n VALUE Data to be written" 6 14 7 15 #include "libbb.h" -
branches/3.2/mindi-busybox/miscutils/eject.c
r2725 r3232 13 13 * Most of the dirty work blatantly ripped off from cat.c =) 14 14 */ 15 16 //usage:#define eject_trivial_usage 17 //usage: "[-t] [-T] [DEVICE]" 18 //usage:#define eject_full_usage "\n\n" 19 //usage: "Eject DEVICE or default /dev/cdrom\n" 20 //usage: IF_FEATURE_EJECT_SCSI( 21 //usage: "\n -s SCSI device" 22 //usage: ) 23 //usage: "\n -t Close tray" 24 //usage: "\n -T Open/close tray (toggle)" 15 25 16 26 #include <sys/mount.h> -
branches/3.2/mindi-busybox/miscutils/fbsplash.c
r2725 r3232 22 22 */ 23 23 24 //usage:#define fbsplash_trivial_usage 25 //usage: "-s IMGFILE [-c] [-d DEV] [-i INIFILE] [-f CMD]" 26 //usage:#define fbsplash_full_usage "\n\n" 27 //usage: " -s Image" 28 //usage: "\n -c Hide cursor" 29 //usage: "\n -d Framebuffer device (default /dev/fb0)" 30 //usage: "\n -i Config file (var=value):" 31 //usage: "\n BAR_LEFT,BAR_TOP,BAR_WIDTH,BAR_HEIGHT" 32 //usage: "\n BAR_R,BAR_G,BAR_B" 33 //usage: "\n -f Control pipe (else exit after drawing image)" 34 //usage: "\n commands: 'NN' (% for progress bar) or 'exit'" 35 24 36 #include "libbb.h" 25 37 #include <linux/fb.h> … … 27 39 /* If you want logging messages on /tmp/fbsplash.log... */ 28 40 #define DEBUG 0 29 30 #define BYTES_PER_PIXEL 231 32 typedef unsigned short DATA;33 41 34 42 struct globals { … … 42 50 struct fb_var_screeninfo scr_var; 43 51 struct fb_fix_screeninfo scr_fix; 52 unsigned bytes_per_pixel; 53 // cached (8 - scr_var.COLOR.length): 54 unsigned red_shift; 55 unsigned green_shift; 56 unsigned blue_shift; 44 57 }; 45 58 #define G (*ptr_to_globals) … … 66 79 #endif 67 80 68 69 /** 70 * Open and initialize the framebuffer device 81 /** 82 * Configure palette for RGB:332 83 */ 84 static void fb_setpal(int fd) 85 { 86 struct fb_cmap cmap; 87 /* fb colors are 16 bit */ 88 unsigned short red[256], green[256], blue[256]; 89 unsigned i; 90 91 /* RGB:332 */ 92 for (i = 0; i < 256; i++) { 93 /* Color is encoded in pixel value as rrrgggbb. 94 * 3-bit color is mapped to 16-bit one as: 95 * 000 -> 00000000 00000000 96 * 001 -> 00100100 10010010 97 * ... 98 * 011 -> 01101101 10110110 99 * 100 -> 10010010 01001001 100 * ... 101 * 111 -> 11111111 11111111 102 */ 103 red[i] = (( i >> 5 ) * 0x9249) >> 2; // rrr * 00 10010010 01001001 >> 2 104 green[i] = (((i >> 2) & 0x7) * 0x9249) >> 2; // ggg * 00 10010010 01001001 >> 2 105 /* 2-bit color is easier: */ 106 blue[i] = ( i & 0x3) * 0x5555; // bb * 01010101 01010101 107 } 108 109 cmap.start = 0; 110 cmap.len = 256; 111 cmap.red = red; 112 cmap.green = green; 113 cmap.blue = blue; 114 cmap.transp = 0; 115 116 xioctl(fd, FBIOPUTCMAP, &cmap); 117 } 118 119 /** 120 * Open and initialize the framebuffer device 71 121 * \param *strfb_device pointer to framebuffer device 72 122 */ … … 79 129 xioctl(fbfd, FBIOGET_FSCREENINFO, &G.scr_fix); 80 130 81 if (G.scr_var.bits_per_pixel != 16) 82 bb_error_msg_and_die("only 16 bpp is supported"); 131 switch (G.scr_var.bits_per_pixel) { 132 case 8: 133 fb_setpal(fbfd); 134 break; 135 136 case 16: 137 case 24: 138 case 32: 139 break; 140 141 default: 142 bb_error_msg_and_die("unsupported %u bpp", (int)G.scr_var.bits_per_pixel); 143 break; 144 } 145 146 G.red_shift = 8 - G.scr_var.red.length; 147 G.green_shift = 8 - G.scr_var.green.length; 148 G.blue_shift = 8 - G.scr_var.blue.length; 149 G.bytes_per_pixel = (G.scr_var.bits_per_pixel + 7) >> 3; 83 150 84 151 // map the device in memory 85 152 G.addr = mmap(NULL, 86 G.scr_var.xres * G.scr_var.yres 87 * BYTES_PER_PIXEL /*(G.scr_var.bits_per_pixel / 8)*/, 153 G.scr_var.yres * G.scr_fix.line_length, 88 154 PROT_WRITE, MAP_SHARED, fbfd, 0); 89 155 if (G.addr == MAP_FAILED) 90 156 bb_perror_msg_and_die("mmap"); 157 158 // point to the start of the visible screen 159 G.addr += G.scr_var.yoffset * G.scr_fix.line_length + G.scr_var.xoffset * G.bytes_per_pixel; 91 160 close(fbfd); 92 161 } … … 94 163 95 164 /** 96 * Draw hollow rectangle on framebuffer 165 * Return pixel value of the passed RGB color. 166 * This is performance critical fn. 167 */ 168 static unsigned fb_pixel_value(unsigned r, unsigned g, unsigned b) 169 { 170 /* We assume that the r,g,b values are <= 255 */ 171 172 if (G.bytes_per_pixel == 1) { 173 r = r & 0xe0; // 3-bit red 174 g = (g >> 3) & 0x1c; // 3-bit green 175 b = b >> 6; // 2-bit blue 176 return r + g + b; 177 } 178 if (G.bytes_per_pixel == 2) { 179 // ARM PL110 on Integrator/CP has RGBA5551 bit arrangement. 180 // We want to support bit locations like that. 181 // 182 // First shift out unused bits 183 r = r >> G.red_shift; 184 g = g >> G.green_shift; 185 b = b >> G.blue_shift; 186 // Then shift the remaining bits to their offset 187 return (r << G.scr_var.red.offset) + 188 (g << G.scr_var.green.offset) + 189 (b << G.scr_var.blue.offset); 190 } 191 // RGB 888 192 return b + (g << 8) + (r << 16); 193 } 194 195 /** 196 * Draw pixel on framebuffer 197 */ 198 static void fb_write_pixel(unsigned char *addr, unsigned pixel) 199 { 200 switch (G.bytes_per_pixel) { 201 case 1: 202 *addr = pixel; 203 break; 204 case 2: 205 *(uint16_t *)addr = pixel; 206 break; 207 case 4: 208 *(uint32_t *)addr = pixel; 209 break; 210 default: // 24 bits per pixel 211 addr[0] = pixel; 212 addr[1] = pixel >> 8; 213 addr[2] = pixel >> 16; 214 } 215 } 216 217 218 /** 219 * Draw hollow rectangle on framebuffer 97 220 */ 98 221 static void fb_drawrectangle(void) 99 222 { 100 223 int cnt; 101 DATAthispix;102 DATA*ptr1, *ptr2;224 unsigned thispix; 225 unsigned char *ptr1, *ptr2; 103 226 unsigned char nred = G.nbar_colr/2; 104 227 unsigned char ngreen = G.nbar_colg/2; 105 228 unsigned char nblue = G.nbar_colb/2; 106 229 107 nred >>= 3; // 5-bit red 108 ngreen >>= 2; // 6-bit green 109 nblue >>= 3; // 5-bit blue 110 thispix = nblue + (ngreen << 5) + (nred << (5+6)); 230 thispix = fb_pixel_value(nred, ngreen, nblue); 111 231 112 232 // horizontal lines 113 ptr1 = (DATA*)(G.addr + (G.nbar_posy * G.scr_var.xres + G.nbar_posx) * BYTES_PER_PIXEL);114 ptr2 = (DATA*)(G.addr + ((G.nbar_posy + G.nbar_height - 1) * G.scr_var.xres + G.nbar_posx) * BYTES_PER_PIXEL);233 ptr1 = G.addr + G.nbar_posy * G.scr_fix.line_length + G.nbar_posx * G.bytes_per_pixel; 234 ptr2 = G.addr + (G.nbar_posy + G.nbar_height - 1) * G.scr_fix.line_length + G.nbar_posx * G.bytes_per_pixel; 115 235 cnt = G.nbar_width - 1; 116 236 do { 117 *ptr1++ = thispix; 118 *ptr2++ = thispix; 237 fb_write_pixel(ptr1, thispix); 238 fb_write_pixel(ptr2, thispix); 239 ptr1 += G.bytes_per_pixel; 240 ptr2 += G.bytes_per_pixel; 119 241 } while (--cnt >= 0); 120 242 121 243 // vertical lines 122 ptr1 = (DATA*)(G.addr + (G.nbar_posy * G.scr_var.xres + G.nbar_posx) * BYTES_PER_PIXEL);123 ptr2 = (DATA*)(G.addr + (G.nbar_posy * G.scr_var.xres + G.nbar_posx + G.nbar_width - 1) * BYTES_PER_PIXEL);244 ptr1 = G.addr + G.nbar_posy * G.scr_fix.line_length + G.nbar_posx * G.bytes_per_pixel; 245 ptr2 = G.addr + G.nbar_posy * G.scr_fix.line_length + (G.nbar_posx + G.nbar_width - 1) * G.bytes_per_pixel; 124 246 cnt = G.nbar_height - 1; 125 247 do { 126 *ptr1 = thispix; ptr1 += G.scr_var.xres; 127 *ptr2 = thispix; ptr2 += G.scr_var.xres; 248 fb_write_pixel(ptr1, thispix); 249 fb_write_pixel(ptr2, thispix); 250 ptr1 += G.scr_fix.line_length; 251 ptr2 += G.scr_fix.line_length; 128 252 } while (--cnt >= 0); 129 253 } … … 131 255 132 256 /** 133 * 257 * Draw filled rectangle on framebuffer 134 258 * \param nx1pos,ny1pos upper left position 135 259 * \param nx2pos,ny2pos down right position … … 140 264 { 141 265 int cnt1, cnt2, nypos; 142 DATA thispix; 143 DATA *ptr; 144 145 nred >>= 3; // 5-bit red 146 ngreen >>= 2; // 6-bit green 147 nblue >>= 3; // 5-bit blue 148 thispix = nblue + (ngreen << 5) + (nred << (5+6)); 266 unsigned thispix; 267 unsigned char *ptr; 268 269 thispix = fb_pixel_value(nred, ngreen, nblue); 149 270 150 271 cnt1 = ny2pos - ny1pos; 151 272 nypos = ny1pos; 152 273 do { 153 ptr = (DATA*)(G.addr + (nypos * G.scr_var.xres + nx1pos) * BYTES_PER_PIXEL);274 ptr = G.addr + nypos * G.scr_fix.line_length + nx1pos * G.bytes_per_pixel; 154 275 cnt2 = nx2pos - nx1pos; 155 276 do { 156 *ptr++ = thispix; 277 fb_write_pixel(ptr, thispix); 278 ptr += G.bytes_per_pixel; 157 279 } while (--cnt2 >= 0); 158 280 … … 163 285 164 286 /** 165 * 287 * Draw a progress bar on framebuffer 166 288 * \param percent percentage of loading 167 289 */ 168 290 static void fb_drawprogressbar(unsigned percent) 169 291 { 170 int i, left_x, top_y, width, height; 292 int left_x, top_y, pos_x; 293 unsigned width, height; 171 294 172 295 // outer box … … 175 298 width = G.nbar_width - 1; 176 299 height = G.nbar_height - 1; 177 if (( height | width) < 0)300 if ((int)(height | width) < 0) 178 301 return; 179 302 // NB: "width" of 1 actually makes rect with width of 2! … … 185 308 width -= 2; 186 309 height -= 2; 187 if (( height | width) < 0)310 if ((int)(height | width) < 0) 188 311 return; 189 fb_drawfullrectangle( 190 left_x, top_y, 191 left_x + width, top_y + height, 192 G.nbar_colr, G.nbar_colg, G.nbar_colb); 193 312 313 pos_x = left_x; 194 314 if (percent > 0) { 315 int i, y; 316 195 317 // actual progress bar 196 width = width * percent / 100; 318 pos_x += (unsigned)(width * percent) / 100; 319 320 y = top_y; 197 321 i = height; 198 322 if (height == 0) … … 201 325 // draw one-line thick "rectangle" 202 326 // top line will have gray lvl 200, bottom one 100 203 unsigned gray_level = 100 + i*100/height;327 unsigned gray_level = 100 + (unsigned)i*100 / height; 204 328 fb_drawfullrectangle( 205 left_x, top_y, left_x + width, top_y,329 left_x, y, pos_x, y, 206 330 gray_level, gray_level, gray_level); 207 top_y++;331 y++; 208 332 i--; 209 333 } 210 334 } 211 } 212 213 214 /** 215 * Draw image from PPM file 335 336 fb_drawfullrectangle( 337 pos_x, top_y, 338 left_x + width, top_y + height, 339 G.nbar_colr, G.nbar_colg, G.nbar_colb); 340 } 341 342 343 /** 344 * Draw image from PPM file 216 345 */ 217 346 static void fb_drawimage(void) … … 274 403 for (j = 0; j < height; j++) { 275 404 unsigned char *pixel; 276 DATA*src;405 unsigned char *src; 277 406 278 407 if (fread(pixline, 1, line_size, theme_file) != line_size) 279 408 bb_error_msg_and_die("bad PPM file '%s'", G.image_filename); 280 409 pixel = pixline; 281 src = (DATA *)(G.addr + j * G.scr_fix.line_length);410 src = G.addr + j * G.scr_fix.line_length; 282 411 for (i = 0; i < width; i++) { 283 unsigned thispix; 284 thispix = (((unsigned)pixel[0] << 8) & 0xf800) 285 | (((unsigned)pixel[1] << 3) & 0x07e0) 286 | (((unsigned)pixel[2] >> 3)); 287 *src++ = thispix; 412 unsigned thispix = fb_pixel_value(pixel[0], pixel[1], pixel[2]); 413 fb_write_pixel(src, thispix); 414 src += G.bytes_per_pixel; 288 415 pixel += 3; 289 416 } … … 295 422 296 423 /** 297 * 424 * Parse configuration file 298 425 * \param *cfg_filename name of the configuration file 299 426 */ -
branches/3.2/mindi-busybox/miscutils/flash_eraseall.c
r2725 r3232 10 10 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 11 11 */ 12 13 //usage:#define flash_eraseall_trivial_usage 14 //usage: "[-jq] MTD_DEVICE" 15 //usage:#define flash_eraseall_full_usage "\n\n" 16 //usage: "Erase an MTD device\n" 17 //usage: "\n -j Format the device for jffs2" 18 //usage: "\n -q Don't display progress messages" 12 19 13 20 #include "libbb.h" -
branches/3.2/mindi-busybox/miscutils/flash_lock_unlock.c
r2725 r3232 4 4 * Licensed under GPLv2, see file LICENSE in this source tree. 5 5 */ 6 7 //usage:#define flash_lock_trivial_usage 8 //usage: "MTD_DEVICE OFFSET SECTORS" 9 //usage:#define flash_lock_full_usage "\n\n" 10 //usage: "Lock part or all of an MTD device. If SECTORS is -1, then all sectors\n" 11 //usage: "will be locked, regardless of the value of OFFSET" 12 //usage: 13 //usage:#define flash_unlock_trivial_usage 14 //usage: "MTD_DEVICE" 15 //usage:#define flash_unlock_full_usage "\n\n" 16 //usage: "Unlock an MTD device" 17 6 18 #include "libbb.h" 7 19 #include <mtd/mtd-user.h> -
branches/3.2/mindi-busybox/miscutils/flashcp.c
r2725 r3232 7 7 * Licensed under GPLv2, see file LICENSE in this source tree. 8 8 */ 9 10 //usage:#define flashcp_trivial_usage 11 //usage: "-v FILE MTD_DEVICE" 12 //usage:#define flashcp_full_usage "\n\n" 13 //usage: "Copy an image to MTD device\n" 14 //usage: "\n -v Verbose" 9 15 10 16 #include "libbb.h" … … 45 51 int i; 46 52 uoff_t erase_count; 47 unsigned opts;48 53 struct mtd_info_user mtd; 49 54 struct erase_info_user e; … … 54 59 55 60 opt_complementary = "=2"; /* exactly 2 non-option args: file, dev */ 56 opts =getopt32(argv, "v");61 /*opts =*/ getopt32(argv, "v"); 57 62 argv += optind; 58 63 // filename = *argv++; -
branches/3.2/mindi-busybox/miscutils/hdparm.c
r2725 r3232 12 12 * - by Mark Lord (C) 1994-2002 -- freely distributable 13 13 */ 14 15 //usage:#define hdparm_trivial_usage 16 //usage: "[OPTIONS] [DEVICE]" 17 //usage:#define hdparm_full_usage "\n\n" 18 //usage: " -a Get/set fs readahead" 19 //usage: "\n -A Set drive read-lookahead flag (0/1)" 20 //usage: "\n -b Get/set bus state (0 == off, 1 == on, 2 == tristate)" 21 //usage: "\n -B Set Advanced Power Management setting (1-255)" 22 //usage: "\n -c Get/set IDE 32-bit IO setting" 23 //usage: "\n -C Check IDE power mode status" 24 //usage: IF_FEATURE_HDPARM_HDIO_GETSET_DMA( 25 //usage: "\n -d Get/set using_dma flag") 26 //usage: "\n -D Enable/disable drive defect-mgmt" 27 //usage: "\n -f Flush buffer cache for device on exit" 28 //usage: "\n -g Display drive geometry" 29 //usage: "\n -h Display terse usage information" 30 //usage: IF_FEATURE_HDPARM_GET_IDENTITY( 31 //usage: "\n -i Display drive identification") 32 //usage: IF_FEATURE_HDPARM_GET_IDENTITY( 33 //usage: "\n -I Detailed/current information directly from drive") 34 //usage: "\n -k Get/set keep_settings_over_reset flag (0/1)" 35 //usage: "\n -K Set drive keep_features_over_reset flag (0/1)" 36 //usage: "\n -L Set drive doorlock (0/1) (removable harddisks only)" 37 //usage: "\n -m Get/set multiple sector count" 38 //usage: "\n -n Get/set ignore-write-errors flag (0/1)" 39 //usage: "\n -p Set PIO mode on IDE interface chipset (0,1,2,3,4,...)" 40 //usage: "\n -P Set drive prefetch count" 41 /* //usage: "\n -q Change next setting quietly" - not supported ib bbox */ 42 //usage: "\n -Q Get/set DMA tagged-queuing depth (if supported)" 43 //usage: "\n -r Get/set readonly flag (DANGEROUS to set)" 44 //usage: IF_FEATURE_HDPARM_HDIO_SCAN_HWIF( 45 //usage: "\n -R Register an IDE interface (DANGEROUS)") 46 //usage: "\n -S Set standby (spindown) timeout" 47 //usage: "\n -t Perform device read timings" 48 //usage: "\n -T Perform cache read timings" 49 //usage: "\n -u Get/set unmaskirq flag (0/1)" 50 //usage: IF_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF( 51 //usage: "\n -U Unregister an IDE interface (DANGEROUS)") 52 //usage: "\n -v Defaults; same as -mcudkrag for IDE drives" 53 //usage: "\n -V Display program version and exit immediately" 54 //usage: IF_FEATURE_HDPARM_HDIO_DRIVE_RESET( 55 //usage: "\n -w Perform device reset (DANGEROUS)") 56 //usage: "\n -W Set drive write-caching flag (0/1) (DANGEROUS)" 57 //usage: IF_FEATURE_HDPARM_HDIO_TRISTATE_HWIF( 58 //usage: "\n -x Tristate device for hotswap (0/1) (DANGEROUS)") 59 //usage: "\n -X Set IDE xfer mode (DANGEROUS)" 60 //usage: "\n -y Put IDE drive in standby mode" 61 //usage: "\n -Y Put IDE drive to sleep" 62 //usage: "\n -Z Disable Seagate auto-powersaving mode" 63 //usage: "\n -z Reread partition table" 64 14 65 #include "libbb.h" 15 66 /* must be _after_ libbb.h: */ … … 383 434 #define hwif_ctrl (G.hwif_ctrl ) 384 435 #define hwif_irq (G.hwif_irq ) 436 #define INIT_G() do { } while (0) 385 437 386 438 … … 971 1023 if ((like_std > 3) && (val[CMDS_SUPP_1] & 0x0008)) { 972 1024 /* We print out elsewhere whether the APM feature is enabled or 973 974 1025 * not. If it's not enabled, let's not repeat the info; just print 1026 * nothing here. */ 975 1027 printf("\tAdvancedPM level: "); 976 1028 if ((val[ADV_PWR] & 0xFF00) == 0x4000) { … … 987 1039 } 988 1040 } else { 989 1041 /* ATAPI */ 990 1042 if (eqpt != CDROM && (val[CAPAB_0] & SWRST_REQ)) 991 1043 printf("\tATA sw reset required\n"); … … 2008 2060 int c; 2009 2061 int flagcount = 0; 2062 2063 INIT_G(); 2010 2064 2011 2065 while ((c = getopt(argc, argv, hdparm_options)) >= 0) { -
branches/3.2/mindi-busybox/miscutils/inotifyd.c
r2725 r3232 27 27 * See below for mask names explanation. 28 28 */ 29 30 //usage:#define inotifyd_trivial_usage 31 //usage: "PROG FILE1[:MASK]..." 32 //usage:#define inotifyd_full_usage "\n\n" 33 //usage: "Run PROG on filesystem changes." 34 //usage: "\nWhen a filesystem event matching MASK occurs on FILEn," 35 //usage: "\nPROG ACTUAL_EVENTS FILEn [SUBFILE] is run." 36 //usage: "\nIf PROG is -, events are sent to stdout." 37 //usage: "\nEvents:" 38 //usage: "\n a File is accessed" 39 //usage: "\n c File is modified" 40 //usage: "\n e Metadata changed" 41 //usage: "\n w Writable file is closed" 42 //usage: "\n 0 Unwritable file is closed" 43 //usage: "\n r File is opened" 44 //usage: "\n D File is deleted" 45 //usage: "\n M File is moved" 46 //usage: "\n u Backing fs is unmounted" 47 //usage: "\n o Event queue overflowed" 48 //usage: "\n x File can't be watched anymore" 49 //usage: "\nIf watching a directory:" 50 //usage: "\n m Subfile is moved into dir" 51 //usage: "\n y Subfile is moved out of dir" 52 //usage: "\n n Subfile is created" 53 //usage: "\n d Subfile is deleted" 54 //usage: "\n" 55 //usage: "\ninotifyd waits for PROG to exit." 56 //usage: "\nWhen x event happens for all FILEs, inotifyd exits." 29 57 30 58 #include "libbb.h" … … 151 179 } 152 180 *s = '\0'; 153 // bb_error_msg("exec %s %08X\t%s\t%s\t%s", args[0], 154 // ie->mask, events, watches[ie->wd], ie->len ? ie->name : ""); 155 args[1] = events; 156 args[2] = watches[ie->wd]; 157 args[3] = ie->len ? ie->name : NULL; 158 spawn_and_wait((char **)args); 181 if (LONE_CHAR(args[0], '-')) { 182 /* "inotifyd - FILE": built-in echo */ 183 printf(ie->len ? "%s\t%s\t%s\n" : "%s\t%s\n", events, 184 watches[ie->wd], 185 ie->name); 186 fflush(stdout); 187 } else { 188 // bb_error_msg("exec %s %08X\t%s\t%s\t%s", args[0], 189 // ie->mask, events, watches[ie->wd], ie->len ? ie->name : ""); 190 args[1] = events; 191 args[2] = watches[ie->wd]; 192 args[3] = ie->len ? ie->name : NULL; 193 spawn_and_wait((char **)args); 194 } 159 195 // we are done if all files got final x event 160 196 if (ie->mask & 0x8000) { -
branches/3.2/mindi-busybox/miscutils/ionice.c
r2725 r3232 7 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 8 8 */ 9 10 //usage:#define ionice_trivial_usage 11 //usage: "[-c 1-3] [-n 0-7] [-p PID] [PROG]" 12 //usage:#define ionice_full_usage "\n\n" 13 //usage: "Change I/O priority and class\n" 14 //usage: "\n -c Class. 1:realtime 2:best-effort 3:idle" 15 //usage: "\n -n Priority" 9 16 10 17 #include <sys/syscall.h> -
branches/3.2/mindi-busybox/miscutils/last.c
r2725 r3232 8 8 */ 9 9 10 //usage:#define last_trivial_usage 11 //usage: ""IF_FEATURE_LAST_FANCY("[-HW] [-f FILE]") 12 //usage:#define last_full_usage "\n\n" 13 //usage: "Show listing of the last users that logged into the system" 14 //usage: IF_FEATURE_LAST_FANCY( "\n" 15 /* //usage: "\n -H Show header line" */ 16 //usage: "\n -W Display with no host column truncation" 17 //usage: "\n -f FILE Read from FILE instead of /var/log/wtmp" 18 //usage: ) 19 10 20 #include "libbb.h" 11 #include <utmp.h>12 21 13 22 /* NB: ut_name and ut_user are the same field, use only one name (ut_user) … … 63 72 64 73 printf("%-10s %-14s %-18s %-12.12s %s\n", 65 74 "USER", "TTY", "HOST", "LOGIN", "TIME"); 66 75 /* yikes. We reverse over the file and that is a not too elegant way */ 67 76 pos = xlseek(file, 0, SEEK_END); … … 123 132 t_tmp = (time_t)ut.ut_tv.tv_sec; 124 133 printf("%-10s %-14s %-18s %-12.12s\n", 125 134 ut.ut_user, ut.ut_line, ut.ut_host, ctime(&t_tmp) + 4); 126 135 next: 127 136 pos -= sizeof(ut); -
branches/3.2/mindi-busybox/miscutils/last_fancy.c
r2725 r3232 9 9 10 10 #include "libbb.h" 11 #include <utmp.h>12 11 13 12 /* NB: ut_name and ut_user are the same field, use only one name (ut_user) … … 95 94 96 95 printf(HEADER_FORMAT, 97 98 99 100 101 102 103 104 96 ut->ut_user, 97 ut->ut_line, 98 show_wide ? INET6_ADDRSTRLEN : INET_ADDRSTRLEN, 99 show_wide ? INET6_ADDRSTRLEN : INET_ADDRSTRLEN, 100 ut->ut_host, 101 login_time, 102 logout_str, 103 duration_str); 105 104 } 106 105 … … 163 162 time_t down_time; 164 163 int file; 165 unsigned opt;166 164 smallint going_down; 167 165 smallint boot_down; 168 166 169 opt =getopt32(argv, "Wf:" /* "H" */, &filename);167 /*opt =*/ getopt32(argv, "Wf:" /* "H" */, &filename); 170 168 #ifdef BUT_UTIL_LINUX_LAST_HAS_NO_SUCH_OPT 171 169 if (opt & LAST_OPT_H) { -
branches/3.2/mindi-busybox/miscutils/less.c
r2725 r3232 22 22 */ 23 23 24 //config:config LESS 25 //config: bool "less" 26 //config: default y 27 //config: help 28 //config: 'less' is a pager, meaning that it displays text files. It possesses 29 //config: a wide array of features, and is an improvement over 'more'. 30 //config: 31 //config:config FEATURE_LESS_MAXLINES 32 //config: int "Max number of input lines less will try to eat" 33 //config: default 9999999 34 //config: depends on LESS 35 //config: 36 //config:config FEATURE_LESS_BRACKETS 37 //config: bool "Enable bracket searching" 38 //config: default y 39 //config: depends on LESS 40 //config: help 41 //config: This option adds the capability to search for matching left and right 42 //config: brackets, facilitating programming. 43 //config: 44 //config:config FEATURE_LESS_FLAGS 45 //config: bool "Enable -m/-M" 46 //config: default y 47 //config: depends on LESS 48 //config: help 49 //config: The -M/-m flag enables a more sophisticated status line. 50 //config: 51 //config:config FEATURE_LESS_MARKS 52 //config: bool "Enable marks" 53 //config: default y 54 //config: depends on LESS 55 //config: help 56 //config: Marks enable positions in a file to be stored for easy reference. 57 //config: 58 //config:config FEATURE_LESS_REGEXP 59 //config: bool "Enable regular expressions" 60 //config: default y 61 //config: depends on LESS 62 //config: help 63 //config: Enable regular expressions, allowing complex file searches. 64 //config: 65 //config:config FEATURE_LESS_WINCH 66 //config: bool "Enable automatic resizing on window size changes" 67 //config: default y 68 //config: depends on LESS 69 //config: help 70 //config: Makes less track window size changes. 71 //config: 72 //config:config FEATURE_LESS_ASK_TERMINAL 73 //config: bool "Use 'tell me cursor position' ESC sequence to measure window" 74 //config: default y 75 //config: depends on FEATURE_LESS_WINCH 76 //config: help 77 //config: Makes less track window size changes. 78 //config: If terminal size can't be retrieved and $LINES/$COLUMNS are not set, 79 //config: this option makes less perform a last-ditch effort to find it: 80 //config: position cursor to 999,999 and ask terminal to report real 81 //config: cursor position using "ESC [ 6 n" escape sequence, then read stdin. 82 //config: 83 //config: This is not clean but helps a lot on serial lines and such. 84 //config: 85 //config:config FEATURE_LESS_DASHCMD 86 //config: bool "Enable flag changes ('-' command)" 87 //config: default y 88 //config: depends on LESS 89 //config: help 90 //config: This enables the ability to change command-line flags within 91 //config: less itself ('-' keyboard command). 92 //config: 93 //config:config FEATURE_LESS_LINENUMS 94 //config: bool "Enable dynamic switching of line numbers" 95 //config: default y 96 //config: depends on FEATURE_LESS_DASHCMD 97 //config: help 98 //config: Enables "-N" command. 99 100 //usage:#define less_trivial_usage 101 //usage: "[-E" IF_FEATURE_LESS_FLAGS("Mm") "Nh~I?] [FILE]..." 102 //usage:#define less_full_usage "\n\n" 103 //usage: "View FILE (or stdin) one screenful at a time\n" 104 //usage: "\n -E Quit once the end of a file is reached" 105 //usage: IF_FEATURE_LESS_FLAGS( 106 //usage: "\n -M,-m Display status line with line numbers" 107 //usage: "\n and percentage through the file" 108 //usage: ) 109 //usage: "\n -N Prefix line number to each line" 110 //usage: "\n -I Ignore case in all searches" 111 //usage: "\n -~ Suppress ~s displayed past EOF" 112 24 113 #include <sched.h> /* sched_yield() */ 25 114 … … 97 186 regex_t pattern; 98 187 smallint pattern_valid; 188 #endif 189 #if ENABLE_FEATURE_LESS_ASK_TERMINAL 190 smallint winsize_err; 99 191 #endif 100 192 smallint terminated; … … 618 710 619 711 /* Each part of the line that matches has the HIGHLIGHT 620 621 622 712 * and NORMAL escape sequences placed around it. 713 * NB: we regex against line, but insert text 714 * from quarantined copy (buf[]) */ 623 715 str = buf; 624 716 growline = NULL; … … 629 721 char *new = xasprintf("%s%.*s"HIGHLIGHT"%.*s"NORMAL, 630 722 growline ? growline : "", 631 match_structs.rm_so, str,632 match_structs.rm_eo - match_structs.rm_so,723 (int)match_structs.rm_so, str, 724 (int)(match_structs.rm_eo - match_structs.rm_so), 633 725 str + match_structs.rm_so); 634 726 free(growline); … … 805 897 max_lineno = 0; 806 898 open_file_and_read_lines(); 899 #if ENABLE_FEATURE_LESS_ASK_TERMINAL 900 if (G.winsize_err) 901 printf("\033[999;999H" "\033[6n"); 902 #endif 807 903 buffer_fill_and_print(); 808 904 } 809 905 810 static int getch_nowait(void)906 static int64_t getch_nowait(void) 811 907 { 812 908 int rd; 909 int64_t key64; 813 910 struct pollfd pfd[2]; 814 911 … … 858 955 /* We have kbd_fd in O_NONBLOCK mode, read inside read_key() 859 956 * would not block even if there is no input available */ 860 rd= read_key(kbd_fd, kbd_input, /*timeout off:*/ -2);861 if ( rd== -1) {957 key64 = read_key(kbd_fd, kbd_input, /*timeout off:*/ -2); 958 if ((int)key64 == -1) { 862 959 if (errno == EAGAIN) { 863 960 /* No keyboard input available. Since poll() did return, … … 871 968 } 872 969 set_tty_cooked(); 873 return rd;970 return key64; 874 971 } 875 972 … … 877 974 * May return KEYCODE_xxx values. 878 975 * Note that this function works best with raw input. */ 879 static int less_getch(int pos) 880 { 881 int i; 976 static int64_t less_getch(int pos) 977 { 978 int64_t key64; 979 int key; 882 980 883 981 again: 884 982 less_gets_pos = pos; 885 i= getch_nowait();983 key = key64 = getch_nowait(); 886 984 less_gets_pos = -1; 887 985 888 /* Discard Ctrl-something chars */ 889 if (i >= 0 && i < ' ' && i != 0x0d && i != 8) 986 /* Discard Ctrl-something chars. 987 * (checking only lower 32 bits is a size optimization: 988 * upper 32 bits are used only by KEYCODE_CURSOR_POS) 989 */ 990 if (key >= 0 && key < ' ' && key != 0x0d && key != 8) 890 991 goto again; 891 return i; 992 993 return key64; 892 994 } 893 995 … … 1429 1531 #endif 1430 1532 case 'r': case 'R': 1533 /* TODO: (1) also bind ^R, ^L to this? 1534 * (2) re-measure window size? 1535 */ 1431 1536 buffer_print(); 1432 1537 break; … … 1504 1609 int less_main(int argc, char **argv) 1505 1610 { 1506 int keypress;1507 1508 1611 INIT_G(); 1509 1612 … … 1548 1651 term_less.c_cc[VTIME] = 0; 1549 1652 1550 get_terminal_width_height(kbd_fd, &width, &max_displayed_line);1653 IF_FEATURE_LESS_ASK_TERMINAL(G.winsize_err =) get_terminal_width_height(kbd_fd, &width, &max_displayed_line); 1551 1654 /* 20: two tabstops + 4 */ 1552 1655 if (width < 20 || max_displayed_line < 3) … … 1563 1666 reinitialize(); 1564 1667 while (1) { 1668 int64_t keypress; 1669 1565 1670 #if ENABLE_FEATURE_LESS_WINCH 1566 1671 while (WINCH_COUNTER) { 1567 1672 again: 1568 1673 winch_counter--; 1569 get_terminal_width_height(kbd_fd, &width, &max_displayed_line); 1674 IF_FEATURE_LESS_ASK_TERMINAL(G.winsize_err =) get_terminal_width_height(kbd_fd, &width, &max_displayed_line); 1675 IF_FEATURE_LESS_ASK_TERMINAL(got_size:) 1570 1676 /* 20: two tabstops + 4 */ 1571 1677 if (width < 20) … … 1587 1693 * were there another SIGWINCH? */ 1588 1694 } 1589 #endif1590 1695 keypress = less_getch(-1); /* -1: do not position cursor */ 1696 # if ENABLE_FEATURE_LESS_ASK_TERMINAL 1697 if ((int32_t)keypress == KEYCODE_CURSOR_POS) { 1698 uint32_t rc = (keypress >> 32); 1699 width = (rc & 0x7fff); 1700 max_displayed_line = ((rc >> 16) & 0x7fff); 1701 goto got_size; 1702 } 1703 # endif 1704 #else 1705 keypress = less_getch(-1); /* -1: do not position cursor */ 1706 #endif 1591 1707 keypress_process(keypress); 1592 1708 } -
branches/3.2/mindi-busybox/miscutils/makedevs.c
r2725 r3232 7 7 * known bugs: can't deal with alpha ranges 8 8 */ 9 10 //usage:#if ENABLE_FEATURE_MAKEDEVS_LEAF 11 //usage:#define makedevs_trivial_usage 12 //usage: "NAME TYPE MAJOR MINOR FIRST LAST [s]" 13 //usage:#define makedevs_full_usage "\n\n" 14 //usage: "Create a range of block or character special files" 15 //usage: "\n" 16 //usage: "\nTYPE is:" 17 //usage: "\n b Block device" 18 //usage: "\n c Character device" 19 //usage: "\n f FIFO, MAJOR and MINOR are ignored" 20 //usage: "\n" 21 //usage: "\nFIRST..LAST specify numbers appended to NAME." 22 //usage: "\nIf 's' is the last argument, the base device is created as well." 23 //usage: "\n" 24 //usage: "\nExamples:" 25 //usage: "\n makedevs /dev/ttyS c 4 66 2 63 -> ttyS2-ttyS63" 26 //usage: "\n makedevs /dev/hda b 3 0 0 8 s -> hda,hda1-hda8" 27 //usage: 28 //usage:#define makedevs_example_usage 29 //usage: "# makedevs /dev/ttyS c 4 66 2 63\n" 30 //usage: "[creates ttyS2-ttyS63]\n" 31 //usage: "# makedevs /dev/hda b 3 0 0 8 s\n" 32 //usage: "[creates hda,hda1-hda8]\n" 33 //usage:#endif 34 //usage: 35 //usage:#if ENABLE_FEATURE_MAKEDEVS_TABLE 36 //usage:#define makedevs_trivial_usage 37 //usage: "[-d device_table] rootdir" 38 //usage:#define makedevs_full_usage "\n\n" 39 //usage: "Create a range of special files as specified in a device table.\n" 40 //usage: "Device table entries take the form of:\n" 41 //usage: "<name> <type> <mode> <uid> <gid> <major> <minor> <start> <inc> <count>\n" 42 //usage: "Where name is the file name, type can be one of:\n" 43 //usage: " f Regular file\n" 44 //usage: " d Directory\n" 45 //usage: " c Character device\n" 46 //usage: " b Block device\n" 47 //usage: " p Fifo (named pipe)\n" 48 //usage: "uid is the user id for the target file, gid is the group id for the\n" 49 //usage: "target file. The rest of the entries (major, minor, etc) apply to\n" 50 //usage: "to device special files. A '-' may be used for blank entries." 51 //usage: 52 //usage:#define makedevs_example_usage 53 //usage: "For example:\n" 54 //usage: "<name> <type> <mode><uid><gid><major><minor><start><inc><count>\n" 55 //usage: "/dev d 755 0 0 - - - - -\n" 56 //usage: "/dev/console c 666 0 0 5 1 - - -\n" 57 //usage: "/dev/null c 666 0 0 1 3 0 0 -\n" 58 //usage: "/dev/zero c 666 0 0 1 5 0 0 -\n" 59 //usage: "/dev/hda b 640 0 0 3 0 0 0 -\n" 60 //usage: "/dev/hda b 640 0 0 3 1 1 1 15\n\n" 61 //usage: "Will Produce:\n" 62 //usage: "/dev\n" 63 //usage: "/dev/console\n" 64 //usage: "/dev/null\n" 65 //usage: "/dev/zero\n" 66 //usage: "/dev/hda\n" 67 //usage: "/dev/hda[0-15]\n" 68 //usage:#endif 9 69 10 70 #include "libbb.h" -
branches/3.2/mindi-busybox/miscutils/man.c
r2725 r3232 3 3 * Licensed under GPLv2, see file LICENSE in this source tree. 4 4 */ 5 6 //usage:#define man_trivial_usage 7 //usage: "[-aw] [MANPAGE]..." 8 //usage:#define man_full_usage "\n\n" 9 //usage: "Format and display manual page\n" 10 //usage: "\n -a Display all pages" 11 //usage: "\n -w Show page locations" 5 12 6 13 #include "libbb.h" … … 23 30 24 31 */ 25 26 #if ENABLE_FEATURE_SEAMLESS_LZMA27 #define Z_SUFFIX ".lzma"28 #elif ENABLE_FEATURE_SEAMLESS_BZ229 #define Z_SUFFIX ".bz2"30 #elif ENABLE_FEATURE_SEAMLESS_GZ31 #define Z_SUFFIX ".gz"32 #else33 #define Z_SUFFIX ""34 #endif35 32 36 33 static int show_manpage(const char *pager, char *man_filename, int man, int level); … … 96 93 /* Links do not have .gz extensions, even if manpage 97 94 * is compressed */ 98 man_filename = xasprintf("%s/%s" Z_SUFFIX, man_filename, linkname);95 man_filename = xasprintf("%s/%s", man_filename, linkname); 99 96 free(line); 100 97 /* Note: we leak "new" man_filename string as well... */ … … 118 115 } 119 116 120 /* man_filename is of the form "/dir/dir/dir/name.s" Z_SUFFIX*/117 /* man_filename is of the form "/dir/dir/dir/name.s" */ 121 118 static int show_manpage(const char *pager, char *man_filename, int man, int level) 122 119 { 120 #if SEAMLESS_COMPRESSION 121 /* We leak this allocation... */ 122 char *filename_with_zext = xasprintf("%s.lzma", man_filename); 123 char *ext = strrchr(filename_with_zext, '.') + 1; 124 #endif 125 123 126 #if ENABLE_FEATURE_SEAMLESS_LZMA 124 if (run_pipe(pager, man_filename, man, level)) 125 return 1; 126 #endif 127 127 if (run_pipe(pager, filename_with_zext, man, level)) 128 return 1; 129 #endif 130 #if ENABLE_FEATURE_SEAMLESS_XZ 131 strcpy(ext, "xz"); 132 if (run_pipe(pager, filename_with_zext, man, level)) 133 return 1; 134 #endif 128 135 #if ENABLE_FEATURE_SEAMLESS_BZ2 129 #if ENABLE_FEATURE_SEAMLESS_LZMA 130 strcpy(strrchr(man_filename, '.') + 1, "bz2"); 131 #endif 132 if (run_pipe(pager, man_filename, man, level)) 133 return 1; 134 #endif 135 136 strcpy(ext, "bz2"); 137 if (run_pipe(pager, filename_with_zext, man, level)) 138 return 1; 139 #endif 136 140 #if ENABLE_FEATURE_SEAMLESS_GZ 137 #if ENABLE_FEATURE_SEAMLESS_LZMA || ENABLE_FEATURE_SEAMLESS_BZ2 138 strcpy(strrchr(man_filename, '.') + 1, "gz"); 139 #endif 140 if (run_pipe(pager, man_filename, man, level)) 141 return 1; 142 #endif 143 144 #if ENABLE_FEATURE_SEAMLESS_LZMA || ENABLE_FEATURE_SEAMLESS_BZ2 || ENABLE_FEATURE_SEAMLESS_GZ 145 *strrchr(man_filename, '.') = '\0'; 146 #endif 147 if (run_pipe(pager, man_filename, man, level)) 148 return 1; 149 150 return 0; 141 strcpy(ext, "gz"); 142 if (run_pipe(pager, filename_with_zext, man, level)) 143 return 1; 144 #endif 145 146 return run_pipe(pager, man_filename, man, level); 151 147 } 152 148 … … 256 252 while (cat0man1 < 2) { 257 253 int found_here; 258 man_filename = xasprintf("%s/%s%.*s/%s.%.*s" Z_SUFFIX,254 man_filename = xasprintf("%s/%s%.*s/%s.%.*s", 259 255 cur_path, 260 256 "cat\0man" + (cat0man1 * 4), -
branches/3.2/mindi-busybox/miscutils/microcom.c
r2725 r3232 8 8 * Licensed under GPLv2, see file LICENSE in this source tree. 9 9 */ 10 11 //usage:#define microcom_trivial_usage 12 //usage: "[-d DELAY] [-t TIMEOUT] [-s SPEED] [-X] TTY" 13 //usage:#define microcom_full_usage "\n\n" 14 //usage: "Copy bytes for stdin to TTY and from TTY to stdout\n" 15 //usage: "\n -d Wait up to DELAY ms for TTY output before sending every" 16 //usage: "\n next byte to it" 17 //usage: "\n -t Exit if both stdin and TTY are silent for TIMEOUT ms" 18 //usage: "\n -s Set serial line to SPEED" 19 //usage: "\n -X Disable special meaning of NUL and Ctrl-X from stdin" 20 10 21 #include "libbb.h" 11 22 -
branches/3.2/mindi-busybox/miscutils/mountpoint.c
r2725 r3232 9 9 * Based on sysvinit's mountpoint 10 10 */ 11 12 //usage:#define mountpoint_trivial_usage 13 //usage: "[-q] <[-dn] DIR | -x DEVICE>" 14 //usage:#define mountpoint_full_usage "\n\n" 15 //usage: "Check if the directory is a mountpoint\n" 16 //usage: "\n -q Quiet" 17 //usage: "\n -d Print major/minor device number of the filesystem" 18 //usage: "\n -n Print device name of the filesystem" 19 //usage: "\n -x Print major/minor device number of the blockdevice" 20 //usage: 21 //usage:#define mountpoint_example_usage 22 //usage: "$ mountpoint /proc\n" 23 //usage: "/proc is not a mountpoint\n" 24 //usage: "$ mountpoint /sys\n" 25 //usage: "/sys is a mountpoint\n" 11 26 12 27 #include "libbb.h" -
branches/3.2/mindi-busybox/miscutils/mt.c
r2725 r3232 3 3 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 4 4 */ 5 6 //usage:#define mt_trivial_usage 7 //usage: "[-f device] opcode value" 8 //usage:#define mt_full_usage "\n\n" 9 //usage: "Control magnetic tape drive operation\n" 10 //usage: "\n" 11 //usage: "Available Opcodes:\n" 12 //usage: "\n" 13 //usage: "bsf bsfm bsr bss datacompression drvbuffer eof eom erase\n" 14 //usage: "fsf fsfm fsr fss load lock mkpart nop offline ras1 ras2\n" 15 //usage: "ras3 reset retension rewind rewoffline seek setblk setdensity\n" 16 //usage: "setpart tell unload unlock weof wset" 5 17 6 18 #include "libbb.h" -
branches/3.2/mindi-busybox/miscutils/nandwrite.c
r2725 r3232 9 9 */ 10 10 11 //applet:IF_NANDWRITE(APPLET(nandwrite, _BB_DIR_USR_SBIN, _BB_SUID_DROP))12 //applet:IF_NANDWRITE(APPLET_ODDNAME(nanddump, nandwrite, _BB_DIR_USR_SBIN, _BB_SUID_DROP, nanddump))13 14 //kbuild:lib-$(CONFIG_NANDWRITE) += nandwrite.o15 //kbuild:lib-$(CONFIG_NANDDUMP) += nandwrite.o16 17 11 //config:config NANDWRITE 18 12 //config: bool "nandwrite" 19 //config: default n20 //config: depends onPLATFORM_LINUX13 //config: default y 14 //config: select PLATFORM_LINUX 21 15 //config: help 22 16 //config: Write to the specified MTD device, with bad blocks awareness … … 24 18 //config:config NANDDUMP 25 19 //config: bool "nanddump" 26 //config: default n27 //config: depends onPLATFORM_LINUX20 //config: default y 21 //config: select PLATFORM_LINUX 28 22 //config: help 29 23 //config: Dump the content of raw NAND chip 24 25 //applet:IF_NANDWRITE(APPLET(nandwrite, BB_DIR_USR_SBIN, BB_SUID_DROP)) 26 //applet:IF_NANDWRITE(APPLET_ODDNAME(nanddump, nandwrite, BB_DIR_USR_SBIN, BB_SUID_DROP, nanddump)) 27 28 //kbuild:lib-$(CONFIG_NANDWRITE) += nandwrite.o 29 //kbuild:lib-$(CONFIG_NANDDUMP) += nandwrite.o 30 30 31 31 //usage:#define nandwrite_trivial_usage … … 33 33 //usage:#define nandwrite_full_usage "\n\n" 34 34 //usage: "Write to the specified MTD device\n" 35 //usage: "\nOptions:"36 35 //usage: "\n -p Pad to page size" 37 36 //usage: "\n -s ADDR Start address" … … 40 39 //usage: "[-o] [-b] [-s ADDR] [-f FILE] MTD_DEVICE" 41 40 //usage:#define nanddump_full_usage "\n\n" 42 //usage: "Dump the sepcified MTD device\n" 43 //usage: "\nOptions:" 44 //usage: "\n -o Omit oob data" 41 //usage: "Dump the specified MTD device\n" 42 //usage: "\n -o Dump oob data" 45 43 //usage: "\n -b Omit bad block from the dump" 46 44 //usage: "\n -s ADDR Start address" … … 132 130 } 133 131 134 fd = xopen(argv[0], O_RDWR);132 fd = xopen(argv[0], IS_NANDWRITE ? O_RDWR : O_RDONLY); 135 133 xioctl(fd, MEMGETINFO, &meminfo); 136 134 … … 165 163 if (tmp != blockstart) { 166 164 /* bad block(s), advance mtdoffset */ 167 if (IS_NANDDUMP & !(opts & OPT_b)) {165 if (IS_NANDDUMP && !(opts & OPT_b)) { 168 166 int bad_len = MIN(tmp, end_addr) - mtdoffset; 169 dump_bad(&meminfo, bad_len, !(opts & OPT_o));167 dump_bad(&meminfo, bad_len, opts & OPT_o); 170 168 } 171 169 mtdoffset = tmp; … … 185 183 if (IS_NANDWRITE) 186 184 printf("Writing at 0x%08x\n", mtdoffset); 187 else if (mtdoffset > blockstart ) {185 else if (mtdoffset > blockstart && !(opts & OPT_b)) { 188 186 int bad_len = MIN(mtdoffset, limit) - blockstart; 189 dump_bad(&meminfo, bad_len, !(opts & OPT_o));187 dump_bad(&meminfo, bad_len, opts & OPT_o); 190 188 } 191 189 if (mtdoffset >= limit) … … 213 211 xwrite(output_fd, filebuf, meminfo_writesize); 214 212 215 if (IS_NANDDUMP && !(opts & OPT_o)) {213 if (IS_NANDDUMP && (opts & OPT_o)) { 216 214 /* Dump OOB data */ 217 215 oob.start = mtdoffset; -
branches/3.2/mindi-busybox/miscutils/raidautorun.c
r2725 r3232 8 8 * 9 9 */ 10 11 //usage:#define raidautorun_trivial_usage 12 //usage: "DEVICE" 13 //usage:#define raidautorun_full_usage "\n\n" 14 //usage: "Tell the kernel to automatically search and start RAID arrays" 15 //usage: 16 //usage:#define raidautorun_example_usage 17 //usage: "$ raidautorun /dev/md0" 10 18 11 19 #include "libbb.h" -
branches/3.2/mindi-busybox/miscutils/readahead.c
r2725 r3232 10 10 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 11 11 */ 12 13 //usage:#define readahead_trivial_usage 14 //usage: "[FILE]..." 15 //usage:#define readahead_full_usage "\n\n" 16 //usage: "Preload FILEs to RAM" 12 17 13 18 #include "libbb.h" -
branches/3.2/mindi-busybox/miscutils/rfkill.c
r2725 r3232 7 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 8 8 */ 9 10 //usage:#define rfkill_trivial_usage 11 //usage: "COMMAND [INDEX|TYPE]" 12 //usage:#define rfkill_full_usage "\n\n" 13 //usage: "Enable/disable wireless devices\n" 14 //usage: "\nCommands:" 15 //usage: "\n list [INDEX|TYPE] List current state" 16 //usage: "\n block INDEX|TYPE Disable device" 17 //usage: "\n unblock INDEX|TYPE Enable device" 18 //usage: "\n" 19 //usage: "\n TYPE: all, wlan(wifi), bluetooth, uwb(ultrawideband)," 20 //usage: "\n wimax, wwan, gps, fm" 21 9 22 #include "libbb.h" 10 23 #include <linux/rfkill.h> -
branches/3.2/mindi-busybox/miscutils/runlevel.c
r2725 r3232 12 12 * initially busyboxified by Bernhard Reutner-Fischer 13 13 */ 14 15 //usage:#define runlevel_trivial_usage 16 //usage: "[FILE]" 17 //usage:#define runlevel_full_usage "\n\n" 18 //usage: "Find the current and previous system runlevel\n" 19 //usage: "\n" 20 //usage: "If no utmp FILE exists or if no runlevel record can be found,\n" 21 //usage: "print \"unknown\"" 22 //usage: 23 //usage:#define runlevel_example_usage 24 //usage: "$ runlevel /var/run/utmp\n" 25 //usage: "N 2" 26 14 27 #include "libbb.h" 15 #include <utmp.h>16 28 17 29 int runlevel_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; -
branches/3.2/mindi-busybox/miscutils/rx.c
r2725 r3232 15 15 * This was originally written for blob and then adapted for busybox. 16 16 */ 17 18 //usage:#define rx_trivial_usage 19 //usage: "FILE" 20 //usage:#define rx_full_usage "\n\n" 21 //usage: "Receive a file using the xmodem protocol" 22 //usage: 23 //usage:#define rx_example_usage 24 //usage: "$ rx /tmp/foo\n" 17 25 18 26 #include "libbb.h" … … 101 109 } 102 110 /* Write previously received block */ 103 if (blockLength) { 104 errno = 0; 105 if (full_write(file_fd, blockBuf, blockLength) != blockLength) { 106 bb_perror_msg("can't write to file"); 107 goto fatal; 108 } 111 errno = 0; 112 if (full_write(file_fd, blockBuf, blockLength) != blockLength) { 113 bb_perror_msg(bb_msg_write_error); 114 goto fatal; 109 115 } 110 116 … … 148 154 } 149 155 156 cksum_or_crc = read_byte(TIMEOUT); 157 if (cksum_or_crc < 0) 158 goto timeout; 150 159 if (do_crc) { 151 cksum_or_crc = read_byte(TIMEOUT);152 if (cksum_or_crc < 0)153 goto timeout;154 160 cksum_or_crc = (cksum_or_crc << 8) | read_byte(TIMEOUT); 155 if (cksum_or_crc < 0)156 goto timeout;157 } else {158 cksum_or_crc = read_byte(TIMEOUT);159 161 if (cksum_or_crc < 0) 160 162 goto timeout; … … 165 167 /* this also ignores the initial block 0 which is */ 166 168 /* meta data. */ 169 blockLength = 0; 167 170 goto next; 168 171 } … … 191 194 if (cksum_or_crc != expected) { 192 195 bb_error_msg(do_crc ? "crc error, expected 0x%04x, got 0x%04x" 193 194 196 : "checksum error, expected 0x%02x, got 0x%02x", 197 expected, cksum_or_crc); 195 198 goto error; 196 199 } … … 205 208 error: 206 209 timeout: 210 blockLength = 0; 207 211 errors++; 208 212 if (errors == MAXERRORS) { -
branches/3.2/mindi-busybox/miscutils/setsid.c
r2725 r3232 14 14 * - busyboxed 15 15 */ 16 17 //usage:#define setsid_trivial_usage 18 //usage: "PROG ARGS" 19 //usage:#define setsid_full_usage "\n\n" 20 //usage: "Run PROG in a new session. PROG will have no controlling terminal\n" 21 //usage: "and will not be affected by keyboard signals (Ctrl-C etc).\n" 22 //usage: "See setsid(2) for details." 16 23 17 24 #include "libbb.h" -
branches/3.2/mindi-busybox/miscutils/strings.c
r2725 r3232 7 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 8 8 */ 9 10 //usage:#define strings_trivial_usage 11 //usage: "[-afo] [-n LEN] [FILE]..." 12 //usage:#define strings_full_usage "\n\n" 13 //usage: "Display printable strings in a binary file\n" 14 //usage: "\n -a Scan whole file (default)" 15 //usage: "\n -f Precede strings with filenames" 16 //usage: "\n -n LEN At least LEN characters form a string (default 4)" 17 //usage: "\n -o Precede strings with decimal offsets" 9 18 10 19 #include "libbb.h" -
branches/3.2/mindi-busybox/miscutils/taskset.c
r2725 r3232 6 6 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 7 7 */ 8 9 //usage:#define taskset_trivial_usage 10 //usage: "[-p] [MASK] [PID | PROG ARGS]" 11 //usage:#define taskset_full_usage "\n\n" 12 //usage: "Set or get CPU affinity\n" 13 //usage: "\n -p Operate on an existing PID" 14 //usage: 15 //usage:#define taskset_example_usage 16 //usage: "$ taskset 0x7 ./dgemm_test&\n" 17 //usage: "$ taskset -p 0x1 $!\n" 18 //usage: "pid 4790's current affinity mask: 7\n" 19 //usage: "pid 4790's new affinity mask: 1\n" 20 //usage: "$ taskset 0x7 /bin/sh -c './taskset -p 0x1 $$'\n" 21 //usage: "pid 6671's current affinity mask: 1\n" 22 //usage: "pid 6671's new affinity mask: 1\n" 23 //usage: "$ taskset -p 1\n" 24 //usage: "pid 1's current affinity mask: 3\n" 8 25 9 26 #include <sched.h> -
branches/3.2/mindi-busybox/miscutils/time.c
r2725 r3232 10 10 */ 11 11 12 //usage:#define time_trivial_usage 13 //usage: "[-v] PROG ARGS" 14 //usage:#define time_full_usage "\n\n" 15 //usage: "Run PROG, display resource usage when it exits\n" 16 //usage: "\n -v Verbose" 17 12 18 #include "libbb.h" 19 #include <sys/resource.h> /* getrusage */ 13 20 14 21 /* Information on the resources used by a child process. */ … … 64 71 65 72 /* Ignore signals, but don't ignore the children. When wait3 66 73 * returns the child process, set the time the command finished. */ 67 74 while ((caught = wait3(&resp->waitstatus, 0, &resp->ru)) != pid) { 68 75 if (caught == -1 && errno != EINTR) { -
branches/3.2/mindi-busybox/miscutils/timeout.c
r2725 r3232 28 28 * rewrite 14-11-2008 vda 29 29 */ 30 31 //usage:#define timeout_trivial_usage 32 //usage: "[-t SECS] [-s SIG] PROG ARGS" 33 //usage:#define timeout_full_usage "\n\n" 34 //usage: "Runs PROG. Sends SIG to it if it is not gone in SECS seconds.\n" 35 //usage: "Defaults: SECS: 10, SIG: TERM." 30 36 31 37 #include "libbb.h" … … 84 90 /* Here we are grandchild. Sleep, then kill grandparent */ 85 91 grandchild: 86 /* Just sleep( NUGE_NUM); kill(parent) may kill wrong process! */92 /* Just sleep(HUGE_NUM); kill(parent) may kill wrong process! */ 87 93 while (1) { 88 94 sleep(1); -
branches/3.2/mindi-busybox/miscutils/ttysize.c
r2725 r3232 10 10 * Licensed under GPLv2, see file LICENSE in this source tree. 11 11 */ 12 13 //usage:#define ttysize_trivial_usage 14 //usage: "[w] [h]" 15 //usage:#define ttysize_full_usage "\n\n" 16 //usage: "Print dimension(s) of stdin's terminal, on error return 80x25" 17 12 18 #include "libbb.h" 13 19 -
branches/3.2/mindi-busybox/miscutils/volname.c
r2725 r3232 28 28 * Matthew Stoltenberg <d3matt@gmail.com> 29 29 */ 30 31 //usage:#define volname_trivial_usage 32 //usage: "[DEVICE]" 33 //usage:#define volname_full_usage "\n\n" 34 //usage: "Show CD volume name of the DEVICE (default /dev/cdrom)" 35 30 36 #include "libbb.h" 31 37 -
branches/3.2/mindi-busybox/miscutils/wall.c
r2725 r3232 7 7 */ 8 8 9 //usage:#define wall_trivial_usage 10 //usage: "[FILE]" 11 //usage:#define wall_full_usage "\n\n" 12 //usage: "Write content of FILE or stdin to all logged-in users" 13 //usage: 14 //usage:#define wall_sample_usage 15 //usage: "echo foo | wall\n" 16 //usage: "wall ./mymessage" 17 9 18 #include "libbb.h" 10 #include <utmp.h>11 19 12 20 int wall_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; -
branches/3.2/mindi-busybox/miscutils/watchdog.c
r2725 r3232 9 9 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 10 10 */ 11 12 //usage:#define watchdog_trivial_usage 13 //usage: "[-t N[ms]] [-T N[ms]] [-F] DEV" 14 //usage:#define watchdog_full_usage "\n\n" 15 //usage: "Periodically write to watchdog device DEV\n" 16 //usage: "\n -T N Reboot after N seconds if not reset (default 60)" 17 //usage: "\n -t N Reset every N seconds (default 30)" 18 //usage: "\n -F Run in foreground" 19 //usage: "\n" 20 //usage: "\nUse 500ms to specify period in milliseconds" 11 21 12 22 #include "libbb.h" … … 22 32 static const char V = 'V'; 23 33 34 remove_pidfile(CONFIG_PID_FILE_PATH "/watchdog.pid"); 24 35 write(3, &V, 1); /* Magic, see watchdog-api.txt in kernel */ 25 36 if (ENABLE_FEATURE_CLEAN_UP) … … 86 97 #endif 87 98 99 write_pidfile(CONFIG_PID_FILE_PATH "/watchdog.pid"); 100 88 101 while (1) { 89 102 /*
Note:
See TracChangeset
for help on using the changeset viewer.