As in the old nextboot.sh script:
- First write everything to a tempfile instead of /boot/nextboot.conf.
- fsync() the tempfile before renaming it to nextboot.conf.
While here fix some other nits:
- Don't hard-code the dirname of the "fn" parameter in write_nextboot().
- Use err/errx/errc() instead of E(). In those error paths it doesn't
make sense to continue even if "force" is set.
Fixes: fd6d47375a78 ("rescue,nextboot: Install nextboot as a link to reboot, rm nextboot.sh")