ls: w/o -l follow symlinks to dirs for commandline args
This commit is contained in:
parent
4c7e5b6c76
commit
2110aa9ece
@ -156,13 +156,13 @@ enum {
|
|||||||
|
|
||||||
static int status = EXIT_SUCCESS;
|
static int status = EXIT_SUCCESS;
|
||||||
|
|
||||||
static struct dnode *my_stat(char *fullname, char *name)
|
static struct dnode *my_stat(char *fullname, char *name, int force_follow)
|
||||||
{
|
{
|
||||||
struct stat dstat;
|
struct stat dstat;
|
||||||
struct dnode *cur;
|
struct dnode *cur;
|
||||||
USE_SELINUX(security_context_t sid = NULL;)
|
USE_SELINUX(security_context_t sid = NULL;)
|
||||||
|
|
||||||
if (all_fmt & FOLLOW_LINKS) {
|
if ((all_fmt & FOLLOW_LINKS) || force_follow) {
|
||||||
#if ENABLE_SELINUX
|
#if ENABLE_SELINUX
|
||||||
if (is_selinux_enabled()) {
|
if (is_selinux_enabled()) {
|
||||||
getfilecon(fullname, &sid);
|
getfilecon(fullname, &sid);
|
||||||
@ -176,7 +176,7 @@ static struct dnode *my_stat(char *fullname, char *name)
|
|||||||
} else {
|
} else {
|
||||||
#if ENABLE_SELINUX
|
#if ENABLE_SELINUX
|
||||||
if (is_selinux_enabled()) {
|
if (is_selinux_enabled()) {
|
||||||
lgetfilecon(fullname,&sid);
|
lgetfilecon(fullname, &sid);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (lstat(fullname, &dstat)) {
|
if (lstat(fullname, &dstat)) {
|
||||||
@ -510,7 +510,7 @@ static struct dnode **list_dir(const char *path)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
fullname = concat_path_file(path, entry->d_name);
|
fullname = concat_path_file(path, entry->d_name);
|
||||||
cur = my_stat(fullname, strrchr(fullname, '/') + 1);
|
cur = my_stat(fullname, strrchr(fullname, '/') + 1, 0);
|
||||||
if (!cur) {
|
if (!cur) {
|
||||||
free(fullname);
|
free(fullname);
|
||||||
continue;
|
continue;
|
||||||
@ -819,7 +819,7 @@ int ls_main(int argc, char **argv)
|
|||||||
if (terminal_width_str)
|
if (terminal_width_str)
|
||||||
terminal_width = xatou(terminal_width_str);
|
terminal_width = xatou(terminal_width_str);
|
||||||
#else
|
#else
|
||||||
opt = getopt32(argc, argv, ls_options USE_FEATURE_LS_COLOR(, &color_opt));
|
opt = getopt32(argc, argv, ls_options USE_FEATURE_LS_COLOR(, &color_opt));
|
||||||
#endif
|
#endif
|
||||||
for (i = 0; opt_flags[i] != (1U<<31); i++) {
|
for (i = 0; opt_flags[i] != (1U<<31); i++) {
|
||||||
if (opt & (1 << i)) {
|
if (opt & (1 << i)) {
|
||||||
@ -837,8 +837,9 @@ int ls_main(int argc, char **argv)
|
|||||||
all_fmt &= ~TIME_MASK;
|
all_fmt &= ~TIME_MASK;
|
||||||
if (flags & LIST_CONTEXT)
|
if (flags & LIST_CONTEXT)
|
||||||
all_fmt |= STYLE_SINGLE;
|
all_fmt |= STYLE_SINGLE;
|
||||||
if (LS_DISP_HR && opt == 'l')
|
/* huh?? opt cannot be 'l' */
|
||||||
all_fmt &= ~LS_DISP_HR;
|
//if (LS_DISP_HR && opt == 'l')
|
||||||
|
// all_fmt &= ~LS_DISP_HR;
|
||||||
all_fmt |= flags;
|
all_fmt |= flags;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -904,7 +905,8 @@ int ls_main(int argc, char **argv)
|
|||||||
/* stuff the command line file names into a dnode array */
|
/* stuff the command line file names into a dnode array */
|
||||||
dn = NULL;
|
dn = NULL;
|
||||||
for (oi = 0; oi < ac; oi++) {
|
for (oi = 0; oi < ac; oi++) {
|
||||||
cur = my_stat(av[oi], av[oi]);
|
/* ls w/o -l follows links on command line */
|
||||||
|
cur = my_stat(av[oi], av[oi], !(all_fmt & STYLE_LONG));
|
||||||
if (!cur)
|
if (!cur)
|
||||||
continue;
|
continue;
|
||||||
cur->allocated = 0;
|
cur->allocated = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user