#include <getopt.h>
#include <inttypes.h>
#include <unistd.h>
-#include <sys/mman.h>
#include <fcntl.h>
#include <signal.h>
#include <time.h>
#include <sys/time.h>
-#include <malloc.h>
-#include <termios.h>
-#include <sys/poll.h>
#include <errno.h>
-#include <sys/wait.h>
#include <sys/stat.h>
#include <netinet/in.h>
-#include "vl.h"
+#include "cow.h"
#include "bswap.h"
void help(void)
{
- printf("vlmkcow version " QEMU_VERSION ", Copyright (c) 2003 Fabrice Bellard\n"
- "usage: vlmkcow [-h] [-f disk_image] cow_image [cow_size]\n"
+ printf("qemu-mkcow version " QEMU_VERSION ", Copyright (c) 2003 Fabrice Bellard\n"
+ "usage: qemu-mkcow [-h] [-f disk_image] cow_image [cow_size]\n"
"Create a Copy On Write disk image from an optional raw disk image\n"
"\n"
"-f disk_image set the raw disk image name\n"
int main(int argc, char **argv)
{
const char *image_filename, *cow_filename;
- int cow_fd, c, nb_args;
+ int cow_fd, c, nb_args, simple_image;
int64_t image_size;
image_filename = NULL;
image_size = 0;
+ simple_image = 0;
for(;;) {
- c = getopt(argc, argv, "hf:");
+ c = getopt(argc, argv, "hf:s");
if (c == -1)
break;
switch(c) {
case 'f':
image_filename = optarg;
break;
+ case 's':
+ simple_image = 1;
+ break;
}
}
if (!image_filename)
image_size = (int64_t)atoi(argv[optind + 1]) * 2 * 1024;
}
- cow_fd = open(cow_filename, O_RDWR | O_CREAT | O_TRUNC, 0644);
+ cow_fd = open(cow_filename, O_RDWR | O_CREAT | O_TRUNC | O_LARGEFILE, 0644);
if (!cow_fd < 0)
return -1;
- if (cow_create(cow_fd, image_filename, image_size) < 0) {
- fprintf(stderr, "%s: error while formating\n", cow_filename);
- exit(1);
+ if (simple_image) {
+ ftruncate64(cow_fd, image_size * 512);
+ } else {
+ if (cow_create(cow_fd, image_filename, image_size) < 0) {
+ fprintf(stderr, "%s: error while formating\n", cow_filename);
+ exit(1);
+ }
}
close(cow_fd);
return 0;