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;
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 (!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);
- 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;
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 */
- 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 {
- 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) &
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;
}
/* 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 (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;
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;
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);
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;
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;
+ /* XXX: race condition possible */
pstrcpy(filename, size, "/tmp/vl.XXXXXX");
fd = mkstemp(filename);
close(fd);
}
+#endif
static BlockDriver *find_image_format(const char *filename)
{
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;
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;
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;
0644);
if (fd < 0)
return -EIO;
- ftruncate64(fd, total_size * 512);
+ ftruncate(fd, total_size * 512);
close(fd);
return 0;
}