Re: Difference between dvd and dmg
Re: Difference between dvd and dmg
- Subject: Re: Difference between dvd and dmg
- From: John Stiles <email@hidden>
- Date: Wed, 12 Oct 2005 10:53:36 -0700
On Oct 12, 2005, at 9:54 AM, Gerriet M. Denkmann wrote:
On 12.10.2005, at 18:08, John Stiles wrote:
Gerriet M. Denkmann wrote:
Because pread() wants both nbr_of_bytes and byte_offset to be a
multiple of the hardware value, which seems to be 512 in case of
my hard disk, and 2048 for cds and dvds.
Somehow I failed to see this on the pread man page.
What can I do to make it work?
Use appropriate values (see above).
Or, if this is impossible: how can I recognize beforehand those
filesystems which do not work with pread?
That now becomes a new question:
how to get this hardware value (hardware block-size?) before
trying to read?
This may be an artifact of opening up the /dev/rdisk directly.
With a regular file, pread works even when the requested data is
not sector-aligned.
This is correct. So the question should be:
When one opens a raw device via open(/dev/rdisk...) how does one
get the hardware sector size (which in this case is needed for read
or pread)?
It seems to be 512 for disks, 2048 for rotating media. But maybe
there is something better than trial and error?
I'm sure there is a better answer than this, but there's always good
old trial and error.
uint8 buffer[65536];
for( int sectorSize=1; sectorSize<=65536; sectorSize<<=1 )
{
if( pread( file, buffer, sectorSize, 0 ) ) break;
}
if( sectorSize > 65536 ) abort(1); // do something better
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden