[XFS] use generic_permission

Now that all direct caller of xfs_iaccess are gone we can kill xfs_iaccess
and xfs_access and just use generic_permission with a check_acl callback.
This is required for the per-mount read-only patchset in -mm to work
properly with XFS.

SGI-PV: 971186
SGI-Modid: xfs-linux-melb:xfs-kern:30370a

Signed-off-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
This commit is contained in:
Christoph Hellwig
2008-02-05 12:13:24 +11:00
committed by Lachlan McIlroy
parent f6aa7f2184
commit 4576758db5
7 changed files with 26 additions and 121 deletions

View File

@@ -3583,69 +3583,6 @@ xfs_iflush_all(
XFS_MOUNT_IUNLOCK(mp);
}
/*
* xfs_iaccess: check accessibility of inode for mode.
*/
int
xfs_iaccess(
xfs_inode_t *ip,
mode_t mode,
cred_t *cr)
{
int error;
mode_t orgmode = mode;
struct inode *inode = vn_to_inode(XFS_ITOV(ip));
if (mode & S_IWUSR) {
umode_t imode = inode->i_mode;
if (IS_RDONLY(inode) &&
(S_ISREG(imode) || S_ISDIR(imode) || S_ISLNK(imode)))
return XFS_ERROR(EROFS);
if (IS_IMMUTABLE(inode))
return XFS_ERROR(EACCES);
}
/*
* If there's an Access Control List it's used instead of
* the mode bits.
*/
if ((error = _ACL_XFS_IACCESS(ip, mode, cr)) != -1)
return error ? XFS_ERROR(error) : 0;
if (current_fsuid(cr) != ip->i_d.di_uid) {
mode >>= 3;
if (!in_group_p((gid_t)ip->i_d.di_gid))
mode >>= 3;
}
/*
* If the DACs are ok we don't need any capability check.
*/
if ((ip->i_d.di_mode & mode) == mode)
return 0;
/*
* Read/write DACs are always overridable.
* Executable DACs are overridable if at least one exec bit is set.
*/
if (!(orgmode & S_IXUSR) ||
(inode->i_mode & S_IXUGO) || S_ISDIR(inode->i_mode))
if (capable_cred(cr, CAP_DAC_OVERRIDE))
return 0;
if ((orgmode == S_IRUSR) ||
(S_ISDIR(inode->i_mode) && (!(orgmode & S_IWUSR)))) {
if (capable_cred(cr, CAP_DAC_READ_SEARCH))
return 0;
#ifdef NOISE
cmn_err(CE_NOTE, "Ick: mode=%o, orgmode=%o", mode, orgmode);
#endif /* NOISE */
return XFS_ERROR(EACCES);
}
return XFS_ERROR(EACCES);
}
#ifdef XFS_ILOCK_TRACE
ktrace_t *xfs_ilock_trace_buf;