aboutsummaryrefslogtreecommitdiff
path: root/coreutils/ls.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2000-06-07 17:28:53 +0000
committerEric Andersen <andersen@codepoet.org>2000-06-07 17:28:53 +0000
commita42982e8f569417e93bc3b47c501cbe83a5bfade (patch)
treea28be75735aa78f38cf8464f874857fd0132c664 /coreutils/ls.c
parent1f6262b8e2b4225a028b016fed4a3a9ee717b540 (diff)
downloadbusybox-w32-a42982e8f569417e93bc3b47c501cbe83a5bfade.tar.gz
busybox-w32-a42982e8f569417e93bc3b47c501cbe83a5bfade.tar.bz2
busybox-w32-a42982e8f569417e93bc3b47c501cbe83a5bfade.zip
* Fixed 'swapon -a' and 'swapoff -a', which were broken.
* Fixed 'mount -a' so it works as expected. * Implemented 'ls -R' (enabled by enabling BB_FEATURE_LS_RECURSIVE) -Erik
Diffstat (limited to 'coreutils/ls.c')
-rw-r--r--coreutils/ls.c51
1 files changed, 44 insertions, 7 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 6ab11c4e5..0b1aa6221 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -86,8 +86,9 @@
86#define DISP_DOT 8 /* show . and .. */ 86#define DISP_DOT 8 /* show . and .. */
87#define DISP_NUMERIC 16 /* numeric uid and gid */ 87#define DISP_NUMERIC 16 /* numeric uid and gid */
88#define DISP_FULLTIME 32 /* show extended time display */ 88#define DISP_FULLTIME 32 /* show extended time display */
89#define DIR_NOLIST 64 /* show directory as itself, not contents */ 89#define DIR_NOLIST 64 /* show directory as itself, not contents */
90#define DISP_DIRNAME 128 /* show directory name (for internal use) */ 90#define DISP_DIRNAME 128 /* show directory name (for internal use) */
91#define DISP_RECURSIVE 256 /* Do a recursive listing */
91 92
92#ifndef MAJOR 93#ifndef MAJOR
93#define MAJOR(dev) (((dev)>>8)&0xff) 94#define MAJOR(dev) (((dev)>>8)&0xff)
@@ -449,6 +450,9 @@ static const char ls_usage[] = "ls [-1a"
449#ifdef BB_FEATURE_LS_FILETYPES 450#ifdef BB_FEATURE_LS_FILETYPES
450 "F" 451 "F"
451#endif 452#endif
453#ifdef BB_FEATURE_LS_RECURSIVE
454 "R"
455#endif
452 "] [filenames...]\n" 456 "] [filenames...]\n"
453#ifndef BB_FEATURE_TRIVIAL_HELP 457#ifndef BB_FEATURE_TRIVIAL_HELP
454 "\nList directory contents\n\n" 458 "\nList directory contents\n\n"
@@ -477,9 +481,24 @@ static const char ls_usage[] = "ls [-1a"
477#ifdef BB_FEATURE_LS_FILETYPES 481#ifdef BB_FEATURE_LS_FILETYPES
478 "\t-F\tappend indicator (one of */=@|) to entries\n" 482 "\t-F\tappend indicator (one of */=@|) to entries\n"
479#endif 483#endif
484#ifdef BB_FEATURE_LS_RECURSIVE
485 "\t-R\tlist subdirectories recursively\n"
486#endif
480#endif 487#endif
481 ; 488 ;
482 489
490
491#ifdef BB_FEATURE_LS_RECURSIVE
492static int dirAction(const char *fileName, struct stat *statbuf, void* junk)
493{
494 int i;
495 fprintf(stdout, "\n%s:\n", fileName);
496 i = list_item(fileName);
497 newline();
498 return (i);
499}
500#endif
501
483extern int ls_main(int argc, char **argv) 502extern int ls_main(int argc, char **argv)
484{ 503{
485 int argi = 1, i; 504 int argi = 1, i;
@@ -544,6 +563,11 @@ extern int ls_main(int argc, char **argv)
544 opts |= DISP_FULLTIME; 563 opts |= DISP_FULLTIME;
545 break; 564 break;
546#endif 565#endif
566#ifdef BB_FEATURE_LS_RECURSIVE
567 case 'R':
568 opts |= DISP_RECURSIVE;
569 break;
570#endif
547 default: 571 default:
548 goto print_usage_message; 572 goto print_usage_message;
549 } 573 }
@@ -570,12 +594,25 @@ extern int ls_main(int argc, char **argv)
570#endif 594#endif
571 595
572 /* process files specified, or current directory if none */ 596 /* process files specified, or current directory if none */
573 i = 0; 597#ifdef BB_FEATURE_LS_RECURSIVE
574 if (argi == argc) 598 if (opts & DISP_RECURSIVE) {
575 i = list_item("."); 599 i = 0;
576 while (argi < argc) 600 if (argi == argc) {
577 i |= list_item(argv[argi++]); 601 i = recursiveAction(".", TRUE, FALSE, FALSE, NULL, dirAction, NULL);
578 newline(); 602 }
603 while (argi < argc) {
604 i |= recursiveAction(argv[argi++], TRUE, FALSE, FALSE, NULL, dirAction, NULL);
605 }
606 } else
607#endif
608 {
609 i = 0;
610 if (argi == argc)
611 i = list_item(".");
612 while (argi < argc)
613 i |= list_item(argv[argi++]);
614 newline();
615 }
579 exit(i); 616 exit(i);
580 617
581 print_usage_message: 618 print_usage_message: