提交 57d1a2b6 编写于 作者: B bellard

win32 port


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1041 c046a42c-6fe2-441c-8c8c-71466251a162
上级 d5249393
...@@ -113,7 +113,7 @@ void __attribute__((noreturn)) error(const char *fmt, ...) ...@@ -113,7 +113,7 @@ void __attribute__((noreturn)) error(const char *fmt, ...)
{ {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
fprintf(stderr, "qemuimg: "); fprintf(stderr, "qemu-img: ");
vfprintf(stderr, fmt, ap); vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
exit(1); exit(1);
...@@ -127,8 +127,8 @@ static void format_print(void *opaque, const char *name) ...@@ -127,8 +127,8 @@ static void format_print(void *opaque, const char *name)
void help(void) void help(void)
{ {
printf("qemuimg version " QEMU_VERSION ", Copyright (c) 2004 Fabrice Bellard\n" printf("qemu-img version " QEMU_VERSION ", Copyright (c) 2004 Fabrice Bellard\n"
"usage: qemuimg command [command options]\n" "usage: qemu-img command [command options]\n"
"QEMU disk image utility\n" "QEMU disk image utility\n"
"\n" "\n"
"Command syntax:\n" "Command syntax:\n"
...@@ -592,6 +592,24 @@ static int img_convert(int argc, char **argv) ...@@ -592,6 +592,24 @@ static int img_convert(int argc, char **argv)
return 0; return 0;
} }
#ifdef _WIN32
static int64_t get_allocated_file_size(const char *filename)
{
struct _stati64 st;
if (_stati64(filename, &st) < 0)
return -1;
return st.st_size;
}
#else
static int64_t get_allocated_file_size(const char *filename)
{
struct stat st;
if (stat(filename, &st) < 0)
return -1;
return (int64_t)st.st_blocks * 512;
}
#endif
static int img_info(int argc, char **argv) static int img_info(int argc, char **argv)
{ {
int c; int c;
...@@ -599,8 +617,7 @@ static int img_info(int argc, char **argv) ...@@ -599,8 +617,7 @@ static int img_info(int argc, char **argv)
BlockDriver *drv; BlockDriver *drv;
BlockDriverState *bs; BlockDriverState *bs;
char fmt_name[128], size_buf[128], dsize_buf[128]; char fmt_name[128], size_buf[128], dsize_buf[128];
int64_t total_sectors; int64_t total_sectors, allocated_size;
struct stat st;
fmt = NULL; fmt = NULL;
for(;;) { for(;;) {
...@@ -637,10 +654,11 @@ static int img_info(int argc, char **argv) ...@@ -637,10 +654,11 @@ static int img_info(int argc, char **argv)
bdrv_get_format(bs, fmt_name, sizeof(fmt_name)); bdrv_get_format(bs, fmt_name, sizeof(fmt_name));
bdrv_get_geometry(bs, &total_sectors); bdrv_get_geometry(bs, &total_sectors);
get_human_readable_size(size_buf, sizeof(size_buf), total_sectors * 512); get_human_readable_size(size_buf, sizeof(size_buf), total_sectors * 512);
if (stat(filename, &st) < 0) allocated_size = get_allocated_file_size(filename);
error("Could not stat '%s'", filename); if (allocated_size < 0)
error("Could not get file size '%s'", filename);
get_human_readable_size(dsize_buf, sizeof(dsize_buf), get_human_readable_size(dsize_buf, sizeof(dsize_buf),
(int64_t)st.st_blocks * 512); allocated_size);
printf("image: %s\n" printf("image: %s\n"
"file format: %s\n" "file format: %s\n"
"virtual size: %s (%lld bytes)\n" "virtual size: %s (%lld bytes)\n"
......
...@@ -45,7 +45,16 @@ ...@@ -45,7 +45,16 @@
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
#define lseek64 _lseeki64 #define lseek _lseeki64
#define ENOTSUP 4096
/* XXX: find 64 bit version */
#define ftruncate chsize
static inline char *realpath(const char *path, char *resolved_path)
{
_fullpath(resolved_path, path, _MAX_PATH);
return resolved_path;
}
#endif #endif
#ifdef QEMU_TOOL #ifdef QEMU_TOOL
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册