Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 297213
b: refs/heads/master
c: 1a1d772
h: refs/heads/master
i:
  297211: b99e23b
v: v3
  • Loading branch information
Dave Chinner authored and Ben Myers committed Mar 22, 2012
1 parent 1a002bf commit 7db5ffd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5575acc7807595687288b3bbac15103f2a5462e1
refs/heads/master: 1a1d772433d42aaff7315b3468fef5951604f5c6
14 changes: 5 additions & 9 deletions trunk/fs/xfs/xfs_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ xfs_open_by_handle(
struct file *filp;
struct inode *inode;
struct dentry *dentry;
fmode_t fmode;

if (!capable(CAP_SYS_ADMIN))
return -XFS_ERROR(EPERM);
Expand All @@ -228,26 +229,21 @@ xfs_open_by_handle(
hreq->oflags |= O_LARGEFILE;
#endif

/* Put open permission in namei format. */
permflag = hreq->oflags;
if ((permflag+1) & O_ACCMODE)
permflag++;
if (permflag & O_TRUNC)
permflag |= 2;

fmode = OPEN_FMODE(permflag);
if ((!(permflag & O_APPEND) || (permflag & O_TRUNC)) &&
(permflag & FMODE_WRITE) && IS_APPEND(inode)) {
(fmode & FMODE_WRITE) && IS_APPEND(inode)) {
error = -XFS_ERROR(EPERM);
goto out_dput;
}

if ((permflag & FMODE_WRITE) && IS_IMMUTABLE(inode)) {
if ((fmode & FMODE_WRITE) && IS_IMMUTABLE(inode)) {
error = -XFS_ERROR(EACCES);
goto out_dput;
}

/* Can't write directories. */
if (S_ISDIR(inode->i_mode) && (permflag & FMODE_WRITE)) {
if (S_ISDIR(inode->i_mode) && (fmode & FMODE_WRITE)) {
error = -XFS_ERROR(EISDIR);
goto out_dput;
}
Expand Down

0 comments on commit 7db5ffd

Please sign in to comment.