Bug 67773

Summary: 5.x series - md5 on dev no longer works e.g. md5 /dev/ad2
Product: Base System Reporter: Dan Fletcher <drfmail>
Component: i386Assignee: Remko Lodder <remko>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description Dan Fletcher 2004-06-10 03:20:20 UTC
I work computer forensics for a law enforcement agency.  I use FreeBSD extensively.  Tried to upgrade to 5.x series for the SATA support.  However the md5 checksum no longer works on raw devices.  I have tried it with 5.0 and 5.2.1, neither work.

Worked fine with 4.x series.

cksum of a raw device works fine, e.g.
cksum /dev/ad2

How-To-Repeat: Try to md5 checksum any raw device:

md5 /dev/fd0
md5 /dev/ad2, etc.
Comment 1 Michael Johnson 2004-06-10 03:26:17 UTC
it works, but I think the md5 sum will be different after each boot 
(correct me if I'm wrong) because 5.x uses devfs.

Michael
Comment 2 Bruce Evans 2004-06-10 11:17:54 UTC
On Thu, 10 Jun 2004, Dan Fletcher wrote:

> >Description:
> I work computer forensics for a law enforcement agency.  I use FreeBSD extensively.  Tried to upgrade to 5.x series for the SATA support.  However the md5 checksum no longer works on raw devices.  I have tried it with 5.0 and 5.2.1, neither work.
>
> Worked fine with 4.x series.
>
> cksum of a raw device works fine, e.g.
> cksum /dev/ad2
> >How-To-Repeat:
> Try to md5 checksum any raw device:
>
> md5 /dev/fd0
> md5 /dev/ad2, etc.

This seems to have been broken in at least rev.1.14 of libmd/mdXhl.c
by using fstat() to determine a wrong size for the file.  fstat() only
gives the file size for regular files that don't change while being
read.  Pipes are handled differently, so the breakage doesn't affect
them.  Regular files that change while being read aren't handled very
well anyway.

As a workaround, pipe the file to md5 (e.g., cat /dev/ad2 | md5).

Bruce
Comment 3 Remko Lodder freebsd_committer freebsd_triage 2006-09-11 13:58:43 UTC
State Changed
From-To: open->feedback

Hello, 
can you tell me whether this problem got solved and/or is still 
there on recent freebsd versions (6.1 for example?) 
thanks! 


Comment 4 Remko Lodder freebsd_committer freebsd_triage 2006-09-11 13:58:43 UTC
Responsible Changed
From-To: freebsd-i386->remko

grab the pr
Comment 5 Remko Lodder freebsd_committer freebsd_triage 2007-04-06 07:27:27 UTC
State Changed
From-To: feedback->closed

Feedback timeout (Workaround provided)