tay10r
tay10r

Reputation: 4357

where does file data go in a device file?

I'm writing a character device file and would like to know if there's any way to have a section of data for each instance of a device file. I've been looking at the inode and file structures for a place to store a non-volatile pointer, but have had no luck. can you do this with character device files, or should I be considering something else? i need to have custom read and write operations with data for each file instance.

Upvotes: 0

Views: 145

Answers (1)

sleske
sleske

Reputation: 83599

You cannot store data in a device file. The whole point of a device file is that the data you write to it is passed to some driver.

You could theoretically store information in the file name, or in the group id field of the inode, but that would be very weird.

Your best solution is most likely to store your data separately. For example, why don't you create a regular file alongside the device file? Maybe use some naming convention to associate the two.

Upvotes: 1

Related Questions