Generalizing safe_inode_cast so that we only need one version