ia64/xen-unstable

changeset 14799:380db34694d7

[TAPDISK] Fix qcow initialization bug.

fd_end was being incorrectly initialized upon open, leading to data corruption.

Signed-off-by: Jake Wires <jwires@xensource.com>
author Jake Wires <jwires@xensource.com>
date Tue Apr 10 11:40:43 2007 -0700 (2007-04-10)
parents 4dc14c591e6c
children 87e2174b8a0d
files tools/blktap/drivers/block-qcow.c
line diff
     1.1 --- a/tools/blktap/drivers/block-qcow.c	Tue Apr 10 18:49:20 2007 +0100
     1.2 +++ b/tools/blktap/drivers/block-qcow.c	Tue Apr 10 11:40:43 2007 -0700
     1.3 @@ -949,8 +949,14 @@ int tdqcow_open (struct disk_driver *dd,
     1.4  		goto fail;
     1.5  	}
     1.6  	init_fds(dd);
     1.7 -	s->fd_end = (final_cluster == 0 ? (s->l1_table_offset + l1_table_size) : 
     1.8 -				(final_cluster + s->cluster_size));
     1.9 +
    1.10 +	if (!final_cluster)
    1.11 +		s->fd_end = s->l1_table_offset + l1_table_size;
    1.12 +	else {
    1.13 +		s->fd_end = lseek64(fd, 0, SEEK_END);
    1.14 +		if (s->fd_end == (off64_t)-1)
    1.15 +			goto fail;
    1.16 +	}
    1.17  
    1.18  	return 0;
    1.19