Is a device being a block or character device determined purely by hardware?
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
From https://unix.stackexchange.com/a/472920/674
A "character device" and "block device" are abstractions, usually used in Unix-style systems in classifying various devices.
Is a device being a block or character device determined by hardware (either device or device controller), device driver, file system, OS kernel I/O subsystem, and/or something else?
I thought they are concepts of purely hardware (either device or device controller), independent of device driver, file system, and OS kernel I/O subsystem.
From Are there implications between block/character device and random/sequential access?
the only real visible difference is that block devices use the buffer cache and character devices don't. (And some block device drivers may offer the option of bypassing the buffer cache on a per-file basis).
Is the buffer cache used by block devices provided by device driver, file systems, or by hardware (either the device or device controller)? If by the hardware, then does it mean that a device being a block or character device is determined purely by hardware (either device or device controller)?
Thanks.
io block-device character-device
add a comment |Â
up vote
2
down vote
favorite
From https://unix.stackexchange.com/a/472920/674
A "character device" and "block device" are abstractions, usually used in Unix-style systems in classifying various devices.
Is a device being a block or character device determined by hardware (either device or device controller), device driver, file system, OS kernel I/O subsystem, and/or something else?
I thought they are concepts of purely hardware (either device or device controller), independent of device driver, file system, and OS kernel I/O subsystem.
From Are there implications between block/character device and random/sequential access?
the only real visible difference is that block devices use the buffer cache and character devices don't. (And some block device drivers may offer the option of bypassing the buffer cache on a per-file basis).
Is the buffer cache used by block devices provided by device driver, file systems, or by hardware (either the device or device controller)? If by the hardware, then does it mean that a device being a block or character device is determined purely by hardware (either device or device controller)?
Thanks.
io block-device character-device
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
From https://unix.stackexchange.com/a/472920/674
A "character device" and "block device" are abstractions, usually used in Unix-style systems in classifying various devices.
Is a device being a block or character device determined by hardware (either device or device controller), device driver, file system, OS kernel I/O subsystem, and/or something else?
I thought they are concepts of purely hardware (either device or device controller), independent of device driver, file system, and OS kernel I/O subsystem.
From Are there implications between block/character device and random/sequential access?
the only real visible difference is that block devices use the buffer cache and character devices don't. (And some block device drivers may offer the option of bypassing the buffer cache on a per-file basis).
Is the buffer cache used by block devices provided by device driver, file systems, or by hardware (either the device or device controller)? If by the hardware, then does it mean that a device being a block or character device is determined purely by hardware (either device or device controller)?
Thanks.
io block-device character-device
From https://unix.stackexchange.com/a/472920/674
A "character device" and "block device" are abstractions, usually used in Unix-style systems in classifying various devices.
Is a device being a block or character device determined by hardware (either device or device controller), device driver, file system, OS kernel I/O subsystem, and/or something else?
I thought they are concepts of purely hardware (either device or device controller), independent of device driver, file system, and OS kernel I/O subsystem.
From Are there implications between block/character device and random/sequential access?
the only real visible difference is that block devices use the buffer cache and character devices don't. (And some block device drivers may offer the option of bypassing the buffer cache on a per-file basis).
Is the buffer cache used by block devices provided by device driver, file systems, or by hardware (either the device or device controller)? If by the hardware, then does it mean that a device being a block or character device is determined purely by hardware (either device or device controller)?
Thanks.
io block-device character-device
io block-device character-device
asked Oct 4 at 12:52
Tim
23.9k67232418
23.9k67232418
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
4
down vote
accepted
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.
1
I mentioned this at Tim's earlier question unix.stackexchange.com/questions/471376 too.
â JdeBP
Oct 4 at 15:16
@JdeBP I an sorry.
â Tim
Oct 4 at 15:26
1
@Tim to represent hardware like hard disks
â sourcejedi
Oct 4 at 15:32
1
@Tim it is not like a hard disk :).
â sourcejedi
Oct 4 at 15:34
1
For the answers to Tim's answer-comment-questions about/dev/tty
, see unix.stackexchange.com/questions/447197 , unix.stackexchange.com/questions/446166 , and unix.stackexchange.com/questions/149236 where answerers explain what/dev/tty
is.
â JdeBP
Oct 4 at 16:27
 |Â
