Linux Character Special

While exploring benchmarking pipe-related programs like cat /dev/zero | pv > /dev/null with some friends, I found that yes > /dev/null is actually quite slow. benchmark script here

I looked deeper into character special files like /dev/null, and found something I haven’t heard of: /dev/aio (POSIX Asynchronous I/O). Well that’s interesting.

Here is the full list of block and character special devices on Linux: https://www.kernel.org/doc/Documentation/admin-guide/devices.txt

To see the a special file’s identity, run

> file /dev/zero
/dev/zero: character special (1/5)

(1/5) means major 1 minor 5 (Null byte source).

I tried replacing the database of a simple program with urandom, and it fails at ftruncate (cannot truncate file).

Here’s the command that I used.

doas mknod -m 0666 data c 1 9

Less interesting than I wanted this to be.

Update(2024-03-22): The special files stay on the filesystem forever! Now that’s interesting.