-CFLAGS=-Wall -O2 -g -fno-strict-aliasing
+CFLAGS=-Wall -O2 -g -fno-strict-aliasing
ifdef CONFIG_DARWIN
CFLAGS+= -mdynamic-no-pic
endif
ifdef CONFIG_DARWIN
CFLAGS+= -mdynamic-no-pic
endif
+DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
TOOLS=qemu-img
ifdef CONFIG_STATIC
LDFLAGS+=-static
TOOLS=qemu-img
ifdef CONFIG_STATIC
LDFLAGS+=-static
#########################################################
#########################################################
+DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
LIBS+=-lm
ifndef CONFIG_USER_ONLY
LIBS+=-lz
LIBS+=-lm
ifndef CONFIG_USER_ONLY
LIBS+=-lz
while (nb_sectors > 0) {
if (is_changed(s->cow_bitmap, sector_num, nb_sectors, &n)) {
while (nb_sectors > 0) {
if (is_changed(s->cow_bitmap, sector_num, nb_sectors, &n)) {
- lseek64(s->fd, s->cow_sectors_offset + sector_num * 512, SEEK_SET);
+ lseek(s->fd, s->cow_sectors_offset + sector_num * 512, SEEK_SET);
ret = read(s->fd, buf, n * 512);
if (ret != n * 512)
return -1;
ret = read(s->fd, buf, n * 512);
if (ret != n * 512)
return -1;
BDRVCowState *s = bs->opaque;
int ret, i;
BDRVCowState *s = bs->opaque;
int ret, i;
- lseek64(s->fd, s->cow_sectors_offset + sector_num * 512, SEEK_SET);
+ lseek(s->fd, s->cow_sectors_offset + sector_num * 512, SEEK_SET);
ret = write(s->fd, buf, nb_sectors * 512);
if (ret != nb_sectors * 512)
return -1;
ret = write(s->fd, buf, nb_sectors * 512);
if (ret != nb_sectors * 512)
return -1;
s->l1_table = qemu_malloc(s->l1_size * sizeof(uint64_t));
if (!s->l1_table)
goto fail;
s->l1_table = qemu_malloc(s->l1_size * sizeof(uint64_t));
if (!s->l1_table)
goto fail;
- lseek64(fd, s->l1_table_offset, SEEK_SET);
+ lseek(fd, s->l1_table_offset, SEEK_SET);
if (read(fd, s->l1_table, s->l1_size * sizeof(uint64_t)) !=
s->l1_size * sizeof(uint64_t))
goto fail;
if (read(fd, s->l1_table, s->l1_size * sizeof(uint64_t)) !=
s->l1_size * sizeof(uint64_t))
goto fail;
len = header.backing_file_size;
if (len > 1023)
len = 1023;
len = header.backing_file_size;
if (len > 1023)
len = 1023;
- lseek64(fd, header.backing_file_offset, SEEK_SET);
+ lseek(fd, header.backing_file_offset, SEEK_SET);
if (read(fd, bs->backing_file, len) != len)
goto fail;
bs->backing_file[len] = '\0';
if (read(fd, bs->backing_file, len) != len)
goto fail;
bs->backing_file[len] = '\0';
if (!allocate)
return 0;
/* allocate a new l2 entry */
if (!allocate)
return 0;
/* allocate a new l2 entry */
- l2_offset = lseek64(s->fd, 0, SEEK_END);
+ l2_offset = lseek(s->fd, 0, SEEK_END);
/* round to cluster size */
l2_offset = (l2_offset + s->cluster_size - 1) & ~(s->cluster_size - 1);
/* update the L1 entry */
s->l1_table[l1_index] = l2_offset;
tmp = cpu_to_be64(l2_offset);
/* round to cluster size */
l2_offset = (l2_offset + s->cluster_size - 1) & ~(s->cluster_size - 1);
/* update the L1 entry */
s->l1_table[l1_index] = l2_offset;
tmp = cpu_to_be64(l2_offset);
- lseek64(s->fd, s->l1_table_offset + l1_index * sizeof(tmp), SEEK_SET);
+ lseek(s->fd, s->l1_table_offset + l1_index * sizeof(tmp), SEEK_SET);
if (write(s->fd, &tmp, sizeof(tmp)) != sizeof(tmp))
return 0;
new_l2_table = 1;
if (write(s->fd, &tmp, sizeof(tmp)) != sizeof(tmp))
return 0;
new_l2_table = 1;
overwritten */
if (decompress_cluster(s, cluster_offset) < 0)
return 0;
overwritten */
if (decompress_cluster(s, cluster_offset) < 0)
return 0;
- cluster_offset = lseek64(s->fd, 0, SEEK_END);
+ cluster_offset = lseek(s->fd, 0, SEEK_END);
cluster_offset = (cluster_offset + s->cluster_size - 1) &
~(s->cluster_size - 1);
/* write the cluster content */
cluster_offset = (cluster_offset + s->cluster_size - 1) &
~(s->cluster_size - 1);
/* write the cluster content */
- lseek64(s->fd, cluster_offset, SEEK_SET);
+ lseek(s->fd, cluster_offset, SEEK_SET);
if (write(s->fd, s->cluster_cache, s->cluster_size) !=
s->cluster_size)
return -1;
} else {
if (write(s->fd, s->cluster_cache, s->cluster_size) !=
s->cluster_size)
return -1;
} else {
- cluster_offset = lseek64(s->fd, 0, SEEK_END);
+ cluster_offset = lseek(s->fd, 0, SEEK_END);
if (allocate == 1) {
/* round to cluster size */
cluster_offset = (cluster_offset + s->cluster_size - 1) &
if (allocate == 1) {
/* round to cluster size */
cluster_offset = (cluster_offset + s->cluster_size - 1) &
s->cluster_data,
s->cluster_data + 512, 1, 1,
&s->aes_encrypt_key);
s->cluster_data,
s->cluster_data + 512, 1, 1,
&s->aes_encrypt_key);
- lseek64(s->fd, cluster_offset + i * 512, SEEK_SET);
+ lseek(s->fd, cluster_offset + i * 512, SEEK_SET);
if (write(s->fd, s->cluster_data, 512) != 512)
return -1;
}
if (write(s->fd, s->cluster_data, 512) != 512)
return -1;
}
/* update L2 table */
tmp = cpu_to_be64(cluster_offset);
l2_table[l2_index] = tmp;
/* update L2 table */
tmp = cpu_to_be64(cluster_offset);
l2_table[l2_index] = tmp;
- lseek64(s->fd, l2_offset + l2_index * sizeof(tmp), SEEK_SET);
+ lseek(s->fd, l2_offset + l2_index * sizeof(tmp), SEEK_SET);
if (write(s->fd, &tmp, sizeof(tmp)) != sizeof(tmp))
return 0;
}
if (write(s->fd, &tmp, sizeof(tmp)) != sizeof(tmp))
return 0;
}
if (s->cluster_cache_offset != coffset) {
csize = cluster_offset >> (63 - s->cluster_bits);
csize &= (s->cluster_size - 1);
if (s->cluster_cache_offset != coffset) {
csize = cluster_offset >> (63 - s->cluster_bits);
csize &= (s->cluster_size - 1);
- lseek64(s->fd, coffset, SEEK_SET);
+ lseek(s->fd, coffset, SEEK_SET);
ret = read(s->fd, s->cluster_data, csize);
if (ret != csize)
return -1;
ret = read(s->fd, s->cluster_data, csize);
if (ret != csize)
return -1;
return -1;
memcpy(buf, s->cluster_cache + index_in_cluster * 512, 512 * n);
} else {
return -1;
memcpy(buf, s->cluster_cache + index_in_cluster * 512, 512 * n);
} else {
- lseek64(s->fd, cluster_offset + index_in_cluster * 512, SEEK_SET);
+ lseek(s->fd, cluster_offset + index_in_cluster * 512, SEEK_SET);
ret = read(s->fd, buf, n * 512);
if (ret != n * 512)
return -1;
ret = read(s->fd, buf, n * 512);
if (ret != n * 512)
return -1;
index_in_cluster + n);
if (!cluster_offset)
return -1;
index_in_cluster + n);
if (!cluster_offset)
return -1;
- lseek64(s->fd, cluster_offset + index_in_cluster * 512, SEEK_SET);
+ lseek(s->fd, cluster_offset + index_in_cluster * 512, SEEK_SET);
if (s->crypt_method) {
encrypt_sectors(s, sector_num, s->cluster_data, buf, n, 1,
&s->aes_encrypt_key);
if (s->crypt_method) {
encrypt_sectors(s, sector_num, s->cluster_data, buf, n, 1,
&s->aes_encrypt_key);
cluster_offset = get_cluster_offset(bs, sector_num << 9, 2,
out_len, 0, 0);
cluster_offset &= s->cluster_offset_mask;
cluster_offset = get_cluster_offset(bs, sector_num << 9, 2,
out_len, 0, 0);
cluster_offset &= s->cluster_offset_mask;
- lseek64(s->fd, cluster_offset, SEEK_SET);
+ lseek(s->fd, cluster_offset, SEEK_SET);
if (write(s->fd, out_buf, out_len) != out_len) {
qemu_free(out_buf);
return -1;
if (write(s->fd, out_buf, out_len) != out_len) {
qemu_free(out_buf);
return -1;
if (!cluster_offset) {
memset(buf, 0, 512 * n);
} else {
if (!cluster_offset) {
memset(buf, 0, 512 * n);
} else {
- lseek64(s->fd, cluster_offset + index_in_cluster * 512, SEEK_SET);
+ lseek(s->fd, cluster_offset + index_in_cluster * 512, SEEK_SET);
ret = read(s->fd, buf, n * 512);
if (ret != n * 512)
return -1;
ret = read(s->fd, buf, n * 512);
if (ret != n * 512)
return -1;
return drv->bdrv_create(filename, size_in_sectors, backing_file, flags);
}
return drv->bdrv_create(filename, size_in_sectors, backing_file, flags);
}
-/* XXX: race condition possible */
+#ifdef _WIN32
+static void get_tmp_filename(char *filename, int size)
+{
+ /* XXX: find a better function */
+ tmpnam(filename);
+}
+#else
static void get_tmp_filename(char *filename, int size)
{
int fd;
static void get_tmp_filename(char *filename, int size)
{
int fd;
+ /* XXX: race condition possible */
pstrcpy(filename, size, "/tmp/vl.XXXXXX");
fd = mkstemp(filename);
close(fd);
}
pstrcpy(filename, size, "/tmp/vl.XXXXXX");
fd = mkstemp(filename);
close(fd);
}
static BlockDriver *find_image_format(const char *filename)
{
static BlockDriver *find_image_format(const char *filename)
{
return -1;
bs->read_only = 1;
}
return -1;
bs->read_only = 1;
}
- size = lseek64(fd, 0, SEEK_END);
+ size = lseek(fd, 0, SEEK_END);
bs->total_sectors = size / 512;
s->fd = fd;
return 0;
bs->total_sectors = size / 512;
s->fd = fd;
return 0;
BDRVRawState *s = bs->opaque;
int ret;
BDRVRawState *s = bs->opaque;
int ret;
- lseek64(s->fd, sector_num * 512, SEEK_SET);
+ lseek(s->fd, sector_num * 512, SEEK_SET);
ret = read(s->fd, buf, nb_sectors * 512);
if (ret != nb_sectors * 512)
return -1;
ret = read(s->fd, buf, nb_sectors * 512);
if (ret != nb_sectors * 512)
return -1;
BDRVRawState *s = bs->opaque;
int ret;
BDRVRawState *s = bs->opaque;
int ret;
- lseek64(s->fd, sector_num * 512, SEEK_SET);
+ lseek(s->fd, sector_num * 512, SEEK_SET);
ret = write(s->fd, buf, nb_sectors * 512);
if (ret != nb_sectors * 512)
return -1;
ret = write(s->fd, buf, nb_sectors * 512);
if (ret != nb_sectors * 512)
return -1;
0644);
if (fd < 0)
return -EIO;
0644);
if (fd < 0)
return -EIO;
- ftruncate64(fd, total_size * 512);
+ ftruncate(fd, total_size * 512);
# XXX: suppress that
if [ "$bsd" = "yes" ] ; then
echo "#define O_LARGEFILE 0" >> $config_h
# XXX: suppress that
if [ "$bsd" = "yes" ] ; then
echo "#define O_LARGEFILE 0" >> $config_h
- echo "#define lseek64 lseek" >> $config_h
- echo "#define mkstemp64 mkstemp" >> $config_h
- echo "#define ftruncate64 ftruncate" >> $config_h
- echo "#define off64_t off_t" >> $config_h
echo "#define MAP_ANONYMOUS MAP_ANON" >> $config_h
echo "#define _BSD 1" >> $config_h
fi
echo "#define MAP_ANONYMOUS MAP_ANON" >> $config_h
echo "#define _BSD 1" >> $config_h
fi