[Bug 293789] file(1) reads excessive input, takes a long time with slow devices

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 13 Mar 2026 15:39:20 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=293789

            Bug ID: 293789
           Summary: file(1) reads excessive input, takes a long time with
                    slow devices
           Product: Base System
           Version: 16.0-CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: emaste@freebsd.org

Raspberry Pi Pico (RP2040) exposes a virtual umass device with a FAT
filesystem. Running `file -s` on the device took a long time:

# time file -s /dev/da1s1
/dev/da1s1: DOS/MBR boot sector, code offset 0x3c+2, OEM-ID "MSWIN4.1",
sectors/cluster 8, root entries 512, Media descriptor 0xf8, sectors/FAT 129,
sectors/track 1, heads 1, hidden sectors 1, sectors 262143 (volumes > 32 MB),
serial number 0x2d2c1, label: "RPI-RP2    ", FAT (16 bit)
        8.80 real         0.00 user         0.00 sys

ktrace shows that it's reading 7MiB:

  9846 file     0.007679501 CALL  read(0x3,0xc2398000640,0x700000)
  9846 file     8.802080842 RET   read 7340032/0x700000

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