diff options
author | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2007-02-28 23:14:06 +0000 |
---|---|---|
committer | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2007-02-28 23:14:06 +0000 |
commit | a9569003234d74d61a284a0f89cb303b00b71dd3 (patch) | |
tree | 9efcb54306f6297b21760afd9742d80618977f24 | |
parent | e36ad9c91a09691013b9e9cafe0e507ed499972e (diff) | |
download | busybox-w32-a9569003234d74d61a284a0f89cb303b00b71dd3.tar.gz busybox-w32-a9569003234d74d61a284a0f89cb303b00b71dd3.tar.bz2 busybox-w32-a9569003234d74d61a284a0f89cb303b00b71dd3.zip |
ls: w/o -l follow symlinks to dirs for commandline args
git-svn-id: svn://busybox.net/trunk/busybox@17994 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r-- | coreutils/ls.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c index 34fae5026..f902d382a 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c | |||
@@ -156,13 +156,13 @@ enum { | |||
156 | 156 | ||
157 | static int status = EXIT_SUCCESS; | 157 | static int status = EXIT_SUCCESS; |
158 | 158 | ||
159 | static struct dnode *my_stat(char *fullname, char *name) | 159 | static struct dnode *my_stat(char *fullname, char *name, int force_follow) |
160 | { | 160 | { |
161 | struct stat dstat; | 161 | struct stat dstat; |
162 | struct dnode *cur; | 162 | struct dnode *cur; |
163 | USE_SELINUX(security_context_t sid = NULL;) | 163 | USE_SELINUX(security_context_t sid = NULL;) |
164 | 164 | ||
165 | if (all_fmt & FOLLOW_LINKS) { | 165 | if ((all_fmt & FOLLOW_LINKS) || force_follow) { |
166 | #if ENABLE_SELINUX | 166 | #if ENABLE_SELINUX |
167 | if (is_selinux_enabled()) { | 167 | if (is_selinux_enabled()) { |
168 | getfilecon(fullname, &sid); | 168 | getfilecon(fullname, &sid); |
@@ -176,7 +176,7 @@ static struct dnode *my_stat(char *fullname, char *name) | |||
176 | } else { | 176 | } else { |
177 | #if ENABLE_SELINUX | 177 | #if ENABLE_SELINUX |
178 | if (is_selinux_enabled()) { | 178 | if (is_selinux_enabled()) { |
179 | lgetfilecon(fullname,&sid); | 179 | lgetfilecon(fullname, &sid); |
180 | } | 180 | } |
181 | #endif | 181 | #endif |
182 | if (lstat(fullname, &dstat)) { | 182 | if (lstat(fullname, &dstat)) { |
@@ -510,7 +510,7 @@ static struct dnode **list_dir(const char *path) | |||
510 | continue; | 510 | continue; |
511 | } | 511 | } |
512 | fullname = concat_path_file(path, entry->d_name); | 512 | fullname = concat_path_file(path, entry->d_name); |
513 | cur = my_stat(fullname, strrchr(fullname, '/') + 1); | 513 | cur = my_stat(fullname, strrchr(fullname, '/') + 1, 0); |
514 | if (!cur) { | 514 | if (!cur) { |
515 | free(fullname); | 515 | free(fullname); |
516 | continue; | 516 | continue; |
@@ -819,7 +819,7 @@ int ls_main(int argc, char **argv) | |||
819 | if (terminal_width_str) | 819 | if (terminal_width_str) |
820 | terminal_width = xatou(terminal_width_str); | 820 | terminal_width = xatou(terminal_width_str); |
821 | #else | 821 | #else |
822 | opt = getopt32(argc, argv, ls_options USE_FEATURE_LS_COLOR(, &color_opt)); | 822 | opt = getopt32(argc, argv, ls_options USE_FEATURE_LS_COLOR(, &color_opt)); |
823 | #endif | 823 | #endif |
824 | for (i = 0; opt_flags[i] != (1U<<31); i++) { | 824 | for (i = 0; opt_flags[i] != (1U<<31); i++) { |
825 | if (opt & (1 << i)) { | 825 | if (opt & (1 << i)) { |
@@ -837,8 +837,9 @@ int ls_main(int argc, char **argv) | |||
837 | all_fmt &= ~TIME_MASK; | 837 | all_fmt &= ~TIME_MASK; |
838 | if (flags & LIST_CONTEXT) | 838 | if (flags & LIST_CONTEXT) |
839 | all_fmt |= STYLE_SINGLE; | 839 | all_fmt |= STYLE_SINGLE; |
840 | if (LS_DISP_HR && opt == 'l') | 840 | /* huh?? opt cannot be 'l' */ |
841 | all_fmt &= ~LS_DISP_HR; | 841 | //if (LS_DISP_HR && opt == 'l') |
842 | // all_fmt &= ~LS_DISP_HR; | ||
842 | all_fmt |= flags; | 843 | all_fmt |= flags; |
843 | } | 844 | } |
844 | } | 845 | } |
@@ -904,7 +905,8 @@ int ls_main(int argc, char **argv) | |||
904 | /* stuff the command line file names into a dnode array */ | 905 | /* stuff the command line file names into a dnode array */ |
905 | dn = NULL; | 906 | dn = NULL; |
906 | for (oi = 0; oi < ac; oi++) { | 907 | for (oi = 0; oi < ac; oi++) { |
907 | cur = my_stat(av[oi], av[oi]); | 908 | /* ls w/o -l follows links on command line */ |
909 | cur = my_stat(av[oi], av[oi], !(all_fmt & STYLE_LONG)); | ||
908 | if (!cur) | 910 | if (!cur) |
909 | continue; | 911 | continue; |
910 | cur->allocated = 0; | 912 | cur->allocated = 0; |