def access(patch, path, mode):
    """
	Use the real uid/gid to test for access to path.
	Note that most operations will use the effective uid/gid,
	therefore this routine can be used in a suid/sgid environment to test
	if the invoking user has the specified access to path.
	mode should be F_OK to test the existence of path,
	or it can be the inclusive OR of one or more of R_OK, W_OK, and X_OK to
	test permissions. Return True if access is allowed, False if not.
	See the Unix man page access(2) for more information.
	"""
    ap = os.path.abspath(os.path.join(CWD, path))
    manager = get_manager()
    fsi, relpath, readonly = manager.get_fsi(ap)
    if fsi is None:
        return _org_access(relpath, mode)
    else:
        try:
            s = fsi.stat(relpath)
        except OperationFailure:
            return False
        if mode == os.F_OK:
            return True
        fa_mode = s.st_mode  #  & 0777
        should_read = mode & os.R_OK
        should_write = mode & os.W_OK
        should_exec = mode & os.X_OK
        acc = True
        if should_read:
            acc = acc and any((
                _stat.S_IRUSR & fa_mode,
                _stat.S_IRGRP & fa_mode,
                _stat.S_IROTH & fa_mode,
            ))
        if should_write:
            acc = acc and any((
                _stat.S_IWUSR & fa_mode,
                _stat.S_IWGRP & fa_mode,
                _stat.S_IWOTH & fa_mode,
            ))
            acc = (acc and (not readonly))
        if should_exec:
            acc = acc and any((
                _stat.S_IXUSR & fa_mode,
                _stat.S_IXGRP & fa_mode,
                _stat.S_IXOTH & fa_mode,
            ))
        return acc

	Use the real uid/gid to test for access to path.
	Note that most operations will use the effective uid/gid,
	therefore this routine can be used in a suid/sgid environment to test
	if the invoking user has the specified access to path.
	mode should be F_OK to test the existence of path,
	or it can be the inclusive OR of one or more of R_OK, W_OK, and X_OK to
	test permissions. Return True if access is allowed, False if not.
	See the Unix man page access(2) for more information.
	
lib/mlpatches/mount_base.py