aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/xfs/xfs_ioctl.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index f588320dc4b9..91f8ff547ab3 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -209,6 +209,7 @@ xfs_open_by_handle(
209 struct file *filp; 209 struct file *filp;
210 struct inode *inode; 210 struct inode *inode;
211 struct dentry *dentry; 211 struct dentry *dentry;
212 fmode_t fmode;
212 213
213 if (!capable(CAP_SYS_ADMIN)) 214 if (!capable(CAP_SYS_ADMIN))
214 return -XFS_ERROR(EPERM); 215 return -XFS_ERROR(EPERM);
@@ -228,26 +229,21 @@ xfs_open_by_handle(
228 hreq->oflags |= O_LARGEFILE; 229 hreq->oflags |= O_LARGEFILE;
229#endif 230#endif
230 231
231 /* Put open permission in namei format. */
232 permflag = hreq->oflags; 232 permflag = hreq->oflags;
233 if ((permflag+1) & O_ACCMODE) 233 fmode = OPEN_FMODE(permflag);
234 permflag++;
235 if (permflag & O_TRUNC)
236 permflag |= 2;
237
238 if ((!(permflag & O_APPEND) || (permflag & O_TRUNC)) && 234 if ((!(permflag & O_APPEND) || (permflag & O_TRUNC)) &&
239 (permflag & FMODE_WRITE) && IS_APPEND(inode)) { 235 (fmode & FMODE_WRITE) && IS_APPEND(inode)) {
240 error = -XFS_ERROR(EPERM); 236 error = -XFS_ERROR(EPERM);
241 goto out_dput; 237 goto out_dput;
242 } 238 }
243 239
244 if ((permflag & FMODE_WRITE) && IS_IMMUTABLE(inode)) { 240 if ((fmode & FMODE_WRITE) && IS_IMMUTABLE(inode)) {
245 error = -XFS_ERROR(EACCES); 241 error = -XFS_ERROR(EACCES);
246 goto out_dput; 242 goto out_dput;
247 } 243 }
248 244
249 /* Can't write directories. */ 245 /* Can't write directories. */
250 if (S_ISDIR(inode->i_mode) && (permflag & FMODE_WRITE)) { 246 if (S_ISDIR(inode->i_mode) && (fmode & FMODE_WRITE)) {
251 error = -XFS_ERROR(EISDIR); 247 error = -XFS_ERROR(EISDIR);
252 goto out_dput; 248 goto out_dput;
253 } 249 }