Does writing to dev-node actually write to storage medium?
I've got an idea for customising emacs to make my new fancy corsair RGB keyboard to light up in different colours on some events. To control the LED's I'll be writing commands to /dev/input/ckb1/cmd, and I'm a bit worried that it will write to the SSD. I'm not familiar with how dev-nodes work on a lower level, and I'm wondering if the kernel(?) creates some form of stream that bypass the permanent storage medium. If not, there's a potential for a lot of unnecessary read/writes which I want to avoid.
Update: the /dev/input/ckb1/cmd is a named pipe. So there's nothing to worry about.
Edited 24 Sep 2015. We only hold this version.
About this post
- Posted
- Archived
- Edited
- Score
- 1 · 100% up
- Kind
- Text
- ID
- 3m2o7z
5 comments
That depends. As long as you are not writing to a block device you should be fine.
It is perfectly safe to write to
/dev/input/ckb1/cmdthough.So if I have some Java program that has a buffer to
/dev/input/ckb1/cmd, when I flush the buffer it won't be written to my HDD or SSD, but stored in RAM, for the keyboard driver to read (the ckb driver creates the node, and then read from cmd line by line)? If so, how does that work? I read up a bit on buffers and cache in Linux, but it still seems a bit... fuzzy and unpredictable to me.Dev nodes look a bit like files, but they are are not ordinary files.
Unix has more different types of filesystem objects than somebody with Windows experience might expect.
Everybody knows that a filesystem can contain both files and directories; some people know about symlinks, but most people don't know about fifos, domain sockets and dev nodes. They are each referred to by a filesystem path, but are not regular files (much like a directory is not a regular file), and serve to transfer data between different processes (or between a userspace process and the kernel/hardware) rather than the permanently store data. The reason they exist is, essentially "why have lots of different APIs that are all just for reading and writing data?".