factor out portname-to-filename 'logic'