show 4 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
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.
1
I mentioned this at Tim's earlier question unix.stackexchange.com/questions/471376 too.
â JdeBP
Oct 4 at 15:16
@JdeBP I an sorry.
â Tim
Oct 4 at 15:26
1
@Tim to represent hardware like hard disks
â sourcejedi
Oct 4 at 15:32
1
@Tim it is not like a hard disk :).
â sourcejedi
Oct 4 at 15:34
1
For the answers to Tim's answer-comment-questions about/dev/tty
, see unix.stackexchange.com/questions/447197 , unix.stackexchange.com/questions/446166 , and unix.stackexchange.com/questions/149236 where answerers explain what/dev/tty
is.
â JdeBP
Oct 4 at 16:27
 |Â
show 4 more comments
up vote
4
down vote
accepted
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.
1
I mentioned this at Tim's earlier question unix.stackexchange.com/questions/471376 too.
â JdeBP
Oct 4 at 15:16
@JdeBP I an sorry.
â Tim
Oct 4 at 15:26
1
@Tim to represent hardware like hard disks
â sourcejedi
Oct 4 at 15:32
1
@Tim it is not like a hard disk :).
â sourcejedi
Oct 4 at 15:34
1
For the answers to Tim's answer-comment-questions about/dev/tty
, see unix.stackexchange.com/questions/447197 , unix.stackexchange.com/questions/446166 , and unix.stackexchange.com/questions/149236 where answerers explain what/dev/tty
is.
â JdeBP
Oct 4 at 16:27
 |Â
show 4 more comments
up vote
4
down vote
accepted
up vote
4
down vote
accepted
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.
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.
edited Oct 4 at 17:17
answered Oct 4 at 15:01
sourcejedi
20.6k42888
20.6k42888
1
I mentioned this at Tim's earlier question unix.stackexchange.com/questions/471376 too.
â JdeBP
Oct 4 at 15:16
@JdeBP I an sorry.
â Tim
Oct 4 at 15:26
1
@Tim to represent hardware like hard disks
â sourcejedi
Oct 4 at 15:32
1
@Tim it is not like a hard disk :).
â sourcejedi
Oct 4 at 15:34
1
For the answers to Tim's answer-comment-questions about/dev/tty
, see unix.stackexchange.com/questions/447197 , unix.stackexchange.com/questions/446166 , and unix.stackexchange.com/questions/149236 where answerers explain what/dev/tty
is.
â JdeBP
Oct 4 at 16:27
 |Â
show 4 more comments
1
I mentioned this at Tim's earlier question unix.stackexchange.com/questions/471376 too.
â JdeBP
Oct 4 at 15:16
@JdeBP I an sorry.
â Tim
Oct 4 at 15:26
1
@Tim to represent hardware like hard disks
â sourcejedi
Oct 4 at 15:32
1
@Tim it is not like a hard disk :).
â sourcejedi
Oct 4 at 15:34
1
For the answers to Tim's answer-comment-questions about/dev/tty
, see unix.stackexchange.com/questions/447197 , unix.stackexchange.com/questions/446166 , and unix.stackexchange.com/questions/149236 where answerers explain what/dev/tty
is.
â JdeBP
Oct 4 at 16:27
1
1
I mentioned this at Tim's earlier question unix.stackexchange.com/questions/471376 too.
â JdeBP
Oct 4 at 15:16
I mentioned this at Tim's earlier question unix.stackexchange.com/questions/471376 too.
â JdeBP
Oct 4 at 15:16
@JdeBP I an sorry.
â Tim
Oct 4 at 15:26
@JdeBP I an sorry.
â Tim
Oct 4 at 15:26
1
1
@Tim to represent hardware like hard disks
â sourcejedi
Oct 4 at 15:32
@Tim to represent hardware like hard disks
â sourcejedi
Oct 4 at 15:32
1
1
@Tim it is not like a hard disk :).
â sourcejedi
Oct 4 at 15:34
@Tim it is not like a hard disk :).
â sourcejedi
Oct 4 at 15:34
1
1
For the answers to Tim's answer-comment-questions about
/dev/tty
, see unix.stackexchange.com/questions/447197 , unix.stackexchange.com/questions/446166 , and unix.stackexchange.com/questions/149236 where answerers explain what /dev/tty
is.â JdeBP
Oct 4 at 16:27
For the answers to Tim's answer-comment-questions about
/dev/tty
, see unix.stackexchange.com/questions/447197 , unix.stackexchange.com/questions/446166 , and unix.stackexchange.com/questions/149236 where answerers explain what /dev/tty
is.â JdeBP
Oct 4 at 16:27
 |Â
show 4 more comments
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f473230%2fis-a-device-being-a-block-or-character-device-determined-purely-by-hardware%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password