From: "Theo de Raadt" Subject: Re: Verify rrootdev in rootdisk_nodes To: Andrew Hewus Fresh Cc: tech@openbsd.org Date: Mon, 21 Sep 2026 11:00:09 -0600 I guess so, though it is very hard to see how the nodes could go wrong. Andrew Hewus Fresh wrote: > While adjusting style in rootdisk_nodes, I noticed that we don't > verify that rrootdisk is in sync, just the main one. While this is > really only protecting against _rootdev changing, not an accident, but > it's just one extra stat. > > Comments, OK? > > Index: rc > =================================================================== > RCS file: /cvs/src/etc/rc,v > diff -u -p -r1.596 rc > --- rc 21 Sep 2026 02:52:29 -0000 1.596 > +++ rc 21 Sep 2026 02:54:38 -0000 > @@ -316,16 +316,17 @@ rootdisk_nodes() { > _rootdev=$(mount | grep ' / ' | grep -v ':' | cut -d ' ' -f 1) > [[ -n $_rootdev ]] || return > > + _rrootdev=$(echo "$_rootdev" | sed -e 's,dev/,dev/r,') > _maj=$(stat -f %Hr $_rootdev) > + _rmaj=$(stat -f %Hr $_rrootdev) > _omin=$(stat -f %Lr $_rootdev) > _min=$((_omin / 16 * 64)) > - [[ -b /dev/rootdisk ]] && > + [[ -b /dev/rootdisk ]] && [[ -b /dev/rrootdisk ]] && > [[ "$(stat -qf %Hr,%Lr /dev/rootdisk)" = "$_maj,$_min" ]] && > + [[ "$(stat -qf %Hr,%Lr /dev/rrootdisk)" = "$_rmaj,$_min" ]] && > return > > # does not exist or device changed, redo > - _rrootdev=$(echo "$_rootdev" | sed -e 's,dev/,dev/r,') > - _rmaj=$(stat -f %Hr $_rrootdev) > rm -f /dev/rrootdisk /dev/rootdisk > mknod -m 600 /dev/rrootdisk c $_rmaj $_min > mknod -m 600 /dev/rootdisk b $_maj $_min >