diff options
Diffstat (limited to 'ls.c')
-rw-r--r-- | ls.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -159,6 +159,9 @@ static unsigned int sort_order= SORT_FORWARD; | |||
159 | #ifdef BB_FEATURE_LS_TIMESTAMPS | 159 | #ifdef BB_FEATURE_LS_TIMESTAMPS |
160 | static unsigned int time_fmt= TIME_MOD; | 160 | static unsigned int time_fmt= TIME_MOD; |
161 | #endif | 161 | #endif |
162 | #ifdef BB_FEATURE_LS_FOLLOWLINKS | ||
163 | static unsigned int follow_links=FALSE; | ||
164 | #endif | ||
162 | 165 | ||
163 | static unsigned short column = 0; | 166 | static unsigned short column = 0; |
164 | #ifdef BB_FEATURE_AUTOWIDTH | 167 | #ifdef BB_FEATURE_AUTOWIDTH |
@@ -474,6 +477,16 @@ struct dnode **list_dir(char *path) | |||
474 | cur= (struct dnode *)xmalloc(sizeof(struct dnode)); | 477 | cur= (struct dnode *)xmalloc(sizeof(struct dnode)); |
475 | cur->fullname= xstrdup(fullname); | 478 | cur->fullname= xstrdup(fullname); |
476 | cur->name= cur->fullname + (int)(fnend - fullname) ; | 479 | cur->name= cur->fullname + (int)(fnend - fullname) ; |
480 | #ifdef BB_FEATURE_LS_FOLLOWLINKS | ||
481 | if (follow_links == TRUE) { | ||
482 | if (stat(fullname, &cur->dstat)) { | ||
483 | errorMsg("%s: %s\n", fullname, strerror(errno)); | ||
484 | free(cur->fullname); | ||
485 | free(cur); | ||
486 | continue; | ||
487 | } | ||
488 | } else | ||
489 | #endif | ||
477 | if (lstat(fullname, &cur->dstat)) { /* get file stat info into node */ | 490 | if (lstat(fullname, &cur->dstat)) { /* get file stat info into node */ |
478 | errorMsg("%s: %s\n", fullname, strerror(errno)); | 491 | errorMsg("%s: %s\n", fullname, strerror(errno)); |
479 | free(cur->fullname); | 492 | free(cur->fullname); |
@@ -682,6 +695,9 @@ extern int ls_main(int argc, char **argv) | |||
682 | #ifdef BB_FEATURE_LS_TIMESTAMPS | 695 | #ifdef BB_FEATURE_LS_TIMESTAMPS |
683 | "cetu" | 696 | "cetu" |
684 | #endif | 697 | #endif |
698 | #ifdef BB_FEATURE_LS_FOLLOWLINKS | ||
699 | "L" | ||
700 | #endif | ||
685 | )) > 0) { | 701 | )) > 0) { |
686 | switch (opt) { | 702 | switch (opt) { |
687 | case '1': style_fmt = STYLE_SINGLE; break; | 703 | case '1': style_fmt = STYLE_SINGLE; break; |
@@ -714,6 +730,9 @@ extern int ls_main(int argc, char **argv) | |||
714 | case 't': sort_opts= SORT_MTIME; break; | 730 | case 't': sort_opts= SORT_MTIME; break; |
715 | case 'u': time_fmt = TIME_ACCESS; sort_opts= SORT_ATIME; break; | 731 | case 'u': time_fmt = TIME_ACCESS; sort_opts= SORT_ATIME; break; |
716 | #endif | 732 | #endif |
733 | #ifdef BB_FEATURE_LS_FOLLOWLINKS | ||
734 | case 'L': follow_links= TRUE; break; | ||
735 | #endif | ||
717 | #ifdef BB_FEATURE_AUTOWIDTH | 736 | #ifdef BB_FEATURE_AUTOWIDTH |
718 | case 'T': tabstops= atoi(optarg); break; | 737 | case 'T': tabstops= atoi(optarg); break; |
719 | case 'w': terminal_width= atoi(optarg); break; | 738 | case 'w': terminal_width= atoi(optarg); break; |