]> err.no Git - linux-2.6/blobdiff - fs/xfs/xfs_dfrag.c
Merge branch 'header-move' of git://git.kernel.org/pub/scm/linux/kernel/git/hskinnemo...
[linux-2.6] / fs / xfs / xfs_dfrag.c
index 5d3285952ff74e85693cbad9f6eb8d99e062d949..2211e885ef243d47d690bb9a4bf044cf9bf26504 100644 (file)
@@ -74,12 +74,23 @@ xfs_swapext(
                goto out_free_sxp;
        }
 
+       if (!(file->f_mode & FMODE_WRITE) || (file->f_flags & O_APPEND)) {
+               error = XFS_ERROR(EBADF);
+               goto out_put_file;
+       }
+
        target_file = fget((int)sxp->sx_fdtmp);
        if (!target_file) {
                error = XFS_ERROR(EINVAL);
                goto out_put_file;
        }
 
+       if (!(target_file->f_mode & FMODE_WRITE) ||
+           (target_file->f_flags & O_APPEND)) {
+               error = XFS_ERROR(EBADF);
+               goto out_put_target_file;
+       }
+
        ip = XFS_I(file->f_path.dentry->d_inode);
        tip = XFS_I(target_file->f_path.dentry->d_inode);
 
@@ -105,7 +116,7 @@ xfs_swapext(
  out_put_file:
        fput(file);
  out_free_sxp:
-       kmem_free(sxp, sizeof(xfs_swapext_t));
+       kmem_free(sxp);
  out:
        return error;
 }
@@ -151,18 +162,9 @@ xfs_swap_extents(
                ips[1] = ip;
        }
 
-       xfs_lock_inodes(ips, 2, 0, lock_flags);
+       xfs_lock_inodes(ips, 2, lock_flags);
        locked = 1;
 
-       /* Check permissions */
-       error = xfs_iaccess(ip, S_IWUSR, NULL);
-       if (error)
-               goto error0;
-
-       error = xfs_iaccess(tip, S_IWUSR, NULL);
-       if (error)
-               goto error0;
-
        /* Verify that both files have the same format */
        if ((ip->i_d.di_mode & S_IFMT) != (tip->i_d.di_mode & S_IFMT)) {
                error = XFS_ERROR(EINVAL);
@@ -263,7 +265,7 @@ xfs_swap_extents(
                locked = 0;
                goto error0;
        }
-       xfs_lock_inodes(ips, 2, 0, XFS_ILOCK_EXCL);
+       xfs_lock_inodes(ips, 2, XFS_ILOCK_EXCL);
 
        /*
         * Count the number of extended attribute blocks
@@ -379,6 +381,6 @@ xfs_swap_extents(
                xfs_iunlock(tip, lock_flags);
        }
        if (tempifp != NULL)
-               kmem_free(tempifp, sizeof(xfs_ifork_t));
+               kmem_free(tempifp);
        return error;
 }