#define NO_THUNK_TYPE_SIZE
#include "thunk.h"
#define NO_THUNK_TYPE_SIZE
#include "thunk.h"
struct BlockDriverState {
int fd; /* if -1, only COW mappings */
int64_t total_sectors;
struct BlockDriverState {
int fd; /* if -1, only COW mappings */
int64_t total_sectors;
--- /dev/null
+/* user mode linux compatible COW file */
+#define COW_MAGIC 0x4f4f4f4d /* MOOO */
+#define COW_VERSION 2
+
+struct cow_header_v2 {
+ uint32_t magic;
+ uint32_t version;
+ char backing_file[1024];
+ int32_t mtime;
+ uint64_t size;
+ uint32_t sectorsize;
+};
+
#include <sys/stat.h>
#include <netinet/in.h>
#include <sys/stat.h>
#include <netinet/in.h>
int main(int argc, char **argv)
{
const char *image_filename, *cow_filename;
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;
int64_t image_size;
image_filename = NULL;
image_size = 0;
- c = getopt(argc, argv, "hf:");
+ c = getopt(argc, argv, "hf:s");
if (c == -1)
break;
switch(c) {
if (c == -1)
break;
switch(c) {
case 'f':
image_filename = optarg;
break;
case 'f':
image_filename = optarg;
break;
+ case 's':
+ simple_image = 1;
+ break;
image_size = (int64_t)atoi(argv[optind + 1]) * 2 * 1024;
}
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_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;
}
close(cow_fd);
return 0;
int bdrv_commit(BlockDriverState *bs);
void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size);
int bdrv_commit(BlockDriverState *bs);
void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size);
-/* user mode linux compatible COW file */
-#define COW_MAGIC 0x4f4f4f4d /* MOOO */
-#define COW_VERSION 2
-
-struct cow_header_v2 {
- uint32_t magic;
- uint32_t version;
- char backing_file[1024];
- int32_t mtime;
- uint64_t size;
- uint32_t sectorsize;
-};
-
/* vga.c */
#define VGA_RAM_SIZE (4096 * 1024)
/* vga.c */
#define VGA_RAM_SIZE (4096 * 1024)