Extract filesystem-related functions into fs.c