mirror of https://github.com/xemu-project/xemu.git
added cow.h
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@653 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
a735aa3139
commit
00af2b2680
2
block.c
2
block.c
|
@ -45,6 +45,8 @@
|
||||||
#define NO_THUNK_TYPE_SIZE
|
#define NO_THUNK_TYPE_SIZE
|
||||||
#include "thunk.h"
|
#include "thunk.h"
|
||||||
|
|
||||||
|
#include "cow.h"
|
||||||
|
|
||||||
struct BlockDriverState {
|
struct BlockDriverState {
|
||||||
int fd; /* if -1, only COW mappings */
|
int fd; /* if -1, only COW mappings */
|
||||||
int64_t total_sectors;
|
int64_t total_sectors;
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
/* 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;
|
||||||
|
};
|
||||||
|
|
22
qemu-mkcow.c
22
qemu-mkcow.c
|
@ -41,7 +41,7 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
|
||||||
#include "vl.h"
|
#include "cow.h"
|
||||||
|
|
||||||
#include "bswap.h"
|
#include "bswap.h"
|
||||||
|
|
||||||
|
@ -101,13 +101,14 @@ void help(void)
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
const char *image_filename, *cow_filename;
|
const char *image_filename, *cow_filename;
|
||||||
int cow_fd, c, nb_args;
|
int cow_fd, c, nb_args, simple_image;
|
||||||
int64_t image_size;
|
int64_t image_size;
|
||||||
|
|
||||||
image_filename = NULL;
|
image_filename = NULL;
|
||||||
image_size = 0;
|
image_size = 0;
|
||||||
|
simple_image = 0;
|
||||||
for(;;) {
|
for(;;) {
|
||||||
c = getopt(argc, argv, "hf:");
|
c = getopt(argc, argv, "hf:s");
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
switch(c) {
|
switch(c) {
|
||||||
|
@ -117,6 +118,9 @@ int main(int argc, char **argv)
|
||||||
case 'f':
|
case 'f':
|
||||||
image_filename = optarg;
|
image_filename = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 's':
|
||||||
|
simple_image = 1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!image_filename)
|
if (!image_filename)
|
||||||
|
@ -131,12 +135,16 @@ int main(int argc, char **argv)
|
||||||
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)
|
if (!cow_fd < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (cow_create(cow_fd, image_filename, image_size) < 0) {
|
if (simple_image) {
|
||||||
fprintf(stderr, "%s: error while formating\n", cow_filename);
|
ftruncate64(cow_fd, image_size * 512);
|
||||||
exit(1);
|
} 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);
|
close(cow_fd);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
13
vl.h
13
vl.h
|
@ -58,19 +58,6 @@ void bdrv_get_geometry(BlockDriverState *bs, int64_t *nb_sectors_ptr);
|
||||||
int bdrv_commit(BlockDriverState *bs);
|
int bdrv_commit(BlockDriverState *bs);
|
||||||
void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size);
|
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 */
|
/* vga.c */
|
||||||
|
|
||||||
#define VGA_RAM_SIZE (4096 * 1024)
|
#define VGA_RAM_SIZE (4096 * 1024)
|
||||||
|
|
Loading…
Reference in New Issue