No, it is determined by the OS.
FreeBSD Architecture Handbook dated 2018-09-23 11:38:04.
9.4 Block Devices (Are Gone)
Other UNIX® systems may support a second type of disk device known as block devices. Block devices are disk devices for which the kernel provides caching [...] FreeBSD dropped support for cached disk devices as part of the modernization of the disk I/O infrastructure.
FreeBSD still has "raw" devices, which are character devices that allow reading and writing disk blocks.
Do not be confused by the names. Block devices provide buffering - which allows you to read and write in units of bytes. Raw devices are a type of character device - but they require you to read and write in units of blocks. The block size depends on the specific disk hardware.
"Character devices" were probably originally named after teletype terminals, which physically work one character at a time. Block devices were a specific case where read()
and write()
interacted with the buffer cache, instead of directly with the device driver. Character devices became the general case, used for every other device file. The interface is flexible, because as well as device-specific read()
and write()
, it can support arbitrary commands with ioctl()
.
https://en.wikipedia.org/wiki/Device_file#Block_devices
Most systems create both block and character devices to represent hardware like hard disks. FreeBSD and Linux notably do not; the former has removed support for block devices,[6] while the latter creates only block devices. In Linux, to get a character device for a disk one must use the "raw" driver, though one can get the same effect as opening a character device by opening the block device with the Linux-specific O_DIRECT
flag.
Block special files or block devices provide buffered access to hardware devices, and provide some abstraction from their specifics.[5] Unlike character devices, block devices will always allow the programmer to read or write a block of any size (including single characters/bytes) and any alignment. The downside is that because block devices are buffered, the programmer does not know how long it will take before written data is passed from the kernel's buffers to the actual device, or indeed in what order two separate writes will arrive at the physical device. Additionally, if the same hardware exposes both character and block devices, there is a risk of data corruption due to clients using the character device being unaware of changes made in the buffers of the block device.