# This enables O_DIRECT on ubd devices.  This needs work, as it will die
# when creating a COW file.  It also needs to do buffered I/O on backing
# files.
Index: linux-2.6.17/arch/um/drivers/ubd_kern.c
===================================================================
--- linux-2.6.17.orig/arch/um/drivers/ubd_kern.c	2007-11-19 11:25:47.000000000 -0500
+++ linux-2.6.17/arch/um/drivers/ubd_kern.c	2007-11-19 11:31:48.000000000 -0500
@@ -121,10 +121,10 @@ static struct gendisk *fake_gendisk[MAX_
 
 #ifdef CONFIG_BLK_DEV_UBD_SYNC
 #define OPEN_FLAGS ((struct openflags) { .r = 1, .w = 1, .s = 1, .c = 0, \
-					 .cl = 1 })
+				         .cl = 1, .d = 1 })
 #else
 #define OPEN_FLAGS ((struct openflags) { .r = 1, .w = 1, .s = 0, .c = 0, \
-					 .cl = 1 })
+					 .cl = 1, .d = 1  })
 #endif
 static struct openflags global_openflags = OPEN_FLAGS;
 
@@ -944,6 +944,7 @@ static int ubd_add(int n, char **error_o
 	ubd_dev->queue->queuedata = ubd_dev;
 
 	blk_queue_max_hw_segments(ubd_dev->queue, MAX_SG);
+	blk_queue_hardsect_size(ubd_dev->queue, PAGE_SIZE);
 	err = ubd_disk_register(MAJOR_NR, ubd_dev->size, n, &ubd_gendisk[n]);
 	if(err){
 		*error_out = "Failed to register device";
Index: linux-2.6.17/arch/um/os-Linux/file.c
===================================================================
--- linux-2.6.17.orig/arch/um/os-Linux/file.c	2007-11-19 10:54:33.000000000 -0500
+++ linux-2.6.17/arch/um/os-Linux/file.c	2007-11-19 11:31:48.000000000 -0500
@@ -259,6 +259,7 @@ int os_open_file(char *file, struct open
 	if(flags.c) f |= O_CREAT;
 	if(flags.t) f |= O_TRUNC;
 	if(flags.e) f |= O_EXCL;
+	if(flags.d) f |= O_DIRECT;
 
 	fd = open64(file, f, mode);
 	if(fd < 0)