From 74f4edad7ffd17e3a9d388b8a3a02d4f5db36799 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Tue, 5 Feb 2008 12:13:15 +1100 Subject: [PATCH] --- yaml --- r: 84485 b: refs/heads/master c: f6aa7f2184330262e1cb5f7802536e5346bd46a3 h: refs/heads/master i: 84483: 9468d4cd8760cc993062a2a58148189c5b301532 v: v3 --- [refs] | 2 +- trunk/fs/xfs/xfs_dfrag.c | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/[refs] b/[refs] index cdd36446e8d1..0e5236c36b09 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 35fec8df65217546f6d9d508b203c1d135a67fbc +refs/heads/master: f6aa7f2184330262e1cb5f7802536e5346bd46a3 diff --git a/trunk/fs/xfs/xfs_dfrag.c b/trunk/fs/xfs/xfs_dfrag.c index 5d3285952ff7..3f53fad356a3 100644 --- a/trunk/fs/xfs/xfs_dfrag.c +++ b/trunk/fs/xfs/xfs_dfrag.c @@ -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); @@ -154,15 +165,6 @@ xfs_swap_extents( xfs_lock_inodes(ips, 2, 0, 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);