Skip to content

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.

1 points5 comments
Open on Reddit
About this post
Posted
Archived
Edited
Score
1 · 100% up
Kind
Text
ID
3m2o7z

Author

5
posts
198
comments
0
media
View profile

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/cmd though.

1 points

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.

1 points

If so, how does that work

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?".

2 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.