Revision d5249393

b/Makefile
1 1
include config-host.mak
2 2

  
3
CFLAGS=-Wall -O2 -g -fno-strict-aliasing
3
CFLAGS=-Wall -O2 -g -fno-strict-aliasing 
4 4
ifdef CONFIG_DARWIN
5 5
CFLAGS+= -mdynamic-no-pic
6 6
endif
......
9 9
endif
10 10
LDFLAGS=-g
11 11
LIBS=
12
DEFINES+=-D_GNU_SOURCE
12
DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
13 13
TOOLS=qemu-img
14 14
ifdef CONFIG_STATIC
15 15
LDFLAGS+=-static
b/Makefile.target
159 159

  
160 160
#########################################################
161 161

  
162
DEFINES+=-D_GNU_SOURCE
162
DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
163 163
LIBS+=-lm
164 164
ifndef CONFIG_USER_ONLY
165 165
LIBS+=-lz
b/block-cow.c
173 173
    
174 174
    while (nb_sectors > 0) {
175 175
        if (is_changed(s->cow_bitmap, sector_num, nb_sectors, &n)) {
176
            lseek64(s->fd, s->cow_sectors_offset + sector_num * 512, SEEK_SET);
176
            lseek(s->fd, s->cow_sectors_offset + sector_num * 512, SEEK_SET);
177 177
            ret = read(s->fd, buf, n * 512);
178 178
            if (ret != n * 512) 
179 179
                return -1;
......
193 193
    BDRVCowState *s = bs->opaque;
194 194
    int ret, i;
195 195
    
196
    lseek64(s->fd, s->cow_sectors_offset + sector_num * 512, SEEK_SET);
196
    lseek(s->fd, s->cow_sectors_offset + sector_num * 512, SEEK_SET);
197 197
    ret = write(s->fd, buf, nb_sectors * 512);
198 198
    if (ret != nb_sectors * 512) 
199 199
        return -1;
b/block-qcow.c
137 137
    s->l1_table = qemu_malloc(s->l1_size * sizeof(uint64_t));
138 138
    if (!s->l1_table)
139 139
        goto fail;
140
    lseek64(fd, s->l1_table_offset, SEEK_SET);
140
    lseek(fd, s->l1_table_offset, SEEK_SET);
141 141
    if (read(fd, s->l1_table, s->l1_size * sizeof(uint64_t)) != 
142 142
        s->l1_size * sizeof(uint64_t))
143 143
        goto fail;
......
161 161
        len = header.backing_file_size;
162 162
        if (len > 1023)
163 163
            len = 1023;
164
        lseek64(fd, header.backing_file_offset, SEEK_SET);
164
        lseek(fd, header.backing_file_offset, SEEK_SET);
165 165
        if (read(fd, bs->backing_file, len) != len)
166 166
            goto fail;
167 167
        bs->backing_file[len] = '\0';
......
275 275
        if (!allocate)
276 276
            return 0;
277 277
        /* allocate a new l2 entry */
278
        l2_offset = lseek64(s->fd, 0, SEEK_END);
278
        l2_offset = lseek(s->fd, 0, SEEK_END);
279 279
        /* round to cluster size */
280 280
        l2_offset = (l2_offset + s->cluster_size - 1) & ~(s->cluster_size - 1);
281 281
        /* update the L1 entry */
282 282
        s->l1_table[l1_index] = l2_offset;
283 283
        tmp = cpu_to_be64(l2_offset);
284
        lseek64(s->fd, s->l1_table_offset + l1_index * sizeof(tmp), SEEK_SET);
284
        lseek(s->fd, s->l1_table_offset + l1_index * sizeof(tmp), SEEK_SET);
285 285
        if (write(s->fd, &tmp, sizeof(tmp)) != sizeof(tmp))
286 286
            return 0;
287 287
        new_l2_table = 1;
......
336 336
               overwritten */
337 337
            if (decompress_cluster(s, cluster_offset) < 0)
338 338
                return 0;
339
            cluster_offset = lseek64(s->fd, 0, SEEK_END);
339
            cluster_offset = lseek(s->fd, 0, SEEK_END);
340 340
            cluster_offset = (cluster_offset + s->cluster_size - 1) & 
341 341
                ~(s->cluster_size - 1);
342 342
            /* write the cluster content */
343
            lseek64(s->fd, cluster_offset, SEEK_SET);
343
            lseek(s->fd, cluster_offset, SEEK_SET);
344 344
            if (write(s->fd, s->cluster_cache, s->cluster_size) != 
345 345
                s->cluster_size)
346 346
                return -1;
347 347
        } else {
348
            cluster_offset = lseek64(s->fd, 0, SEEK_END);
348
            cluster_offset = lseek(s->fd, 0, SEEK_END);
349 349
            if (allocate == 1) {
350 350
                /* round to cluster size */
351 351
                cluster_offset = (cluster_offset + s->cluster_size - 1) & 
......
364 364
                                            s->cluster_data, 
365 365
                                            s->cluster_data + 512, 1, 1,
366 366
                                            &s->aes_encrypt_key);
367
                            lseek64(s->fd, cluster_offset + i * 512, SEEK_SET);
367
                            lseek(s->fd, cluster_offset + i * 512, SEEK_SET);
368 368
                            if (write(s->fd, s->cluster_data, 512) != 512)
369 369
                                return -1;
370 370
                        }
......
378 378
        /* update L2 table */
379 379
        tmp = cpu_to_be64(cluster_offset);
380 380
        l2_table[l2_index] = tmp;
381
        lseek64(s->fd, l2_offset + l2_index * sizeof(tmp), SEEK_SET);
381
        lseek(s->fd, l2_offset + l2_index * sizeof(tmp), SEEK_SET);
382 382
        if (write(s->fd, &tmp, sizeof(tmp)) != sizeof(tmp))
383 383
            return 0;
384 384
    }
