127685a8dSFam Zheng /* 227685a8dSFam Zheng * Header for DMG driver 327685a8dSFam Zheng * 427685a8dSFam Zheng * Copyright (c) 2004-2006 Fabrice Bellard 527685a8dSFam Zheng * Copyright (c) 2016 Red hat, Inc. 627685a8dSFam Zheng * 727685a8dSFam Zheng * Permission is hereby granted, free of charge, to any person obtaining a copy 827685a8dSFam Zheng * of this software and associated documentation files (the "Software"), to deal 927685a8dSFam Zheng * in the Software without restriction, including without limitation the rights 1027685a8dSFam Zheng * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 1127685a8dSFam Zheng * copies of the Software, and to permit persons to whom the Software is 1227685a8dSFam Zheng * furnished to do so, subject to the following conditions: 1327685a8dSFam Zheng * 1427685a8dSFam Zheng * The above copyright notice and this permission notice shall be included in 1527685a8dSFam Zheng * all copies or substantial portions of the Software. 1627685a8dSFam Zheng * 1727685a8dSFam Zheng * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1827685a8dSFam Zheng * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1927685a8dSFam Zheng * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 2027685a8dSFam Zheng * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 2127685a8dSFam Zheng * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 2227685a8dSFam Zheng * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 2327685a8dSFam Zheng * THE SOFTWARE. 2427685a8dSFam Zheng */ 2527685a8dSFam Zheng 2627685a8dSFam Zheng #ifndef BLOCK_DMG_H 2727685a8dSFam Zheng #define BLOCK_DMG_H 2827685a8dSFam Zheng 2927685a8dSFam Zheng #include "block/block_int.h" 3027685a8dSFam Zheng #include <zlib.h> 3127685a8dSFam Zheng 3227685a8dSFam Zheng typedef struct BDRVDMGState { 3327685a8dSFam Zheng CoMutex lock; 3427685a8dSFam Zheng /* each chunk contains a certain number of sectors, 3527685a8dSFam Zheng * offsets[i] is the offset in the .dmg file, 3627685a8dSFam Zheng * lengths[i] is the length of the compressed chunk, 3727685a8dSFam Zheng * sectors[i] is the sector beginning at offsets[i], 3827685a8dSFam Zheng * sectorcounts[i] is the number of sectors in that chunk, 3927685a8dSFam Zheng * the sectors array is ordered 4027685a8dSFam Zheng * 0<=i<n_chunks */ 4127685a8dSFam Zheng 4227685a8dSFam Zheng uint32_t n_chunks; 4327685a8dSFam Zheng uint32_t *types; 4427685a8dSFam Zheng uint64_t *offsets; 4527685a8dSFam Zheng uint64_t *lengths; 4627685a8dSFam Zheng uint64_t *sectors; 4727685a8dSFam Zheng uint64_t *sectorcounts; 4827685a8dSFam Zheng uint32_t current_chunk; 4927685a8dSFam Zheng uint8_t *compressed_chunk; 5027685a8dSFam Zheng uint8_t *uncompressed_chunk; 5127685a8dSFam Zheng z_stream zstream; 5227685a8dSFam Zheng } BDRVDMGState; 5327685a8dSFam Zheng 54*fdd5e90fSPhilippe Mathieu-Daudé typedef int BdrvDmgUncompressFunc(char *next_in, unsigned int avail_in, 5527685a8dSFam Zheng char *next_out, unsigned int avail_out); 5627685a8dSFam Zheng 57*fdd5e90fSPhilippe Mathieu-Daudé extern BdrvDmgUncompressFunc *dmg_uncompress_bz2; 58*fdd5e90fSPhilippe Mathieu-Daudé extern BdrvDmgUncompressFunc *dmg_uncompress_lzfse; 597a40b418SJulio Faracco 6027685a8dSFam Zheng #endif 61