Repository navigation
Match the BSD df partition fallback by exact device name and fixed units - #3833
Conversation
When disklabel cannot be read without root, OpenBSD and NetBSD list a disk's partitions from df. That fallback had three faults: - It took every row starting with /dev/<disk>, so sd1 also claimed sd10's partitions. A row now belongs to the disk only when its device is the disk name plus one partition letter (a-p). - It assumed 512-byte blocks, but plain df follows BLOCKSIZE, so sizes were halved with BLOCKSIZE=1k. It now runs df -k, which reports 1K blocks regardless of BLOCKSIZE on both OpenBSD 7.9 (cfarm220) and NetBSD 10.1 (cfarm428); df -P still follows BLOCKSIZE on NetBSD. - It split the whole row on whitespace, cutting a mount point at its first space. The row is now split into at most six fields.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📜 Recent review details
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3833 +/- ##
============================================
- Coverage 81.09% 81.04% -0.05%
Complexity 773 773
============================================
Files 726 726
Lines 26320 26320
Branches 4472 4471 -1
============================================
- Hits 21344 21332 -12
- Misses 2767 2779 +12
Partials 2209 2209
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
When
disklabelcannot be read without root,HWDiskStore.getPartitions()on OpenBSD and NetBSD lists a disk's partitions fromdfinstead. That fallback,Disklabel.parseDfFallback, had three faults, all fixed here.Changes
/dev/<disk>was taken, sosd1also claimedsd10's partitions. A row now belongs to the disk only when its device is the disk name plus one partition letter (a-p).dffollows theBLOCKSIZEenvironment variable, so sizes were halved withBLOCKSIZE=1k. It now runsdf -kand multiplies by 1024.-kreports 1K blocks whateverBLOCKSIZEis, on both OpenBSD 7.9 (cfarm220) and NetBSD 10.1 (cfarm428).df -Pwould not do, because it still followsBLOCKSIZEon NetBSD.Verification
dfhandlesBLOCKSIZEby hand on both systems. The test fixtures follow cfarm220's realdf -koutput.-Paggregate-coveragepasses, and so does the-Perror-pronebuild.Summary by CodeRabbit
BLOCKSIZEsetting, similarly named disks are distinguished correctly, and mount points containing spaces are preserved.