Skip to content
Advertisement

Get Character String Written to Custom /dev/ file

I’m currently working with a custom device driver that I installed. I’m very new to this and having trouble understanding how to get the data that I write into it from the command line.

For example, I write data to the file like so:

JavaScript

And then I merely want to get the string here, so I can use the characters within:

JavaScript

Advertisement

Answer

The string is in buf, but it’s in user memory. You need to use copy_from_user() to copy to kernel memory.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement