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/archival/libunarchive/decompress_unlzma.c

    r821 r1770  
    1 /* vi:set ts=4: */
     1/* vi: set sw=4 ts=4: */
    22/*
    33 * Small lzma deflate implementation.
     
    1313#include "unarchive.h"
    1414
    15 #ifdef CONFIG_FEATURE_LZMA_FAST
    16 #  define speed_inline ATTRIBUTE_ALWAYS_INLINE
     15#if ENABLE_FEATURE_LZMA_FAST
     16#  define speed_inline ALWAYS_INLINE
    1717#else
    1818#  define speed_inline
     
    2323    int fd;
    2424    uint8_t *ptr;
    25     uint8_t *buffer;
     25
     26/* Was keeping rc on stack in unlzma and separately allocating buffer,
     27 * but with "buffer 'attached to' allocated rc" code is smaller: */
     28    /* uint8_t *buffer; */
     29#define RC_BUFFER ((uint8_t*)(rc+1))
     30
    2631    uint8_t *buffer_end;
    27     int buffer_size;
     32
     33/* Had provisions for variable buffer, but we don't need it here */
     34    /* int buffer_size; */
     35#define RC_BUFFER_SIZE 0x10000
     36
    2837    uint32_t code;
    2938    uint32_t range;
     
    3140} rc_t;
    3241
    33 
    3442#define RC_TOP_BITS 24
    3543#define RC_MOVE_BITS 5
     
    4048static void rc_read(rc_t * rc)
    4149{
    42     rc->buffer_size = read(rc->fd, rc->buffer, rc->buffer_size);
    43     if (rc->buffer_size <= 0)
     50    int buffer_size = safe_read(rc->fd, RC_BUFFER, RC_BUFFER_SIZE);
     51    if (buffer_size <= 0)
    4452        bb_error_msg_and_die("unexpected EOF");
    45     rc->ptr = rc->buffer;
    46     rc->buffer_end = rc->buffer + rc->buffer_size;
     53    rc->ptr = RC_BUFFER;
     54    rc->buffer_end = RC_BUFFER + buffer_size;
    4755}
    4856
    4957/* Called once */
    50 static void rc_init(rc_t * rc, int fd, int buffer_size)
     58static rc_t* rc_init(int fd) /*, int buffer_size) */
    5159{
    5260    int i;
     61    rc_t* rc;
     62
     63    rc = xmalloc(sizeof(rc_t) + RC_BUFFER_SIZE);
    5364
    5465    rc->fd = fd;
    55     rc->buffer = xmalloc(buffer_size);
    56     rc->buffer_size = buffer_size;
    57     rc->buffer_end = rc->buffer + rc->buffer_size;
     66    /* rc->buffer_size = buffer_size; */
     67    rc->buffer_end = RC_BUFFER + RC_BUFFER_SIZE;
    5868    rc->ptr = rc->buffer_end;
    5969
     
    6575        rc->code = (rc->code << 8) | *rc->ptr++;
    6676    }
    67 }
    68 
    69 /* Called once. TODO: bb_maybe_free() */
    70 static ATTRIBUTE_ALWAYS_INLINE void rc_free(rc_t * rc)
     77    return rc;
     78}
     79
     80/* Called once  */
     81static ALWAYS_INLINE void rc_free(rc_t * rc)
    7182{
    7283    if (ENABLE_FEATURE_CLEAN_UP)
    73         free(rc->buffer);
     84        free(rc);
    7485}
    7586
     
    8293    rc->code = (rc->code << 8) | *rc->ptr++;
    8394}
    84 static ATTRIBUTE_ALWAYS_INLINE void rc_normalize(rc_t * rc)
     95static ALWAYS_INLINE void rc_normalize(rc_t * rc)
    8596{
    8697    if (rc->range < (1 << RC_TOP_BITS)) {
     
    89100}
    90101
    91 /* Called 9 times */
     102/* rc_is_bit_0 is called 9 times */
    92103/* Why rc_is_bit_0_helper exists?
    93  * Because we want to always expose (rc->code < rc->bound) to optimizer
     104 * Because we want to always expose (rc->code < rc->bound) to optimizer.
     105 * Thus rc_is_bit_0 is always inlined, and rc_is_bit_0_helper is inlined
     106 * only if we compile for speed.
    94107 */
    95108static speed_inline uint32_t rc_is_bit_0_helper(rc_t * rc, uint16_t * p)
     
    99112    return rc->bound;
    100113}
    101 static ATTRIBUTE_ALWAYS_INLINE int rc_is_bit_0(rc_t * rc, uint16_t * p)
     114static ALWAYS_INLINE int rc_is_bit_0(rc_t * rc, uint16_t * p)
    102115{
    103116    uint32_t t = rc_is_bit_0_helper(rc, p);
     
    133146
    134147/* Called once */
    135 static ATTRIBUTE_ALWAYS_INLINE int rc_direct_bit(rc_t * rc)
     148static ALWAYS_INLINE int rc_direct_bit(rc_t * rc)
    136149{
    137150    rc_normalize(rc);
     
    164177
    165178
    166 #define LZMA_BASE_SIZE 1846
    167 #define LZMA_LIT_SIZE 768
    168 
    169 #define LZMA_NUM_POS_BITS_MAX 4
    170 
    171 #define LZMA_LEN_NUM_LOW_BITS 3
    172 #define LZMA_LEN_NUM_MID_BITS 3
    173 #define LZMA_LEN_NUM_HIGH_BITS 8
    174 
    175 #define LZMA_LEN_CHOICE 0
    176 #define LZMA_LEN_CHOICE_2 (LZMA_LEN_CHOICE + 1)
    177 #define LZMA_LEN_LOW (LZMA_LEN_CHOICE_2 + 1)
    178 #define LZMA_LEN_MID (LZMA_LEN_LOW \
    179               + (1 << (LZMA_NUM_POS_BITS_MAX + LZMA_LEN_NUM_LOW_BITS)))
    180 #define LZMA_LEN_HIGH (LZMA_LEN_MID \
    181                +(1 << (LZMA_NUM_POS_BITS_MAX + LZMA_LEN_NUM_MID_BITS)))
    182 #define LZMA_NUM_LEN_PROBS (LZMA_LEN_HIGH + (1 << LZMA_LEN_NUM_HIGH_BITS))
    183 
    184 #define LZMA_NUM_STATES 12
    185 #define LZMA_NUM_LIT_STATES 7
    186 
    187 #define LZMA_START_POS_MODEL_INDEX 4
    188 #define LZMA_END_POS_MODEL_INDEX 14
    189 #define LZMA_NUM_FULL_DISTANCES (1 << (LZMA_END_POS_MODEL_INDEX >> 1))
    190 
    191 #define LZMA_NUM_POS_SLOT_BITS 6
    192 #define LZMA_NUM_LEN_TO_POS_STATES 4
    193 
    194 #define LZMA_NUM_ALIGN_BITS 4
    195 
    196 #define LZMA_MATCH_MIN_LEN 2
    197 
    198 #define LZMA_IS_MATCH 0
    199 #define LZMA_IS_REP (LZMA_IS_MATCH + (LZMA_NUM_STATES <<LZMA_NUM_POS_BITS_MAX))
    200 #define LZMA_IS_REP_G0 (LZMA_IS_REP + LZMA_NUM_STATES)
    201 #define LZMA_IS_REP_G1 (LZMA_IS_REP_G0 + LZMA_NUM_STATES)
    202 #define LZMA_IS_REP_G2 (LZMA_IS_REP_G1 + LZMA_NUM_STATES)
    203 #define LZMA_IS_REP_0_LONG (LZMA_IS_REP_G2 + LZMA_NUM_STATES)
    204 #define LZMA_POS_SLOT (LZMA_IS_REP_0_LONG \
    205                + (LZMA_NUM_STATES << LZMA_NUM_POS_BITS_MAX))
    206 #define LZMA_SPEC_POS (LZMA_POS_SLOT \
    207                +(LZMA_NUM_LEN_TO_POS_STATES << LZMA_NUM_POS_SLOT_BITS))
    208 #define LZMA_ALIGN (LZMA_SPEC_POS \
    209             + LZMA_NUM_FULL_DISTANCES - LZMA_END_POS_MODEL_INDEX)
    210 #define LZMA_LEN_CODER (LZMA_ALIGN + (1 << LZMA_NUM_ALIGN_BITS))
    211 #define LZMA_REP_LEN_CODER (LZMA_LEN_CODER + LZMA_NUM_LEN_PROBS)
    212 #define LZMA_LITERAL (LZMA_REP_LEN_CODER + LZMA_NUM_LEN_PROBS)
    213 
    214 
    215 int unlzma(int src_fd, int dst_fd)
    216 {
     179/* #defines will force compiler to compute/optimize each one with each usage.
     180 * Have heart and use enum instead. */
     181enum {
     182    LZMA_BASE_SIZE = 1846,
     183    LZMA_LIT_SIZE  = 768,
     184
     185    LZMA_NUM_POS_BITS_MAX = 4,
     186
     187    LZMA_LEN_NUM_LOW_BITS  = 3,
     188    LZMA_LEN_NUM_MID_BITS  = 3,
     189    LZMA_LEN_NUM_HIGH_BITS = 8,
     190
     191    LZMA_LEN_CHOICE     = 0,
     192    LZMA_LEN_CHOICE_2   = (LZMA_LEN_CHOICE + 1),
     193    LZMA_LEN_LOW        = (LZMA_LEN_CHOICE_2 + 1),
     194    LZMA_LEN_MID        = (LZMA_LEN_LOW \
     195                          + (1 << (LZMA_NUM_POS_BITS_MAX + LZMA_LEN_NUM_LOW_BITS))),
     196    LZMA_LEN_HIGH       = (LZMA_LEN_MID \
     197                          + (1 << (LZMA_NUM_POS_BITS_MAX + LZMA_LEN_NUM_MID_BITS))),
     198    LZMA_NUM_LEN_PROBS  = (LZMA_LEN_HIGH + (1 << LZMA_LEN_NUM_HIGH_BITS)),
     199
     200    LZMA_NUM_STATES     = 12,
     201    LZMA_NUM_LIT_STATES = 7,
     202
     203    LZMA_START_POS_MODEL_INDEX = 4,
     204    LZMA_END_POS_MODEL_INDEX   = 14,
     205    LZMA_NUM_FULL_DISTANCES    = (1 << (LZMA_END_POS_MODEL_INDEX >> 1)),
     206
     207    LZMA_NUM_POS_SLOT_BITS = 6,
     208    LZMA_NUM_LEN_TO_POS_STATES = 4,
     209
     210    LZMA_NUM_ALIGN_BITS = 4,
     211
     212    LZMA_MATCH_MIN_LEN  = 2,
     213
     214    LZMA_IS_MATCH       = 0,
     215    LZMA_IS_REP         = (LZMA_IS_MATCH + (LZMA_NUM_STATES << LZMA_NUM_POS_BITS_MAX)),
     216    LZMA_IS_REP_G0      = (LZMA_IS_REP + LZMA_NUM_STATES),
     217    LZMA_IS_REP_G1      = (LZMA_IS_REP_G0 + LZMA_NUM_STATES),
     218    LZMA_IS_REP_G2      = (LZMA_IS_REP_G1 + LZMA_NUM_STATES),
     219    LZMA_IS_REP_0_LONG  = (LZMA_IS_REP_G2 + LZMA_NUM_STATES),
     220    LZMA_POS_SLOT       = (LZMA_IS_REP_0_LONG \
     221                          + (LZMA_NUM_STATES << LZMA_NUM_POS_BITS_MAX)),
     222    LZMA_SPEC_POS       = (LZMA_POS_SLOT \
     223                          + (LZMA_NUM_LEN_TO_POS_STATES << LZMA_NUM_POS_SLOT_BITS)),
     224    LZMA_ALIGN          = (LZMA_SPEC_POS \
     225                          + LZMA_NUM_FULL_DISTANCES - LZMA_END_POS_MODEL_INDEX),
     226    LZMA_LEN_CODER      = (LZMA_ALIGN + (1 << LZMA_NUM_ALIGN_BITS)),
     227    LZMA_REP_LEN_CODER  = (LZMA_LEN_CODER + LZMA_NUM_LEN_PROBS),
     228    LZMA_LITERAL        = (LZMA_REP_LEN_CODER + LZMA_NUM_LEN_PROBS),
     229};
     230
     231
     232USE_DESKTOP(long long) int
     233unpack_lzma_stream(int src_fd, int dst_fd)
     234{
     235    USE_DESKTOP(long long total_written = 0;)
    217236    lzma_header_t header;
    218237    int lc, pb, lp;
     
    225244    int num_bits;
    226245    int num_probs;
    227     rc_t rc;
     246    rc_t *rc;
    228247    int i, mi;
    229248    uint8_t *buffer;
     
    234253    uint32_t rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1;
    235254
    236     if (read(src_fd, &header, sizeof(header)) != sizeof(header))
    237         bb_error_msg_and_die("can't read header");
     255    xread(src_fd, &header, sizeof(header));
    238256
    239257    if (header.pos >= (9 * 5 * 5))
     
    260278        p[i] = (1 << RC_MODEL_TOTAL_BITS) >> 1;
    261279
    262     rc_init(&rc, src_fd, 0x10000);
     280    rc = rc_init(src_fd); /*, RC_BUFFER_SIZE); */
    263281
    264282    while (global_pos + buffer_pos < header.dst_size) {
     
    267285        prob =
    268286            p + LZMA_IS_MATCH + (state << LZMA_NUM_POS_BITS_MAX) + pos_state;
    269         if (rc_is_bit_0(&rc, prob)) {
     287        if (rc_is_bit_0(rc, prob)) {
    270288            mi = 1;
    271             rc_update_bit_0(&rc, prob);
     289            rc_update_bit_0(rc, prob);
    272290            prob = (p + LZMA_LITERAL + (LZMA_LIT_SIZE
    273291                    * ((((buffer_pos + global_pos) & literal_pos_mask) << lc)
     
    287305                    bit = match_byte & 0x100;
    288306                    prob_lit = prob + 0x100 + bit + mi;
    289                     if (rc_get_bit(&rc, prob_lit, &mi)) {
     307                    if (rc_get_bit(rc, prob_lit, &mi)) {
    290308                        if (!bit)
    291309                            break;
     
    298316            while (mi < 0x100) {
    299317                prob_lit = prob + mi;
    300                 rc_get_bit(&rc, prob_lit, &mi);
     318                rc_get_bit(rc, prob_lit, &mi);
    301319            }
    302320            previous_byte = (uint8_t) mi;
     
    306324                buffer_pos = 0;
    307325                global_pos += header.dict_size;
    308                 write(dst_fd, buffer, header.dict_size);
     326                if (full_write(dst_fd, buffer, header.dict_size) != header.dict_size)
     327                    goto bad;
     328                USE_DESKTOP(total_written += header.dict_size;)
    309329            }
    310330            if (state < 4)
     
    318338            uint16_t *prob_len;
    319339
    320             rc_update_bit_1(&rc, prob);
     340            rc_update_bit_1(rc, prob);
    321341            prob = p + LZMA_IS_REP + state;
    322             if (rc_is_bit_0(&rc, prob)) {
    323                 rc_update_bit_0(&rc, prob);
     342            if (rc_is_bit_0(rc, prob)) {
     343                rc_update_bit_0(rc, prob);
    324344                rep3 = rep2;
    325345                rep2 = rep1;
     
    328348                prob = p + LZMA_LEN_CODER;
    329349            } else {
    330                 rc_update_bit_1(&rc, prob);
     350                rc_update_bit_1(rc, prob);
    331351                prob = p + LZMA_IS_REP_G0 + state;
    332                 if (rc_is_bit_0(&rc, prob)) {
    333                     rc_update_bit_0(&rc, prob);
     352                if (rc_is_bit_0(rc, prob)) {
     353                    rc_update_bit_0(rc, prob);
    334354                    prob = (p + LZMA_IS_REP_0_LONG
    335355                            + (state << LZMA_NUM_POS_BITS_MAX) + pos_state);
    336                     if (rc_is_bit_0(&rc, prob)) {
    337                         rc_update_bit_0(&rc, prob);
     356                    if (rc_is_bit_0(rc, prob)) {
     357                        rc_update_bit_0(rc, prob);
    338358
    339359                        state = state < LZMA_NUM_LIT_STATES ? 9 : 11;
     
    346366                            buffer_pos = 0;
    347367                            global_pos += header.dict_size;
    348                             write(dst_fd, buffer, header.dict_size);
     368                            if (full_write(dst_fd, buffer, header.dict_size) != header.dict_size)
     369                                goto bad;
     370                            USE_DESKTOP(total_written += header.dict_size;)
    349371                        }
    350372                        continue;
    351373                    } else {
    352                         rc_update_bit_1(&rc, prob);
     374                        rc_update_bit_1(rc, prob);
    353375                    }
    354376                } else {
    355377                    uint32_t distance;
    356378
    357                     rc_update_bit_1(&rc, prob);
     379                    rc_update_bit_1(rc, prob);
    358380                    prob = p + LZMA_IS_REP_G1 + state;
    359                     if (rc_is_bit_0(&rc, prob)) {
    360                         rc_update_bit_0(&rc, prob);
     381                    if (rc_is_bit_0(rc, prob)) {
     382                        rc_update_bit_0(rc, prob);
    361383                        distance = rep1;
    362384                    } else {
    363                         rc_update_bit_1(&rc, prob);
     385                        rc_update_bit_1(rc, prob);
    364386                        prob = p + LZMA_IS_REP_G2 + state;
    365                         if (rc_is_bit_0(&rc, prob)) {
    366                             rc_update_bit_0(&rc, prob);
     387                        if (rc_is_bit_0(rc, prob)) {
     388                            rc_update_bit_0(rc, prob);
    367389                            distance = rep2;
    368390                        } else {
    369                             rc_update_bit_1(&rc, prob);
     391                            rc_update_bit_1(rc, prob);
    370392                            distance = rep3;
    371393                            rep3 = rep2;
     
    381403
    382404            prob_len = prob + LZMA_LEN_CHOICE;
    383             if (rc_is_bit_0(&rc, prob_len)) {
    384                 rc_update_bit_0(&rc, prob_len);
     405            if (rc_is_bit_0(rc, prob_len)) {
     406                rc_update_bit_0(rc, prob_len);
    385407                prob_len = (prob + LZMA_LEN_LOW
    386408                            + (pos_state << LZMA_LEN_NUM_LOW_BITS));
     
    388410                num_bits = LZMA_LEN_NUM_LOW_BITS;
    389411            } else {
    390                 rc_update_bit_1(&rc, prob_len);
     412                rc_update_bit_1(rc, prob_len);
    391413                prob_len = prob + LZMA_LEN_CHOICE_2;
    392                 if (rc_is_bit_0(&rc, prob_len)) {
    393                     rc_update_bit_0(&rc, prob_len);
     414                if (rc_is_bit_0(rc, prob_len)) {
     415                    rc_update_bit_0(rc, prob_len);
    394416                    prob_len = (prob + LZMA_LEN_MID
    395417                                + (pos_state << LZMA_LEN_NUM_MID_BITS));
     
    397419                    num_bits = LZMA_LEN_NUM_MID_BITS;
    398420                } else {
    399                     rc_update_bit_1(&rc, prob_len);
     421                    rc_update_bit_1(rc, prob_len);
    400422                    prob_len = prob + LZMA_LEN_HIGH;
    401423                    offset = ((1 << LZMA_LEN_NUM_LOW_BITS)
     
    404426                }
    405427            }
    406             rc_bit_tree_decode(&rc, prob_len, num_bits, &len);
     428            rc_bit_tree_decode(rc, prob_len, num_bits, &len);
    407429            len += offset;
    408430
     
    417439                      LZMA_NUM_LEN_TO_POS_STATES - 1)
    418440                     << LZMA_NUM_POS_SLOT_BITS);
    419                 rc_bit_tree_decode(&rc, prob, LZMA_NUM_POS_SLOT_BITS,
     441                rc_bit_tree_decode(rc, prob, LZMA_NUM_POS_SLOT_BITS,
    420442                                   &pos_slot);
    421443                if (pos_slot >= LZMA_START_POS_MODEL_INDEX) {
     
    428450                        num_bits -= LZMA_NUM_ALIGN_BITS;
    429451                        while (num_bits--)
    430                             rep0 = (rep0 << 1) | rc_direct_bit(&rc);
     452                            rep0 = (rep0 << 1) | rc_direct_bit(rc);
    431453                        prob = p + LZMA_ALIGN;
    432454                        rep0 <<= LZMA_NUM_ALIGN_BITS;
     
    436458                    mi = 1;
    437459                    while (num_bits--) {
    438                         if (rc_get_bit(&rc, prob + mi, &mi))
     460                        if (rc_get_bit(rc, prob + mi, &mi))
    439461                            rep0 |= i;
    440462                        i <<= 1;
     
    457479                    buffer_pos = 0;
    458480                    global_pos += header.dict_size;
    459                     write(dst_fd, buffer, header.dict_size);
     481                    if (full_write(dst_fd, buffer, header.dict_size) != header.dict_size)
     482                        goto bad;
     483                    USE_DESKTOP(total_written += header.dict_size;)
    460484                }
    461485                len--;
     
    464488    }
    465489
    466     write(dst_fd, buffer, buffer_pos);
    467     rc_free(&rc);
    468     return 0;
    469 }
    470 
    471 /* vi:set ts=4: */
     490
     491    if (full_write(dst_fd, buffer, buffer_pos) != buffer_pos) {
     492 bad:
     493        rc_free(rc);
     494        return -1;
     495    }
     496    rc_free(rc);
     497    USE_DESKTOP(total_written += buffer_pos;)
     498    return USE_DESKTOP(total_written) + 0;
     499}
Note: See TracChangeset for help on using the changeset viewer.