diff options
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | fs/xfs/xfs_dfrag.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/fs/xfs/xfs_dfrag.c b/fs/xfs/xfs_dfrag.c index 5d3285952ff7..3f53fad356a3 100644 --- a/fs/xfs/xfs_dfrag.c +++ b/fs/xfs/xfs_dfrag.c | |||
@@ -74,12 +74,23 @@ xfs_swapext( | |||
74 | goto out_free_sxp; | 74 | goto out_free_sxp; |
75 | } | 75 | } |
76 | 76 | ||
77 | if (!(file->f_mode & FMODE_WRITE) || (file->f_flags & O_APPEND)) { | ||
78 | error = XFS_ERROR(EBADF); | ||
79 | goto out_put_file; | ||
80 | } | ||
81 | |||
77 | target_file = fget((int)sxp->sx_fdtmp); | 82 | target_file = fget((int)sxp->sx_fdtmp); |
78 | if (!target_file) { | 83 | if (!target_file) { |
79 | error = XFS_ERROR(EINVAL); | 84 | error = XFS_ERROR(EINVAL); |
80 | goto out_put_file; | 85 | goto out_put_file; |
81 | } | 86 | } |
82 | 87 | ||
88 | if (!(target_file->f_mode & FMODE_WRITE) || | ||
89 | (target_file->f_flags & O_APPEND)) { | ||
90 | error = XFS_ERROR(EBADF); | ||
91 | goto out_put_target_file; | ||
92 | } | ||
93 | |||
83 | ip = XFS_I(file->f_path.dentry->d_inode); | 94 | ip = XFS_I(file->f_path.dentry->d_inode); |
84 | tip = XFS_I(target_file->f_path.dentry->d_inode); | 95 | tip = XFS_I(target_file->f_path.dentry->d_inode); |
85 | 96 | ||
@@ -154,15 +165,6 @@ xfs_swap_extents( | |||
154 | xfs_lock_inodes(ips, 2, 0, lock_flags); | 165 | xfs_lock_inodes(ips, 2, 0, lock_flags); |
155 | locked = 1; | 166 | locked = 1; |
156 | 167 | ||
157 | /* Check permissions */ | ||
158 | error = xfs_iaccess(ip, S_IWUSR, NULL); | ||
159 | if (error) | ||
160 | goto error0; | ||
161 | |||
162 | error = xfs_iaccess(tip, S_IWUSR, NULL); | ||
163 | if (error) | ||
164 | goto error0; | ||
165 | |||
166 | /* Verify that both files have the same format */ | 168 | /* Verify that both files have the same format */ |
167 | if ((ip->i_d.di_mode & S_IFMT) != (tip->i_d.di_mode & S_IFMT)) { | 169 | if ((ip->i_d.di_mode & S_IFMT) != (tip->i_d.di_mode & S_IFMT)) { |
168 | error = XFS_ERROR(EINVAL); | 170 | error = XFS_ERROR(EINVAL); |