On 2/19/24 7:54 PM, Gleb Smirnoff wrote:
The branch main has been updated by glebius:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=0c3ade2cf13df1ed5cd9db4081137ec90fcd19d0

commit 0c3ade2cf13df1ed5cd9db4081137ec90fcd19d0
Author:     Gleb Smirnoff <gleb...@freebsd.org>
AuthorDate: 2024-02-20 03:51:22 +0000
Commit:     Gleb Smirnoff <gleb...@freebsd.org>
CommitDate: 2024-02-20 03:51:22 +0000

     nextboot: fix nextboot -k on ZFS
zfsbootcfg(1) expects pool name to operate on, not currently mounted
     filesystem name.
Fixes: fd6d47375a78fbf0737012b7cc11180291781e8b
---
  sbin/reboot/reboot.c | 5 +++++
  1 file changed, 5 insertions(+)

diff --git a/sbin/reboot/reboot.c b/sbin/reboot/reboot.c
index 7ea4d50eaf74..ac3927cc2432 100644
--- a/sbin/reboot/reboot.c
+++ b/sbin/reboot/reboot.c
@@ -130,6 +130,11 @@ write_nextboot(const char *fn, const char *env, bool force)
        }
if (zfs) {
+               char *slash;
+
+               if ((slash = strchr(sfs.f_mntfromname, '/')) == NULL)
+                       E("Can't find ZFS pool name in %s", sfs.f_mntfromname);
+               *slash = '\0';
                zfsbootcfg(sfs.f_mntfromname, force);

This broke nextboot -k on my systems using ZFS (was working fine prior to this 
commit):

# nextboot -k test
nextboot: Can't find ZFS pool name in head: No error: 0
# zpool list
NAME   SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  
ALTROOT
head  79.5G  36.2G  43.3G        -         -    41%    45%  1.00x    ONLINE  -
# zfs list
NAME             USED  AVAIL  REFER  MOUNTPOINT
head            36.2G  40.8G  2.16G  legacy
head/public     1.13G  40.8G  1.13G  legacy
head/tmp         836M  40.8G   836M  legacy
head/usr        28.3G  40.8G  2.34G  legacy
head/usr/local   534M  40.8G   534M  legacy
head/usr/obj    21.4G  40.8G  21.4G  legacy
head/usr/ports    23K  40.8G    23K  legacy
head/usr/src    4.00G  40.8G  4.00G  legacy
head/var        3.83G  40.8G   266M  legacy
head/var/crash  3.57G  40.8G  3.57G  legacy
head/var/tmp      23K  40.8G    23K  legacy

I think we should just punt on the error and pass the entire string again if 
slash is NULL.
I'll test this locally and put it in a review if it works.

--
John Baldwin


Reply via email to