Am 01.07.2011 06:55, schrieb Fam Zheng: > The return type of get_cluster_offset was an offset that use 0 to denote > 'not allocated', this will be no longer true for flat extents, as we see > flat extent file as a single huge cluster whose offset is 0 and length > is the whole file length. > So now we use int return value, 0 means success and otherwise offset > invalid. > > Signed-off-by: Fam Zheng <famc...@gmail.com> > --- > block/vmdk.c | 73 > +++++++++++++++++++++++++++++++--------------------------- > 1 files changed, 39 insertions(+), 34 deletions(-) > > diff --git a/block/vmdk.c b/block/vmdk.c > index 8783629..40e4464 100644 > --- a/block/vmdk.c > +++ b/block/vmdk.c > @@ -685,18 +685,23 @@ static int vmdk_L2update(VmdkExtent *extent, > VmdkMetaData *m_data) > return 0; > } > > -static uint64_t get_cluster_offset(BlockDriverState *bs, > +static int get_cluster_offset(BlockDriverState *bs, > VmdkExtent *extent, > VmdkMetaData *m_data, > - uint64_t offset, int allocate) > + uint64_t offset, > + int allocate, > + uint64_t *cluster_offset) > { > unsigned int l1_index, l2_offset, l2_index; > int min_index, i, j; > uint32_t min_count, *l2_table, tmp = 0; > - uint64_t cluster_offset; > > if (m_data) > m_data->valid = 0; > + if (extent->flat) { > + *cluster_offset = 0; > + return 0; > + } > > l1_index = (offset >> 9) / extent->l1_entry_sectors; > if (l1_index >= extent->l1_size) {
Let me complete what comes next: l1_index = (offset >> 9) / extent->l1_entry_sectors; if (l1_index >= extent->l1_size) { return 0; } l2_offset = extent->l1_table[l1_index]; if (!l2_offset) { return 0; } Shouldn't these returns be changed to -1? Also there is a return 0; after a failed read, which doesn't seem to be changed. Kevin