satish kumar
satish kumar

Reputation: 1

How to rename devicenode in char driver

I wrote driver which creates two device nodes as /dev/dummy1 and /dev/dummy2. created test.txt and cattest.txt > /dev/dummy1 ,

cat /dev/dummy1 & cat /dev/dummy2 

is fine.

I want to redirect same data to file /tmp/copy.txt

How to redirect data form /dev/dummy1 to /tmp/copy.txt from char driver itself.(without command line or user application)

Is there any way to rename the device node from /dev/dummy2 to /tmp/xxxx ? or create the new device node with /tmp/xxx and copy /dev/dummy2 to /tmp/xxx.

Thanks in advance.

Upvotes: 0

Views: 409

Answers (1)

Andrejs Cainikovs
Andrejs Cainikovs

Reputation: 28474

No. Devices are located in devfs, period. Your driver does not know neither about tmpfs existence, nor about it's mounting point. You are going the wrong direction.

If you want to obtain data from your driver and save it in a custom location, you need to implement a daemon, user-space application that extracts data from driver via devfs or sysfs, or do the same via command line if you prefer manual approach.

Upvotes: 1

Related Questions