Bug 15521 - findfs cannot find fat32 filesystems by UUID in certain configurations
Summary: findfs cannot find fat32 filesystems by UUID in certain configurations
Status: NEW
Alias: None
Product: Busybox
Classification: Unclassified
Component: Standard Compliance (show other bugs)
Version: 1.35.x
Hardware: All Linux
: P5 major
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-04-07 18:53 UTC by VIAVI_AB
Modified: 2023-04-07 18:53 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments
patch (830 bytes, application/octet-stream)
2023-04-07 18:53 UTC, VIAVI_AB
Details

Note You need to log in before you can comment on or make changes to this bug.
Description VIAVI_AB 2023-04-07 18:53:02 UTC
Created attachment 9576 [details]
patch

(vanilla busybox 1.35 sources)

findfs relies on the assumption that if cluster_count is within the limits of a FAT16 filesystem, the filesystem *must* be FAT16 (util-linux/volume_id/fat.c, volume_id_probe_vfat).

This fails for me in two situations:
- On "standard" disks, with a fat32 filesystem in a relatively small partition (say, 10M).
- On disks with 4KB logical sectors, even for larger filesystems (in my case, a 512M EFI ESP partition formatted with busybox mkdosfs); this is because on this kind of device you don't need as many clusters (the sector being 8 times larger than usual).

This is a simple script that reproduces this behavior (all busybox binaries):

#! /bin/sh
for size in 10M 100M 5G; do
  echo
  echo "testing with size=$size"
  sfdisk --quiet --wipe=always --wipe-partitions=always /dev/sda << EOF
label: dos
1: type=0b, size=$size
EOF
  mkdosfs /dev/sda1 # unlike util-linux, this always makes a fat32 filesystem
  uuid=$(lsblk -nr -o UUID /dev/sda1)
  echo "uuid is $uuid"
  dev=$(findfs UUID=$uuid)
  echo "dev is $dev" # fals in the 10M case
done

I'm not an expert in the various versions of BPB/EBPB of FAT, but I'm assuming that if there is a clear FAT32 signature it should be honored regardless of the value of cluster_count.

Attached is a trivial patch for consideration.