block: Refactor get_tmp_filename()