I am trying to populate a stat struct for each record in readdir() and pass that corresponding stat to getattr via filler(). I read somewhere that FUSE only recognizes certain fields of the stat struct when populated at readdir (tangent question: is this always the case?). Apparently, one of these accepted fields is st_ino. However, when I populate a stat struct's st_ino at readdir() for a given record, I do not see the corresponding change for that record at getattr().
Maybe it's worth noting that the problem that I am trying to solve with the above issue is that I want to pass (non POSIX) information from readdir to getattr on a per record basis. Initially, my hack was to append a unique identifier to each record name that functioned as the primary key into a database that contains this (non POSIX) information. The problem with that solution is that users see the funky naming scheme when issuing an 'ls'. If I can store this primary key in the st_ino field, then I can uniquely identify records without users seeing the naming scheme. So I suppose another solution to this problem would be to find a way to alter the name that readdir populates the record buffer with, with the name that ls prints to the screen. I'm not sure if that's possible without modifying FUSE source, however.
Any help is appreciated!
I wrote some FUSE filesystems a long time ago and this is a bit blurry for me. But when I look at my old code, I see that FUSE allows a private_data field. You can manage the information in private_data however you wish. This should provide a mechanism to transport information from readdir to getattr without polluting the file name space or any other data members that are reserved for specific use.