Diff for /qemu/block-cloop.c between versions 1.1.1.3 and 1.1.1.4

version 1.1.1.3, 2018/04/24 16:44:49 version 1.1.1.4, 2018/04/24 16:47:12
Line 1 Line 1
 /*  /*
  * QEMU Block driver for CLOOP images   * QEMU Block driver for CLOOP images
  *    *
  * Copyright (c) 2004 Johannes E. Schindelin   * Copyright (c) 2004 Johannes E. Schindelin
  *    *
  * Permission is hereby granted, free of charge, to any person obtaining a copy   * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal   * of this software and associated documentation files (the "Software"), to deal
  * in the Software without restriction, including without limitation the rights   * in the Software without restriction, including without limitation the rights
Line 21 Line 21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.   * THE SOFTWARE.
  */   */
 #include "vl.h"  #include "qemu-common.h"
 #include "block_int.h"  #include "block_int.h"
 #include <zlib.h>  #include <zlib.h>
   
Line 96  cloop_close: Line 96  cloop_close:
     if(inflateInit(&s->zstream) != Z_OK)      if(inflateInit(&s->zstream) != Z_OK)
         goto cloop_close;          goto cloop_close;
     s->current_block=s->n_blocks;      s->current_block=s->n_blocks;
       
     s->sectors_per_block = s->block_size/512;      s->sectors_per_block = s->block_size/512;
     bs->total_sectors = s->n_blocks*s->sectors_per_block;      bs->total_sectors = s->n_blocks*s->sectors_per_block;
     return 0;      return 0;
Line 107  static inline int cloop_read_block(BDRVC Line 107  static inline int cloop_read_block(BDRVC
     if(s->current_block != block_num) {      if(s->current_block != block_num) {
         int ret;          int ret;
         uint32_t bytes = s->offsets[block_num+1]-s->offsets[block_num];          uint32_t bytes = s->offsets[block_num+1]-s->offsets[block_num];
               
         lseek(s->fd, s->offsets[block_num], SEEK_SET);          lseek(s->fd, s->offsets[block_num], SEEK_SET);
         ret = read(s->fd, s->compressed_block, bytes);          ret = read(s->fd, s->compressed_block, bytes);
         if (ret != bytes)           if (ret != bytes)
             return -1;              return -1;
           
         s->zstream.next_in = s->compressed_block;          s->zstream.next_in = s->compressed_block;
         s->zstream.avail_in = bytes;          s->zstream.avail_in = bytes;
         s->zstream.next_out = s->uncompressed_block;          s->zstream.next_out = s->uncompressed_block;
Line 123  static inline int cloop_read_block(BDRVC Line 123  static inline int cloop_read_block(BDRVC
         ret = inflate(&s->zstream, Z_FINISH);          ret = inflate(&s->zstream, Z_FINISH);
         if(ret != Z_STREAM_END || s->zstream.total_out != s->block_size)          if(ret != Z_STREAM_END || s->zstream.total_out != s->block_size)
             return -1;              return -1;
           
         s->current_block = block_num;          s->current_block = block_num;
     }      }
     return 0;      return 0;
 }  }
   
 static int cloop_read(BlockDriverState *bs, int64_t sector_num,   static int cloop_read(BlockDriverState *bs, int64_t sector_num,
                     uint8_t *buf, int nb_sectors)                      uint8_t *buf, int nb_sectors)
 {  {
     BDRVCloopState *s = bs->opaque;      BDRVCloopState *s = bs->opaque;

Removed from v.1.1.1.3  
changed lines
  Added in v.1.1.1.4


unix.superglobalmegacorp.com