DVD Block device access

BigBadBonobo

Registered
Hey all - newbie Mac user and first time OsX forum poster. I am experimenting with creating a version of DVDShrink for the Mac, but am running into an annoying problem right out of the starting gate - any attempt to access the DVD block device (usually /dev/disk1, /dev/disk2 e.t.c.) using open() or fopen() fail with errno 16 - 'Resource Busy'. My guess is that it has to do with the OS mounting the drive to other volumes, but that doesnt explain how other DVD applications can access the drive. I'd appreciate insights from anyone who has had experience with low-level access to block devices in Mac OSX. Thanks.
 
Your problem is that on MacOS X, the actual device is locked down by drivers when mounted, and multiplexed access is supported through them. This way multiple applications in userland can do raw read/write to devices using POSIX or Cocoa/Carbon without conflicting on who gets access.

Instead of using /dev/disk1, for example, you should use /dev/rdisk1. I ran into the same problem, as I wrote a small app that used POSIX APIs to rip the 2nd layer of a PS2 DVD9 disc into its own ISO, which required raw I/O, as you could guess... since I did something very similar, I could probably fire off a snippet of code to you later on the subject.
 
Spot on - thanks Krevinek - that was exactly it. I was wondering about the 'r' counterparts to all the disk devices - now I know what they do. Well, time to brew a pot and continue with this grand experiment. Thanks again for your help.
 
Back
Top