|
|
cd9d16 |
diff -rup qemu-kvm-0.15.1/block/vvfat.c frob/block/vvfat.c
|
|
|
cd9d16 |
--- qemu-kvm-0.15.1/block/vvfat.c 2012-07-29 20:56:28.318227757 -0400
|
|
|
cd9d16 |
+++ frob/block/vvfat.c 2012-07-29 20:59:15.537859208 -0400
|
|
|
cd9d16 |
@@ -2795,7 +2795,12 @@ static int enable_write_target(BDRVVVFAT
|
|
|
cd9d16 |
array_init(&(s->commits), sizeof(commit_t));
|
|
|
cd9d16 |
|
|
|
cd9d16 |
s->qcow_filename = qemu_malloc(1024);
|
|
|
cd9d16 |
- get_tmp_filename(s->qcow_filename, 1024);
|
|
|
cd9d16 |
+ ret = get_tmp_filename(s->qcow_filename, 1024);
|
|
|
cd9d16 |
+ if (ret < 0) {
|
|
|
cd9d16 |
+ free(s->qcow_filename);
|
|
|
cd9d16 |
+ s->qcow_filename = NULL;
|
|
|
cd9d16 |
+ return ret;
|
|
|
cd9d16 |
+ }
|
|
|
cd9d16 |
|
|
|
cd9d16 |
bdrv_qcow = bdrv_find_format("qcow");
|
|
|
cd9d16 |
options = parse_option_parameters("", bdrv_qcow->create_options, NULL);
|
|
|
cd9d16 |
diff -rup qemu-kvm-0.15.1/block.c frob/block.c
|
|
|
cd9d16 |
--- qemu-kvm-0.15.1/block.c 2012-07-29 20:56:28.367221495 -0400
|
|
|
cd9d16 |
+++ frob/block.c 2012-07-29 20:58:24.931326050 -0400
|
|
|
cd9d16 |
@@ -254,28 +254,36 @@ int bdrv_create_file(const char* filenam
|
|
|
cd9d16 |
return bdrv_create(drv, filename, options);
|
|
|
cd9d16 |
}
|
|
|
cd9d16 |
|
|
|
cd9d16 |
-#ifdef _WIN32
|
|
|
cd9d16 |
-void get_tmp_filename(char *filename, int size)
|
|
|
cd9d16 |
+/*
|
|
|
cd9d16 |
+ * Create a uniquely-named empty temporary file.
|
|
|
cd9d16 |
+ * Return 0 upon success, otherwise a negative errno value.
|
|
|
cd9d16 |
+ */
|
|
|
cd9d16 |
+int get_tmp_filename(char *filename, int size)
|
|
|
cd9d16 |
{
|
|
|
cd9d16 |
+#ifdef _WIN32
|
|
|
cd9d16 |
char temp_dir[MAX_PATH];
|
|
|
cd9d16 |
-
|
|
|
cd9d16 |
- GetTempPath(MAX_PATH, temp_dir);
|
|
|
cd9d16 |
- GetTempFileName(temp_dir, "qem", 0, filename);
|
|
|
cd9d16 |
-}
|
|
|
cd9d16 |
+ /* GetTempFileName requires that its output buffer (4th param)
|
|
|
cd9d16 |
+ have length MAX_PATH or greater. */
|
|
|
cd9d16 |
+ assert(size >= MAX_PATH);
|
|
|
cd9d16 |
+ return (GetTempPath(MAX_PATH, temp_dir)
|
|
|
cd9d16 |
+ && GetTempFileName(temp_dir, "qem", 0, filename)
|
|
|
cd9d16 |
+ ? 0 : -GetLastError());
|
|
|
cd9d16 |
#else
|
|
|
cd9d16 |
-void get_tmp_filename(char *filename, int size)
|
|
|
cd9d16 |
-{
|
|
|
cd9d16 |
int fd;
|
|
|
cd9d16 |
const char *tmpdir;
|
|
|
cd9d16 |
- /* XXX: race condition possible */
|
|
|
cd9d16 |
tmpdir = getenv("TMPDIR");
|
|
|
cd9d16 |
if (!tmpdir)
|
|
|
cd9d16 |
tmpdir = "/tmp";
|
|
|
cd9d16 |
- snprintf(filename, size, "%s/vl.XXXXXX", tmpdir);
|
|
|
cd9d16 |
+ if (snprintf(filename, size, "%s/vl.XXXXXX", tmpdir) >= size) {
|
|
|
cd9d16 |
+ return -EOVERFLOW;
|
|
|
cd9d16 |
+ }
|
|
|
cd9d16 |
fd = mkstemp(filename);
|
|
|
cd9d16 |
- close(fd);
|
|
|
cd9d16 |
-}
|
|
|
cd9d16 |
+ if (fd < 0 || close(fd)) {
|
|
|
cd9d16 |
+ return -errno;
|
|
|
cd9d16 |
+ }
|
|
|
cd9d16 |
+ return 0;
|
|
|
cd9d16 |
#endif
|
|
|
cd9d16 |
+}
|
|
|
cd9d16 |
|
|
|
cd9d16 |
/*
|
|
|
cd9d16 |
* Detect host devices. By convention, /dev/cdrom[N] is always
|
|
|
cd9d16 |
@@ -555,7 +563,10 @@ int bdrv_open(BlockDriverState *bs, cons
|
|
|
cd9d16 |
|
|
|
cd9d16 |
bdrv_delete(bs1);
|
|
|
cd9d16 |
|
|
|
cd9d16 |
- get_tmp_filename(tmp_filename, sizeof(tmp_filename));
|
|
|
cd9d16 |
+ ret = get_tmp_filename(tmp_filename, sizeof(tmp_filename));
|
|
|
cd9d16 |
+ if (ret < 0) {
|
|
|
cd9d16 |
+ return ret;
|
|
|
cd9d16 |
+ }
|
|
|
cd9d16 |
|
|
|
cd9d16 |
/* Real path is meaningless for protocols */
|
|
|
cd9d16 |
if (is_protocol)
|
|
|
cd9d16 |
diff -rup qemu-kvm-0.15.1/block_int.h frob/block_int.h
|
|
|
cd9d16 |
--- qemu-kvm-0.15.1/block_int.h 2011-10-19 09:54:48.000000000 -0400
|
|
|
cd9d16 |
+++ frob/block_int.h 2012-07-29 20:58:24.932325925 -0400
|
|
|
cd9d16 |
@@ -216,7 +216,7 @@ struct BlockDriverAIOCB {
|
|
|
cd9d16 |
BlockDriverAIOCB *next;
|
|
|
cd9d16 |
};
|
|
|
cd9d16 |
|
|
|
cd9d16 |
-void get_tmp_filename(char *filename, int size);
|
|
|
cd9d16 |
+int get_tmp_filename(char *filename, int size);
|
|
|
cd9d16 |
|
|
|
cd9d16 |
void *qemu_aio_get(AIOPool *pool, BlockDriverState *bs,
|
|
|
cd9d16 |
BlockDriverCompletionFunc *cb, void *opaque);
|