linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / mm / fadvise.c
index e6d1c32..d257c89 100644 (file)
@@ -15,6 +15,9 @@
 #include <linux/backing-dev.h>
 #include <linux/pagevec.h>
 #include <linux/fadvise.h>
+#include <linux/syscalls.h>
+
+#include <asm/unistd.h>
 
 /*
  * POSIX_FADV_WILLNEED could set PG_Referenced, and POSIX_FADV_NOREUSE could
@@ -34,12 +37,21 @@ asmlinkage long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice)
        if (!file)
                return -EBADF;
 
+       if (S_ISFIFO(file->f_dentry->d_inode->i_mode)) {
+               ret = -ESPIPE;
+               goto out;
+       }
+
        mapping = file->f_mapping;
        if (!mapping || len < 0) {
                ret = -EINVAL;
                goto out;
        }
 
+       if (mapping->a_ops->get_xip_page)
+               /* no bad return value, but ignore advice */
+               goto out;
+
        /* Careful about overflows. Len == 0 means "as much as possible" */
        endbyte = offset + len;
        if (!len || endbyte < len)
@@ -98,8 +110,11 @@ out:
        return ret;
 }
 
+#ifdef __ARCH_WANT_SYS_FADVISE64
+
 asmlinkage long sys_fadvise64(int fd, loff_t offset, size_t len, int advice)
 {
        return sys_fadvise64_64(fd, offset, len, advice);
 }
 
+#endif