Implement fs_write.