git: stat(2): Fix 'st_rdev' to report correct (major, minor) numbers
Aaron LI
aly at crater.dragonflybsd.org
Tue Nov 17 01:30:56 PST 2026
commit 911533c713a9f7376ed0d932677d8616b7f2eaea
Author: Aaron LI <aly at aaronly.me>
Date: Sat Nov 7 18:49:57 2026 +0800
stat(2): Fix 'st_rdev' to report correct (major, minor) numbers
* Fix vn_stat() to fill 'st_rdev' with makeudev() for character and
block devices that have a valid device number.
* In addition, fix devfs_vop_getattr() to fill 'va_rmajor' in addition to
'va_rminor', and fix hammer2_vop_getattr() to fill 'va_rmajor' and
'va_rminor'.
Before the fix, a manually mknod()-created device would have a 'st_rdev'
of NODEV (i.e., -1), for example:
```
$ ~/mknod /tmp/dev-1-2 1 2
dev: 0x102 (major=1, minor=2)
$ ls -l /tmp/dev-1-2
crw------- 1 root wheel 255, 0xffff00ff Nov 7 18:34 dev-1-2
$ stat -f '%Z' /tmp/dev-1-2
255,4294902015
```
After the fix:
```
$ ~/mknod /tmp/dev-1-2 1 2
dev: 0x102 (major=1, minor=2)
$ ls -l /tmp/dev-1-2
crw------- 1 root wheel 1, 0x00000002 Nov 7 18:44 /tmp/dev-1-2
$ stat -f '%Z' /tmp/dev-1-2
1,2
```
Found-by: pjdfstest (https://github.com/pjd/pjdfstest)
Assisted-by: DeepSeek-v4.1-flash (with Pi Coding Agent)
Summary of changes:
sys/kern/vfs_vnops.c | 13 ++++++++++++-
sys/vfs/devfs/devfs_vnops.c | 1 +
sys/vfs/hammer2/hammer2_vnops.c | 4 ++--
3 files changed, 15 insertions(+), 3 deletions(-)
http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/911533c713a9f7376ed0d932677d8616b7f2eaea
--
DragonFly BSD source repository
More information about the Commits
mailing list