Make one fs function

sending this again, to simplify/dedupe the code, keeping the old functions for backwards compatibility with non core modules.