'Probe the file-system to determine whether permissions can be trusted.
:return: True if permissions can be trusted, False otherwise.'

def _determine_file_mode(self):

    fname = os.path.join(self.path, '.probe-permissions')
    with open(fname, 'w') as f:
        f.write('')
    st1 = os.lstat(fname)
    os.chmod(fname, (st1.st_mode ^ stat.S_IXUSR))
    st2 = os.lstat(fname)
    os.unlink(fname)
    mode_differs = (st1.st_mode != st2.st_mode)
    st2_has_exec = ((st2.st_mode & stat.S_IXUSR) != 0)
    return (mode_differs and st2_has_exec)
