vfs: Assert that st_rdev is NODEV for non-devices

From: Bakul Shah <bakul_at_iitbombay.org>
Date: Sun, 17 Aug 2025 22:54:08 UTC
etcupdate panics since this commit:

commit f9ff1e48cc1b77f1840fd514050ccc5904a0cac2
Author: Dag-Erling Smørgrav <des@FreeBSD.org>
Date:   Sun Aug 17 19:08:56 2025 +0200

    vfs: Assert that st_rdev is NODEV for non-devices

    Reviewed by:    kib
    Differential Revision:  https://reviews.freebsd.org/D51956

Further src commits do not seem to change this. I modified
etcupdate to print some more info.

This is where it panics:

# etcupdate
+ update_cmd
+ local dir new old
+ [ 0 -ne 0 ]
+ log 'update command: rerun= tarball= preworld='
+ echo '>>>' 'update command: rerun= tarball= preworld='
+ id -u
+ [ 0 -ne 0 ]
+ umask 022
+ [ -e /var/db/etcupdate/conflicts ]
+ find -d /var/db/etcupdate/conflicts -type d -empty -delete
+ rmdir /var/db/etcupdate/conflicts
+ [ -d /var/db/etcupdate/conflicts ]
+ old=/var/db/etcupdate/old
+ new=/var/db/etcupdate/current
+ [ -z '' ]
+ mktemp -d /var/db/etcupdate/etcupdate-XXXXXXX
+ dir=/var/db/etcupdate/etcupdate-Y6uUECa
+ [ 0 -ne 0 ]
+ extract_tree /var/db/etcupdate/etcupdate-Y6uUECa
+ local files
+ [ -n '' ]
+ build_tree /var/db/etcupdate/etcupdate-Y6uUECa
+ local destdir dir file make autogenfiles metatmp
+ make='make  -DNO_FILEMON'
+ [ -n '' ]
+ metatmp=/dev/null
+ trap 'return 1' INT
+ log 'Building tree at /var/db/etcupdate/etcupdate-Y6uUECa with make  -DNO_FILEMON'
+ echo '>>>' 'Building tree at /var/db/etcupdate/etcupdate-Y6uUECa with make  -DNO_FILEMON'
+ exec
panic: st_rdev should be NODEV unless the file is a device node
cpuid = 0
time = 1755470767
KDB: stack backtrace:
#0 0xffffffff80bcfa2d at kdb_backtrace+0x5d
#1 0xffffffff80b7ff66 at vpanic+0x136
#2 0xffffffff80b7fe23 at panic+0x43
#3 0xffffffff80c97cb5 at kern_statat+0x255
#4 0xffffffff80c982c7 at sys_fstatat+0x27
#5 0xffffffff810d08b9 at amd64_syscall+0x169
#6 0xffffffff810a21fb at fast_syscall_common+0xf8
KDB: enter: panic

Running remote gdb on the host (where this VM runs):

#11 0xffffffff80b7ffbb in vpanic (
    fmt=0xffffffff811c4eb6 "st_rdev should be NODEV unless the file is a device node", ap=ap@entry=0xfffffe0054050ba0)
    at /home/FreeBSD/current/sys/kern/kern_shutdown.c:962
#12 0xffffffff80b7fe23 in panic (
    fmt=0xffffffff81d9eab0 <cnputs_mtx> "\226[\033\201\377\377\377\377")
    at /home/FreeBSD/current/sys/kern/kern_shutdown.c:887
#13 0xffffffff80c97cb5 in kern_statat (td=0xfffff8007e7fc000,
    flag=<optimized out>, fd=<optimized out>, path=0x19e4d3242358 "/usr/src",
    pathseg=UIO_USERSPACE, sbp=0xfffffe0054050d18)
    at /home/FreeBSD/current/sys/kern/vfs_syscalls.c:2574
#14 0xffffffff80c982c7 in sys_fstatat (td=0xffffffff81d9eab0 <cnputs_mtx>,
    uap=0xfffff8007e7fc428)
    at /home/FreeBSD/current/sys/kern/vfs_syscalls.c:2544
#15 0xffffffff810d08b9 in syscallenter (td=0xfffff8007e7fc000)
    at /home/FreeBSD/current/sys/amd64/amd64/../../kern/subr_syscall.c:193
#16 amd64_syscall (td=0xfffff8007e7fc000, traced=0)