Changeset 1770 in MondoRescue for branches/stable/mindi-busybox/coreutils/wc.c


Ignore:
Timestamp:
Nov 6, 2007, 11:01:53 AM (12 years ago)
Author:
Bruno Cornec
Message:
  • Better output for mindi-busybox revision
  • Remove dummy file created on NFS - report from Arnaud Tiger <arnaud.tiger_at_hp.com>
  • strace useful for debug
  • fix new versions for pb (2.0.0 for mindi and 1.7.2 for mindi-busybox)
  • fix build process for mindi-busybox + options used in that version (dd for label-partitions-as-necessary)
  • fix typo in label-partitions-as-necessary which doesn't seem to work
  • Update to busybox 1.7.2
  • perl is now required at restore time to support uuid swap partitions (and will be used for many other thigs

in the future for sure)

  • next mindi version will be 2.0.0 due to all the changes made in it (udev may break working distros)
  • small optimization in mindi on keyboard handling (one single find instead of multiple)
  • better interaction for USB device when launching mindi manually
  • attempt to automatically guess block disk size for ramdisk
  • fix typos in bkphw
  • Fix the remaining problem with UUID support for swap partitions
  • Updates mondoarchive man page for USB support
  • Adds preliminary Hardware support to mindi (Proliant SSSTK)
  • Tries to add udev support also for rhel4
  • Fix UUID support which was still broken.
  • Be conservative in test for the start-nfs script
  • Update config file for mindi-busybox for 1.7.2 migration
  • Try to run around a busybox bug (1.2.2 pb on inexistant links)
  • Add build content for mindi-busybox in pb
  • Remove distributions content for mindi-busybox
  • Fix a warning on inexistant raidtab
  • Solve problem on tmpfs in restore init (Problem of inexistant symlink and busybox)
  • Create MONDO_CACHE and use it everywhere + creation at start
  • Really never try to eject a USB device
  • Fix a issue with &> usage (replaced with 1> and 2>)
  • Adds magic file to depllist in order to have file working + ldd which helps for debugging issues
  • tty modes correct to avoid sh error messages
  • Use ext3 normally and not ext2 instead
  • USB device should be corrected after reading (take 1st part)
  • Adds a mount_USB_here function derived from mount_CDROM_here
  • usb detection place before /dev detection in device name at restore time
  • Fix when restoring from USB: media is asked in interactive mode
  • Adds USB support for mondorestore
  • mount_cdrom => mount_media
  • elilo.efi is now searched throughout /boot/efi and not in a fixed place as there is no standard
  • untar-and-softlink => untar (+ interface change)
  • suppress useless softlinks creation/removal in boot process
  • avoids udevd messages on groups
  • Increase # of disks to 99 as in mindi at restore time (should be a conf file parameter)
  • skip existing big file creation
  • seems to work correctly for USB mindi boot
  • Adds group and tty link to udev conf
  • Always load usb-torage (even 2.6) to initiate USB bus discovery
  • Better printing of messages
  • Attempt to fix a bug in supporting OpenSusE 10.3 kernel for initramfs (mindi may now use multiple regex for kernel initrd detection)
  • Links were not correctly done as non relative for modules in mindi
  • exclusion of modules denied now works
  • Also create modules in their ordinary place, so that classical modprobe works + copy modules.dep
  • Fix bugs for DENY_MODS handling
  • Add device /dev/console for udev
  • ide-generic should now really be excluded
  • Fix a bug in major number for tty
  • If udev then adds modprobe/insmod to rootfs
  • tty0 is also cretaed with udev
  • ide-generic put rather in DENY_MODS
  • udevd remove from deplist s handled in mindi directly
  • better default for mindi when using --usb
  • Handles dynamically linked busybox (in case we want to use it soon ;-)
  • Adds fixed devices to create for udev
  • ide-generic should not be part of the initrd when using libata v2
  • support a dynamically linked udev (case on Ubuntu 7.10 and Mandriva 2008.0 so should be quite generic) This will give incitation to move to dyn. linked binaries in the initrd which will help for other tasks (ia6 4)
  • Improvement in udev support (do not use cl options not available in busybox)
  • Udev in mindi
    • auto creation of the right links at boot time with udev-links.conf(from Mandriva 2008.0)
    • rework startup of udev as current makes kernel crash (from Mandriva 2008.0)
    • add support for 64 bits udev
  • Try to render MyInsmod? silent at boot time
  • Adds udev support (mandatory for newest distributions to avoid remapping of devices in a different way as on the original system)
  • We also need vaft format support for USB boot
  • Adds libusual support (Ubuntu 7.10 needs it for USB)
  • Improve Ubuntu/Debian? keyboard detection and support
  • pbinit adapted to new pb (0.8.10). Filtering of docs done in it
  • Suppress some mondo warnings and errors on USB again
  • Tries to fix lack of files in deb mindi package
  • Verify should now work for USB devices
  • More log/mesages improvement for USB support
  • - Supress g_erase_tmpdir_and_scratchdir
  • Improve some log messages for USB support
  • Try to improve install in mindi to avoid issues with isolinux.cfg not installed vene if in the pkg :-(
  • Improve mindi-busybox build
  • In conformity with pb 0.8.9
  • Add support for Ubuntu 7.10 in build process
  • Add USB Key button to Menu UI (CD streamer removed)
  • Attempt to fix error messages on tmp/scratch files at the end by removing those dir at the latest possible.
  • Fix a bug linked to the size of the -E param which could be used (Arnaud Tiger/René? Ribaud).
  • Integrate ~/.pbrc content into mondorescue.pb (required project-builder >= 0.8.7)
  • Put mondorescue in conformity with new pb filtering rules
  • Add USB support at restore time (no test done yet). New start-usb script PB varibale added where useful
  • Unmounting USB device before removal of temporary scratchdir
  • Stil refining USB copy back to mondo (one command was not executed)
  • No need to have the image subdor in the csratchdir when USB.
  • umount the USB partition before attempting to use it
  • Remove useless copy from mindi to mondo at end of USB handling

(risky merge, we are raising the limits of 2 diverging branches. The status of stable is not completely sure as such. Will need lots of tests, but it's not yet done :-()
(merge -r1692:1769 $SVN_M/branches/2.2.5)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mindi-busybox/coreutils/wc.c

    r821 r1770  
    55 * Copyright (C) 2003  Manuel Novoa III  <mjn3@codepoet.org>
    66 *
    7  * This program is free software; you can redistribute it and/or modify
    8  * it under the terms of the GNU General Public License as published by
    9  * the Free Software Foundation; either version 2 of the License, or
    10  * (at your option) any later version.
    11  *
    12  * This program is distributed in the hope that it will be useful,
    13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    15  * General Public License for more details.
    16  *
    17  * You should have received a copy of the GNU General Public License
    18  * along with this program; if not, write to the Free Software
    19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    20  *
     7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
    218 */
    229
     
    5037 *
    5138 *      echo hello > /tmp/testfile &&
    52  *      (dd ibs=1k skip=1 count=0 &> /dev/null ; wc -c) < /tmp/testfile
     39 *      (dd ibs=1k skip=1 count=0 &> /dev/null; wc -c) < /tmp/testfile
    5340 *
    5441 * for which 'wc -c' should output '0'.
    5542 */
    5643
    57 #include <stdio.h>
    58 #include <stdlib.h>
    59 #include <string.h>
    60 #include <unistd.h>
    61 #include "busybox.h"
    62 
    63 #ifdef CONFIG_LOCALE_SUPPORT
    64 #include <locale.h>
    65 #include <ctype.h>
     44#include "libbb.h"
     45
     46#if ENABLE_LOCALE_SUPPORT
    6647#define isspace_given_isprint(c) isspace(c)
    6748#else
     
    7354#endif
    7455
     56#if ENABLE_FEATURE_WC_LARGE
     57#define COUNT_T unsigned long long
     58#define COUNT_FMT "llu"
     59#else
     60#define COUNT_T unsigned
     61#define COUNT_FMT "u"
     62#endif
     63
    7564enum {
    7665    WC_LINES    = 0,
     
    8069};
    8170
    82 /* Note: If this changes, remember to change the initialization of
    83  *       'name' in wc_main.  It needs to point to the terminating nul. */
    84 static const char wc_opts[] = "lwcL";   /* READ THE WARNING ABOVE! */
    85 
    86 enum {
    87     OP_INC_LINE = 1, /* OP_INC_LINE must be 1. */
    88     OP_SPACE    = 2,
    89     OP_NEWLINE  = 4,
    90     OP_TAB      = 8,
    91     OP_NUL      = 16,
    92 };
    93 
    94 /* Note: If fmt_str changes, the offsets to 's' in the OUTPUT section
    95  *       will need to be updated. */
    96 static const char fmt_str[] = " %7u\0 %s\n";
    97 static const char total_str[] = "total";
    98 
     71int wc_main(int argc, char **argv);
    9972int wc_main(int argc, char **argv)
    10073{
    10174    FILE *fp;
    102     const char *s;
    103     unsigned int *pcounts;
    104     unsigned int counts[4];
    105     unsigned int totals[4];
    106     unsigned int linepos;
    107     unsigned int u;
     75    const char *s, *arg;
     76    const char *start_fmt = "%9"COUNT_FMT;
     77    const char *fname_fmt = " %s\n";
     78    COUNT_T *pcounts;
     79    COUNT_T counts[4];
     80    COUNT_T totals[4];
     81    unsigned linepos;
     82    unsigned u;
    10883    int num_files = 0;
    10984    int c;
    110     char status = EXIT_SUCCESS;
    111     char in_word;
    112     char print_type;
    113 
    114     print_type = bb_getopt_ulflags(argc, argv, wc_opts);
     85    smallint status = EXIT_SUCCESS;
     86    smallint in_word;
     87    unsigned print_type;
     88
     89    print_type = getopt32(argv, "lwcL");
    11590
    11691    if (print_type == 0) {
     
    11994
    12095    argv += optind;
    121     if (!*argv) {
     96    if (!argv[0]) {
    12297        *--argv = (char *) bb_msg_standard_input;
     98        fname_fmt = "\n";
     99        if (!((print_type-1) & print_type)) /* exactly one option? */
     100            start_fmt = "%"COUNT_FMT;
    123101    }
    124102
     
    127105    pcounts = counts;
    128106
    129     do {
     107    while ((arg = *argv++) != 0) {
    130108        ++num_files;
    131         if (!(fp = bb_wfopen_input(*argv))) {
     109        fp = fopen_or_warn_stdin(arg);
     110        if (!fp) {
    132111            status = EXIT_FAILURE;
    133112            continue;
     
    139118
    140119        do {
     120            /* Our -w doesn't match GNU wc exactly... oh well */
     121
    141122            ++counts[WC_CHARS];
    142123            c = getc(fp);
     
    170151            } else if (c == EOF) {
    171152                if (ferror(fp)) {
    172                     bb_perror_msg("%s", *argv);
     153                    bb_perror_msg("%s", arg);
    173154                    status = EXIT_FAILURE;
    174155                }
     
    191172        totals[WC_LENGTH] -= counts[WC_LENGTH];
    192173
    193         bb_fclose_nonstdin(fp);
     174        fclose_if_not_stdin(fp);
    194175
    195176    OUTPUT:
    196         s = fmt_str + 1;            /* Skip the leading space on 1st pass. */
     177        /* coreutils wc tries hard to print pretty columns
     178         * (saves results for all files, find max col len etc...)
     179         * we won't try that hard, it will bloat us too much */
     180        s = start_fmt;
    197181        u = 0;
    198182        do {
    199183            if (print_type & (1 << u)) {
    200                 bb_printf(s, pcounts[u]);
    201                 s = fmt_str;        /* Ok... restore the leading space. */
     184                printf(s, pcounts[u]);
     185                s = " %9"COUNT_FMT; /* Ok... restore the leading space. */
    202186            }
    203187            totals[u] += pcounts[u];
    204188        } while (++u < 4);
    205 
    206         s += 8;                     /* Set the format to the empty string. */
    207 
    208         if (*argv != bb_msg_standard_input) {
    209             s -= 3;                 /* We have a name, so do %s conversion. */
    210         }
    211         bb_printf(s, *argv);
    212 
    213     } while (*++argv);
     189        printf(fname_fmt, arg);
     190    }
    214191
    215192    /* If more than one file was processed, we want the totals.  To save some
     
    219196    if (num_files > 1) {
    220197        num_files = 0;              /* Make sure we don't get here again. */
    221         *--argv = (char *) total_str;
     198        arg = "total";
    222199        pcounts = totals;
     200        --argv;
    223201        goto OUTPUT;
    224202    }
    225203
    226     bb_fflush_stdout_and_exit(status);
     204    fflush_stdout_and_exit(status);
    227205}
Note: See TracChangeset for help on using the changeset viewer.