Revision 31f38120

b/block/cow.c
209 209
    struct stat st;
210 210
    int64_t image_sectors = 0;
211 211
    const char *image_filename = NULL;
212
    int ret;
212 213

  
213 214
    /* Read out options */
214 215
    while (options && options->name) {
......
248 249
    }
249 250
    cow_header.sectorsize = cpu_to_be32(512);
250 251
    cow_header.size = cpu_to_be64(image_sectors * 512);
251
    write(cow_fd, &cow_header, sizeof(cow_header));
252
    ret = qemu_write_full(cow_fd, &cow_header, sizeof(cow_header));
253
    if (ret != sizeof(cow_header)) {
254
        ret = -1;
255
        goto exit;
256
    }
257

  
252 258
    /* resize to include at least all the bitmap */
253
    ftruncate(cow_fd, sizeof(cow_header) + ((image_sectors + 7) >> 3));
259
    ret = ftruncate(cow_fd, sizeof(cow_header) + ((image_sectors + 7) >> 3));
260
    if (ret) {
261
        ret = -errno;
262
        goto exit;
263
    }
264

  
265
    ret = 0;
266
exit:
254 267
    close(cow_fd);
255
    return 0;
268
    return ret;
256 269
}
257 270

  
258 271
static void cow_flush(BlockDriverState *bs)

Also available in: Unified diff