Benches macOS

4

Block and character special files

apple Verified

Imported from the Apple Support Forums via the Wayback Machine 🔗

What is the difference in semantics between block and character special files on Mac OS X?

In the olden days, character special files were intended for serial character-oriented devices such as teletypes, printers, modems etc. not capable of seeking and block special files were intended for seekable block-oriented devices such as winchester disks etc.

But nowadays, Apple uses /dev/rdisk* as the raw (unbuffered) hard disk device, and it is a character special file, and it is seekable. /dev/disk* on the other hand, is buffered, slower, and a block character special file.

Is there still any semantic difference at any O.S. level between these two kinds of special files, or is it all entirely up to the driver designer and it only effectively provides us with one more bit for the device number?

4 replies

Sign in or join Beachball Help to reply.

  1. 0

    Jun T.

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Hi,

    Is there still any semantic difference at any O.S. level between these two kinds of special files

    As you write, a block device is bufferd by OS, while a character device is not bufferd by OS (=raw device).

    In the olden days, character special files were intended for serial character-oriented devices

    Even in olden days, I guess a seekable mass storage had both block and character devices; the latter is for partitioning, disk diagnose, backup, etc. Only block devices can be mounted.

    Serial (un-seekable) device can only be a character device, I guess.

  2. 0

    Dr. T

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Excellent, thank you. So to sum it up, block special files +have to be+ seek capable, whereas character special files
    may be seek capable, and I/O to block special files is buffered by the OS but I/O to character special files is not.

    That seems clear enough.

    Is there anywhere where these things are documented, and where (in kernel sources etc.) might one look for the differences in the handling of the two? I'm assuming you can control the buffering of block special files?

  3. 0

    Cole Tierney

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    I'd also be interested. For example, sometimes I would like to be able to mount the joliet partition of a hybrid cd to access files that are not included on the hfs partition. My optical drive is /dev/disk1, its media is /dev/disk1s1, then I think disk1s1s1 and disk1s1s2 are file systems. Does /dev/disk1s1s2 represent the joliet file system? I'd love to have a better understanding of these devices.

    --

    Cole

  4. 0

    Jun T.

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    I don't know any detail about Darwin kernel. You may get better answer in dawrin-dev or darwin-kernel mailig list. For example,

    http://lists.apple.com/archives/Darwin-kernel/2006/Jul/msg00030.html

    As mentioned in this thread, it seems buffering can be disabled for a specific open file by using F_NOCACHE command in fcntl(2). (I guess there is no way to control the buffering of whole the mounted disk.) F_RDAHEAD command would also be of interest.