Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / fs / udf / file.c
index 76ef18b..e34b00e 100644 (file)
@@ -4,11 +4,6 @@
  * PURPOSE
  *  File handling routines for the OSTA-UDF(tm) filesystem.
  *
- * CONTACTS
- *  E-mail regarding any portion of the Linux UDF file system should be
- *  directed to the development team mailing list (run by majordomo):
- *    linux_udf@hpesjro.fc.hp.com
- *
  * COPYRIGHT
  *  This file is distributed under the terms of the GNU General Public
  *  License (GPL). Copies of the GPL can be obtained from:
@@ -36,6 +31,7 @@
 #include <asm/uaccess.h>
 #include <linux/kernel.h>
 #include <linux/string.h> /* memset */
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/smp_lock.h>
 #include <linux/pagemap.h>
@@ -49,8 +45,7 @@ static int udf_adinicb_readpage(struct file *file, struct page * page)
        struct inode *inode = page->mapping->host;
        char *kaddr;
 
-       if (!PageLocked(page))
-               PAGE_BUG(page);
+       BUG_ON(!PageLocked(page));
 
        kaddr = kmap(page);
        memset(kaddr, 0, PAGE_CACHE_SIZE);
@@ -67,8 +62,7 @@ static int udf_adinicb_writepage(struct page *page, struct writeback_control *wb
        struct inode *inode = page->mapping->host;
        char *kaddr;
 
-       if (!PageLocked(page))
-               PAGE_BUG(page);
+       BUG_ON(!PageLocked(page));
 
        kaddr = kmap(page);
        memcpy(UDF_I_DATA(inode) + UDF_I_LENEATTR(inode), kaddr, inode->i_size);
@@ -109,7 +103,7 @@ struct address_space_operations udf_adinicb_aops = {
        .commit_write           = udf_adinicb_commit_write,
 };
 
-static ssize_t udf_file_write(struct file * file, const char * buf,
+static ssize_t udf_file_write(struct file * file, const char __user * buf,
        size_t count, loff_t *ppos)
 {
        ssize_t retval;
@@ -188,7 +182,7 @@ int udf_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
 {
        int result = -EINVAL;
 
-       if ( permission(inode, MAY_READ, NULL) != 0 )
+       if ( file_permission(filp, MAY_READ) != 0 )
        {
                udf_debug("no permission to access inode %lu\n",
                                                inode->i_ino);
@@ -204,26 +198,26 @@ int udf_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
        switch (cmd)
        {
                case UDF_GETVOLIDENT:
-                       return copy_to_user((char *)arg,
+                       return copy_to_user((char __user *)arg,
                                UDF_SB_VOLIDENT(inode->i_sb), 32) ? -EFAULT : 0;
                case UDF_RELOCATE_BLOCKS:
                {
                        long old, new;
 
                        if (!capable(CAP_SYS_ADMIN)) return -EACCES;
-                       if (get_user(old, (long *)arg)) return -EFAULT;
+                       if (get_user(old, (long __user *)arg)) return -EFAULT;
                        if ((result = udf_relocate_blocks(inode->i_sb,
                                        old, &new)) == 0)
-                               result = put_user(new, (long *)arg);
+                               result = put_user(new, (long __user *)arg);
 
                        return result;
                }
                case UDF_GETEASIZE:
-                       result = put_user(UDF_I_LENEATTR(inode), (int *)arg);
+                       result = put_user(UDF_I_LENEATTR(inode), (int __user *)arg);
                        break;
 
                case UDF_GETEABLOCK:
-                       result = copy_to_user((char *)arg, UDF_I_DATA(inode),
+                       result = copy_to_user((char __user *)arg, UDF_I_DATA(inode),
                                UDF_I_LENEATTR(inode)) ? -EFAULT : 0;
                        break;
        }
@@ -254,30 +248,10 @@ static int udf_release_file(struct inode * inode, struct file * filp)
        return 0;
 }
 
-/*
- * udf_open_file
- *
- * PURPOSE
- *  Called when an inode is about to be open.
- *
- * DESCRIPTION
- *  Use this to disallow opening RW large files on 32 bit systems.
- *  On 64 bit systems we force on O_LARGEFILE in sys_open.
- *
- * HISTORY
- *
- */
-static int udf_open_file(struct inode * inode, struct file * filp)
-{
-       if ((inode->i_size & 0xFFFFFFFF80000000ULL) && !(filp->f_flags & O_LARGEFILE))
-               return -EFBIG;
-       return 0;
-}
-
-struct file_operations udf_file_operations = {
+const struct file_operations udf_file_operations = {
        .read                   = generic_file_read,
        .ioctl                  = udf_ioctl,
-       .open                   = udf_open_file,
+       .open                   = generic_file_open,
        .mmap                   = generic_file_mmap,
        .write                  = udf_file_write,
        .release                = udf_release_file,