Bug 185070

Summary: [patch] dd(1) add better error message when partial write to dev
Product: Base System Reporter: luke.tw
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Open ---    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description luke.tw 2013-12-21 14:40:00 UTC
when dd writes to a device, the error message is misleading if the write size is less than the sector size of the device.

Fix: 3. after applying the patch:
bsd10# ./dd if=/root/513b of=/dev/da1
dd: /root/513b: not a multiple of /dev/da1's sector size (512 bytes)
1+1 records in
1+0 records out
512 bytes transferred in 0.003080 secs (166227 bytes/sec)
bsd10# ./dd if=/root/513b of=/dev/da1 bs=1
dd: bs=1: not a multiple of /dev/da1's sector size (512 bytes)
1+0 records in
0+0 records out
0 bytes transferred in 0.000059 secs (0 bytes/sec)

Patch attached with submission follows:
How-To-Repeat: 1. create input files
bsd10# dd if=/dev/random of=/root/512b bs=1 count=512
512+0 records in
512+0 records out
512 bytes transferred in 0.001007 secs (508400 bytes/sec)
bsd10# dd if=/dev/random of=/root/513b bs=1 count=513
513+0 records in
513+0 records out
513 bytes transferred in 0.000936 secs (548059 bytes/sec)

2. dd these input files to /dev/
bsd10# dd if=/root/512b of=/dev/da1
1+0 records in
1+0 records out
512 bytes transferred in 0.005722 secs (89478 bytes/sec)
bsd10# dd if=/root/513b of=/dev/da1
dd: /dev/da1: Invalid argument
1+1 records in
1+0 records out
512 bytes transferred in 0.000363 secs (1410962 bytes/sec)
bsd10# dd if=/root/513b of=/dev/da1 bs=1
dd: /dev/da1: Invalid argument
1+0 records in
0+0 records out
0 bytes transferred in 0.000159 secs (0 bytes/sec)
Comment 1 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:01:41 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped