+ for (i = 0; i <= 31; i++) {
+ switch (all_fmt & (1 << i)) {
+ case LIST_INO:
+ column += printf("%7ld ", (long int) dn->dstat.st_ino);
+ break;
+ case LIST_BLOCKS:
+#if _FILE_OFFSET_BITS == 64
+ column += printf("%4lld ", dn->dstat.st_blocks >> 1);
+#else
+ column += printf("%4ld ", dn->dstat.st_blocks >> 1);
+#endif
+ break;
+ case LIST_MODEBITS:
+ column += printf("%-10s ", (char *) bb_mode_string(dn->dstat.st_mode));
+ break;
+ case LIST_NLINKS:
+ column += printf("%4ld ", (long) dn->dstat.st_nlink);
+ break;
+ case LIST_ID_NAME:
+#ifdef CONFIG_FEATURE_LS_USERNAME
+ my_getpwuid(scratch, dn->dstat.st_uid, sizeof(scratch));
+ printf("%-8.8s ", scratch);
+ my_getgrgid(scratch, dn->dstat.st_gid, sizeof(scratch));
+ printf("%-8.8s", scratch);
+ column += 17;
+ break;
+#endif
+ case LIST_ID_NUMERIC:
+ column += printf("%-8d %-8d", dn->dstat.st_uid, dn->dstat.st_gid);
+ break;
+ case LIST_SIZE:
+ case LIST_DEV:
+ if (S_ISBLK(dn->dstat.st_mode) || S_ISCHR(dn->dstat.st_mode)) {
+ column += printf("%4d, %3d ", (int) major(dn->dstat.st_rdev),
+ (int) minor(dn->dstat.st_rdev));
+ } else {
+#ifdef CONFIG_FEATURE_HUMAN_READABLE
+ if (all_fmt & LS_DISP_HR) {
+ column += printf("%9s ",
+ make_human_readable_str(dn->dstat.st_size, 1, 0));
+ } else
+#endif
+ {
+#if _FILE_OFFSET_BITS == 64
+ column += printf("%9lld ", (long long) dn->dstat.st_size);
+#else
+ column += printf("%9ld ", dn->dstat.st_size);
+#endif
+ }
+ }
+ break;
+#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
+ case LIST_FULLTIME:
+ printf("%24.24s ", filetime);
+ column += 25;
+ break;
+ case LIST_DATE_TIME:
+ if ((all_fmt & LIST_FULLTIME) == 0) {
+ age = time(NULL) - ttime;
+ printf("%6.6s ", filetime + 4);
+ if (age < 3600L * 24 * 365 / 2 && age > -15 * 60) {
+ /* hh:mm if less than 6 months old */
+ printf("%5.5s ", filetime + 11);
+ } else {
+ printf(" %4.4s ", filetime + 20);
+ }
+ column += 13;
+ }
+ break;
+#endif
+#ifdef CONFIG_SELINUX
+ case LIST_CONTEXT:
+ {
+ char context[64];
+ int len = sizeof(context);
+ if(security_sid_to_context(dn->sid, context, &len))
+ {
+ strcpy(context, "unknown");
+ len = 7;
+ }
+ printf("%-32s ", context);
+ column += MAX(33, len);
+ }
+ break;
+#endif
+ case LIST_FILENAME:
+#ifdef CONFIG_FEATURE_LS_COLOR
+ errno = 0;
+ if (show_color && !lstat(dn->fullname, &info)) {
+ printf("\033[%d;%dm", bgcolor(info.st_mode),
+ fgcolor(info.st_mode));
+ }
+#endif
+ column += printf("%s", dn->name);
+#ifdef CONFIG_FEATURE_LS_COLOR
+ if (show_color) {
+ printf("\033[0m");
+ }
+#endif
+ break;
+ case LIST_SYMLINK:
+ if (S_ISLNK(dn->dstat.st_mode)) {
+ char *lpath = xreadlink(dn->fullname);
+
+ if (lpath) {
+ printf(" -> ");
+#if defined(CONFIG_FEATURE_LS_FILETYPES) || defined (CONFIG_FEATURE_LS_COLOR)
+ if (!stat(dn->fullname, &info)) {
+ append = append_char(info.st_mode);
+ }
+#endif
+#ifdef CONFIG_FEATURE_LS_COLOR
+ if (show_color) {
+ errno = 0;
+ printf("\033[%d;%dm", bgcolor(info.st_mode),
+ fgcolor(info.st_mode));
+ }
+#endif
+ column += printf("%s", lpath) + 4;
+#ifdef CONFIG_FEATURE_LS_COLOR
+ if (show_color) {
+ printf("\033[0m");
+ }
+#endif
+ free(lpath);
+ }
+ }
+ break;
+#ifdef CONFIG_FEATURE_LS_FILETYPES
+ case LIST_FILETYPE:
+ if (append != '\0') {
+ printf("%1c", append);
+ column++;
+ }
+ break;
+#endif