diff options
author | Ron Yorston <rmy@pobox.com> | 2020-01-08 12:30:49 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2020-01-08 12:30:49 +0000 |
commit | a9271a8e97e6e7be5285330d5f19352decabf807 (patch) | |
tree | bf3c4464c369a15a46454792dac167505f74769f /shell/shell_common.c | |
parent | b0b7ab792bc1f45963f4b84b94faaf05054e1613 (diff) | |
parent | 9ec836c033fc6e55e80f3309b3e05acdf09bb297 (diff) | |
download | busybox-w32-a9271a8e97e6e7be5285330d5f19352decabf807.tar.gz busybox-w32-a9271a8e97e6e7be5285330d5f19352decabf807.tar.bz2 busybox-w32-a9271a8e97e6e7be5285330d5f19352decabf807.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'shell/shell_common.c')
-rw-r--r-- | shell/shell_common.c | 77 |
1 files changed, 59 insertions, 18 deletions
diff --git a/shell/shell_common.c b/shell/shell_common.c index 06a6b6e5f..be69ff249 100644 --- a/shell/shell_common.c +++ b/shell/shell_common.c | |||
@@ -371,52 +371,91 @@ shell_builtin_read(struct builtin_read_params *params) | |||
371 | struct limits { | 371 | struct limits { |
372 | uint8_t cmd; /* RLIMIT_xxx fit into it */ | 372 | uint8_t cmd; /* RLIMIT_xxx fit into it */ |
373 | uint8_t factor_shift; /* shift by to get rlim_{cur,max} values */ | 373 | uint8_t factor_shift; /* shift by to get rlim_{cur,max} values */ |
374 | const char *name; | ||
375 | }; | 374 | }; |
376 | 375 | ||
377 | static const struct limits limits_tbl[] = { | 376 | static const struct limits limits_tbl[] = { |
378 | { RLIMIT_CORE, 9, "core file size (blocks)" }, // -c | 377 | { RLIMIT_CORE, 9, }, // -c |
379 | { RLIMIT_DATA, 10, "data seg size (kb)" }, // -d | 378 | { RLIMIT_DATA, 10, }, // -d |
380 | { RLIMIT_NICE, 0, "scheduling priority" }, // -e | 379 | { RLIMIT_NICE, 0, }, // -e |
381 | { RLIMIT_FSIZE, 9, "file size (blocks)" }, // -f | 380 | { RLIMIT_FSIZE, 9, }, // -f |
382 | #define LIMIT_F_IDX 3 | 381 | #define LIMIT_F_IDX 3 |
383 | #ifdef RLIMIT_SIGPENDING | 382 | #ifdef RLIMIT_SIGPENDING |
384 | { RLIMIT_SIGPENDING, 0, "pending signals" }, // -i | 383 | { RLIMIT_SIGPENDING, 0, }, // -i |
385 | #endif | 384 | #endif |
386 | #ifdef RLIMIT_MEMLOCK | 385 | #ifdef RLIMIT_MEMLOCK |
387 | { RLIMIT_MEMLOCK, 10, "max locked memory (kb)" }, // -l | 386 | { RLIMIT_MEMLOCK, 10, }, // -l |
388 | #endif | 387 | #endif |
389 | #ifdef RLIMIT_RSS | 388 | #ifdef RLIMIT_RSS |
390 | { RLIMIT_RSS, 10, "max memory size (kb)" }, // -m | 389 | { RLIMIT_RSS, 10, }, // -m |
391 | #endif | 390 | #endif |
392 | #ifdef RLIMIT_NOFILE | 391 | #ifdef RLIMIT_NOFILE |
393 | { RLIMIT_NOFILE, 0, "open files" }, // -n | 392 | { RLIMIT_NOFILE, 0, }, // -n |
394 | #endif | 393 | #endif |
395 | #ifdef RLIMIT_MSGQUEUE | 394 | #ifdef RLIMIT_MSGQUEUE |
396 | { RLIMIT_MSGQUEUE, 0, "POSIX message queues (bytes)" }, // -q | 395 | { RLIMIT_MSGQUEUE, 0, }, // -q |
397 | #endif | 396 | #endif |
398 | #ifdef RLIMIT_RTPRIO | 397 | #ifdef RLIMIT_RTPRIO |
399 | { RLIMIT_RTPRIO, 0, "real-time priority" }, // -r | 398 | { RLIMIT_RTPRIO, 0, }, // -r |
400 | #endif | 399 | #endif |
401 | #ifdef RLIMIT_STACK | 400 | #ifdef RLIMIT_STACK |
402 | { RLIMIT_STACK, 10, "stack size (kb)" }, // -s | 401 | { RLIMIT_STACK, 10, }, // -s |
403 | #endif | 402 | #endif |
404 | #ifdef RLIMIT_CPU | 403 | #ifdef RLIMIT_CPU |
405 | { RLIMIT_CPU, 0, "cpu time (seconds)" }, // -t | 404 | { RLIMIT_CPU, 0, }, // -t |
406 | #endif | 405 | #endif |
407 | #ifdef RLIMIT_NPROC | 406 | #ifdef RLIMIT_NPROC |
408 | { RLIMIT_NPROC, 0, "max user processes" }, // -u | 407 | { RLIMIT_NPROC, 0, }, // -u |
409 | #endif | 408 | #endif |
410 | #ifdef RLIMIT_AS | 409 | #ifdef RLIMIT_AS |
411 | { RLIMIT_AS, 10, "virtual memory (kb)" }, // -v | 410 | { RLIMIT_AS, 10, }, // -v |
412 | #endif | 411 | #endif |
413 | #ifdef RLIMIT_LOCKS | 412 | #ifdef RLIMIT_LOCKS |
414 | { RLIMIT_LOCKS, 0, "file locks" }, // -x | 413 | { RLIMIT_LOCKS, 0, }, // -x |
415 | #endif | 414 | #endif |
416 | }; | 415 | }; |
417 | // bash also shows: | 416 | // bash also shows: |
418 | //pipe size (512 bytes, -p) 8 | 417 | //pipe size (512 bytes, -p) 8 |
419 | 418 | ||
419 | static const char limits_help[] ALIGN1 = | ||
420 | "core file size (blocks)" // -c | ||
421 | "\0""data seg size (kb)" // -d | ||
422 | "\0""scheduling priority" // -e | ||
423 | "\0""file size (blocks)" // -f | ||
424 | #ifdef RLIMIT_SIGPENDING | ||
425 | "\0""pending signals" // -i | ||
426 | #endif | ||
427 | #ifdef RLIMIT_MEMLOCK | ||
428 | "\0""max locked memory (kb)" // -l | ||
429 | #endif | ||
430 | #ifdef RLIMIT_RSS | ||
431 | "\0""max memory size (kb)" // -m | ||
432 | #endif | ||
433 | #ifdef RLIMIT_NOFILE | ||
434 | "\0""open files" // -n | ||
435 | #endif | ||
436 | #ifdef RLIMIT_MSGQUEUE | ||
437 | "\0""POSIX message queues (bytes)" // -q | ||
438 | #endif | ||
439 | #ifdef RLIMIT_RTPRIO | ||
440 | "\0""real-time priority" // -r | ||
441 | #endif | ||
442 | #ifdef RLIMIT_STACK | ||
443 | "\0""stack size (kb)" // -s | ||
444 | #endif | ||
445 | #ifdef RLIMIT_CPU | ||
446 | "\0""cpu time (seconds)" // -t | ||
447 | #endif | ||
448 | #ifdef RLIMIT_NPROC | ||
449 | "\0""max user processes" // -u | ||
450 | #endif | ||
451 | #ifdef RLIMIT_AS | ||
452 | "\0""virtual memory (kb)" // -v | ||
453 | #endif | ||
454 | #ifdef RLIMIT_LOCKS | ||
455 | "\0""file locks" // -x | ||
456 | #endif | ||
457 | ; | ||
458 | |||
420 | static const char limit_chars[] ALIGN1 = | 459 | static const char limit_chars[] ALIGN1 = |
421 | "c" | 460 | "c" |
422 | "d" | 461 | "d" |
@@ -607,10 +646,12 @@ shell_builtin_ulimit(char **argv) | |||
607 | if (!(opts & (OPT_hard | OPT_soft))) | 646 | if (!(opts & (OPT_hard | OPT_soft))) |
608 | opts |= (OPT_hard | OPT_soft); | 647 | opts |= (OPT_hard | OPT_soft); |
609 | if (opts & OPT_all) { | 648 | if (opts & OPT_all) { |
649 | const char *help = limits_help; | ||
610 | for (i = 0; i < ARRAY_SIZE(limits_tbl); i++) { | 650 | for (i = 0; i < ARRAY_SIZE(limits_tbl); i++) { |
611 | getrlimit(limits_tbl[i].cmd, &limit); | 651 | getrlimit(limits_tbl[i].cmd, &limit); |
612 | printf("%-32s(-%c) ", limits_tbl[i].name, limit_chars[i]); | 652 | printf("%-32s(-%c) ", help, limit_chars[i]); |
613 | printlim(opts, &limit, &limits_tbl[i]); | 653 | printlim(opts, &limit, &limits_tbl[i]); |
654 | help += strlen(help) + 1; | ||
614 | } | 655 | } |
615 | return EXIT_SUCCESS; | 656 | return EXIT_SUCCESS; |
616 | } | 657 | } |
@@ -641,7 +682,7 @@ shell_builtin_ulimit(char **argv) | |||
641 | getrlimit(limits_tbl[i].cmd, &limit); | 682 | getrlimit(limits_tbl[i].cmd, &limit); |
642 | if (!val_str) { | 683 | if (!val_str) { |
643 | if (opt_cnt > 1) | 684 | if (opt_cnt > 1) |
644 | printf("%-32s(-%c) ", limits_tbl[i].name, limit_chars[i]); | 685 | printf("%-32s(-%c) ", nth_string(limits_help, i), limit_chars[i]); |
645 | printlim(opts, &limit, &limits_tbl[i]); | 686 | printlim(opts, &limit, &limits_tbl[i]); |
646 | } else { | 687 | } else { |
647 | rlim_t val = RLIM_INFINITY; | 688 | rlim_t val = RLIM_INFINITY; |