OT: Hard Drive low-level access

My apps specialize (in part) in accessing disk drives that have non-standard file systems written to them. This is a past practice of the music industry with keyboards that used external storage, all SCSI, manufactured between 1980 and about 1995.

This tends to be easy when dealing with removable media. Both Windows and Mac have facilities to access those disks low-level (reading and writing directly to the disk bypassing any file-system routines - which obviously are useless with non-standard systems).

Fixed internal (or even external) hard drives are a different matter, but fortunately such use is rare, but it happens. The problem is OSX: in the routines that access the disk, which is actually no more complicated than the POSIX open(), read() and write() commands (I do this is C++), don’t work with these drives, presumably because the OS doesn’t allow permission to the admin to access the drives low-level. My thought (a guess but I think I’m right) is that it requires root permissions.

Let me introduce an intervening fact. As of OSX 10.8, Apple closed the “security hole” of accessing even non-fixed media low-level and required root permissions for all of it. Since root-level permissions for an entire app is discouraged, I did it Apple’s way and created a small Helper App to do it, communicating via IPC from my main app. I run the Helper App as root, after the standard authentication that is necessary. This works perfect.

So, back to accessing fixed hard drives, I had an occasion where someone had a SCSI fixed hard drive that had a foreign file-system on it, and I wanted to direct my attention to handling that. Since the 10.8 solution worked with playing the permission game, I thought I could get it to work with this SCSI fixed hard drive.

The problem I encountered is modern computers don’t and can’t handle SCSI interfaces. The only Desktop Mac I have is a G4 running OSX 10.4 and it has a SCSI interface on it. Since my apps are Universal Binary and I support OSX 10.4, I ran my app on my G4, but could not access the drive, even after I modified my app to use the Helper App (and modified the Helper App to run PPC). The Helper App is running as root (I checked) but the problems come when calling open() - it fails with a bad permissions error.

(One answer I’d like to head off early. As a workaround I often tell the user to use Disk Utility to image the hard drive. Then my apps can easily with little effort read that image and deal with it appropriately. The problem in this case is that a certain drive always errors I/O midway into reading the disk, thus making it unable to image. I know from experience that Disk Utility is very picky and doesn’t try very hard to overcome read errors,a nd then assumes for you that you don’t want the image and removes it. For the file-systems, I greatly WANT the image even if there are disk errors here-or-there on it.)

I’m almost certainly writing this post for Thomas Templeman, who long ago in the RB3 days wrote some code for me concerning this, but anyone is welcome to suggest something. I have two questions.

  1. What does it take to access these SCSI fixed hard drives? I thought root access was enough.

  2. Why doesn’t Disk Utility ask for authentication to access disks low-level, like I have to a Apple recommends? Certainly it can’t be running as root all the time - Apple tells all of us not to do such things.

You might want to contact Thomas directly. He doesn’t always read the forums.

Garth, try an older version of iBored that still runs on PPC, to see if that can access the SCSI drive. If so, I can help you, otherwise I may be as clueless as you are: http://files.tempel.org/iBored/