/* Used to check for read/write/execute permissions on a file. We use "fsuid" for this, letting us set arbitrary permissions for filesystem access without changing the "normal" uids which are used for other things..  */
int generic_permission(struct inode *inode, int mask, int(*check_acl)(struct inode *inode, int mask))
/* Used to check for read/write/execute permissions on a file. We use "fsuid" for this, letting us set arbitrary permissions for filesystem access without changing the "normal" uids which are used for other things..  */
int generic_permission(struct inode *inode, int mask, int(*check_acl)(struct inode *inode, int mask))
{
	int ret;
	ret = acl_permission_check(inode, mask, check_acl);
	if (ret != -EACCES)
		return ret;
	if (!(mask & MAY_EXEC) || execute_ok(inode))
		if (capable(CAP_DAC_OVERRIDE))
			return 0;
	mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
	if (mask == MAY_READ || (S_ISDIR(inode->i_mode) && !(mask & MAY_WRITE)))
		if (capable(CAP_DAC_READ_SEARCH))
			return 0;
	return -EACCES;
}