......
437 437
    if (s->cluster_cache_offset != coffset) {
438 438
        csize = cluster_offset >> (63 - s->cluster_bits);
439 439
        csize &= (s->cluster_size - 1);
440
        lseek64(s->fd, coffset, SEEK_SET);
440
        lseek(s->fd, coffset, SEEK_SET);
441 441
        ret = read(s->fd, s->cluster_data, csize);
442 442
        if (ret != csize) 
443 443
            return -1;
......
470 470
                return -1;
471 471
            memcpy(buf, s->cluster_cache + index_in_cluster * 512, 512 * n);
472 472
        } else {
473
            lseek64(s->fd, cluster_offset + index_in_cluster * 512, SEEK_SET);
473
            lseek(s->fd, cluster_offset + index_in_cluster * 512, SEEK_SET);
474 474
            ret = read(s->fd, buf, n * 512);
475 475
            if (ret != n * 512) 
476 476
                return -1;
......
503 503
                                            index_in_cluster + n);
504 504
        if (!cluster_offset)
505 505
            return -1;
506
        lseek64(s->fd, cluster_offset + index_in_cluster * 512, SEEK_SET);
506
        lseek(s->fd, cluster_offset + index_in_cluster * 512, SEEK_SET);
507 507
        if (s->crypt_method) {
508 508
            encrypt_sectors(s, sector_num, s->cluster_data, buf, n, 1,
509 509
                            &s->aes_encrypt_key);
......
650 650
        cluster_offset = get_cluster_offset(bs, sector_num << 9, 2, 
651 651
                                            out_len, 0, 0);
652 652
        cluster_offset &= s->cluster_offset_mask;
653
        lseek64(s->fd, cluster_offset, SEEK_SET);
653
        lseek(s->fd, cluster_offset, SEEK_SET);
654 654
        if (write(s->fd, out_buf, out_len) != out_len) {
655 655
            qemu_free(out_buf);
656 656
            return -1;
b/block-vmdk.c
239 239
        if (!cluster_offset) {
240 240
            memset(buf, 0, 512 * n);
241 241
        } else {
242
            lseek64(s->fd, cluster_offset + index_in_cluster * 512, SEEK_SET);
242
            lseek(s->fd, cluster_offset + index_in_cluster * 512, SEEK_SET);
243 243
            ret = read(s->fd, buf, n * 512);
244 244
            if (ret != n * 512) 
245 245
                return -1;
b/block.c
71 71
    return drv->bdrv_create(filename, size_in_sectors, backing_file, flags);
72 72
}
73 73

  
74
/* XXX: race condition possible */
74
#ifdef _WIN32
75
static void get_tmp_filename(char *filename, int size)
76
{
77
    /* XXX: find a better function */
78
    tmpnam(filename);
79
}
80
#else
75 81
static void get_tmp_filename(char *filename, int size)
76 82
{
77 83
    int fd;
84
    /* XXX: race condition possible */
78 85
    pstrcpy(filename, size, "/tmp/vl.XXXXXX");
79 86
    fd = mkstemp(filename);
80 87
    close(fd);
81 88
}
89
#endif
82 90

  
83 91
static BlockDriver *find_image_format(const char *filename)
84 92
{
......
514 522
            return -1;
515 523
        bs->read_only = 1;
516 524
    }
517
    size = lseek64(fd, 0, SEEK_END);
525
    size = lseek(fd, 0, SEEK_END);
518 526
    bs->total_sectors = size / 512;
519 527
    s->fd = fd;
520 528
    return 0;
......
526 534
    BDRVRawState *s = bs->opaque;
527 535
    int ret;
528 536
    
529
    lseek64(s->fd, sector_num * 512, SEEK_SET);
537
    lseek(s->fd, sector_num * 512, SEEK_SET);
530 538
    ret = read(s->fd, buf, nb_sectors * 512);
531 539
    if (ret != nb_sectors * 512) 
532 540
        return -1;
......
539 547
    BDRVRawState *s = bs->opaque;
540 548
    int ret;
541 549
    
542
    lseek64(s->fd, sector_num * 512, SEEK_SET);
550
    lseek(s->fd, sector_num * 512, SEEK_SET);
543 551
    ret = write(s->fd, buf, nb_sectors * 512);
544 552
    if (ret != nb_sectors * 512) 
545 553
        return -1;
......
564 572
              0644);
565 573
    if (fd < 0)
566 574
        return -EIO;
567
    ftruncate64(fd, total_size * 512);
575
    ftruncate(fd, total_size * 512);
568 576
    close(fd);
569 577
    return 0;
570 578
}
b/configure
429 429
# XXX: suppress that
430 430
if [ "$bsd" = "yes" ] ; then
431 431
  echo "#define O_LARGEFILE 0" >> $config_h
432
  echo "#define lseek64 lseek" >> $config_h
433
  echo "#define mkstemp64 mkstemp" >> $config_h
434
  echo "#define ftruncate64 ftruncate" >> $config_h
435
  echo "#define off64_t off_t" >> $config_h
436 432
  echo "#define MAP_ANONYMOUS MAP_ANON" >> $config_h
437 433
  echo "#define _BSD 1" >> $config_h
438 434
fi

Also available in: Unified diff