diff options
author | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2004-02-26 00:20:56 +0000 |
---|---|---|
committer | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2004-02-26 00:20:56 +0000 |
commit | 00af2b26809d9cfb20af348ea7df255780348dd2 (patch) | |
tree | 859dd98f9c840d38649f6b977c927d93d380087a /qemu-mkcow.c | |
parent | a735aa3139c5b9785eac09dcf6384d89c8d8c445 (diff) | |
download | qemu-00af2b26809d9cfb20af348ea7df255780348dd2.zip qemu-00af2b26809d9cfb20af348ea7df255780348dd2.tar.gz qemu-00af2b26809d9cfb20af348ea7df255780348dd2.tar.bz2 |
added cow.h
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@653 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'qemu-mkcow.c')
-rw-r--r-- | qemu-mkcow.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/qemu-mkcow.c b/qemu-mkcow.c index 2cc6332..7968bf9 100644 --- a/qemu-mkcow.c +++ b/qemu-mkcow.c @@ -41,7 +41,7 @@ #include <sys/stat.h> #include <netinet/in.h> -#include "vl.h" +#include "cow.h" #include "bswap.h" @@ -101,13 +101,14 @@ void help(void) 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) { @@ -117,6 +118,9 @@ int main(int argc, char **argv) case 'f': image_filename = optarg; break; + case 's': + simple_image = 1; + break; } } if (!image_filename) @@ -131,12 +135,16 @@ int main(int argc, char **argv) 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; |