resmgr - how to figure out the client type?

I’m writing a resmgr (Analog card driver) that shows it’s interface in a directory/files manner under /dev. The resmgr expects client code to request data values by reading the “files” by issuing read() calls and passing the address of a variable of the corresponding data type. In this case, the resmgr simply replies with the address of the variable corresponding to the file read. But I would also like the resmgr to convert this value into a string if the request if from, say, the “cat” utility so that the user will get a readout of the actual value of the variable. How can I give my resmgr this ability?

What I do is provide two files, something like /dev/directory/files.bin and /dev/directory/files.txt. Hence when the resmgr receives the read request on files.txt it must convert the binary data to ascii and return it.

Note that you can use spatch to view binary data.

Could it be any simpler? :slight_smile:

They both use “read()” then no. You can make your application use something like “readcone()” which comes into the server with an IO_READ_XTYPE, since other utils like “cat” won’t use readcond()",
your server could probably figure out the difference.

Other way is the server figures out sender’s pid, and find out sender’s name from /proc//as, and if it’s a “cat”, do different. But this hardly qulify “simpler” I guess :slight_smile: