I'm wondering what the difference is between disk0 and rdisk0.
If you use *ls -l* on the devices you will see a difference
ls -l /dev/*disk0
brw-r----- 1 root operator 14, 0 Jan 2 09:39 /dev/disk0
crw-r----- 1 root operator 14, 0 Jan 2 09:39 /dev/rdisk0
disk0 has
b as the device type which indicates it is a
Block device.
rdisk0 has
c as the device type which indicates it is a
Character device.
In this case
Character for a disk means access via this device means it is a
Raw device interface.
So far I have not really told you anything. Just introduced new terms.
BEFORE I GO ON. I do not know if Mac OS X device drivers behave the way I'm about to describe.
A
Raw device driver (for disks)
MUST perform I/O operations that start on sector boundaries. Write operations
MUST uses sizes that are exact multiples of a sector. Reads could be less than an exact multiple of a sector, but generally it is also done in exact multiples as well (typically a sector is 512 bytes, but that is not an absolute).
A
Block device driver allows the caller to read and write using sizes that are not exact multiples of 1 sector, starting on sector boundaries. The
Block device driver will provide buffering, and even caching of disk sectors.
A
Raw/Character deivce driver transfers data directly from the device controller to the caller's buffer. A
Block device driver firsts transfers the data to a system buffer, and then the data is transferred to the caller's buffer.
The advantage of a block device is data caching and allowing reads and writes to occur on in something less than exact sectors.
The advantage of a
Raw/Character device driver is that there is no extra software between the device and the application. Applications that perform their own buffering (think databases) do not want their data double buffered. They would prefer to get the operating system out of the way.
Now from your stand point, you access the disk via a file system which will use the device driver that makes the most sense to that file system implementation.
I'm learning about FreeBSD right now, from which Apple used some code and have found a lot of similarities.
Mac OS X device drivers are totally different from FreeBSD. Mac OS X implemented its own device driver architecture.
I'm reading about the FreeBSD vinum volume manager and wondered if OS X uses something like this. I'm not sure why /Volumes/
hdName exists... it is just a symlink to / from what I can see when doing 'ls -l /Volumes/'.
I do not think so. Again because the volume manager is generally a layered device driver, and as I said Mac OS X implemented its own device driver architecture and wrote their own drivers. The closest thing to a volume manager is the RAID driver in Mac OS X.
/Volumes is the a Mac OS X convention for placing automatically mounted file systems. They have to go somewhere. The boot device is a file system, but since the boot file system is / you can not be both / and /volumes/yourdiskname. But you can put a symlink in /Volumes. Plus / is not your volume name. But the symlink name in /Volumes can be your boot volume's name.