On Tuesday 29 September 2009 01:33, Ian Wienand wrote:
> Hi,
> 
> Although it sounds a little ridiculous for embedded systems, with the
> advent of big-disk NAS systems etc it's probably quite easy to
> overflow the 9 characters for the file size in ls.  We noticed when
> people tried ls against tb sized files on VMFS partitions.

It is till is readable, though, right? It just does not line up anymore,
like this:

-rw-r--r--    1 2049807  201     1073741824 Sep 28 16:14 big
-rwxr-xr-x    1 2049807  201       855368 Sep 28 16:13 busybox
-rwxr-xr-x    1 2049807  201       999754 Sep 28 16:22 busybox_old

> This implements a flexi-size for the size field.  Although other
> fields could also be made flexi, it seems they're less likely to
> expand past their limits.

It needs to be at least conditional on ENABLE_DESKTOP,
or should get a new ENABLE_xxxx.>       if (all_fmt & STYLE_LONG) {
>               ncols = 1;
> +
> +             /* find the longest file size */
> +             for (i = 0; i < nfiles; i++) {
> +               int w;
> +               if (all_fmt & LS_DISP_HR) {
> +                 w = 
> bb_mbstrlen(make_human_readable_str(dn[i]->dstat.st_size, 1, 0));

In this case, it never overflows 9 chars. Right?

Also, it is in ASCII, you can use just strlen().

> +               } else {
> +                 off_t s = dn[i]->dstat.st_size;
> +                 w = 2; // 1 + 1 for padding
> +                 while (s > 10) {
> +                   w++; s /= 10;
> +                 }
> +               }
> +
> +               if (w > size_width) {
> +                 size_width = w;
> +               }
> +             }
> +     

--
vda
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to