vmdk.c (32cc71de) | vmdk.c (353a5d84) |
---|---|
1/* 2 * Block driver for the VMDK format 3 * 4 * Copyright (c) 2004 Fabrice Bellard 5 * Copyright (c) 2005 Filip Navara 6 * 7 * Permission is hereby granted, free of charge, to any person obtaining a copy 8 * of this software and associated documentation files (the "Software"), to deal --- 459 unchanged lines hidden (view full) --- 468 BDRVVmdkState *s = bs->opaque; 469 int ret; 470 471 desc = g_malloc0(DESC_SIZE + 1); 472 ret = bdrv_pread(bs->file, s->desc_offset, DESC_SIZE, desc, 0); 473 if (ret < 0) { 474 goto out; 475 } | 1/* 2 * Block driver for the VMDK format 3 * 4 * Copyright (c) 2004 Fabrice Bellard 5 * Copyright (c) 2005 Filip Navara 6 * 7 * Permission is hereby granted, free of charge, to any person obtaining a copy 8 * of this software and associated documentation files (the "Software"), to deal --- 459 unchanged lines hidden (view full) --- 468 BDRVVmdkState *s = bs->opaque; 469 int ret; 470 471 desc = g_malloc0(DESC_SIZE + 1); 472 ret = bdrv_pread(bs->file, s->desc_offset, DESC_SIZE, desc, 0); 473 if (ret < 0) { 474 goto out; 475 } |
476 ret = 0; | |
477 478 p_name = strstr(desc, "parentFileNameHint"); 479 if (p_name != NULL) { 480 char *end_name; 481 482 p_name += sizeof("parentFileNameHint") + 1; 483 end_name = strchr(p_name, '\"'); 484 if (end_name == NULL) { --- 415 unchanged lines hidden (view full) --- 900 buf = g_malloc(size + 1); 901 902 ret = bdrv_pread(file, desc_offset, size, buf, 0); 903 if (ret < 0) { 904 error_setg_errno(errp, -ret, "Could not read from file"); 905 g_free(buf); 906 return NULL; 907 } | 476 477 p_name = strstr(desc, "parentFileNameHint"); 478 if (p_name != NULL) { 479 char *end_name; 480 481 p_name += sizeof("parentFileNameHint") + 1; 482 end_name = strchr(p_name, '\"'); 483 if (end_name == NULL) { --- 415 unchanged lines hidden (view full) --- 899 buf = g_malloc(size + 1); 900 901 ret = bdrv_pread(file, desc_offset, size, buf, 0); 902 if (ret < 0) { 903 error_setg_errno(errp, -ret, "Could not read from file"); 904 g_free(buf); 905 return NULL; 906 } |
908 buf[ret] = 0; | 907 buf[size] = 0; |
909 910 return buf; 911} 912 913static int vmdk_open_vmdk4(BlockDriverState *bs, 914 BdrvChild *file, 915 int flags, QDict *options, Error **errp) 916{ --- 708 unchanged lines hidden (view full) --- 1625 } 1626 l2_table = (char *)extent->l2_cache + (min_index * l2_size_bytes); 1627 BLKDBG_EVENT(extent->file, BLKDBG_L2_LOAD); 1628 if (bdrv_pread(extent->file, 1629 (int64_t)l2_offset * 512, 1630 l2_size_bytes, 1631 l2_table, 1632 0 | 908 909 return buf; 910} 911 912static int vmdk_open_vmdk4(BlockDriverState *bs, 913 BdrvChild *file, 914 int flags, QDict *options, Error **errp) 915{ --- 708 unchanged lines hidden (view full) --- 1624 } 1625 l2_table = (char *)extent->l2_cache + (min_index * l2_size_bytes); 1626 BLKDBG_EVENT(extent->file, BLKDBG_L2_LOAD); 1627 if (bdrv_pread(extent->file, 1628 (int64_t)l2_offset * 512, 1629 l2_size_bytes, 1630 l2_table, 1631 0 |
1633 ) != l2_size_bytes) { | 1632 ) < 0) { |
1634 return VMDK_ERROR; 1635 } 1636 1637 extent->l2_cache_offsets[min_index] = l2_offset; 1638 extent->l2_cache_counts[min_index] = 1; 1639 found: 1640 l2_index = ((offset >> 9) / extent->cluster_sectors) % extent->l2_size; 1641 if (m_data) { --- 1507 unchanged lines hidden --- | 1633 return VMDK_ERROR; 1634 } 1635 1636 extent->l2_cache_offsets[min_index] = l2_offset; 1637 extent->l2_cache_counts[min_index] = 1; 1638 found: 1639 l2_index = ((offset >> 9) / extent->cluster_sectors) % extent->l2_size; 1640 if (m_data) { --- 1507 unchanged lines hidden --- |