diff -uNr linux-2.6.4-uml2641.orig/arch/um/drivers/ubd_kern.c linux-2.6.4-uml2641-odirectswap.orig/arch/um/drivers/ubd_kern.c --- linux-2.6.4-uml2641.orig/arch/um/drivers/ubd_kern.c Sat Feb 14 14:00:43 2004 +++ linux-2.6.4-uml2641-odirectswap.orig/arch/um/drivers/ubd_kern.c Fri Mar 19 00:08:33 2004 @@ -15,6 +15,8 @@ * only /dev/ubdN/discN this version also has lots of * clean ups preparing for ubd-many. * James McMechan + * 2004-03-19 Addition of O_DIRECT option 'D' by + * William Stearns (wstearns@pobox.com) */ #define MAJOR_NR UBD_MAJOR @@ -326,6 +328,10 @@ dev->no_cow = 1; str++; } + if (*str == 'D'){ + flags.d = 1; + str++; + } if(*str++ != '='){ printk(KERN_ERR "ubd_setup : Expected '='\n"); @@ -369,7 +375,10 @@ " 0 to 7. Appending an 'r' to the number will cause that device\n" " to be mounted read-only. For example ubd1r=./ext_fs. Appending\n" " an 's' (has to be _after_ 'r', if there is one) will cause data\n" -" to be written to disk on the host immediately.\n\n" +" to be written to disk on the host immediately. The third option\n" +" 'd' tells uml 'do not use a cow file' for this block device.\n" +" Finally, 'D' turns on DIRECT disk access, where the host writes\n" +" the data directly with no caching. Good for swap files.\n\n" ); static int fakehd_set = 0; diff -uNr linux-2.6.4-uml2641.orig/arch/um/include/os.h linux-2.6.4-uml2641-odirectswap.orig/arch/um/include/os.h --- linux-2.6.4-uml2641.orig/arch/um/include/os.h Sat Feb 14 14:00:43 2004 +++ linux-2.6.4-uml2641-odirectswap.orig/arch/um/include/os.h Thu Mar 18 23:22:49 2004 @@ -52,10 +52,12 @@ unsigned int a : 1; /* O_APPEND */ unsigned int e : 1; /* O_EXCL */ unsigned int cl : 1; /* FD_CLOEXEC */ + unsigned int d : 1; /* O_DIRECT */ }; #define OPENFLAGS() ((struct openflags) { .r = 0, .w = 0, .s = 0, .c = 0, \ - .t = 0, .a = 0, .e = 0, .cl = 0 }) + .t = 0, .a = 0, .e = 0, .cl = 0, \ + .d = 0 }) static inline struct openflags of_read(struct openflags flags) { @@ -116,6 +118,12 @@ flags.cl = 1; return(flags); } + +static inline struct openflags of_direct(struct openflags flags) +{ + flags.d = 1; + return(flags); +} extern int os_stat_file(const char *file_name, struct uml_stat *buf); extern int os_stat_fd(const int fd, struct uml_stat *buf); diff -uNr linux-2.6.4-uml2641.orig/arch/um/os-Linux/file.c linux-2.6.4-uml2641-odirectswap.orig/arch/um/os-Linux/file.c --- linux-2.6.4-uml2641.orig/arch/um/os-Linux/file.c Sat Feb 14 14:00:43 2004 +++ linux-2.6.4-uml2641-odirectswap.orig/arch/um/os-Linux/file.c Thu Mar 18 23:24:40 2004 @@ -265,6 +265,7 @@ 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)