-2

I'm currently building a kernal module that creates a device under /dev and I want to store some data inside of the device file. However, every time I try to write to the device file, nothing is being saved to that specific file.

Currently, I've tried to use device_write/device_read with no luck since the data I'm writing does not save in the kernel space after running the userprogram again. I've also tried using ioctl calls from the user-program and using copy_from_user and copy_to_user but that also doesn't save any data.

Harsh Patel
  • 151
  • 6
  • 1
    How do you expect the data to be stored? A "device file" isn't a form of storage. Show us your code. –  Nov 09 '18 at 07:32

1 Answers1

0

Just by creating a device node in /dev doesnt mean you have a device which can read/write. Its just a handle to talk to hardware from user space. If you are creating a driver for some block device SD/USB you need to refer the device specific framework.

If you are just creating a dummy device and want to implement read/write the you can just allocate some kernel memory in probe and in device_write, copy to that memory and in device_read, read the contents of the memory.

Prabhakar Lad
  • 1,248
  • 1
  • 8
  • 12