summaryrefslogtreecommitdiff
path: root/coreutils/ls.c
diff options
context:
space:
mode:
authorDenis Vlasenko2009-03-03 13:20:22 +0000
committerDenis Vlasenko2009-03-03 13:20:22 +0000
commit11a6f9b44f4a425b03e3a7a984e7b3e253e5f884 (patch)
tree6b27aba28cdfcab0d8dcd5013513edaa4104fb44 /coreutils/ls.c
parent7886275c982286e69fef12236d119ca39b831cec (diff)
downloadbusybox-11a6f9b44f4a425b03e3a7a984e7b3e253e5f884.zip
busybox-11a6f9b44f4a425b03e3a7a984e7b3e253e5f884.tar.gz
ls: do not follow links with -s (closes bug 33),
display unsigned data with %XXu, not %XXd.
Diffstat (limited to 'coreutils/ls.c')
-rw-r--r--coreutils/ls.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c
index f4e71bc..8aa0550 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -604,16 +604,16 @@ static int list_single(const struct dnode *dn)
for (i = 0; i <= 31; i++) {
switch (all_fmt & (1 << i)) {
case LIST_INO:
- column += printf("%7ld ", (long) dn->dstat.st_ino);
+ column += printf("%7lu ", (long) dn->dstat.st_ino);
break;
case LIST_BLOCKS:
- column += printf("%4"OFF_FMT"d ", (off_t) dn->dstat.st_blocks >> 1);
+ column += printf("%4"OFF_FMT"u ", (off_t) dn->dstat.st_blocks >> 1);
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);
+ column += printf("%4lu ", (long) dn->dstat.st_nlink);
break;
case LIST_ID_NAME:
#if ENABLE_FEATURE_LS_USERNAME
@@ -624,19 +624,19 @@ static int list_single(const struct dnode *dn)
break;
#endif
case LIST_ID_NUMERIC:
- column += printf("%-8d %-8d", dn->dstat.st_uid, dn->dstat.st_gid);
+ column += printf("%-8u %-8u", 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),
+ column += printf("%4u, %3u ", (int) major(dn->dstat.st_rdev),
(int) minor(dn->dstat.st_rdev));
} else {
if (all_fmt & LS_DISP_HR) {
column += printf("%9s ",
make_human_readable_str(dn->dstat.st_size, 1, 0));
} else {
- column += printf("%9"OFF_FMT"d ", (off_t) dn->dstat.st_size);
+ column += printf("%9"OFF_FMT"u ", (off_t) dn->dstat.st_size);
}
}
break;
@@ -683,7 +683,7 @@ static int list_single(const struct dnode *dn)
errno = 0;
#if ENABLE_FEATURE_LS_COLOR
if (show_color && !lstat(dn->fullname, &info)) {
- printf("\033[%d;%dm", bgcolor(info.st_mode),
+ printf("\033[%u;%um", bgcolor(info.st_mode),
fgcolor(info.st_mode));
}
#endif
@@ -710,7 +710,7 @@ static int list_single(const struct dnode *dn)
#if ENABLE_FEATURE_LS_COLOR
if (show_color) {
errno = 0;
- printf("\033[%d;%dm", bgcolor(info.st_mode),
+ printf("\033[%u;%um", bgcolor(info.st_mode),
fgcolor(info.st_mode));
}
#endif
@@ -932,8 +932,8 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
dn = NULL;
nfiles = 0;
do {
- /* ls w/o -l follows links on command line */
- cur = my_stat(*argv, *argv, !(all_fmt & STYLE_LONG));
+ /* NB: follow links on command line unless -l or -s */
+ cur = my_stat(*argv, *argv, !(all_fmt & (STYLE_LONG|LIST_BLOCKS)));
argv++;
if (!cur)
continue;