/* which of the three times will be used */
TIME_CHANGE = (1 << 21) * ENABLE_FEATURE_LS_TIMESTAMPS,
-TIME_ACCESS = (1 << 22) * ENABLE_FEATURE_LS_TIMESTAMPS,
+TIME_ACCESS = (2 << 21) * ENABLE_FEATURE_LS_TIMESTAMPS,
TIME_MASK = (3 << 21) * ENABLE_FEATURE_LS_TIMESTAMPS,
/* how will the files be sorted (CONFIG_FEATURE_LS_SORTFILES) */
/* Not fully compatible - we show not only '/' but other chars too */
/* -SXvhTw GNU options, busybox optionally supports */
/* -T TABWIDTH is ignored (we don't use tabs on output) */
-/* -K SELinux mandated options, busybox optionally supports */
+/* -KZ SELinux mandated options, busybox optionally supports */
+/* (coreutils 8.4 has no -K, remove it?) */
/* -e I think we made this one up (looks similar to GNU --full-time) */
-/* Std opts we do not support: */
-/* -H Follow the links on command line only */
static const char ls_options[] ALIGN1 =
"Cadil1gnsxQAk" /* 13 opts, total 13 */
IF_FEATURE_LS_TIMESTAMPS("cetu") /* 4, 17 */
OPTBIT_L = OPTBIT_K + 2 * ENABLE_SELINUX,
OPTBIT_H, /* 27 */
OPTBIT_h = OPTBIT_L + 2 * ENABLE_FEATURE_LS_FOLLOWLINKS,
- OPTBIT_T = OPTBIT_h + 2 * ENABLE_FEATURE_HUMAN_READABLE,
+ OPTBIT_T = OPTBIT_h + 1 * ENABLE_FEATURE_HUMAN_READABLE,
OPTBIT_w, /* 30 */
OPTBIT_color = OPTBIT_T + 2 * ENABLE_FEATURE_AUTOWIDTH,
LIST_LONG | STYLE_LONG, /* l */
STYLE_SINGLE, /* 1 */
0, /* g (don't show owner) - handled via OPT_g */
- LIST_ID_NUMERIC, /* n */
+ LIST_ID_NUMERIC | LIST_LONG | STYLE_LONG, /* n (assumes l) */
LIST_BLOCKS, /* s */
DISP_ROWS | STYLE_COLUMNAR, /* x */
0, /* Q (quote filename) - handled via OPT_Q */
DISP_HIDDEN, /* A */
- ENABLE_SELINUX * LIST_CONTEXT, /* k (ignored if !SELINUX) */
+ ENABLE_SELINUX * (LIST_CONTEXT|STYLE_SINGLE), /* k (ignored if !SELINUX) */
#if ENABLE_FEATURE_LS_TIMESTAMPS
TIME_CHANGE | (ENABLE_FEATURE_LS_SORTFILES * SORT_CTIME), /* c */
LIST_FULLTIME, /* e */
DISP_RECURSIVE, /* R */
#endif
#if ENABLE_SELINUX
- LIST_MODEBITS|LIST_NLINKS|LIST_CONTEXT|LIST_SIZE|LIST_DATE_TIME, /* K */
- LIST_MODEBITS|LIST_ID_NAME|LIST_CONTEXT, /* Z */
+ LIST_MODEBITS|LIST_NLINKS|LIST_CONTEXT|LIST_SIZE|LIST_DATE_TIME|STYLE_SINGLE, /* K */
+ LIST_MODEBITS|LIST_ID_NAME|LIST_CONTEXT|STYLE_SINGLE, /* Z */
#endif
(1U << 31)
/* options after Z are not processed through opt_flags */
column += printf("%-10s ", (char *) bb_mode_string(dn->dstat.st_mode));
if (all_fmt & LIST_NLINKS)
column += printf("%4lu ", (long) dn->dstat.st_nlink);
+ if (all_fmt & LIST_ID_NUMERIC) {
+ if (option_mask32 & OPT_g)
+ column += printf("%-8u ", (int) dn->dstat.st_gid);
+ else
+ column += printf("%-8u %-8u ",
+ (int) dn->dstat.st_uid,
+ (int) dn->dstat.st_gid);
+ }
#if ENABLE_FEATURE_LS_USERNAME
- if (all_fmt & LIST_ID_NAME) {
+ else if (all_fmt & LIST_ID_NAME) {
if (option_mask32 & OPT_g) {
column += printf("%-8.8s ",
get_cached_groupname(dn->dstat.st_gid));
}
}
#endif
- if (all_fmt & LIST_ID_NUMERIC) {
- if (option_mask32 & OPT_g)
- column += printf("%-8u ", (int) dn->dstat.st_gid);
- else
- column += printf("%-8u %-8u ",
- (int) dn->dstat.st_uid,
- (int) dn->dstat.st_gid);
- }
if (all_fmt & LIST_SIZE) {
if (S_ISBLK(dn->dstat.st_mode) || S_ISCHR(dn->dstat.st_mode)) {
column += printf("%4u, %3u ",
init_unicode();
- all_fmt = ENABLE_FEATURE_LS_SORTFILES * SORT_NAME;
+ if (ENABLE_FEATURE_LS_SORTFILES)
+ all_fmt = SORT_NAME;
#if ENABLE_FEATURE_AUTOWIDTH
/* obtain the terminal width */
if (flags & TIME_MASK)
all_fmt &= ~TIME_MASK;
- if (flags & LIST_CONTEXT)
- all_fmt |= STYLE_SINGLE;
all_fmt |= flags;
}
}
if (all_fmt & TIME_ACCESS)
all_fmt = (all_fmt & ~SORT_MASK) | SORT_ATIME;
}
- if ((all_fmt & STYLE_MASK) != STYLE_LONG) /* only for long list */
+ if ((all_fmt & STYLE_MASK) != STYLE_LONG) /* not -l? */
all_fmt &= ~(LIST_ID_NUMERIC|LIST_ID_NAME|LIST_FULLTIME);
- if (ENABLE_FEATURE_LS_USERNAME)
- if ((all_fmt & STYLE_MASK) == STYLE_LONG && (all_fmt & LIST_ID_NUMERIC))
- all_fmt &= ~LIST_ID_NAME; /* don't list names if numeric uid */
/* choose a display format if one was not already specified by an option */
if (!(all_fmt & STYLE_MASK))