Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I read the mknod man page, which is (as far as I can tell) what you would use to make a character device like /dev/zero, but I don't see how you would get it to yield an infinite stream of zero bits (or another pattern). What is the procedure for creating such character devices?

share|improve this question
They're implemented in the kernel. Look at zero_lseek, read_zero, write_zero, mmap_zero in drivers/char/mem.c. – David Schwartz Oct 1 '12 at 7:04
Oh…so I would have to modify the kernel? – Blacklight Shining Oct 1 '12 at 7:07
Not necessarily, it depends on precisely what you want to do. Most likely, you would at least need to implement a module. – David Schwartz Oct 1 '12 at 7:18
What about /dev/one? – Blacklight Shining Oct 1 '12 at 7:45

2 Answers 2

up vote 3 down vote accepted

All mknod does is associate a device file with a device driver. There are device drivers that implement interaction with actual devices, and there are device drivers that just react to read-write requests in useful ways. If you want to you can sit down and write a driver that returns the lyrics of the Star Spangeled Banner. But it's a matter of coding, not finding the right arguments for mknod.

share|improve this answer

mknod creates the device node, but the VFS detects accesses to the device node and reroutes them to the appropriate driver within the kernel for handling. All device nodes, from /dev/null to /dev/sdX to /dev/ttyXX to /dev/videoX are handled this way.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.