b257a9619b
Agreed with espie.
134 lines
2.9 KiB
Plaintext
134 lines
2.9 KiB
Plaintext
$OpenBSD: patch-block-raw-posix_c,v 1.1.1.1 2010/05/27 17:33:42 fgsch Exp $
|
|
--- block-raw-posix.c.orig Sun Jan 6 14:38:42 2008
|
|
+++ block-raw-posix.c Tue Apr 1 22:38:47 2008
|
|
@@ -28,7 +28,9 @@
|
|
#endif
|
|
#include "block_int.h"
|
|
#include <assert.h>
|
|
+#ifndef CONFIG_NO_AIO
|
|
#include <aio.h>
|
|
+#endif
|
|
|
|
#ifdef CONFIG_COCOA
|
|
#include <paths.h>
|
|
@@ -55,6 +57,11 @@
|
|
#ifdef __FreeBSD__
|
|
#include <sys/disk.h>
|
|
#endif
|
|
+#ifdef __OpenBSD__
|
|
+#include <sys/ioctl.h>
|
|
+#include <sys/disklabel.h>
|
|
+#include <sys/dkio.h>
|
|
+#endif
|
|
|
|
//#define DEBUG_FLOPPY
|
|
|
|
@@ -231,6 +238,7 @@ label__raw_write__success:
|
|
}
|
|
|
|
/***********************************************************/
|
|
+#ifndef CONFIG_NO_AIO
|
|
/* Unix AIO using POSIX AIO */
|
|
|
|
typedef struct RawAIOCB {
|
|
@@ -456,6 +464,37 @@ static void raw_aio_cancel(BlockDriverAIOCB *blockacb)
|
|
}
|
|
}
|
|
|
|
+# else /* !CONFIG_NO_AIO */
|
|
+
|
|
+void qemu_aio_init(void)
|
|
+{
|
|
+}
|
|
+
|
|
+void qemu_aio_poll(void)
|
|
+{
|
|
+}
|
|
+
|
|
+void qemu_aio_flush(void)
|
|
+{
|
|
+}
|
|
+
|
|
+void qemu_aio_wait_start(void)
|
|
+{
|
|
+}
|
|
+
|
|
+void qemu_aio_wait(void)
|
|
+{
|
|
+#ifndef QEMU_IMG
|
|
+ qemu_bh_poll();
|
|
+#endif
|
|
+}
|
|
+
|
|
+void qemu_aio_wait_end(void)
|
|
+{
|
|
+}
|
|
+
|
|
+#endif /* !CONFIG_NO_AIO */
|
|
+
|
|
static void raw_close(BlockDriverState *bs)
|
|
{
|
|
BDRVRawState *s = bs->opaque;
|
|
@@ -475,8 +514,25 @@ static int raw_truncate(BlockDriverState *bs, int64_t
|
|
return 0;
|
|
}
|
|
|
|
+#ifdef __OpenBSD__
|
|
static int64_t raw_getlength(BlockDriverState *bs)
|
|
{
|
|
+ int fd = ((BDRVRawState*)bs->opaque)->fd;
|
|
+ struct stat st;
|
|
+ if (fstat(fd, &st))
|
|
+ return -1;
|
|
+ if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode)) {
|
|
+ struct disklabel dl;
|
|
+ if (ioctl(fd, DIOCGDINFO, &dl))
|
|
+ return -1;
|
|
+ return (uint64_t)dl.d_secsize *
|
|
+ dl.d_partitions[DISKPART(st.st_rdev)].p_size;
|
|
+ } else
|
|
+ return st.st_size;
|
|
+}
|
|
+#else /* !__OpenBSD__ */
|
|
+static int64_t raw_getlength(BlockDriverState *bs)
|
|
+{
|
|
BDRVRawState *s = bs->opaque;
|
|
int fd = s->fd;
|
|
int64_t size;
|
|
@@ -521,6 +577,7 @@ static int64_t raw_getlength(BlockDriverState *bs)
|
|
}
|
|
return size;
|
|
}
|
|
+#endif
|
|
|
|
static int raw_create(const char *filename, int64_t total_size,
|
|
const char *backing_file, int flags)
|
|
@@ -555,11 +612,12 @@ BlockDriver bdrv_raw = {
|
|
raw_close,
|
|
raw_create,
|
|
raw_flush,
|
|
-
|
|
+#ifndef CONFIG_NO_AIO
|
|
.bdrv_aio_read = raw_aio_read,
|
|
.bdrv_aio_write = raw_aio_write,
|
|
.bdrv_aio_cancel = raw_aio_cancel,
|
|
.aiocb_size = sizeof(RawAIOCB),
|
|
+#endif
|
|
.protocol_name = "file",
|
|
.bdrv_pread = raw_pread,
|
|
.bdrv_pwrite = raw_pwrite,
|
|
@@ -907,11 +965,12 @@ BlockDriver bdrv_host_device = {
|
|
raw_close,
|
|
NULL,
|
|
raw_flush,
|
|
-
|
|
+#ifndef CONFIG_NO_AIO
|
|
.bdrv_aio_read = raw_aio_read,
|
|
.bdrv_aio_write = raw_aio_write,
|
|
.bdrv_aio_cancel = raw_aio_cancel,
|
|
.aiocb_size = sizeof(RawAIOCB),
|
|
+#endif
|
|
.bdrv_pread = raw_pread,
|
|
.bdrv_pwrite = raw_pwrite,
|
|
.bdrv_getlength = raw_getlength,
|