APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

2004/01/06 not a typewriter

© January 2004 Tony Lawrence

This is the error message (ENOTTY, error 25 on Unix systems) you get if you try to do something that needs a character device to something that isn't. It wouldn't have helped much if it said "Not a character device" instead.

So what's the difference between a block device and a character device? Well, in /dev/, ls -l lists them with a leading "c" or "b" in the perm column:

crw-------  1 root  wheel      23,   0  5 Jan 14:27 bpf0
crw-------  1 root  wheel      23,   1  2 Jan 09:12 bpf1
crw-------  1 root  wheel      23,   2  2 Jan 09:12 bpf2
crw-------  1 root  wheel      23,   3  2 Jan 09:12 bpf3
crw-------  1 apl   staff       0,   0  5 Jan 12:11 console
crw-rw-rw-  1 root  wheel       8,   1  2 Jan 09:12 cu.modem
brw-r-----  1 root  operator   14,   0  2 Jan 09:12 disk0
br--r-----  1 root  operator   14,   1  2 Jan 09:12 disk0s1
brw-r-----  1 root  operator   14,   2  2 Jan 09:12 disk0s2
brw-r-----  1 root  operator   14,   3  2 Jan 09:12 disk0s3
br--r-----  1 root  operator   14,   4  2 Jan 09:12 disk0s4
brw-r-----  1 root  operator   14,   5  2 Jan 09:12 disk0s5

but why are there character and block devices? It gets a little confusing because it's quite possible for a device driver to treat physical hardware almost anyway it likes, but the real important differences is what routines get called- a block open gets a buffer allocated by the kernel and that's where its data is, while a (character device) raw read or write is reading or writing user space.

See https://aplawrence.com/Bofcusm/321.html for even more confusion.

Got something to add? Send me email.

(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

-> not a typewriter

Inexpensive and informative Apple related e-books:

Take Control of Numbers

Take Control of Automating Your Mac

iOS 10: A Take Control Crash Course

Photos: A Take Control Crash Course

Take Control of iCloud

More Articles by © Tony Lawrence

Printer Friendly Version

Have you tried Searching this site?

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us

Printer Friendly Version

The object-oriented model makes it easy to build up programs by accretion. What this often means, in practice, is that it provides a structured way to write spaghetti code. (Paul Graham)

Linux posts

Troubleshooting posts

This post tagged:



Unix/Linux Consultants

Skills Tests

Unix/Linux Book Reviews

My Unix/Linux Troubleshooting Book

This site runs on Linode