Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/coreutils/du.c


Ignore:
Timestamp:
Dec 20, 2016, 4:07:32 PM (7 years ago)
Author:
Bruno Cornec
Message:

New 3?3 banch for incorporation of latest busybox 1.25. Changing minor version to handle potential incompatibilities.

Location:
branches/3.3
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/3.3/mindi-busybox/coreutils/du.c

    r3232 r3621  
    5959
    6060#include "libbb.h"
     61#include "common_bufsiz.h"
    6162
    6263enum {
     
    7677struct globals {
    7778#if ENABLE_FEATURE_HUMAN_READABLE
    78     unsigned long disp_hr;
     79    unsigned long disp_unit;
    7980#else
    8081    unsigned disp_k;
     
    8687    dev_t dir_dev;
    8788} FIX_ALIASING;
    88 #define G (*(struct globals*)&bb_common_bufsiz1)
    89 #define INIT_G() do { } while (0)
    90 
    91 
    92 /* FIXME? coreutils' du rounds sizes up:
    93  * for example,  1025k file is shown as "2" by du -m.
    94  * We round to nearest.
    95  */
     89#define G (*(struct globals*)bb_common_bufsiz1)
     90#define INIT_G() do { setup_common_bufsiz(); } while (0)
     91
     92
    9693static void print(unsigned long long size, const char *filename)
    9794{
    9895    /* TODO - May not want to defer error checking here. */
    9996#if ENABLE_FEATURE_HUMAN_READABLE
     97# if ENABLE_DESKTOP
     98    /* ~30 bytes of code for extra comtat:
     99     * coreutils' du rounds sizes up:
     100     * for example,  1025k file is shown as "2" by du -m.
     101     * We round to nearest if human-readable [too hard to fix],
     102     * else (fixed scale such as -m), we round up. To that end,
     103     * add yet another half of the unit before displaying:
     104     */
     105    if (G.disp_unit)
     106        size += (G.disp_unit-1) / (unsigned)(512 * 2);
     107# endif
    100108    printf("%s\t%s\n",
    101             /* size x 512 / G.disp_hr, show one fractional,
    102              * use suffixes if G.disp_hr == 0 */
    103             make_human_readable_str(size, 512, G.disp_hr),
     109            /* size x 512 / G.disp_unit.
     110             * If G.disp_unit == 0, show one fractional
     111             * and use suffixes
     112             */
     113            make_human_readable_str(size, 512, G.disp_unit),
    104114            filename);
    105115#else
     
    200210
    201211#if ENABLE_FEATURE_HUMAN_READABLE
    202     IF_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_hr = 1024;)
    203     IF_NOT_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_hr = 512;)
     212    IF_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_unit = 1024;)
     213    IF_NOT_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_unit = 512;)
    204214    if (getenv("POSIXLY_CORRECT"))  /* TODO - a new libbb function? */
    205         G.disp_hr = 512;
     215        G.disp_unit = 512;
    206216#else
    207217    IF_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_k = 1;)
     
    221231    argv += optind;
    222232    if (opt & OPT_h_for_humans) {
    223         G.disp_hr = 0;
     233        G.disp_unit = 0;
    224234    }
    225235    if (opt & OPT_m_mbytes) {
    226         G.disp_hr = 1024*1024;
     236        G.disp_unit = 1024*1024;
    227237    }
    228238    if (opt & OPT_k_kbytes) {
    229         G.disp_hr = 1024;
     239        G.disp_unit = 1024;
    230240    }
    231241#else
Note: See TracChangeset for help on using the changeset viewer.