memcg: add mem_cgroup_disabled()
[safe/jmp/linux-2.6] / mm / fadvise.c
index 168c78a..a1da969 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (C) 2002, Linus Torvalds
  *
- * 11Jan2003   akpm@digeo.com
+ * 11Jan2003   Andrew Morton
  *             Initial version.
  */
 
@@ -38,7 +38,7 @@ 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)) {
+       if (S_ISFIFO(file->f_path.dentry->d_inode->i_mode)) {
                ret = -ESPIPE;
                goto out;
        }
@@ -49,9 +49,21 @@ asmlinkage long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice)
                goto out;
        }
 
-       if (mapping->a_ops->get_xip_page)
-               /* no bad return value, but ignore advice */
+       if (mapping->a_ops->get_xip_mem) {
+               switch (advice) {
+               case POSIX_FADV_NORMAL:
+               case POSIX_FADV_RANDOM:
+               case POSIX_FADV_SEQUENTIAL:
+               case POSIX_FADV_WILLNEED:
+               case POSIX_FADV_NOREUSE:
+               case POSIX_FADV_DONTNEED:
+                       /* no bad return value, but ignore advice */
+                       break;
+               default:
+                       ret = -EINVAL;
+               }
                goto out;
+       }
 
        /* Careful about overflows. Len == 0 means "as much as possible" */
        endbyte = offset + len;