[Bug 269190] [patch] bugs in stat(1) and devname(3), wrong report on disk names

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 27 Jan 2023 20:51:53 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=269190

            Bug ID: 269190
           Summary: [patch] bugs in stat(1) and devname(3), wrong report
                    on disk names
           Product: Base System
           Version: 13.1-STABLE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: alexander.naumochkin@gmail.com

Created attachment 239747
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=239747&action=edit
patches lib/libc/gen/devname.c and usr.bin/stat/stat.c

If I want to know the name of the partition a file is on I run stat(1) with the
-f "%Sd %Sr" option and it always reports #NODEV #NODEV. I checked out the
stat(1) source code and found that it always calls devname(3) for dev_t with
S_ISBLK mode, which is gone since FreeBSD 6.x AFAIR.

Also during my investigation I figured out that devname(3) has 10 years old
bug: when it tries to check that the `type' is one of S_IFCHR or S_IFBLK, it
applies S_ISBLK macro to `dev' instead of `type'.


patches attached

-- 
You are receiving this mail because:
You are the assignee for the bug.