dmg.c (6ed5546fa7bf12c5b87ef76bafb86e1d77ed6e85) | dmg.c (a65064816d64db463f4c24bd81dcaad62fee89eb) |
---|---|
1/* 2 * QEMU Block driver for DMG images 3 * 4 * Copyright (c) 2004 Johannes E. Schindelin 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights --- 425 unchanged lines hidden (view full) --- 434 BDRVDMGState *s = bs->opaque; 435 DmgHeaderState ds; 436 uint64_t rsrc_fork_offset, rsrc_fork_length; 437 uint64_t plist_xml_offset, plist_xml_length; 438 int64_t offset; 439 int ret; 440 441 bs->read_only = 1; | 1/* 2 * QEMU Block driver for DMG images 3 * 4 * Copyright (c) 2004 Johannes E. Schindelin 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights --- 425 unchanged lines hidden (view full) --- 434 BDRVDMGState *s = bs->opaque; 435 DmgHeaderState ds; 436 uint64_t rsrc_fork_offset, rsrc_fork_length; 437 uint64_t plist_xml_offset, plist_xml_length; 438 int64_t offset; 439 int ret; 440 441 bs->read_only = 1; |
442 bs->request_alignment = BDRV_SECTOR_SIZE; /* No sub-sector I/O supported */ | |
443 444 s->n_chunks = 0; 445 s->offsets = s->lengths = s->sectors = s->sectorcounts = NULL; 446 /* used by dmg_read_mish_block to keep track of the current I/O position */ 447 ds.data_fork_offset = 0; 448 ds.max_compressed_size = 1; 449 ds.max_sectors_per_chunk = 1; 450 --- 91 unchanged lines hidden (view full) --- 542 g_free(s->lengths); 543 g_free(s->sectors); 544 g_free(s->sectorcounts); 545 qemu_vfree(s->compressed_chunk); 546 qemu_vfree(s->uncompressed_chunk); 547 return ret; 548} 549 | 442 443 s->n_chunks = 0; 444 s->offsets = s->lengths = s->sectors = s->sectorcounts = NULL; 445 /* used by dmg_read_mish_block to keep track of the current I/O position */ 446 ds.data_fork_offset = 0; 447 ds.max_compressed_size = 1; 448 ds.max_sectors_per_chunk = 1; 449 --- 91 unchanged lines hidden (view full) --- 541 g_free(s->lengths); 542 g_free(s->sectors); 543 g_free(s->sectorcounts); 544 qemu_vfree(s->compressed_chunk); 545 qemu_vfree(s->uncompressed_chunk); 546 return ret; 547} 548 |
549static void dmg_refresh_limits(BlockDriverState *bs, Error **errp) 550{ 551 bs->request_alignment = BDRV_SECTOR_SIZE; /* No sub-sector I/O supported */ 552} 553 |
|
550static inline int is_sector_in_chunk(BDRVDMGState* s, 551 uint32_t chunk_num, uint64_t sector_num) 552{ 553 if (chunk_num >= s->n_chunks || s->sectors[chunk_num] > sector_num || 554 s->sectors[chunk_num] + s->sectorcounts[chunk_num] <= sector_num) { 555 return 0; 556 } else { 557 return -1; --- 157 unchanged lines hidden (view full) --- 715 inflateEnd(&s->zstream); 716} 717 718static BlockDriver bdrv_dmg = { 719 .format_name = "dmg", 720 .instance_size = sizeof(BDRVDMGState), 721 .bdrv_probe = dmg_probe, 722 .bdrv_open = dmg_open, | 554static inline int is_sector_in_chunk(BDRVDMGState* s, 555 uint32_t chunk_num, uint64_t sector_num) 556{ 557 if (chunk_num >= s->n_chunks || s->sectors[chunk_num] > sector_num || 558 s->sectors[chunk_num] + s->sectorcounts[chunk_num] <= sector_num) { 559 return 0; 560 } else { 561 return -1; --- 157 unchanged lines hidden (view full) --- 719 inflateEnd(&s->zstream); 720} 721 722static BlockDriver bdrv_dmg = { 723 .format_name = "dmg", 724 .instance_size = sizeof(BDRVDMGState), 725 .bdrv_probe = dmg_probe, 726 .bdrv_open = dmg_open, |
727 .bdrv_refresh_limits = dmg_refresh_limits, |
|
723 .bdrv_co_preadv = dmg_co_preadv, 724 .bdrv_close = dmg_close, 725}; 726 727static void bdrv_dmg_init(void) 728{ 729 bdrv_register(&bdrv_dmg); 730} 731 732block_init(bdrv_dmg_init); | 728 .bdrv_co_preadv = dmg_co_preadv, 729 .bdrv_close = dmg_close, 730}; 731 732static void bdrv_dmg_init(void) 733{ 734 bdrv_register(&bdrv_dmg); 735} 736 737block_init(bdrv_dmg_init); |