def get_the_opened_file_list(openfile_cursor, pid):
    """Return all opened files (W/R)."""
    opened_files_query = """
            SELECT process, name, mode
            FROM opened_files
            WHERE process = %s AND mode <= 2
            """
    openfile_cursor.execute(opened_files_query % pid)
    return openfile_cursor.fetchall()
