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/miscutils/flashcp.c

    r3232 r3621  
    1717#include <mtd/mtd-user.h>
    1818
     19/* If 1, simulates "flashing" by writing to existing regular file */
    1920#define MTD_DEBUG 0
    2021
    2122#define OPT_v (1 << 0)
    2223
    23 #define BUFSIZE (8 * 1024)
     24#define BUFSIZE (4 * 1024)
    2425
    2526static void progress(int mode, uoff_t count, uoff_t total)
     
    3334        percent = (unsigned) (percent / total);
    3435    printf("\r%s: %"OFF_FMT"u/%"OFF_FMT"u (%u%%) ",
    35         (mode == 0) ? "Erasing block" : ((mode == 1) ? "Writing kb" : "Verifying kb"),
     36        (mode < 0) ? "Erasing block" : ((mode == 0) ? "Writing kb" : "Verifying kb"),
    3637        count, total, (unsigned)percent);
    3738    fflush_all();
     
    9899    e.start = 0;
    99100    for (i = 1; i <= erase_count; i++) {
    100         progress(0, i, erase_count);
    101         errno = 0;
     101        progress(-1, i, erase_count);
    102102#if !MTD_DEBUG
    103103        if (ioctl(fd_d, MEMERASE, &e) < 0) {
     
    114114    /* doing this outer loop gives significantly smaller code
    115115     * than doing two separate loops for writing and verifying */
    116     for (i = 1; i <= 2; i++) {
     116    for (i = 0; i <= 1; i++) {
    117117        uoff_t done;
    118118        unsigned count;
     
    123123        count = BUFSIZE;
    124124        while (1) {
    125             uoff_t rem = statb.st_size - done;
     125            uoff_t rem;
     126
     127            progress(i, done / 1024, (uoff_t)statb.st_size / 1024);
     128            rem = statb.st_size - done;
    126129            if (rem == 0)
    127130                break;
    128131            if (rem < BUFSIZE)
    129132                count = rem;
    130             progress(i, done / 1024, (uoff_t)statb.st_size / 1024);
    131133            xread(fd_f, buf, count);
    132             if (i == 1) {
     134            if (i == 0) {
    133135                int ret;
     136                if (count < BUFSIZE)
     137                    memset((char*)buf + count, 0, BUFSIZE - count);
    134138                errno = 0;
    135                 ret = full_write(fd_d, buf, count);
    136                 if (ret != count) {
     139                ret = full_write(fd_d, buf, BUFSIZE);
     140                if (ret != BUFSIZE) {
    137141                    bb_perror_msg_and_die("write error at 0x%"OFF_FMT"x on %s, "
    138142                        "write returned %d",
    139143                        done, devicename, ret);
    140144                }
    141             } else { /* i == 2 */
     145            } else { /* i == 1 */
    142146                xread(fd_d, buf2, count);
    143                 if (memcmp(buf, buf2, count)) {
     147                if (memcmp(buf, buf2, count) != 0) {
    144148                    bb_error_msg_and_die("verification mismatch at 0x%"OFF_FMT"x", done);
    145149                }
Note: See TracChangeset for help on using the changeset viewer.